Example #1
0
 def from_dict(cls, data, strict_lon_validation=False):
     """
     data is a GeoJSON standard data structure, including that the
     coordinates are in GeoJSON order (lon, lat) instead of
     SimpleGeo order (lat, lon)
     """
     assert isinstance(data, dict), (type(data), repr(data))
     coordinates = deep_swap(data['geometry']['coordinates'])
     try:
         deep_validate_lat_lon(coordinates, strict_lon_validation=strict_lon_validation)
     except TypeError, le:
         raise TypeError("The 'coordinates' value is required to be a 2-element sequence of lon, lat for a point (or a more complicated set of coordinates for polygons or multipolygons), but it was %s :: %r. The error that was raised from validating this was: %s" % (type(coordinates), coordinates, le))
Example #2
0
 def to_dict(self):
     """
     Returns a GeoJSON object, including having its coordinates in
     GeoJSON standad order (lon, lat) instead of SimpleGeo standard
     order (lat, lon).
     """
     return {
         'type': 'Feature',
         'id': self.id,
         'geometry': {
             'type': self.geomtype,
             'coordinates': deep_swap(self.coordinates)
         },
         'properties': copy.deepcopy(self.properties),
     }