Um ... yeah, it's late and I'm tired. Please replace "ampersand" with
"at symbol" at the appropriate place. :)
-Abe
On Jan 23, 2005, at 1:44 AM, Abe Gillespie wrote:
Ok, since this list has been so helpful and generous
to me in the past, here is an exhaustive example. I hope this will
finally get you going. Disclaimer: I'm doing this all from memory
and w/o testing so there may be a few errors.
Setup a map file like this:
MAP
NAME "Parcel Query"
STATUS on
EXTENT xmin ymin xmax ymax
SIZE 300 300
SHAPEPATH "/data_path"
IMAGETYPE png
IMAGECOLOR 255 255 255
QUERYMAP
STYLE hilite
COLOR 255 0 0
END
LAYER
NAME "Parcels"
DATA "parcels"
CLASS
OUTLINECOLOR 0 255 0
END
TEMPLATE "x"
END
END
Setup a web page like this:
<
<
<
$parcel_ids = "1|2|3|4|5";
if (PHP_OS == "WINNT" || PHP_OS == "WIN32")
dl("php_mapscript.dll");
else
dl("php_mapscript.so");
$map = ms_newMapObj("parcels.map");
$layer = $map->getLayerByName("parcels");
// Query.
$layer->queryByAttributes("", "/".$parcel_ids."/", MS_MULTIPLE);
// If you want to avoid errors when no matches are found use the
ampersand
// in the above statement like this: @$layer->queryByAttributes();
// Render an image and get its URL.
$img = $map->drawQuery();
$url = $img->saveWebImage(MS_PNG, 1, 1, 0);
$img->free();
?>
<
<
<
<
if ($layer->getNumResults() > 0)
echo $layer->getNumResults()." parcels found.";
else
echo "No parcels found.";
?>
<
<
Now that I look at it, the last thing you may have been missing was
the mapObj::queryMap() method. Anyhow, I hope this helps.
-Abe
On Jan 22, 2005, at 10:07 PM, Steve Lehr wrote:
Abe:
I appreciate the help, still not getting it though. I'm wondering if
I need
to draw out the map after rendering? I've sceen other posts but no
real
solutions...
I'll start from scratch rather then trying to reuse something I have.
If
anyone else has a more complete example I'd really appreciate seeing
it.
Thanks
Steven Lehr
Assistant Professor
Freshmen Program
College of Engineering
Embry-Riddle Aeronautical University (LB159)
600 S. Clyde Morris Blvd.
Daytona Beach, FL 32114-3900
386-226-7740
-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS@LISTS.UMN.EDU]On
Behalf Of Abe Gillespie
Sent: Saturday, January 22, 2005 8:22 PM
To: MAPSERVER-USERS@LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] PHP Highlight list of Parcels Passed
In
Something else I noticed. You shouldn't even have to setup a separate
layer to show queried parcels (though there are ways to do this). I
suggest starting out with one layer that renders queried and
non-queried parcels at the same time. Once you get the hang of that
then you can do two different layers (if you still even want to). Make
the layer like this:
LAYER
NAME "parcels"
DATA "parcels"
STATUS on
TYPE polygon
CLASS
OUTLINECOLOR 0 255 0
END
TEMPLATE "x" # Must be present to query on (though "x" means
absolutely nothing).
END
The above layer will render all your parcels green outline with hollow
fill. Then when you use the PHP code to query it will render your
queried parcels red. This assumes you have QUERYMAP setup correctly.
-Abe
On Jan 22, 2005, at 7:12 PM, Steve Lehr wrote:
Abe I've never used the QUERY MAP before, I tried putting it
in the
layer
and it did not like that?
My initial layer looks like:
I changed my code to pass Pipe delimited.
But I'm not quite certian I'm still getting what I need to do to my
.map.
Thanks for the help..below is the layer repeated my EXPRESSION is
trashed I
realize.
LAYER
NAME "selected_parcels"
DATA parcels
STATUS DEFAULT
TYPE POLYGON
CLASSITEM QPID
CLASS
EXPRESSION "/%parcels%/"
COLOR 255 0 0
END
END
Steven Lehr
Assistant Professor
Freshmen Program
College of Engineering
Embry-Riddle Aeronautical University (LB159)
600 S. Clyde Morris Blvd.
Daytona Beach, FL 32114-3900
386-226-7740
-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS@LISTS.UMN.EDU]On
Behalf Of Abe Gillespie
Sent: Saturday, January 22, 2005 7:05 PM
To: MAPSERVER-USERS@LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] PHP Highlight list of Parcels Passed
In
For the red you need to setup the QUERYMAP. For the PHP it will be
something like this:
$target = use_appropriate_string_func_to_conver_semi_to_pipe($parcels);
// $target should look like "1|2|3|4" ... where the numbers are the
IDs.
$layer = $map->getLayerByName("parcels");
$layer->queryByAttributes("parcel_id_field", "/".$target."/",
MS_MULTIPLE);
Also, don't forget to add the TEMPLATE "x" tag in your LAYER
definition.
I'm not a RegEx expert, so someone please put me in check if I'm
leading Steven astray.
-Abe
On Jan 22, 2005, at 6:37 PM, Steve Lehr wrote:
I'm trying to write some PHP that I can send extents and list
of
parcels to
get it to highlight the parcels.
I'd like to highlight all the found parcels in RED.
My php gets a variable by post called parcels and contains at this
time a
semi colon delimited list of ids in the attribute column QPID of the
parcels.dbf.
LAYER
NAME "selected_parcels"
DATA parcels
STATUS DEFAULT
TYPE POLYGON
CLASSITEM QPID
CLASS
EXPRESSION "/%parcels%/"
COLOR 255 0 0
END
END
I've got my extents. I've got the list of parcels. Now I want to
highlight
the list of parcels with something like the below. But I have to do
something in php to take that ; delimited list and the turn on all the
matching attributes. (I belive its a QUERYMAP with MULTIPLE_SELECT)
but I'm
having trouble getting my brain around what I need to code - might
someone
have a sample.
Thanks
Steven Lehr
Assistant Professor
Freshmen Program
College of Engineering
Embry-Riddle Aeronautical University (LB159)
600 S. Clyde Morris Blvd.
Daytona Beach, FL 32114-3900
386-226-7740