Exemplo n.º 1
0
 def to_geojson(self, instance=None) -> dict:
     result = {
         'type': 'Feature',
         'properties': self.get_geojson_properties(instance=instance),
         'geometry': format_geojson(smart_mapping(self.geometry),
                                    round=False),
     }
     original_geometry = getattr(self, 'original_geometry', None)
     if original_geometry:
         result['original_geometry'] = format_geojson(
             smart_mapping(original_geometry), round=False)
     return result
Exemplo n.º 2
0
 def _serialize(self, geometry=True, simple_geometry=False, **kwargs):
     result = super()._serialize(simple_geometry=simple_geometry, **kwargs)
     if geometry:
         result['geometry'] = format_geojson(smart_mapping(self.geometry),
                                             round=False)
     if simple_geometry:
         result['point'] = (self.level_id, ) + tuple(
             round(i, 2) for i in self.point.coords[0])
         if not isinstance(self.geometry, Point):
             minx, miny, maxx, maxy = self.geometry.bounds
             result['bounds'] = ((int(math.floor(minx)),
                                  int(math.floor(miny))),
                                 (int(math.ceil(maxx)),
                                  int(math.ceil(maxy))))
     return result
Exemplo n.º 3
0
 def get_geometry(self, detailed_geometry=True):
     if detailed_geometry:
         return format_geojson(smart_mapping(self.geometry), round=False)
     return format_geojson(smart_mapping(box(*self.geometry.bounds)),
                           round=False)
Exemplo n.º 4
0
 def coords(self):
     return smart_mapping(self.geometry)['coordinates']