class expressions in PHP/Mapscript

Jeff Portwine jdport at VERITIME.COM
Mon Mar 28 12:58:12 PST 2005


Part of what I was asking , I really was making things too difficult... for
my most zoomed out views I just took the national map file and used
"expression  /Interstate/"  and "expression /US/" from the "NAME" field and
this looks alright...  the hard part though is labeling them.   I thought
like you said about re-writing the dbf file to add a field with route
number, and I thought maybe I could have fields like "name", "alternate name
1", alternate name 2"  for roads that have multiple names and separate them
on the comma to fill in those fields.   The only problem is I really don't
know how to re-write a dbf file...  I don't have a problem writing a perl
script or something like that but I just don't know much about how dbf files
work, or how exactly they interact with the other parts of the shapefile and
I wasn't sure if adding fields would throw off other parts of the shape
file.

I'll look into that more...   I was hoping there was a way I couild just use
PHP to grab the number part of the "NAME" and use that as my label text
somehow.

Thanks,
Jeff

----- Original Message -----
From: "Stephen Woodbridge" <woodbri at swoodbridge.com>
To: "Jeff Portwine" <jdport at VERITIME.COM>
Cc: <MAPSERVER-USERS at LISTS.UMN.EDU>
Sent: Monday, March 28, 2005 3:26 PM
Subject: Re: [UMN_MAPSERVER-USERS] class expressions in PHP/Mapscript


> Jeff,
>
> Since I suggested looking at this I take a stab at a response. I think you
> have done about the best you can given the data in its current state. If I
> were trying to work with that data, and I haven't looked at it yet, but
> based on your description, I would be inclined to re-write the dbf file as
> something that would be more useful along the lines of
>
> New DBF fields:
> NAME - suitable for labeling
> RTE_NUM - number of route extract from the name
> RTE_TYPE - I -interstate, S - state, U - US Highway, C - county highway
> RTE_CLASS - maybe for classification of the road for style, but I think I
> would just use RTE_TYPE for that.
>
> Then I can use CLASSITEM "RTE_TYPE", LABELITEM "NAME", and RTE_* for
> highway shields.
>
> You would have to write a script to do this using Perl or PHP and regular
> expressions, you would want to split multiple names on the "," and then
> based on some higharchy populate the new fields.
>
> Or looks for some other data, like NHPN from the BTS.gov or whatever.
>
> I also find it useful to dump the various fields of a dbf and get a unique
> list of the options I am dealing with to better figure out how to deal
> with it.
>
> Some days nothing is simple,
> -Steve
>
> Jeff Portwine wrote:
>> I am trying to add a more "general" version of a "roads" layer to my maps
>> that I could use instead of the Tiger line data while the maps being
>> generated are not zoomed in.    When the maps are zoomed in closer I want
>> to switch to the Tiger data and go from there.    I've downloaded a major
>> roads layer from the national map website called "roadtrl20".   The
>> problem is that it doesn't use fields like "CFCC" like tiger does, it
>> simply has a "NAME" field and a "Feature" field.   The Feature field has
>> strings like "Limited Access Highway Alternate Route", "Other Through
>> HIghway", "Principle Highway", etc.... descriptions that are vague at
>> best as they don't tell me if it is an interstate or  what.... and there
>> are several descriptions that could be the same thing.
>>  In the "Name" field, it has things like  "Interstate Route 1",  "State
>> Route", "US Route", etc... which is a little more useful except again
>> there are several versions of things like "Interstate"  (Alternate
>> Interstate, Business Interstate, etc)  and to make it more complicated
>> many of them show several names separated by comma's.     So, it's
>> difficult to come up with a good expression to separate the different
>> types of roads... I thought I could do it in mapscript just reading the
>> different "Names" into a variable and manipulating that variable to give
>> me one word like "Interstate", "State", "US" that I could then use in my
>> "expression" clause.    I thought I could do something similar to get the
>> route number alone to use for labeling purposes (I'd like to superimpose
>> the route # on a graphic of an interstate sign, etc).     I can't see any
>> methods though that allow me to access the information from the shapefile
>> to do this..    Is this possible, or am I just making this a lot more
>> complicated that I need to?
>>  Thanks,
>> Jeff
>>
>
>



More information about the MapServer-users mailing list