python-mapnik icon indicating copy to clipboard operation
python-mapnik copied to clipboard

TextSymbolizer.__init__(TextSymbolizer, Expression, str, int, Color) did not match C++ signature

Open afrigeri opened this issue 8 years ago • 8 comments

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 avatar Jan 05 '17 13:01 afrigeri

@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

artemp avatar Jan 05 '17 16:01 artemp

ref https://github.com/mapnik/python-mapnik/issues/89 ^

artemp avatar Jan 05 '17 16:01 artemp

@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?

afrigeri avatar Jan 05 '17 16:01 afrigeri

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...

kevinstadler avatar Jan 07 '17 15:01 kevinstadler

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.

talaj avatar Jan 07 '17 21:01 talaj

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.

mrterry avatar Jul 24 '17 17:07 mrterry

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 the inline. 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 avatar Sep 03 '17 17:09 springmeyer

@springmeyer Thanks for the unambiguous answer. We ended up taking the easy path.

mrterry avatar Sep 06 '17 17:09 mrterry