[mapserver-users] Questions about PHP Mapscript and Queries
LaFone, Frank
flafone at GEO.WVU.edu
Mon Jul 29 13:23:39 PDT 2002
The function is one I took from the DM Solutions Group advanced example. I
just renamed it. I haven't verified the function, but I sorta assumed
(yeah, I know what happens to you and me) it worked properly.
function Pix2Geo($nPixPos, $dfPixMin, $dfPixMax, $dfGeoMin, $dfGeoMax,
$nInversePix){
$dfWidthGeo = $dfGeoMax - $dfGeoMin;
$dfWidthPix = $dfPixMax - $dfPixMin;
$dfPixToGeo = $dfWidthGeo / $dfWidthPix;
if (!$nInversePix)
$dfDeltaPix = $nPixPos - $dfPixMin;
else
$dfDeltaPix = $dfPixMax - $nPixPos;
$dfDeltaGeo = $dfDeltaPix * $dfPixToGeo;
$dfPosGeo = $dfGeoMin + $dfDeltaGeo;
return ($dfPosGeo);
}
-----Original Message-----
From: Hankley, Chip [mailto:Chip.Hankley at GASAI.Com]
Sent: Monday, July 29, 2002 4:21 PM
To: 'LaFone, Frank'
Subject: RE: [mapserver-users] Questions about PHP Mapscript and Queries
Frank -
My initial hunch on both of your problems is that your 'Pix2Geo' function
has got some kind of problem with it and isn't returning a valid
coordinate... or at least isn't returning the *correct* coordinate. Have you
checked this? This would certainly explain why your code would be executing
w/out errors, but not giving you the results you expect.
You might want to forward your function back to the list for us to look at.
Chip
-----Original Message-----
From: LaFone, Frank [mailto:flafone at GEO.WVU.edu]
Sent: Monday, July 29, 2002 2:28 PM
To: mapserver-users at lists.gis.umn.edu
Subject: [mapserver-users] Questions about PHP Mapscript and Queries
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