Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force polygon labels within polygon #3948

Closed
mapserver-bot opened this issue Apr 4, 2012 · 5 comments
Closed

Force polygon labels within polygon #3948

mapserver-bot opened this issue Apr 4, 2012 · 5 comments

Comments

@mapserver-bot
Copy link

Reporter: daengineer
Date: 2011/07/06 - 16:38
Trac URL: http://trac.osgeo.org/mapserver/ticket/3948
It would be very nice if there was an option to force polygon labels to fall completely within the polygon. The MINFEATURESIZE directive does a good job of weeding polygons that are too small but many labels are still placed that do not fall within the polygon. ArcMap has an option to tell labels to fall within the polygons. I have attached a screenshot with ArcMap on the left and MapServer on the right to illustrate the problem.

@mapserver-bot
Copy link
Author

@ghost ghost assigned sdlime Apr 5, 2012
@woodbri
Copy link

woodbri commented Sep 4, 2012

Email from Jukka,

The polygons in the data are cadastrial parcels and user wants that
each parcel could be identified right. GetFeatureInfo is not enough
because he wants also printed maps. Therefore each parcel should have
a label that is readable in some scale. That is not always easy
because the size of parcels varies a lot.

Here is a reference implementation by the National Land Survey of
Finland:
http://www.paikkatietoikkuna.fi/web/fi/kartta?zoomLevel=10&coord=271051.5_6947937&mapLayers=base_35+100+!default!,90+100+,99+100+&showMarker=false&forceCache=true

NLS has decided to use vertical labels with variable font size for
keeping the label text usually inside their polygons. Sometimes there
seems to be also leader lines. The result is rather readable but I
believe that labels have at least partly set by hand. In the NLS
service the labels comes from a readily rasterised layer and they are
shown only on three highest zoom levels.

Here is another place with very long and narrow parcels. The NLS
labeling system does not suit here very well for web browsing because
labels are often in a fixed place outside the map window.
http://www.paikkatietoikkuna.fi/web/fi/kartta?zoomLevel=10&coord=227539.5_6999494&mapLayers=base_35+100+!default!,90+100+,99+100+&showMarker=false&forceCache=true

If you look at RFC 81, it is likely that using this placement algorithm with leader lines would also work well with these kinds of parcels. It would be interesting to see how they determine the font size. It looks like it might be based on a function of the horizontal width of the polygon at the label point. It is not clear to me how they compute the label point based on these images. I think they use the leader lines if the horizontal width of the polygon at the label point is less than some %age of the label length.

@markvolzlyoncounty
Copy link

Hello,

I think many users would be able to take advantage of being able to force labels inside polygons. At the same time I realize that the current "bounding box" algorithm is faster. My question is could both be possible?

Scenario One: It would be fastest to use a bounding box to creating labels for a polygon that has a rectangular shape such as a section or township.
LABEL
....
MINFEATURESIZE AUTO
END

Scenario Two: Force labels to fit inside a polygon in layers where avoiding ambiguity is more important than speed such as a soils layer. A ForceLabelInside (or a better keyword) will tell MapServer to use a slower algorithm to help place the label inside the polygon. This slower, but better placed algorithm might also be used for layers that are cached.
LABEL
....
MINFEATURESIZE AUTO
ForceLabeInside YES # Possibilities NO (current and default), YES (force label inside), ?
END

Thanks

@woodbri
Copy link

woodbri commented Sep 5, 2012

Summary of the ideas bounced around on the list:

  • for ANGLE AUTO look into generating the longest line in a polygon and labeling along that line
  • for FONTSIZE AUTO use a function of the horizontal width of the polygon at the label point as a percentage of the label length, will probably need MIN/MAX FONTSIZE to control that
  • if the label will not fit within some percentage of the horizontal width of the polygon at the label point then use the RFC81 positioning mechanism with a leader line.
  • look at labeling a polygon along the polygon boundary offset in or out of the polygon and FOLLOWs the boundary. Add support for MINDISTANCE and this can be used for labeling country polygons along a border or for parcels in a similar manner.

@mapserver-bot
Copy link
Author

This is an automated comment

This issue has been closed due to lack of activity. This doesn't mean the issue is invalid, it simply got no attention within the last year. Please reopen with missing/relevant information if still valid.

Typically, issues fall in this state for one of the following reasons:

  • Hard, impossible or not enough information to reproduce
  • Missing test case
  • Lack of a champion with interest and/or funding to address the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants