mapnik / python-mapnik

Python bindings for mapnik
GNU Lesser General Public License v2.1
156 stars 90 forks source link

FormattingText is not defined #89

Open Jenselme opened 8 years ago

Jenselme commented 8 years ago

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]')
Ghoughpteighbteau commented 7 years ago

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.

Jenselme commented 7 years ago

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.