def __init__(self, obj, band=1, style=None): self._rstore = obj layer = mapnik.Layer(str(obj), srs.SpatialReference(obj.srs).proj4) layer.datasource = mapnik.Gdal(file=obj.image.path, band=band) self._layer = layer self.stylename = style or 'Spectral_r' self._symbolizer = None
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
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
def __init__(self, obj, band=1, style='Spectral_r'): layer = mapnik.Layer(str(obj), srs.SpatialReference(obj.srs).proj4) layer.datasource = mapnik.Gdal(file=obj.image.path, band=band) self._layer = layer self.stylename = style