[mapserver-dev] Labelcache potential optimization using spatial index

Daniel Morissette dmorissette at mapgears.com
Thu Feb 21 06:12:54 PST 2013

On 13-02-21 9:11 AM, Daniel Morissette wrote:
> Devs,
> I came across the following article yesterday:
> http://mapbox.com/osmdev/2013/02/12/labeling-id/
> All very interesting stuff relating to OSM editing, but the bit that
> caught my attention as MapServer dev is this paragraph:
> """
> Because labels are updated with each redraw of the map, they need to be
> extremely fast. iD calculates label bounding boxes based on estimated
> text length, since it’s slow to use browser-calculated bounds. We use
> RTree to optimize collision detection and proximity searches, a
> technique inspired by kothic.js.
> """
> Using a spatial index to optimize collection detection. Of course!

Err... typo:

"Using a spatial index to optimize _ collision_ detection..."

> As you all know, the labelcache processing can sometimes account for a
> significant part of the rendering time in MapServer, even more than 50%
> in some maps with lots of labels, and this idea of using a spatial index
> to manage the collision detection could really help improve that.
> There would be one drawback though: at the moment the order in which the
> labels enter the cache defines their rendering priority, and a
> side-effect of using a spatial index would be to lose that feature.
> However, one could deal with this issue with proper use of the
> LABEL.PRIORITY in all their layers.
> An interesting idea to keep in mind anyway...

Daniel Morissette
Provider of Professional MapServer Support since 2000

More information about the mapserver-dev mailing list