[mapserver-users] Simple ItemQuery with QueryMap & php MapScr ipt
Hankley, Chip
Chip.Hankley at GASAI.Com
Mon Aug 12 07:05:21 PDT 2002
Hi Dana...
Re-visit the way EXPRESSION works in the mapfile syntax. EXPRESSION can be
simple (the way I outlined in my note), or LOGICAL or REGULAR. In your case,
you would probably want to use a LOGICAL expression.
See http://mapserver.gis.umn.edu/doc36/mapfile-reference.html#class
Your original question really had two parts:
a) how to hi-lite a particular record
b) how to zoom to a particular record
So for a)...
$Layer = $map->getlayerbyname("county");
$Object = $Layer->getClass(0);
$myExpression = "('[STATE_NM]' eq 'MARYLAND' AND '[CO_NAME]' eq
'MONTGOMERY')";
$Object->setexpression($myExpression);
... for b)
You would just simply re-work the way you do the dbase query. Rather than
look for records where CO_NAME equals MONTGOMERY, you'd have to look for the
record where STATE_NM also equals MARYLAND. Unfortunately, the dbase module
in PHP doesn't seem to support SQL style queries (I could be wrong on
this)... so the syntax of something like that will be a little ugly.
So...
...
for ($i=1; $i <= $nr; $i++) {
$cur_row = dbase_get_record_with_names ($dbi, $i);
//something like this should work
if (trim($value1) == trim($cur_row[$db_field1]) and trim($value2) ==
trim($cur_row[$db_field2])) {
$row_id = $i;
break;
}
BTW, I haven't done this in PostGIS, but I'm relatively confident it would
be MUCH easier. For starters, you could issue an SQL style query against
PostgreSQL to return the record(s) you want...PLUS I believe you can pull
the spatial extent of a record right out of the PostGIS database, so you
wouldn't have to go through the other little pieces of MapScript code.
Chip
-----Original Message-----
From: Dana Coe [mailto:thesquid at friedbaloney.com]
Sent: Friday, August 09, 2002 8:18 PM
To: Hankley, Chip
Subject: Re: [mapserver-users] Simple ItemQuery with QueryMap & php
MapScr ipt
Chip,
The routine you sent me worked quite well, however, it unfortunately selects
counties with the same name from multiple states. Ie, Montgomery MD &
Montgomery PA.
I've tried setting a separate class in my counties layer to link to the
'State' attribute in the dbf file, but it doesn't seem to get queried, much
less filtered by a regex.
In other words, can I do a nested setexpression on two different attributes
from the same dbf file?
Thanks for your help,
Dana
More information about the MapServer-users
mailing list