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


import collections
from django.utils import six
from greenwich.srs import SpatialReference
from spillway.compat import json, JSONEncoder
    def geojson(self):
        if not self.is_serialized('geometry'):
            return self._dumps()
        geom = self['geometry'] or '{}'
        keys = six.viewkeys(self) - {'geometry'}
        props = json.dumps({k: self[k] for k in keys}, cls=JSONEncoder)[1:-1]
        return '{"geometry": %s, %s}' % (str(geom), props)


class FeatureCollection(AbstractFeature):
    """GeoJSON FeatureCollection dict."""

    def __init__(self, features=None, crs=None, iterable=(), **kwargs):
        super(FeatureCollection, self).__init__()
        self['type'] = self.__class__.__name__
        if crs:
            self['crs'] = NamedCRS(crs)
        if features and not isinstance(next(iter(features)), Feature):
            self['features'] = [Feature(**feat) for feat in features]
        else:
            self['features'] = features or []
        self.update(iterable, **kwargs)

    @property
    def geojson(self):
        if not self.has_serialized_geom:
            return self._dumps()
        features = ','.join(map(str, self['features']))
        keys = six.viewkeys(self) - {'features'}
        collection = '%s, "features": [' % json.dumps(

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


# Path: spillway/collections.py
import collections
from django.utils import six
from greenwich.srs import SpatialReference
from spillway.compat import json, JSONEncoder

    def geojson(self):
        if not self.is_serialized('geometry'):
            return self._dumps()
        geom = self['geometry'] or '{}'
        keys = six.viewkeys(self) - {'geometry'}
        props = json.dumps({k: self[k] for k in keys}, cls=JSONEncoder)[1:-1]
        return '{"geometry": %s, %s}' % (str(geom), props)


class FeatureCollection(AbstractFeature):
    """GeoJSON FeatureCollection dict."""

    def __init__(self, features=None, crs=None, iterable=(), **kwargs):
        super(FeatureCollection, self).__init__()
        self['type'] = self.__class__.__name__
        if crs:
            self['crs'] = NamedCRS(crs)
        if features and not isinstance(next(iter(features)), Feature):
            self['features'] = [Feature(**feat) for feat in features]
        else:
            self['features'] = features or []
        self.update(iterable, **kwargs)

    @property
    def geojson(self):
        if not self.has_serialized_geom:
            return self._dumps()
        features = ','.join(map(str, self['features']))
        keys = six.viewkeys(self) - {'features'}
        collection = '%s, "features": [' % json.dumps(

            {k: self[k] for k in keys}, cls=JSONEncoder)[:-1]