[Mapserver-users] Mapfile problem - polygon layer and labels

Sean Gillies sgillies at frii.com
Sun Mar 7 10:33:47 EST 2004


On Mar 6, 2004, at 8:15 PM, Mike Reilly wrote:

> Hi:
>
> I've got a work around for the problem I'm having right now, however, 
> it causes me to use two layers where I feel one would be more than 
> adequate.  I have a polygon layer called mergeplys, and in one layer 
> declaration I only want to display the layers that contain "food 
> harvest" in the "USE1" field.  To this end, I built the following 
> layers:
>
>  LAYER # TUS polygon layer begins here
>    NAME         tusfoodharvest
>    DATA         "mergeplys"
>    STATUS       ON
>    TYPE         POLYGON
>    TOLERANCE 3
>    PROJECTION
> #      "init=epsg:4326"
>    END
>    CLASSITEM "USE1"
>    CLASS
>      EXPRESSION   "food harvest"
>      TEMPLATE	   "templates/land_query.html"
>      COLOR        100 255 100
>      OUTLINECOLOR 0 255 0
> #      LABEL
> #        COLOR 0 0 0
> #	TYPE TRUETYPE
> #	FONT arial
> #	SIZE 12
> #       POSITION CC
> #        PARTIALS FALSE
> #        BUFFER 2
> #      END
>    END
>  END # TUS polygon layer ends her
>
>  LAYER
>    NAME	tusfoodharvest
>    DATA	"mergeplys"
>    STATUS      ON
>    MAXSCALE	5000000000
>    TYPE	ANNOTATION
>    LABELITEM	"USE1"
>    CLASSITEM	"USE1"
>    LABELMAXSCALE 500000000
>    CLASS
>      EXPRESSION "food harvest"
>      COLOR	0 0 0
>      LABEL
>        COLOR 0 0 0
> 	TYPE TRUETYPE
> 	FONT arial
> 	SIZE 12
>        POSITION CC
>        PARTIALS FALSE
>        BUFFER 2
>      END
>    END
>  END
>
> The first layer displays the polygon layer and the second one adds the 
> label to the polygon.  I would like to be able to combine these two 
> into a single layer.  My attempt at this is commented out in the 
> POLYGON layer above.  What am I missing here?
>
> On a separate note, I am creating a separate LAYER for each 
> EXPRESSION.  Is there a more efficient way to do this?  My .map file 
> is getting very large, and I suspect there's got to be a better way, 
> however, I haven't devised one as yet.
>
> TIA,
> Mike Reilly
>

Mike,

I see right away that the first layer does not define a LABELITEM.  That
may not be the _only_ problem, but you won't get a label without it.

Instead of a separate LAYER for each expression, use another CLASS.

    CLASS
      EXPRESSION   "food harvest"
      TEMPLATE	   "templates/land_query.html"
      COLOR        100 255 100
      OUTLINECOLOR 0 255 0
      ...
    END
    CLASS
      EXPRESSION   "other expression"
      TEMPLATE	   "templates/land_query.html"
      COLOR        200 55 200
      OUTLINECOLOR 0 255 0
      ...
    END

Hope this helps,
Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies




More information about the mapserver-users mailing list