[Mapserver-users] Mapfile problem - polygon layer and labels
Mike Reilly
mikereilly_7 at hotmail.com
Sat Mar 27 14:48:51 PST 2004
Reviving an old thread - I have the labels working fine now, and was messing
around with Sean's suggestion to reduce the number of layers in my .map file
by using multiple CLASS sections inside a single layer since I am using
mostly just 2 shape files.
I am using mapserver cgi with an html interface (I also use the jbox, but
that's beside the point here). I have two main shape files, mergeplys and
"tus points". Both these shape files have fields in their dbf files named
USE1, which I use to filter the polygon and point sites displayed on the map
by uses such as fishing, hunting, ceremonial, cultural, etc. The user can
select the uses they want to see on the map from a drop box in the html
file. The problem is, when I use CLASS instead of separate LAYER
definitions, I can't turn the sites visible on the map on and off. Using
fishing as an example of the two methods I've tried with the method that
works (but requires too many layers) shown first:
LAYER # TUS polygon layer begins here
NAME tusfishing
DATA "mergeplys"
STATUS ON
TYPE POLYGON
TOLERANCE 3
PROJECTION
# "init=epsg:4326"
END
CLASSITEM "USE1"
CLASSITEM "LOCATION"
CLASS
EXPRESSION "fishing"
EXPRESSION "land"
COLOR 160 160 255
TEMPLATE "templates/land_query.html"
OUTLINECOLOR 0 200 0
END
CLASS
EXPRESSION "fishing"
EXPRESSION "Ocean"
TEMPLATE "templates/land_query.html"
COLOR 100 255 100
OUTLINECOLOR 0 255 0
END
END # TUS polygon layer ends her
This layer works fine, and I can have a drop box on my html page that has an
option as follows to allow me to display fishing areas or turn the m off:
<option value="tusfishing" [tusfishing_select]>Fishing</option>
I get no polygon sites displayed when I use the following LAYER definition
when trying to use CLASS for eacy use - I started by making the CLASS for
fishing as a test:
LAYER # TUS polygon layer begins here
NAME "mergeplys"
DATA "mergeplys"
STATUS ON
TYPE POLYGON
TOLERANCE 3
CLASSITEM "USE1"
LABELITEM "USE1"
LABELMAXSCALE 5000000
CLASS
NAME tusfishing
EXPRESSION "fishing"
EXPRESSION "land"
COLOR 160 160 255
LABEL
COLOR 0 0 0
TYPE TRUETYPE
FONT arial
SIZE 12
POSITION CC
PARTIALS FALSE
BUFFER 2
END
TEMPLATE "templates/land_query.html"
OUTLINECOLOR 0 200 0
END
CLASS
NAME tusfishing
EXPRESSION "fishing"
EXPRESSION "Ocean"
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 here
I was hoping this would consolidate things a bit as I was starting to get an
awful lot of layers on my .map file and figured I'd be recompiling the
mapserver to support more layers at this rate. I had thought Sean's
suggestion as listed below would resolve this, however, I must be missing
something somewhere along the line. I tried with Sean's original suggestion
of just using EXPRESSION in the CLASS, however, that didn't work either.
>From: Sean Gillies <sgillies at frii.com>
>To: "Mike Reilly" <mikereilly_7 at hotmail.com>
>CC: mapserver-users at lists.gis.umn.edu
>Subject: Re: [Mapserver-users] Mapfile problem - polygon layer and labels
>Date: Sun, 7 Mar 2004 08:33:47 -0700
>
>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
>
>_______________________________________________
>Mapserver-users mailing list
>Mapserver-users at lists.gis.umn.edu
>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
_________________________________________________________________
Add photos to your messages with MSN Premium. Get 2 months FREE*
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
More information about the MapServer-users
mailing list