[mapserver-users] PHP MapScript queryByPoint fails successive query.
Lime, Steve D (MNIT)
steve.lime at state.mn.us
Thu Dec 13 08:45:57 PST 2018
How many bands are in the raster?
________________________________
From: mapserver-users <mapserver-users-bounces at lists.osgeo.org> on behalf of Moen, Paul T. <pmoen at nd.gov>
Sent: Thursday, December 13, 2018 10:32:44 AM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] PHP MapScript queryByPoint fails successive query.
I am trying to query a raster at 2 points in a single php file using php mapscript.
1. I create a map object.
2. I get a layer object from my raster
3. I create 2 point objects.
4. I query the raster layer object with queryByPoint using point 1 and it is successful, except that it gives me 4 results even though I pass in MS_SINGLE.
5. I query the raster layer object a second time using queryByPoint with the second point object I created and the query fails.
My questions:
Shouldn’t this be possible? If so, what am I doing wrong?
Why are 4 points returned when I pass in MS_SINGLE?
I have tried using MapScript 7.2.1, 6.4.4 and 7.0.7 with the same results.
MapScript
MapServer Version => MapServer version 7.2.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=GEOS SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
PHP MapScript Version => ($Revision$ $Date$)
MapScript
MapServer Version => MapServer version 7.0.7 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
PHP MapScript Version => ($Revision$ $Date$)
MapScript
MapServer Version => MapServer version 6.4.4 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
PHP MapScript Version => ($Revision$ $Date$)
The code I am using is below. I have set up a test script and sample data here http://swc.nd.gov:8000/_Usd8Y3s4N9pgkR.
The test can be run using php query.php 1 for the fail case. Running php query.php 2 is my work around using 2 map objects.
$map = new mapObj($path."/simple.map");
$qlay = $map->getLayerByName("qLayer");
$pq = ms_newPointObj();
$pq->setXY(567231,5086977); // 1298.609
$pq2 = ms_newPointObj();
$pq2->setXY(566445,5086590); // 1304.3274
$rastquery=$qlay->queryByPoint($pq,MS_SINGLE,1);
if($rastquery == MS_SUCCESS){
error_log("Number of results from 1st query: ".$qlay->getNumResults()."\nShouldn't there be only 1 result since MS_SINGLE is passed?");
if($qlay->getNumResults()>0){
$qlay->open();
for ($i=0; $i < $qlay->getNumResults(); $i++) {
$rasresult = $qlay->getResult($i);
if($rasresult === FALSE){
error_log('No result '.$i);
} else {
$rasshptemp = $qlay->getShape($rasresult);
error_log("Result $i = ".$rasshptemp->values['value_0']);
}
}
}
} else {
error_log('1st query failed');
}
$rastquery=$qlay->queryByPoint($pq2,MS_SINGLE,1);
if($rastquery == MS_SUCCESS){
error_log("Number of results from 1st query: ".$qlay->getNumResults()."\nShouldn't there be only 1 result since MS_SINGLE is passed?");
if($qlay->getNumResults()>0){
// error_log("In rastquery");
$qlay->open();
for ($i=0; $i < $qlay->getNumResults(); $i++) {
$rasresult = $qlay->getResult($i);
if($rasresult === FALSE){
error_log('No result'.$i);
} else {
$rasshptemp = $qlay->getShape($rasresult);
error_log("Result $i = ".$rasshptemp->values['value_0']);
}
}
}
} else {
error_log('2nd query failed!');
}
break;
Results
php query.php 1
Number of results from 1st query: 4
Shouldn't there be only 1 result since MS_SINGLE is passed?
Result 0 = 1298.5105
Result 1 = 1298.5105
Result 2 = 1298.5105
Result 3 = 1298.5105
[Thu Dec 13 10:17:07 2018].185483 msQueryByPoint(): Search returned no results. No matching record(s) found.
PHP Warning: layerObj::queryByPoint(): [MapServer Error]: msQueryByPoint(): No matching record(s) found.
in /Volumes/Data/WebServer/fris/php/test/query.php on line 36
2nd query failed!
Any hints or help would be appreciated,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20181213/dc0c53b2/attachment.htm>
More information about the MapServer-users
mailing list