Opened 12 years ago
Closed 12 years ago
#4239 closed defect (invalid)
Issues with multiple label blocks and symbols
Reported by: | woodbri | Owned by: | sdlime |
---|---|---|---|
Priority: | normal | Milestone: | 6.2 release |
Component: | MapServer C Library | Version: | svn-trunk (development) |
Severity: | normal | Keywords: | |
Cc: |
Description
I'm trying to convert my roads layer from a LINE (for stlying the roads and labeling them) and ANNOTATION (for placing hwy shields) into a single LINE layer with with multiple label blocks.
It seems close to working except that the symbols for the shields are not getting rendered. The text for the shields is rendered by not the symbols.
http://imaptools.com:8080/demo/tiger2011.html?zoom=10&lat=34.77041&lon=-92.22651&layers=00B0
The layer looks like this:
LAYER NAME "roads" METADATA "ows_title" "Roadway features" "ows_srs" "EPSG:4269 EPSG:4326" "ows_abstract" "Road way features from the U.S. Census ROADS data layer." END TYPE LINE TILEINDEX "tidx-ROADS" PROJECTION "+proj=longlat +ellps=GRS80 +datum=NAD83" #EPSG: 4269 END INCLUDE "map-ROADS.inc" END
And the include looks like:
MAXSCALEDENOM 500000 CLASSITEM "RTTYP" LABELITEM "FULLNAME" SIZEUNITS METERS CLASS EXPRESSION ('[MTFCC]' = 'S1100') STYLE COLOR "#FFC95B" WIDTH 20 MAXWIDTH 16 OUTLINECOLOR "#E9B352" OUTLINEWIDTH 1.5 END LABEL MAXSCALEDENOM 300000 TYPE TRUETYPE FONT "arial" SIZE 18 MAXSIZE 10 MINSIZE 8 COLOR "#3C0800" OUTLINECOLOR "#FFC95B" PARTIALS FALSE MINDISTANCE 250 MINFEATURESIZE 10 BUFFER 4 ANGLE FOLLOW PRIORITY 4 END LABEL MAXSCALEDENOM 300000 EXPRESSION ('[RTTYP]' = 'I' && '[RTENUM]' ~ '.') TEXT '[RTENUM]' STYLE #GEOMTRANSFORM 'labelpnt' SYMBOL "I" END SIZE TINY POSITION CC OFFSET 1 0 MINDISTANCE 100 COLOR "#ffffff" PARTIALS FALSE PRIORITY 7 END LABEL MAXSCALEDENOM 300000 EXPRESSION ('[RTTYP]' = 'U' && '[RTENUM]' ~ '.') TEXT '[RTENUM]' STYLE #GEOMTRANSFORM 'labelpnt' SYMBOL "U" END SIZE TINY POSITION CC OFFSET 1 0 MINDISTANCE 100 COLOR "#ffffff" PARTIALS FALSE PRIORITY 7 END END
and more classes using the same patterns as above. I have tried with and without the GEOMTRANSFORM 'labelpnt'
At 433K scaledenom and larger I have another layer with generalized data and only one label block per class and it displays the shields correctly.
http://imaptools.com:8080/demo/tiger2011.html?zoom=9&lat=34.77041&lon=-92.22651&layers=00B0
This layer looks like:
LAYER NAME "pri_sec_roads" METADATA "ows_title" "Primary and Secondary Roadway features" "ows_srs" "EPSG:4269 EPSG:4326" "ows_abstract" "Primary and Secondary Roadway features from the U.S. Census PRISECROADS data layer." END TYPE LINE TILEINDEX "tidx-PRISECROADS-S" #DATA "PRISECROADS-S/tl_2011_17_prisecroads.shp" PROJECTION "+proj=longlat +ellps=GRS80 +datum=NAD83" #EPSG: 4269 END INCLUDE "map-PRISECROADS.inc" END
and the include follows:
LABELITEM "RTENUM" CLASS MAXSCALEDENOM 5000000 MINSCALEDENOM 300000 EXPRESSION ('[RTTYP]' = 'I') STYLE COLOR "#FFC95B" WIDTH 1.5 OUTLINECOLOR "#E9B352" OUTLINEWIDTH 0.5 END LABEL STYLE SYMBOL "I" END SIZE TINY POSITION CC OFFSET 1 0 MINDISTANCE 100 COLOR "#ffffff" PARTIALS FALSE PRIORITY 7 END END CLASS MAXSCALEDENOM 5000000 MINSCALEDENOM 300000 EXPRESSION ('[RTTYP]' = 'U' && '[MTFCC]'='S1100') STYLE COLOR "#F3E999" WIDTH 0.5 OUTLINECOLOR "#ECD390" OUTLINEWIDTH 0.5 END LABEL STYLE SYMBOL "U" END SIZE TINY POSITION CC OFFSET 1 0 MINDISTANCE 100 COLOR "#000000" PARTIALS FALSE PRIORITY 7 END END CLASS MAXSCALEDENOM 5000000 MINSCALEDENOM 300000 EXPRESSION ('[RTTYP]' = 'U') STYLE COLOR "#F3E999" WIDTH 0.5 OUTLINECOLOR "#ECD390" OUTLINEWIDTH 0.5 END END CLASS MAXSCALEDENOM 1000000 MINSCALEDENOM 300000 EXPRESSION ('[MTFCC]' = 'S1100') STYLE COLOR "#FFC95B" WIDTH 1.5 OUTLINECOLOR "#E9B352" OUTLINEWIDTH 0.5 END END CLASS MAXSCALEDENOM 1000000 MINSCALEDENOM 300000 EXPRESSION ('[MTFCC]' = 'S1200') STYLE COLOR "#FFFB89" WIDTH 0.75 OUTLINECOLOR "#ECD390" OUTLINEWIDTH 0.5 END END
Change History (11)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
SteveW, can you try this patch ?
Index: maplabel.c =================================================================== --- maplabel.c (revision 13231) +++ maplabel.c (working copy) @@ -486,7 +486,7 @@ classObj *classPtr=NULL; if(!label) return(MS_FAILURE); // RFC 77 TODO: set a proper message - if(!label->annotext) return(MS_SUCCESS); /* not an error */ + if(!label->annotext || label->status == MS_OFF) return(MS_SUCCESS); /* not an error */ layerPtr = (GET_LAYER(map, layerindex)); /* set up a few pointers for clarity */ classPtr = GET_LAYER(map, layerindex)->class[classindex];
follow-up: 4 comment:3 by , 12 years ago
Ok, the patch appears to already be checked into r13239.
So regarding a mix of labels like ANGLE FOLLOW and additional highway shields, I'm not sure I follow the discussion of grouped labels and ungrouped labels. It would seem to me that we might want shields to be grouped but the ANGLE FOLLOWs not part of the group.
I also do not understand how potential label points are generated when you have something like FOLLOW and shields because you obviously want to look for additional label points that are not occupied by the previous label. But maybe that is already part of the logic.
So is the problem that the shield symbol and the text are going at the same point and one is bumping off the other because addLabel is getting drawn instead of addLabelGroup?
comment:4 by , 12 years ago
Replying to woodbri:
So is the problem that the shield symbol and the text are going at the same point and one is bumping off the other because addLabel is getting drawn instead of addLabelGroup?
Yes, this is very probable. The use-case we were targetting with multiple labels did not concern line labelling, and I suspect Steve didn't look into it during implementation.
comment:5 by , 12 years ago
Ok, I can understand that, but what is confusing to me is why is the shield text drawn, but not the shield?
LABEL MAXSCALEDENOM 300000 EXPRESSION ('[RTTYP]' = 'U' && '[RTENUM]' ~ '.') TEXT '[RTENUM]' STYLE #GEOMTRANSFORM 'labelpnt' SYMBOL "U" END SIZE TINY POSITION CC OFFSET 1 0 MINDISTANCE 100 COLOR "#ffffff" PARTIALS FALSE PRIORITY 7 END
So it is obviously processing this label block because the text is getting rendered but the style with the symbol is not getting rendered. So I guess your thought is that this is the difference between addLabel and addLabelGroup? I just seems that if we are processing a label block it should consider all the tags or explicitly error out on some invalid collection of incompatible tags.
I can see that there maybe a need to enhance multiple labels for line labeling especially if we need to generate additional potential label points.
comment:6 by , 12 years ago
Ha! the shields are there, they are just very tiny! I zoomed in to here and found:
http://imaptools.com:8080/demo/tiger2011.html?zoom=16&lat=34.76138&lon=-92.26222&layers=00B0
if you zoom out one you can see tiny blotches that are the shields. So it seems that because I used SIZEUNITS METERS on the ROADS layer and PIXELS on the ANNOTATION layer that I need to fiddle with MINSIZE and MAXSIZE to fix the SYMBOL size. The text didn't scale because it is fixed at SIZE TINY.
comment:7 by , 12 years ago
Ha! I personally gave up on using sizeunits for this kind of cartographic output, as whereas they are an easy way to get things rolling fast for different scales, they make it nearly impossible to precisely play on font sizes, symbol sizes and offsets, etc...
I would probably start using them again if we had a finer grained control on where they are applied, e.g.
STYLE WIDTH 5 meters OFFSET 2 pixels END
comment:8 by , 12 years ago
I would love to see that as an enhancement. Meanwhile MINSIZE and MAXSIZE are always in pixels so you can add them to override the size units. It is a tough trade off, if I setup scale dependent classes versus scalable features like roads it can double or quadruple the size of the mapfile which makes if difficult to edit and keep everything in sync with one another.
comment:9 by , 12 years ago
I have fixed the symbols using MINSIZE and MAXSIZE, but there is a problems with OUTLINEWIDTH scaling on the state shields.
http://imaptools.com:8080/demo/tiger2011.html?zoom=14&lat=34.7514&lon=-92.2684&layers=00B0
Notice the circle shield in the center and zoom in on it and you will see the outline width scale. This is problematic from a couple of points of view.
- I can work around it by changing the symbol to a pixmap image.
- My next iteration on this mapfile is to convert all the pixmap symbols to SVG symbols and I'm not sure how the scaling will impact them.
As noted above, finer grain control on units would solve this issue.
Here is the CLASS definition for the state shield in the URL above.
CLASS EXPRESSION /^[USC]/ STYLE COLOR "#FFFB89" WIDTH 18 OUTLINECOLOR "#ECD390" OUTLINEWIDTH 1 END LABEL MAXSCALEDENOM 200000 TYPE TRUETYPE FONT "arial" SIZE 16 MAXSIZE 10 MINSIZE 8 COLOR "#816C34" OUTLINECOLOR "#FFFB89" PARTIALS FALSE MINDISTANCE 250 MINFEATURESIZE 10 BUFFER 4 ANGLE FOLLOW PRIORITY 4 END LABEL MAXSCALEDENOM 200000 EXPRESSION ('[RTTYP]' = 'U' && '[RTENUM]' ~ '.') TEXT '[RTENUM]' STYLE #GEOMTRANSFORM 'labelpnt' SYMBOL "U" MINSIZE 20 MAXSIZE 20 END SIZE TINY POSITION CC OFFSET 1 0 MINDISTANCE 100 COLOR "#000000" PARTIALS FALSE PRIORITY 7 END LABEL MAXSCALEDENOM 200000 EXPRESSION ('[RTTYP]' = 'S' && '[RTENUM]' ~ '.') TEXT '[RTENUM]' STYLE #GEOMTRANSFORM 'labelpnt' SYMBOL "circle-filled" COLOR "#FFFFFF" OUTLINECOLOR "#000000" # OUTLINEWIDTH 1 ##### problem is outlinewidth scaling MINSIZE 19 MAXSIZE 19 END # STYLE # SYMBOL "circle" # COLOR "#000000" # MINSIZE 19 # MAXSIZE 19 # END SIZE TINY POSITION CC MINDISTANCE 100 COLOR "#000000" PARTIALS FALSE PRIORITY 7 END END
comment:10 by , 12 years ago
I also tried adding OUTLINEWIDTH and removing the OUTLINECOLOR totally and using a separate STYLE block for the OUTLINE, but it scaled in width also.
comment:11 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I have created a circle shield for the state hwys as an image so the outline width is constant with the image. Some url as above, look at the circle shield in the center and zoom in/out.
http://imaptools.com:8080/demo/tiger2011.html?zoom=14&lat=34.7514&lon=-92.2684&layers=00B0
OK, I'm closing this as user error and opening a new ticket for fine grain units support.
Not a solution, but a couple of notes:
The line drawing code does not call msAddLabelGroup, but msAddLabel repeatedly for each label.
Labels that are status OFF are added which seems definitely wrong. Not sure what to do here as ANGLe FOLLOW labels (and by extent line layers) have a different treatment in msDrawLabelCache(). SteveL, maybe msDrawLabelCache should be reworked so that we don't treat FOLLOW labels differently than regular ones, therefore always calling addLabelGroup() and not addLabel() from msDrawShape()?