[OSM-talk] Rendering collisions in Mapnik

Tom Hughes tom at compton.nu
Thu May 29 18:28:03 BST 2008


In message <483EDB84.5050109 at frankieandshadow.com>
          David Earl <david at frankieandshadow.com> wrote:

> I understand Mapnik has some caption collision avoidance built in, yes?
> Can someone explain what the rules are?

Basically it's all down to the order in which things are processed
by mapnik - the first thing it processes wins.

That means that the order is controlled both by the order of the
various rendering rules, which controls whether one type of object
beats another, and by the order in which objects are retrieved from
the database.

> I ask because of this:
> http://www.openstreetmap.org/?lat=52.1988&lon=0.4122&zoom=14&layers=B00FF
> 
> You can see there's a series of small villages, Saxon Street, Little
> Ditton, Woodditton, Stetchworth dotted over the area, but the name of
> probably the most significant is missing, which is rather disturbing as
> it gives an incorrect sense of incompleteness.

It's a known bug that at the moment we don't order places when
fetching them from the database so it is arbitrary which place
wins in a case like this. We need to make osm2pgsql assign
a z_order to place nodes and then retrieve them in order in the
stylesheet.

> If you follow the road South West and then West from Stetchworth you
> come to a crossroads with the B1061. A point very close to that
> crossroads is Dullingham (as you can see if you either zoom out or zoom
> in one level).
> 
> I'm guessing that the collision detection is giving preference to the
> B1061 label.
> 
> Is this a deliberate precedence, or is it just which is seen first?

That will be down to the stylesheet rendering road names before place
names - changing the order of the rules is quite scary though and can
have hard to predict consequences...

> Also for points, what about moving the caption slightly. Are you using
> some kind of grid of cells to decide whether an area of map is occupied
> by a caption? If so rather than abandoning it at first go, might it be
> possibly to try neighbouring cells in an outwardly expanding spiral up
> to some limit deemed too far? In this case it wouldn't matter a jot if
> the name Dullingham was shown 1mm further south.

The ability to indicate that some names can be peturbed a bit to find
space for them is something that would have to be added to mapnik
itself - it is something that has been discussed because there are
definitely cases where it would be useful.

Tom

-- 
Tom Hughes (tom at compton.nu)
http://www.compton.nu/




More information about the talk mailing list