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

FormattingText is not defined

Open Jenselme opened this issue 8 years ago • 2 comments

I am trying to use the python bindings to style text. To do that, I define a TextSymbolizer and I try to set its name property. However, when I do this, I get this expection:

Traceback (most recent call last):
  File "bug.py", line 4, in <module>
    text_symbolizer.name = mapnik.Expression('[name]')
  File "/usr/lib64/python3.4/site-packages/mapnik/__init__.py", line 824, in name
    self.properties.format_tree = FormattingText(name)
NameError: name 'FormattingText' is not defined

From what I see in mapnik_text_placement.cpp the code that provides this functionality is commented. If I try to uncomment the code, python-mapnik doesn't compile.

Can you fix this ?

To reproduce, use the code below:

import mapnik

text_symbolizer = mapnik.TextSymbolizer()
text_symbolizer.name = mapnik.Expression('[name]')

Jenselme avatar Mar 23 '16 10:03 Jenselme

It seems like TextSymbolizer has become deprecated? We've been doing some forensics trying to figure out what's going on.

The last thing to touch the commented out code referenced this issue in mapnik https://github.com/mapnik/mapnik/issues/2324

Which leads to here: https://github.com/mapnik/python-mapnik/issues/7

which says something about the symbolizers being represented differently in python somehow... and that we should be using the "XML styling interface"

We're still looking into what exactly the "XML styling interface" is. :angry:

edit: oh wait. oh wait oh wait oh wait.

It's reading the XML file. instead of creating objects you just read in an XML file, if you want to do it dynamically you write to an XML file then read it via mapnik. OK. I think I see.

Ghoughpteighbteau avatar Sep 06 '16 22:09 Ghoughpteighbteau

It's reading the XML file. instead of creating objects you just read in an XML file, if you want to do it dynamically you write to an XML file then read it via mapnik.

That's how I made text symbolizers work. Took me a while to figure out though.

Jenselme avatar Sep 07 '16 06:09 Jenselme