# Path: spillway/compat.py
# class JSONEncoder(json.JSONEncoder):
# class Mapnik(object):
#     def __getattr__(self, attr):
# 
# Path: spillway/colors.py

# 
# Path: spillway/query.py
# def filter_geometry(queryset, **filters):
# def geo_field(queryset):
# def get_srid(queryset):
# def agg_dims(arr, stat):
#     def _trans_scale(self, colname, deltax, deltay, xfactor, yfactor):
#     def extent(self, srid=None):
#     def filter_geometry(self, **kwargs):
#     def geo_field(self):
#     def pbf(self, bbox, geo_col=None, scale=4096):
#     def tile(self, bbox, z=0, format=None, clip=True):
#     def arrays(self, field_name=None):
#     def aggregate_periods(self, periods):
#     def get(self, *args, **kwargs):
#     def raster_field(self):
#     def summarize(self, geom, stat=None):
#     def warp(self, srid=None, format=None, geom=None):
#     def zipfiles(self, path=None, arcdirname='data'):
# class AsText(geofn.GeoFunc):
# class Simplify(geofn.GeoFunc):
# class SimplifyPreserveTopology(geofn.GeoFunc):
# class TransScale(geofn.GeoFunc):
# class GeoQuerySet(query.QuerySet):
# class RasterQuerySet(GeoQuerySet):


from django.core.files.storage import default_storage
from django.db import connection
from django.contrib.gis import gdal
from greenwich import srs
from rest_framework.exceptions import NotFound
from spillway.compat import mapnik
from spillway import colors, query
        return symbolizer


class VectorLayer(Layer):
    """A Mapnik layer for vector data types."""

    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 symbolizer(self):
        symbolizers = {
            mapnik.DataGeometryType.Point: mapnik.PointSymbolizer,
            mapnik.DataGeometryType.LineString: mapnik.LineSymbolizer,
            mapnik.DataGeometryType.Polygon: mapnik.PolygonSymbolizer
        }
        return symbolizers.get(self._layer.datasource.geometry_type(),

# Path: spillway/compat.py
# class JSONEncoder(json.JSONEncoder):
# class Mapnik(object):
#     def __getattr__(self, attr):
# 
# Path: spillway/colors.py

# 
# Path: spillway/query.py
# def filter_geometry(queryset, **filters):
# def geo_field(queryset):
# def get_srid(queryset):
# def agg_dims(arr, stat):
#     def _trans_scale(self, colname, deltax, deltay, xfactor, yfactor):
#     def extent(self, srid=None):
#     def filter_geometry(self, **kwargs):
#     def geo_field(self):
#     def pbf(self, bbox, geo_col=None, scale=4096):
#     def tile(self, bbox, z=0, format=None, clip=True):
#     def arrays(self, field_name=None):
#     def aggregate_periods(self, periods):
#     def get(self, *args, **kwargs):
#     def raster_field(self):
#     def summarize(self, geom, stat=None):
#     def warp(self, srid=None, format=None, geom=None):
#     def zipfiles(self, path=None, arcdirname='data'):
# class AsText(geofn.GeoFunc):
# class Simplify(geofn.GeoFunc):
# class SimplifyPreserveTopology(geofn.GeoFunc):
# class TransScale(geofn.GeoFunc):
# class GeoQuerySet(query.QuerySet):
# class RasterQuerySet(GeoQuerySet):


# Path: spillway/carto.py
from django.core.files.storage import default_storage
from django.db import connection
from django.contrib.gis import gdal
from greenwich import srs
from rest_framework.exceptions import NotFound
from spillway.compat import mapnik
from spillway import colors, query

        return symbolizer


class VectorLayer(Layer):
    """A Mapnik layer for vector data types."""

    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 symbolizer(self):
        symbolizers = {
            mapnik.DataGeometryType.Point: mapnik.PointSymbolizer,
            mapnik.DataGeometryType.LineString: mapnik.LineSymbolizer,
            mapnik.DataGeometryType.Polygon: mapnik.PolygonSymbolizer
        }
        return symbolizers.get(self._layer.datasource.geometry_type(),

                               mapnik.PolygonSymbolizer)()