[Mapcss] Collisions
Komяpa
me at komzpa.net
Sat Jul 30 15:40:48 BST 2011
Hi,
There's a need to handle collisions in more advanced way.
For now, in both Mapnik and Kothic, layers are being drawn in order of
z-indexes, and icons/labels are just being dropped when they intersect
with other labels.
That's fine on high zoom, where not so much collisions happen, but
isn't useful on low zooms, where lots of cities/towns need to be
shown.
We need to reorder elements before rendering them. For example, when
rendering thousands of cities on a single tile, we want to see the
ones with larger population first. Same applies to country labels.
Also, it's evident that map needs not only icons with centered label
under it. Even a naive algorythm that can move a label around icon
until it fits with other icons can let us, for example, show subway
map on low zoom of a city with labels for each station.
So, I propose to add the following things:
collision-sort-by: (tag/eval()) - a value used for sorting items
within z-index and layer when rendering;
collision-sort-order: asc/desc, by default desc;
collision-separate-marker: true/false, default false. If true, when
it's impossible to find placement for a label but possible for icon or
vice versa, nothing is rendered, otherwise both are rendered;
Also, there are some cool features in mapnik since recently that I'd
wish to see in MapCSS (see Positions on
http://trac.mapnik.org/wiki/TextSymbolizer):
- variable label sizes. Very useful in conjunction with ordering by
population: smaller countries' labels will become smaller and try to
fit until we're really out of space on the image;
- variable text placement, in case of "center" position. Label should
be able to be shifted anywhere possible (still not farther than
"text-offset" from center).
So:
font-size should be allowed not only an exact value, but also a list
of different sizes, tried to be used from start to the end. If a
renderer doesn't want to support that, it should just stick to the
first value;
text-placement, with default value "exact". pssible:
- "any" - whatever renderer decides;
- "exact" or just "X" - the one that was chosen otherwise (centered,
offsetted down by text-offset);
- N, E, S, W, NE, SE, NW, SW, X - values, that can be separated by
commas. show where a label can be shifted instead of "down" by
"text-offset" amount of pixels.
Both parts are quite easily expressed in mapnik2, probably not
including labels offsetted in different directions with
collision-separate-marker: false, as there's no variable position
possible for ShieldSymbolizer in Mapnik currently.
--
Darafei "Komяpa" Praliaskouski
OSM BY Team
xmpp:me at komzpa.net mailto:me at komzpa.net
More information about the Mapcss
mailing list