[Mapserver-users] Building a legend - with class objects in layers

Richard Orchard richard.orchard at ermapper.com.au
Tue Jun 15 01:42:20 PDT 2004


hi,

I am using mapserver to display some geology datasets.

A particular layer has multiple classes in order to show the various
features (different rock types).  The features are color-coded, therefore, i
need each feature (class) to display in the legend.

However, when the legend is generated, it just creates one item, based on
the layer name.  it doesn't iterate through the various class objects.

Is this the way it is supposed to work?  Or is there a way to get it to
create a legend item for each class item within a layer.  At present i am
creating new layer objects for each item i want to display.  I have put the
map file i am using at the bottom of this email.

Thanks in advance,


Richard




---- mapfile


MAP
  NAME "Australia - General Information"
  STATUS ON
  EXTENT 109.337 -44.387 158.742 -8.8081
  SIZE 400 300
  SHAPEPATH "D:\webs\www3\gis_data\australia"
  SYMBOLSET "D:\webs\www3\mapserver\etc\symbols.sym"
  FONTSET "D:\webs\www3\mapserver\etc\fonts.txt"
  IMAGETYPE PNG
  IMAGECOLOR 255 255 255
  UNITS DD
  #
  # Start of web interface definition
  #
  WEB
    MINSCALE 2e+06
    MAXSCALE 5e+07
    #
    # On Windows systems, /tmp and /tmp/ms_tmp/ should be created at the
root
    # of the drive where the .MAP file resides.
    #
    IMAGEPATH "D:/webs/www3/temp/"
    IMAGEURL "/temp/"
  END
  #
  #
  # Start of querymap object
  #
  QUERYMAP
    STATUS OFF
    SIZE -1 -1
    COLOR 255 0 0
    STYLE HILITE
  END
  #
  # Start of legend object
  #
  LEGEND
    STATUS ON
    IMAGECOLOR 255 255 255
    POSITION LL
    KEYSIZE 18 12
    KEYSPACING 5 5
    TEMPLATE "ttt"
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      OFFSET 0 0
      BUFFER 0
      MINDISTANCE -1
      MINFEATURESIZE -1
      COLOR 0 0 89
      PARTIALS TRUE
      FORCE FALSE
    END
  END
  #
  # Start of scalebar object
  #
  SCALEBAR
    STATUS ON
    COLOR 255 255 255
    OUTLINECOLOR 0 0 0
    BACKGROUNDCOLOR 0 0 0
    IMAGECOLOR 255 255 255
    UNITS KILOMETERS
    INTERVALS 5
    SIZE 150 5
    STYLE 0
    POSITION LL
    LABEL
      TYPE BITMAP
      SIZE SMALL
      OFFSET 0 0
      BUFFER 0
      MINDISTANCE -1
      MINFEATURESIZE -1
      COLOR 0 0 0
      PARTIALS TRUE
      FORCE FALSE
    END
  END
  #
  # Start of OutputFormat object
  #
  OUTPUTFORMAT
    NAME "png"
    MIMETYPE "image/png"
    DRIVER "GD/PNG"
    EXTENSION "png"
    IMAGEMODE PC256
    TRANSPARENT FALSE
  END
  #
  # Start of layer definitions
  #
  LAYER
    NAME "Roads"
    STATUS ON
    DATA "./roads/roads"
    TYPE LINE
    UNITS METERS
    SIZEUNITS PIXELS
    METADATA
      "Description"    "Test"
    END
    CLASS
      NAME "Roads"
      STYLE
        SYMBOL 0
        COLOR 220 0 0
        SIZE 1
        MINSIZE 1
        MAXSIZE 100
      END
    END
  END

  LAYER
    NAME "Earth Quake Risk 0.05 - 0.10"
    STATUS ON
    DATA "./earthQuakeHazard/eqriskdd"
    TYPE POLYGON
    UNITS KILOMETERS
    SIZEUNITS PIXELS
    METADATA
      "Description"    "Earth Quake"
    END
    CLASS
      NAME "RISKVAL2"
      EXPRESSION ('[RISKVAL]' eq '0.05 - 0.10')
      LABEL
        TYPE TRUETYPE
        FONT "fritqat-bold"
        SIZE 10
        POSITION LL
        OFFSET 0 0
      END
      STYLE
        SYMBOL 0
        COLOR 255 150 123
        SIZE 1
        MINSIZE 1
        MAXSIZE 100
      END
    END

  END


  LAYER
    NAME "Earth Quake Risk < 0.05"
    STATUS ON
    DATA "./earthQuakeHazard/eqriskdd"
    TYPE POLYGON
    UNITS KILOMETERS
    SIZEUNITS PIXELS
    METADATA
      "Description"    "Earth Quake"
    END
    CLASS
      NAME "RISKVAL2"
      EXPRESSION ('[RISKVAL]' eq '< 0.05')
      LABEL
        TYPE TRUETYPE
        FONT "fritqat-bold"
        SIZE 10
        POSITION LL
        OFFSET 0 0
      END
      STYLE
        SYMBOL 0
        COLOR 255 255 181
        SIZE 1
        MINSIZE 1
        MAXSIZE 100
      END
    END
  END

    LAYER
    NAME "Earth Quake Risk > 0.10"
    STATUS ON
    DATA "./earthQuakeHazard/eqriskdd"
    TYPE POLYGON
    UNITS KILOMETERS
    SIZEUNITS PIXELS
    METADATA
      "Description"    "Earth Quake"
    END
    CLASS
      NAME "RISKVAL2"
      EXPRESSION ('[RISKVAL]' eq '> 0.10')
      LABEL
        TYPE TRUETYPE
        FONT "fritqat-bold"
        SIZE 10
        POSITION LL
        OFFSET 0 0
      END
      STYLE
        SYMBOL 0
        COLOR 247 81 148
        SIZE 1
        MINSIZE 1
        MAXSIZE 100
      END
    END
  END



# Layer
END




This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender immediately and delete the original. Any other use of the email by you is prohibited..

www.ermapper.com
www.earthetc.com





More information about the MapServer-users mailing list