Example #1
0
 def test_can_create(self):
     location = dtos.SpatialLocation(latitude='123.456',
                                     longitude='-23.456')
     self.assertAlmostEqual(location.latitude, 123.456)
     self.assertAlmostEqual(location.longitude, -23.456)
Example #2
0
 def test_throws_on_longitude_not_a_number(self):
     with self.assertRaises(exceptions.InvalidFloatXmlParseException):
         dtos.SpatialLocation(latitude='123.456', longitude='foo')
Example #3
0
def parse_spatial_location_if_defined(site):
    latitude = parse_optional_field(site, 'SpatialLocation/Latitude')
    longitude = parse_optional_field(site, 'SpatialLocation/Longitude')
    if latitude is None or longitude is None:
        return None
    return dtos.SpatialLocation(latitude=latitude, longitude=longitude)