preserve old MemoryDatasource interface in Python
This commit is contained in:
parent
16fafbad43
commit
6297c72f02
4 changed files with 21 additions and 11 deletions
|
@ -627,6 +627,16 @@ def Python(**keywords):
|
||||||
keywords['type'] = 'python'
|
keywords['type'] = 'python'
|
||||||
return CreateDatasource(keywords)
|
return CreateDatasource(keywords)
|
||||||
|
|
||||||
|
def MemoryDatasource(**keywords):
|
||||||
|
"""Create a Memory Datasource.
|
||||||
|
|
||||||
|
Optional keyword arguments:
|
||||||
|
(TODO)
|
||||||
|
"""
|
||||||
|
params = Parameters()
|
||||||
|
params.append(Parameter('type','memory'))
|
||||||
|
return MemoryDatasourceBase(params)
|
||||||
|
|
||||||
class PythonDatasource(object):
|
class PythonDatasource(object):
|
||||||
"""A base class for a Python data source.
|
"""A base class for a Python data source.
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ see the documentation of mapnik.printing.PDFPrinter() for options
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from . import render, Map, Box2d, MemoryDatasource, Layer, Feature, Projection, ProjTransform, Coord, Style, Rule, Geometry2d
|
from . import render, Map, Box2d, Layer, Feature, Projection, ProjTransform, Coord, Style, Rule, Geometry2d
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -1025,4 +1025,3 @@ class PDFPrinter:
|
||||||
if y > h:
|
if y > h:
|
||||||
h = y
|
h = y
|
||||||
return (w,h)
|
return (w,h)
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ using mapnik::datasource;
|
||||||
using mapnik::memory_datasource;
|
using mapnik::memory_datasource;
|
||||||
using mapnik::layer_descriptor;
|
using mapnik::layer_descriptor;
|
||||||
using mapnik::attribute_descriptor;
|
using mapnik::attribute_descriptor;
|
||||||
|
using mapnik::parameters;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -191,7 +192,7 @@ void export_datasource()
|
||||||
|
|
||||||
class_<memory_datasource,
|
class_<memory_datasource,
|
||||||
bases<datasource>, std::shared_ptr<memory_datasource>,
|
bases<datasource>, std::shared_ptr<memory_datasource>,
|
||||||
boost::noncopyable>("MemoryDatasource", no_init)
|
boost::noncopyable>("MemoryDatasourceBase", init<parameters>())
|
||||||
.def("add_feature",&memory_datasource::push,
|
.def("add_feature",&memory_datasource::push,
|
||||||
"Adds a Feature:\n"
|
"Adds a Feature:\n"
|
||||||
">>> ms = MemoryDatasource()\n"
|
">>> ms = MemoryDatasource()\n"
|
||||||
|
|
|
@ -61,7 +61,7 @@ int main(int argc, char** argv)
|
||||||
mapnik::layer lyr("layer");
|
mapnik::layer lyr("layer");
|
||||||
lyr.set_datasource(ds);
|
lyr.set_datasource(ds);
|
||||||
lyr.add_style("style");
|
lyr.add_style("style");
|
||||||
m.add_layer(std::move(lyr));
|
m.add_layer(lyr);
|
||||||
mapnik::feature_type_style the_style;
|
mapnik::feature_type_style the_style;
|
||||||
mapnik::rule r;
|
mapnik::rule r;
|
||||||
mapnik::text_symbolizer text_sym;
|
mapnik::text_symbolizer text_sym;
|
||||||
|
|
Loading…
Reference in a new issue