python-mapnik
python-mapnik copied to clipboard
TextSymbolizer.__init__(TextSymbolizer, Expression, str, int, Color) did not match C++ signature
Hello,
running this:
from mapnik import *
t = TextSymbolizer(Expression('[label]'), 'DejaVu Sans Book', 10, Color('black'))
I'm not able to get rid of this TextSymbolizer related error.
---------------------------------------------------------------------------
ArgumentError Traceback (most recent call last)
<ipython-input-6-eefc1ba347c5> in <module>()
----> 1 t = TextSymbolizer(Expression('[label]'), 'DejaVu Sans Book', 10, Color('black'))
ArgumentError: Python argument types in
TextSymbolizer.__init__(TextSymbolizer, Expression, str, int, Color)
did not match C++ signature:
__init__(_object*)
OS: ubuntu 16.10 mapnik: 3.0.12+ds-1 python-mapnik: 1:0.0~20160830-541fd96-1 boost version: 1.61.0.2
any ideas?
@afrigeri - recommended way to load a style in 3.x.x mapnik is to use XML.
Current python bindings are lacking support for all TextSymbolizer
properties and options. I'll try to find time to add some basic support back but meanwhile consider using load_map
+ XML
ref https://github.com/mapnik/python-mapnik/issues/89 ^
@artemp I see! load_map + XML works with the TextSymbolizer I needed. Is the recommendation to use XML in mapnik temporary for 3.x.x or at some point we can use both python/c++ and xml? Is there a page where I can check the status of this?
I'd be curious about that as well, the 3.0.12 python bindings don't seem to export the Stroke class at all, which makes it impossible to work with most of the other Symbolizers. According to #7 we shouldn't expect a direct style interface any time soon, so using an XML library to dynamically write xml styles and then loading them via load_map seems to be it for now...
Is the recommendation to use XML in mapnik temporary for 3.x.x or at some point we can use both python/c++ and xml?
You can use the C++ style interface anytime if XML doesn't suit your needs. Only Python interface is problematic as there is no maintainer able to keep pace with the C++ interface.
I think the recommendation to use XML is mainly because it's very stable across Mapnik versions, it's simple to use and reasonably fast.
Is there a way to use load_map + XML + mapnik.MemoryDatasource
? All the examples I've found have SQL query or shapefile datasources. I would like to specify my data from Python, but use the XML file for everything else.
Is there a way to use load_map + XML + mapnik.MemoryDatasource?
No @mrterry, by design. The mapnik.MemoryDatasource
API is only a programmatic API and not something that you can create via XML. If you want to create in memory features via XML you could:
- Easy: Use a
geojson
datasource and provide a geojson string in the XML and pass it via theinline
. This effectively allows in-memory data to be used and is quite fast. This would work via python the same way as it does via node.js. A nodejs example of doing this is at https://github.com/mapbox/geojson-mapnikify. - Hard (would require significant C++ coding): pick up this abandoned effort to support the python datasource inside the python bindings: https://github.com/mapnik/python-mapnik/issues/6
@springmeyer Thanks for the unambiguous answer. We ended up taking the easy path.