Tuesday, 22 June 2010

XML Upgrade Problem

I faced a problem when rendering OSM data, that made some elements of the map not to be displayed; the cities appeared in gray and the streets were just thin black lines. The following map of Hartlepool, England, shows how the maps were displayed:


The problem seemed weird to me, because I was following the instructions in Townguide's manual [1] and they produced good results to Waldemar. Besides, Waldemar tried it yesterday in his computer and the maps were rendered correctly, both with mapnik and mapnik2. I thought that the problem was something I changed in the code of AGG renderer, but I went back to the previous revision and the problem was still there.

The problem turned out to be in osm.xml, which I got from: http://svn.openstreetmap.org/applications/rendering/mapnik. Dane Springmeyer had already told me that mapnik2 introduced some changes in the stylesheet, so my stylesheet was outdated. I was also getting deprecation warnings when running mapnik's demos, generate_image.py and nik2img.py:

Deprecation Warning: symbolizer value now an expression, please wrap properly in brackets like "[name]".

My first attempt to eliminate these warnings was to use the upgrade_map_xml utility, as Dane Springmeyer told me. However, it didn't seem to work, because the stylesheet was still the same. So what I did was to replace manually what the warnings were telling me, but I guess I made some mistakes (replacing, for example, in sql queries too).

Searching the web, I found that the output of upgrade_map_xml needed to be printed to a file, as it is displayed in the terminal by default. So the correct usage is:

$ python upgrade_map_xml.py osm.xml > osm.xml

But what I really did was to print the output in a second file, because python generated the following error:

lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1

And indeed it was empty after issuing the command.

[1] http://code.google.com/p/townguide/wiki/InstallationInstructions

No comments:

Post a Comment