def makeFeature(self, wkt, **properties): from mapnik import Feature f = Feature(self.ids.next()) f.add_geometries_from_wkt(wkt) for k, v in properties.iteritems(): f[k] = v return f
def makeFeature(self, wkt, **properties): from mapnik import Feature f = Feature(self.ids.next()) f.add_geometries_from_wkt(wkt) for k,v in properties.iteritems(): f[k] = v return f
def _create_datasource(self, collection): """ Create a Mapnik memory datasource from a feature collection. """ ds = MemoryDatasource() for feature in collection.features: properties = dict(feature.properties) for k, v in properties.iteritems(): if isinstance(v, decimal.Decimal): properties[k] = float(v) elif isinstance(v, (datetime.date, datetime.datetime)): properties[k] = str(v) f = Feature(feature.id, **properties) f.add_geometries_from_wkb(asShape(feature.geometry).wkb) ds.add_feature(f) return ds