class expressions in PHP/Mapscript

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Mon Mar 28 12:26:17 PST 2005


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