Opened 13 years ago

Last modified 12 years ago

#4015 new defect

label style offset, geomtransform labelpoly, symbolscaledenom

Reported by: havatv Owned by: tbonfort
Priority: high Milestone: 6.2 release
Component: Renderer API Version: 6.0
Severity: major Keywords:
Cc: havatv, sdlime, tbonfort

Description

I have discovered that LABEL STYLE OFFSET, at least when used with GEOMTRANSFORM 'labelpoly' does not work as expected when SYMBOLSCALEDENOM is specified for the layer. If someone is interested in testing, use shp2img with the following map file (FONTSET will probably have to be changed). If SYMBOLSCALEDENOM is commented out, behaviour is as expected. When SYMBOLSCALEDENOM is in effect, the offset will be scaled. Documentation says that OFFSET is given in pixels.

MAP
  SIZE 200 200
  EXTENT 0 0 100 100
  UNITS meters
  IMAGETYPE png

  FONTSET /usr/share/fonts/truetype/font.list

  SYMBOL
    NAME "circle"
    TYPE ellipse
    FILLED true
    POINTS 1 1 END
  END

  LAYER
    NAME "feature"
    STATUS DEFAULT
    TYPE POINT
    SYMBOLSCALEDENOM 25000
    FEATURE
      TEXT "Label"
      POINTS
        50 50
      END
    END
    CLASS
      STYLE # black filled circle
        SYMBOL 'circle'
        MINSIZE 4
        SIZE 4
        MAXSIZE 4
        COLOR 0 0 0
      END
      LABEL
        STYLE # ------ Gray Box (shadow) ------
            GEOMTRANSFORM labelpoly
            COLOR 102 102 102
            OFFSET 2 2
        END
        STYLE # ------ Red Box ------
            GEOMTRANSFORM labelpoly
            COLOR 255 0 0
        END
        FONT "arial"
        TYPE TRUETYPE
        POSITION UR
        MINSIZE 12
        SIZE 12
        MAXSIZE 12
        COLOR 0 0 0
      END
    END
  END # point
END # Map file

I have tested with 6.0 and trunk.

See the attached files.

Attachments (3)

labelshadow-offset_with-symbolscaledenom.png (1.2 KB ) - added by havatv 13 years ago.
labelshadow-offset_witout-symbolscaledenom.png (1.1 KB ) - added by havatv 13 years ago.
labelshadow-offset.png (5.8 KB ) - added by havatv 12 years ago.
The new illustration generated from the mapfile in havatv

Download all attachments as: .zip

Change History (6)

comment:1 by tbonfort, 13 years ago

Component: MapServer C LibraryMapServer Documentation
Owner: changed from sdlime to jmckenna

offset for polygon shapes is scaled by the layer's sizeunits/symbolscaledenom, and this also applies to the LABEL STYLE.

doc should be updated to indicate that offset is scaled in the same way as size, width, etc...

comment:2 by havatv, 13 years ago

Cc: sdlime tbonfort added
Component: MapServer DocumentationMapServer C Library
Owner: changed from jmckenna to sdlime

Documentation seems to be OK for style offset. It is Label offsets that are said to be pixels.

The problem here seems to be the use of MAXSIZE and MINSIZE for the LABEL (if MINSIZE and MAXSIZE is not used, everything is OK).

Would it be possible to take LABEL MAXSIZE and MINSIZE into consideration when computing the OFFSET of a LABELPOLY (when symbol scaling is in effect)?

If not, I don't think it will be possible to use a backgroundshadow for labels in a layer with SYMBOLSCALEDENOM specified, and limits to label scaling (LABEL MINSIZE and MAXSIZE) in effect.

comment:3 by havatv, 12 years ago

Component: MapServer C LibraryRenderer API
Milestone: 6.2 release
Owner: changed from sdlime to tbonfort
Priority: normalhigh

I will explain some more, with a new map file and a new illustration. This has to do with labels with a backgroundcolour and backgroundshadow (specified using LABEL BACKGROUNDCOLOR, BACKGROUNDSHADOWCOLOR and BACKGROUNDSHADOWSIZE in pre-6.0 versions of Mapserver).

