[OSM-talk] Mapnik: strange prioritisation/appearance of place names

Andy Allan gravitystorm at gmail.com
Mon Mar 23 12:34:29 GMT 2009


On Mon, Mar 23, 2009 at 12:13 PM, Adam Schreiber <sadam at clemson.edu> wrote:
> On Mon, Mar 23, 2009 at 8:08 AM, Elena of Valhalla
> <elena.valhalla at gmail.com> wrote:
>> finding a working algorithm that uses only objective data and is
>> always able to select the proper item to print would be excellent, but
>> also probably not feasible in real life.
>
> Population?  People can vote importance with their feet.

Seems reasonable to me, even though it's not going to be perfect. The
issue comes with the lack of ordering in the text layer in osm.xml -
effectively, objects are picked at random and their names written, and
if there's no space left for it it gets dropped. It's painfully
obvious on the cycle map that there's problems with name ordering -
e.g. if you have cycle routes in your town, a shield on the route is
likely to kick off the town name. So the map tends towards labelling
towns with no cycle routes! I started looking at fixing it yesterday,
but layering on such complex maps is, well, complex.

<Layer name="text" status="on" srs="+proj=merc +a=6378137 +b=6378137
+lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null
+no_defs +over">
    <StyleName>text</StyleName>
    <Datasource>
      <Parameter name="type">postgis</Parameter>
      <Parameter name="password">martyn</Parameter>
      <Parameter name="host">localhost</Parameter>
      <Parameter name="port">5432</Parameter>
      <Parameter name="user">postgres</Parameter>
      <Parameter name="dbname">osm</Parameter>
      <Parameter name="table">planet_osm_point</Parameter>
      <Parameter name="estimate_extent">false</Parameter>
      <Parameter name="extent">-20037508,-19929239,20037508,19929239</Parameter>
    </Datasource>
</Layer>

The "table" that mapnik selects from for point-text labels could be
ordered by descending population. But it might need a bit more
cleverity, since on the cycle map I've adapted it to take into
consideration the capacity of cycle parking. I suspect steve8 will
need to look into making separate layers for separate labelling needs
- a places-text layer ordered by descending population, pubs ordered
by price_of_lager_in_pounds_per_pint ascending, and so on.
Alternatively, osm2pgsql's z-ordering code could be adapted to all the
circumstances, and a simple "order by z_order" added in mapnik, ala
the roads layers - i.e. the ordering logic could go in either
osm2pgsql or the mapnik layer definitions.

Cheers,
Andy




More information about the talk mailing list