displaying objects based on DBF information

Stephen Lime steve.lime at dnr.state.mn.us
Tue Jan 16 12:38:04 EST 2001


No, you can change the value of EXPRESSION at runtime. It's easiest within
mapscript where you simply use the class method setexpression but you can
do it with the CGI version too. There's an example of this at:

http://maps.dnr.state.mn.us/mapserver_demos/tests/

Basically you need to masage the user input into a valid MapServer class
object expression. It's usually necessary use javascript. Then you use the
syntax available in cgi.html on the main MapServer site to change the
expression dynamically. If you have a single class then create at hidden
variable:

  <input type="hidden" name="map_mylayer_class_expression" value="">

Then at the appropriate time (either form submission or when a control is
mucked with) use javascript to set the value for that hidden variable to
something like:

  /^id1$|^id2$|^id3$|.../ for regex or
  ([ID] = id1 or [ID] = id2 or [ID] = id3 or ...) for logical expressions

A regex assumes a value for CLASSITEM whereas a logical expression
does not. Clear as mud?

Steve


Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Yeewen Sat" <yeewen at petromap.com> 01/16/01 11:27AM >>>
I think my question was a bit unclear. I need to be able to tell mapserv
which object to display based on what a user has selected at runtime. So,
it's like I need to change the CLASS EXPRESSION in the mapfile at runtime,
telling mapserv what to display, based on user selections.

Say, on a page, we will display a list of all objects that are currently
visible (I think we can do this through other methods. Users can then select
the objects they want to display, and click on Refresh to display a new map
containing only those objects being selected (hiding the ones that are not
selected). Say the user selected objects with ObjectID=1, and ObjectID=5.
You would tell mapserv to only display objects with these ObjectIDs. And, at
the same time, user can zoom in/out, and the list of objects will change.
Users can then modify their selections in the same manner.

>From what I understood, CLASS object EXPRESSION is static.....only those
objects that matched the EXPRESSION get displayed, and the selections of
objects get displayed don't change at run time.

Thanks.
--
Yeewen Sat

Petromap Inc.
Voice: (403)263-4664x239
Fax: (403)266-2423
Email: yeewen at petromap.com <mailto:yeewen at petromap.com>



-----Original Message-----
From: Stephen Lime [mailto:steve.lime at dnr.state.mn.us] 
Sent: January 16, 2001 9:39 AM
To: Mapserver-Users; yeewen at petromap.com 
Subject: Re: displaying objects based on DBF information


This is what class objects are for. You can use class expressions to
restrict display to certain sets of features or to change the display
characteristics (eg. color/size/symbol) for each "class". I've attached
a map file that I use to draw different highway shields based on an
item value. Look at the definitions for "major_roads".

Steve

>>> "Yeewen Sat" <yeewen at petromap.com> 01/15/01 03:35PM >>>
Hi,

I like to find out if mapserver CGI support this:

display objects based on specific DBF information?

As an example, DBF file contains a field named ObjectID. And, a map being
displayed has bunch of lines in it. When user zoom into the map, all lines
that fall inside the bounding rectangle will show up. Is there a way to tell
mapserver to draw only those lines that match the given ObjectIDs?

The same question applies to mapscript. Can I just pass these lines
ObjectIDs to some mapscript functions, and it will only plot these lines?

If mapserver cgi or mapscript does supports the above functions, can I get
some examples to get me started?

Thanks.
Yee Wen


Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937






More information about the mapserver-users mailing list