Ticket #13 (assigned defect)

Opened 23 months ago

Last modified 4 months ago

Rendering text labels when point size of labels exceeds the width of the line

Reported by: reid@… Owned by: artem
Priority: critical (top) Milestone: 1.0.0
Component: Core Library Version: 0.5.0
Severity: Major Keywords:
Cc: paulsmith@… Patch Needs Improvement:
Needs Docmentation: Has Patch?:
Design Decision Needed:

Description

We are building tiles where the point size of line labels can exceed the width of the line. In these case, labels are applied very sparsely (see example tiles).

I don't have a complete example to share, since it would require access to our database, but let me know if you can't reproduce it. I can try to get something out of rundemo.py.

Please feel free to contact me if you need more information or testing.

Attachments

171_449.png (1.4 kB) - added by reid@… 23 months ago.
orange roads should have more labels
173_449.png (24.4 kB) - added by reid@… 23 months ago.
orange roads should have more labels
2778_7198.png (21.3 kB) - added by reid@… 23 months ago.
yellow roads should be labeled
highlighted (33.5 kB) - added by paul 12 months ago.
Highlighted blocks to be labeled
highlighted.png (33.5 kB) - added by paul 12 months ago.
Highlighted blocks to be labeled
3ptlabels.png (34.5 kB) - added by paul 12 months ago.
Labels with 3pt font size
4ptlabels.png (32.1 kB) - added by paul 12 months ago.
Labels with 4pt font size
pointplacement.png (43.6 kB) - added by paul 12 months ago.
Labels at 9pt font size with point placement
segments.png (45.9 kB) - added by paul 12 months ago.
Highlighted individual segments
desired.png (25.8 kB) - added by paul 12 months ago.
Desired label layout
strange-placement.png (43.2 kB) - added by paul 12 months ago.
Strange label placement after reducing down blocks to streets
test.shp (52.5 kB) - added by rpriedhorsky 8 months ago.
shapefile which exhibits the bug
232_2432.png (18.8 kB) - added by rpriedhorsky 8 months ago.
poorly labeled tile

Change History

Changed 23 months ago by reid@…

orange roads should have more labels

Changed 23 months ago by reid@…

orange roads should have more labels

  Changed 23 months ago by reid@…

171_449.png was uploaded in error and can be removed.

Changed 23 months ago by reid@…

yellow roads should be labeled

follow-up: ↓ 5   Changed 23 months ago by artem

  • status changed from new to assigned

At the moment there are no attempts to find text placement if length of geometry is less than text length : source:/trunk/src/placement_finder.cpp@452#L213

What are the options?

  1. Place text label on straight line between start/end points?
  2. ???

  Changed 16 months ago by artem

  • component changed from OGC Server (WMS) to Core Library
  • summary changed from fixme to Rendering text labels when point size of labels exceeds the width of the line

  Changed 12 months ago by paul

  • cc paulsmith@… added

in reply to: ↑ 2 ; follow-up: ↓ 6   Changed 12 months ago by paul

Replying to artem:

What are the options? 1. Place text label on straight line between start/end points? 2. ???

For my applications, the common case is a straight street segment. So having the text label extend proportionally beyond the start and end points of the feature is acceptable.

If I were styling my map and the above behavior were implemented, and a particular were /not/ straight, I would expect the label to follow the feature as currently implemented, and then as it goes "off the edges," it would retain the angle of the last character drawn, like a vector extending out from each end.

Changed 12 months ago by paul

Highlighted blocks to be labeled

Changed 12 months ago by paul

Highlighted blocks to be labeled

Changed 12 months ago by paul

Labels with 3pt font size

Changed 12 months ago by paul

Labels with 4pt font size

Changed 12 months ago by paul

Labels at 9pt font size with point placement

Changed 12 months ago by paul

Highlighted individual segments

Changed 12 months ago by paul

Desired label layout

in reply to: ↑ 5   Changed 12 months ago by paul

For an example, I want to label "arterial" streets, highlighted here in red:

Highlighted blocks to be labeled

(It's worth remembering that these actually individual blocks that combine to appear to be contiguous streets; here is the "inverse", so you can see where the arterial segments are:)

Highlighted individual segments

If I use point placement of the labels, say 9pt font size, I get this:

Labels at 9pt font size with point placement

I could control minimum distance and spacing at this point but would still get suboptimal results. Labels need to follow the line of the street. Changing to line placement, labels disappear at 9pt, so changing to a very small size just to see if it works at all (3pt) yields:

Labels with 3pt font size

Increasing the font size starts to knock out most labels, as they get longer than the length of the underlying feature/block:

Labels with 4pt font size

What I desire is this (mocked-up by hand in the GIMP):

Desired label layout

If Google can do it, so should Mapnik ;)

Changed 12 months ago by paul

Strange label placement after reducing down blocks to streets

  Changed 12 months ago by dave

I think the strange placement is caused by the text renderer not handling multi-linestrings nicely. If you could send me a small shapefile that can cause it I will investigate it.

  Changed 11 months ago by artem

  • milestone changed from 0.5.0 to 1.0.0

Changed 8 months ago by rpriedhorsky

shapefile which exhibits the bug

Changed 8 months ago by rpriedhorsky

poorly labeled tile

  Changed 8 months ago by rpriedhorsky

  • version changed from 0.3.0 to 0.5.0

A ping on this bug. I just upgraded to 0.5.1 and it's still present.

The fix that I would really like to see is joining of separate but adjacent linestrings with the same name within mapnik. I had thought (and stated earlier) that this joining could be done in the database. I have not been able to figure out how to do this. The best I can do is to bring the linestrings together as multilinestrings (potentially with gaps), and this still has severe performance problems.

Bottom line: it may still be possible to do this in the database, but I'm not a PostGIS noob and in any case it seems rough to require users to write complex, tricky queries to get this (fairly basic IMO) functionality working.

I have attached two files. 232_2432.png is a rendering taken from our PostGIS database. There should be more labels here: all but the narrowest streets should be labeled at reasonable intervals.

The second attachment is a shapefile extract of our database for the same region as the tile. It is missing a few properties but I don't think they will be missed for this purpose.

Please let me know how I can help improve Mapnik in this aspect. Thanks!

  Changed 4 months ago by springmeyer

  • priority set to critical (top)
Note: See TracTickets for help on using tickets.