[Mapserver-users] Single and multiple query in PHP mapscript
woodbri at swoodbridge.com
woodbri at swoodbridge.com
Wed Mar 12 17:15:21 PST 2003
Bill,
Here are the essentials:
$qmode = MS_SINGLE or MS_MULTIPLE; ### pick one
$point = ms_newPointObj();
$point->setXY($x, $y);
$map = ms_newMapObj(MAPFILE);
for ($i=0; $i<$map->numlayers; $i++) {
$layer = $map->getLayer($i);
$layer->set('status', MS_ON);
$ret = @ $layer->queryByPoint($point, $qmode, -1.0);
if ($ret == MS_SUCCESS) {
$numResults = $layer->getNumResults();
$layer->open($shapepath);
for ($j=0; $j<$numResults; $j++) {
$res = $layer->getResult($j);
$shp = $layer->getShape($res->tileindex, $res-
>shapeindex);
# add code to get attributes from the shp object
# add code to get geometry from the shp object
$shp->free();
}
$layer->close();
}
MS_SINGLE gives you the close object within TOLERANCE of the $x, $y
and MS_MULTIPLE gives you ALL objects within TOLERANCE.
I use code similar to this to do my reverse geocoder. You can check
it out at http://imaptools.com/demos1/?tab=4
-Steve W.
http://imaptools.com
On 12 Mar 2003 at 16:33, Hudspeth, Bill wrote:
> Can anyone send me example code and/or and explanation of how I would
> go about using PHP mapscript to perform single and multiple queries. I
> know that there is an example in the GMap demonstration files that
> uses the Rosa applet, but I would prefer at this point to avoid using
> it and to rely exclusively on mapscript.
>
> Thanks, Bill
>
> *********************************************************************
> *********************************************************************
> William Hudspeth, PhD Earth Data Analysis Center 107 Bandelier Hall
> West University of New Mexico Albuquerque, NM 87131 (505) 277-3622,
> ext. 238 bhudspeth at edac.unm.edu wbhk at unm.edu
>
>
More information about the MapServer-users
mailing list