1) geomtransform labelpoly with OFFSET works fine for non-scaled symbols (no LAYER SYMBOLSCALEDENOM).

2) geomtransform labelpoly with OFFSET works fine for scaled symbols (SYMBOLSCALEDENOM specified), when there is no limit to scaling (no LABEL MINSIZE / MAXSIZE).

3) geomtransform labelpoly with OFFSET does not work as expected for scaled symbols (SYMBOLSCALEDENOM specified) when the scaling is limited (LABEL MINSIZE / MAXSIZE). This has to be fixed in order to maintain the functionality of pre 6.0 Mapserver versions.

Here is a mapfile that demonstrates the problem. Run it with shp2img (FONTSET will have to reflect your system font path). At the bottom is the label resulting from the situation 1) above. At the top is the label resulting from the situation 3) above. In the middle is the label resulting from the situation 2) above. As you can see, for the label in the middle, the shadow offset is scaled without respecting the LABEL MINSIZE / MAXSIZE.

MAP
  SIZE 400 200
  EXTENT 0 0 400 200
  UNITS meters
  IMAGETYPE png

  FONTSET /usr/share/fonts/truetype/font.list

  SYMBOL
    NAME "circle"
    TYPE ellipse
    FILLED true
    POINTS 1 1 END
  END

  LAYER
    NAME "featurescaled"
    STATUS DEFAULT
    TYPE POINT
    SYMBOLSCALEDENOM 25000  # This causes problems in 6.0
    FEATURE
      TEXT "Label"
      POINTS
        10 90
      END
    END
    CLASS
      STYLE # black filled circle
        SYMBOL 'circle'
        MINSIZE 4
        SIZE 4
        MAXSIZE 4
        COLOR 0 0 0
      END
      LABEL
        STYLE # ------ Gray Box (shadow) ------
          GEOMTRANSFORM labelpoly
          COLOR 102 102 102
          OFFSET 2 2
        END
        STYLE # ------ Red Box ------
          GEOMTRANSFORM labelpoly
          COLOR 255 0 0
        END
        FONT "arial"
        TYPE TRUETYPE
        POSITION UR
        SIZE 12
        COLOR 0 0 0
      END
    END
  END # layerscale

  LAYER
    NAME "featurescaledminmax"
    STATUS DEFAULT
    TYPE POINT
    SYMBOLSCALEDENOM 25000
    FEATURE
      TEXT "Label"
      POINTS
        10 50
      END
    END
    CLASS
      STYLE # black filled circle
        SYMBOL 'circle'
        MINSIZE 4
        SIZE 4
        MAXSIZE 4
        COLOR 0 0 0
      END
      LABEL
        STYLE # ------ Gray Box (shadow) ------
            GEOMTRANSFORM labelpoly
            COLOR 102 102 102
            OFFSET 2 2
        END
        STYLE # ------ Red Box ------
            GEOMTRANSFORM labelpoly
            COLOR 255 0 0
        END
        FONT "arial"
        TYPE TRUETYPE
        POSITION UR
        MINSIZE 12
        SIZE 12
        MAXSIZE 12
        COLOR 0 0 0
      END
    END
  END # layer featurescaledminmax

  LAYER
    NAME "featurefixed"
    STATUS DEFAULT
    TYPE POINT
    FEATURE
      TEXT "Label"
      POINTS
        10 10
      END
    END
    CLASS
      STYLE # black filled circle
        SYMBOL 'circle'
        MINSIZE 4
        SIZE 4
        MAXSIZE 4
        COLOR 0 0 0
      END
      LABEL
        STYLE # ------ Gray Box (shadow) ------
            GEOMTRANSFORM labelpoly
            COLOR 102 102 102
            OFFSET 2 2
        END
        STYLE # ------ Red Box ------
            GEOMTRANSFORM labelpoly
            COLOR 255 0 0
        END
        FONT "arial"
        TYPE TRUETYPE
        POSITION UR
        SIZE 12
        COLOR 0 0 0
      END
    END
  END # layer fixed
END # Map file

by havatv, 12 years ago

Attachment: labelshadow-offset.png added

The new illustration generated from the mapfile in havatv

Note: See TracTickets for help on using tickets.