Ejemplo n.º 1
0
 def to_representation(self, data):
     data = [self.child.to_representation(item) for item in data]
     try:
         srid = query.get_srid(self.instance)
     except AttributeError:
         srid = None
     return sc.FeatureCollection(features=data, crs=srid)
Ejemplo n.º 2
0
 def __init__(self, queryset, style=None):
     table = str(queryset.model._meta.db_table)
     field = query.geo_field(queryset)
     sref = srs.SpatialReference(query.get_srid(queryset))
     layer = mapnik.Layer(table, sref.proj4)
     layer.datasource = make_dbsource(
         table=table, geometry_field=field.name)
     self._layer = layer
     self.stylename = style or self._layer.name
     self._symbolizer = None
Ejemplo n.º 3
0
 def __init__(self, queryset):
     table = str(queryset.model._meta.db_table)
     field = query.geo_field(queryset)
     sref = srs.SpatialReference(query.get_srid(queryset))
     layer = mapnik.Layer(table, sref.proj4)
     layer.datasource = make_dbsource(
         table=table, geometry_field=field.name)
     self._layer = layer
     self.stylename = self._layer.name
     self._symbolizer = None
Ejemplo n.º 4
0
 def get_paginated_response(self, data):
     if hasattr(data, '__geo_interface__'):
         paginator = self.page.paginator
         crs = NamedCRS(query.get_srid(paginator.object_list))
         data.update({'count': paginator.count,
                      'next': self.get_next_link(),
                      'previous': self.get_previous_link(),
                      'crs': crs})
         return Response(data)
     return super(FeaturePagination, self).get_paginated_response(data)
Ejemplo n.º 5
0
 def get_paginated_response(self, data):
     if hasattr(data, '__geo_interface__'):
         paginator = self.page.paginator
         crs = NamedCRS(query.get_srid(paginator.object_list))
         data.update({
             'count': paginator.count,
             'next': self.get_next_link(),
             'previous': self.get_previous_link(),
             'crs': crs
         })
         return Response(data)
     return super(FeaturePagination, self).get_paginated_response(data)
Ejemplo n.º 6
0
 def __init__(self, queryset, style=None):
     table = str(queryset.model._meta.db_table)
     field = query.geo_field(queryset)
     sref = srs.SpatialReference(query.get_srid(queryset))
     layer = mapnik.Layer(table, sref.proj4)
     ds = make_dbsource(table=table, geometry_field=field.name)
     # During tests, the spatialite layer statistics are not updated and
     # return an invalid layer extent. Set it from the queryset.
     if not ds.envelope().valid():
         ex = ','.join(map(str, queryset.extent()))
         ds = make_dbsource(table=table, geometry_field=field.name,
                            extent=ex)
     layer.datasource = ds
     self._layer = layer
     self.stylename = style or self._layer.name
     self._symbolizer = None
Ejemplo n.º 7
0
 def __init__(self, queryset, style=None):
     table = str(queryset.model._meta.db_table)
     field = query.geo_field(queryset)
     sref = srs.SpatialReference(query.get_srid(queryset))
     layer = mapnik.Layer(table, sref.proj4)
     ds = make_dbsource(table=table, geometry_field=field.name)
     # During tests, the spatialite layer statistics are not updated and
     # return an invalid layer extent. Set it from the queryset.
     if not ds.envelope().valid():
         ex = ','.join(map(str, queryset.extent()))
         ds = make_dbsource(table=table,
                            geometry_field=field.name,
                            extent=ex)
     layer.datasource = ds
     self._layer = layer
     self.stylename = style or self._layer.name
     self._symbolizer = None