[mapserver-users] Questions about PHP Mapscript and Queries

LaFone, Frank flafone at GEO.WVU.edu
Mon Jul 29 12:28:17 PDT 2002


Hi, I'm pretty new to Mapserver and PHP Mapscript (although I'm an old hand
at PHP).  I can't seem to get any of my queries to work correctly.  What I'm
trying to do is do a simple query on a point, but all I get back is an error
message that says "No records found".  Here's my snipet of code:

            $XGeoMin = $map->extent->minx;
            $XGeoMax = $map->extent->maxx;
            $geox = Pix2Geo($my_point->x, 0, 500, $XGeoMin, $XGeoMax, 0);

            $YGeoMin = $map->extent->miny;
            $YGeoMax = $map->extent->maxy;
            $geoy = Pix2Geo($my_point->y, 0, 500, $YGeoMin, $YGeoMax, 1);
            $clickpt = ms_newpointObj();
            $clickpt->setXY($geox,$geoy);
            $temp = $map->queryByPoint($clickpt, MS_MULTIPLE, -1);

On an vaguely related note, I'm also trying to draw a point on the middle of
a polygon on my map once a search has been done.  In otherwords, I have a
shape file that has a bunch of buildings on it.  If they click on the
building I want the application to do a search for the building on which
they clicked (the query part of my question).  However if they do a search
using my pull down menus with all the buildings listed by name, I want the
map to be updated to feature a red dot somewhere in the building polygon.
Here's my snipet of code of this:

            $XGeoMin = $map->extent->minx;
            $XGeoMax = $map->extent->maxx;
            $geox = Pix2Geo($my_point->x, 0, 500, $XGeoMin, $XGeoMax, 0);

            $YGeoMin = $map->extent->miny;
            $YGeoMax = $map->extent->maxy;
            $geoy = Pix2Geo($my_point->y, 0, 500, $YGeoMin, $YGeoMax, 1);
            $clickpt = ms_newpointObj();
            $clickpt->setXY($geox,$geoy);
            $layer = ms_newLayerObj($map);
            $layer = $map->getLayerByName("WVU Buildings");
            $temp = $clickpt->draw($map, $layer, $image, 0, "This is a test
string");
            $image = $map->draw();

            $image_url=$image->saveWebImage(MS_GIF,1,1,0);

I can get the image, but there's no point on the image and the "This is a
test string" label isn't anywhere on the map.

Any help anyone can give me on either of these two issues would be greatly
appreciated.

Thanks,

Frank LaFone
WV GIS Technical Center
West Virginia University



More information about the MapServer-users mailing list