mapnik2geotools icon indicating copy to clipboard operation
mapnik2geotools copied to clipboard

Support openstreetmap.org "Mapnik" style

Open nrenner opened this issue 14 years ago • 12 comments

Support the main OSM style osm.xml available at http://svn.openstreetmap.org/applications/rendering/mapnik.

Some of the issues are:

  • rgb color format
  • filter minor_roads_casing (not tunnel=yes) not working with null values (the default)
  • TextSymbolizer / Label tag empty
  • ... ?

I am currently working on that (https://github.com/nrenner/mapnik2geotools).

nrenner avatar Oct 05 '11 20:10 nrenner

one other issue is that that style is designed for mapnik 0.7 while the mapquest styles that I've been using with mapnik2geotools are designed for mapnik2. I think we'll want to do some version inspection to support both, since some names and some semantics have changed between the two versions. The most apparent change is the shift from underscore_separated_names to hyphen-separated-ones but there are some others that are less readily automatable.

I'll try and put together a little infrastructure for doing that over the weekend. The color stuff is looking good so far though!

dwins avatar Oct 06 '11 12:10 dwins

I used upgrade_map_xml.py for conversion to Mapnik2 (see Upgrade Guide). This requires entities (inc files) to be merged with generate_xml.py, which in turn requires a Mapnik installation. That seems to work for me, but is a bit of an effort, so supporting both Versions would be nice.

It might be even more convenient to be able to share generated SLDs and configure GeoServer from there, without the need for users to download the Mapnik style, but that is a separate topic.

nrenner avatar Oct 06 '11 15:10 nrenner

Well, the configuration that is done includes more than just the SLDs - mn2gt also sets up various data connections and prepares a layergroup. I don't think it would be difficult to upload SLDs in bulk though. It's also possible to copy geoserver data directories around whole, with a little care regarding absolute vs. relative paths.

dwins avatar Oct 06 '11 18:10 dwins

fixed empty label: upgrade_map_xml.py converts to new TextSymbolizer syntax

nrenner avatar Oct 07 '11 17:10 nrenner

new issue: table column text_poly.ele of type unknown ("NULL as ele" in select) ignored by GeoServer Workaround: alter table text_poly alter column ele type text; or replace "NULL as ele" with "NULL::text as ele"

Not sure if and how this should be addressed in m2gt?

nrenner avatar Oct 07 '11 17:10 nrenner

About the issue: not tunnel=yes with null values

<Filter>(([railway]='rail') and not (([tunnel]='yes')))</Filter>

translates to:

<Filter xmlns="http://www.opengis.net/ogc">
  <And>
    <PropertyIsEqualTo>
      <PropertyName>railway</PropertyName>
      <Literal>rail</Literal>
    </PropertyIsEqualTo>
    <Not>
      <PropertyIsEqualTo>
        <PropertyName>tunnel</PropertyName>
        <Literal>yes</Literal>
      </PropertyIsEqualTo>
    </Not>
  </And>
</Filter>

This filter does not match when tunnel is null with GeoServer (2.1.1) - it does however with GeoTools (8-SNAPSHOT)?

A possible solution seems to be translating to:

<Filter xmlns="http://www.opengis.net/ogc">
  <And>
    <PropertyIsEqualTo>
      <PropertyName>railway</PropertyName>
      <Literal>rail</Literal>
    </PropertyIsEqualTo>
    <Or>
      <PropertyIsNull>
        <PropertyName>tunnel</PropertyName>
      </PropertyIsNull>
      <PropertyIsNotEqualTo>
        <PropertyName>tunnel</PropertyName>
        <Literal>yes</Literal>
      </PropertyIsNotEqualTo>
    </Or>
  </And>
</Filter>

What do you think?

nrenner avatar Oct 07 '11 18:10 nrenner

I've run into this issue regarding nulls while working on the GeoServer CSS module and the solution you propose (ORing with an explicit null check) is exactly what I came up with as well.

dwins avatar Oct 08 '11 14:10 dwins

If this behavior has changed with GeoTools 8, you could also start using GeoServer trunk for rendering - GeoTools 8 is already in use on that branch.

dwins avatar Oct 08 '11 14:10 dwins

Ok, I've merged in your Color improvements and added some pretty basic version inspection in the Mapnik2GeoTools class (see the rulesFor method in Mapnik2Geotools.scala, https://github.com/dwins/mapnik2geotools/blob/26daebd438c004d616cee0ecfb8b6d9ed247e4d9/src/main/scala/Mapnik2GeoTools.scala#L197 )

Basically, we inspect the value and based on that change which SymTransformers to use for the file. I have started on TextSymbolizers a bit so those are the only transformers that are actually different right now.

dwins avatar Oct 09 '11 16:10 dwins

I also put together some notes on how I do development: https://github.com/dwins/mapnik2geotools/wiki/Hacking

Hope you find them useful.

dwins avatar Oct 09 '11 16:10 dwins

Thanks for your notes, I didn't know about the sbt triggered tasks, that's a nice feature!

nrenner avatar Oct 10 '11 19:10 nrenner

On the nulls issue:

I tested GeoServer from trunk, but still the same issue. But I found out that the difference between GeoTools and GeoServer is that SQL pre-filtering is active in GeoServer but not in GeoTools. This is because of different default settings for the maxFiltersToSendToDatastore (5) and MAX_FILTER_RULES (20) parameters, where the filter number of some styles fall in between. The problem now is that the SQL and Java filters evaluate differently with not equals and null values. I opened an issue for that: http://jira.codehaus.org/browse/GEOT-3949.

The workaround is to set maxFiltersToSendToDatastore / MAX_FILTER_RULES = 0 to disable SQL pre-filtering, which is fine in our case, because we have pre-filtered tables per style anyway.

nrenner avatar Nov 13 '11 18:11 nrenner