[mapserver-users] PHP MapScript queryByPoint fails successive query.
Moen, Paul T.
pmoen at nd.gov
Thu Dec 13 09:20:49 PST 2018
Here is the gdalinfo on the raster
gdalinfo gft05665086.asc
Driver: GTiff/GeoTIFF
Files: gft05665086.asc
gft05665086.asc.aux.xml
Size is 2000, 2000
Coordinate System is:
PROJCS["NAD_1983_NSRS2007_UTM_Zone_14N",
GEOGCS["GCS_NAD_1983_NSRS2007",
DATUM["NAD_1983_NSRS2007",
SPHEROID["GRS_1980",6378137,298.257222101]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-99],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]]]
Origin = (566000.000000000000000,5088000.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 566000.000, 5088000.000) ( 98d 8'54.69"W, 45d56'32.63"N)
Lower Left ( 566000.000, 5086000.000) ( 98d 8'55.68"W, 45d55'27.84"N)
Upper Right ( 568000.000, 5088000.000) ( 98d 7'21.81"W, 45d56'31.93"N)
Lower Right ( 568000.000, 5086000.000) ( 98d 7'22.83"W, 45d55'27.13"N)
Center ( 567000.000, 5087000.000) ( 98d 8' 8.75"W, 45d55'59.89"N)
Band 1 Block=2000x1 Type=Float32, ColorInterp=Gray
Min=1288.911 Max=1311.955
Minimum=1288.911, Maximum=1311.955, Mean=1298.017, StdDev=3.670
NoData Value=1.175494351e-38
Metadata:
STATISTICS_MAXIMUM=1311.9554443359
STATISTICS_MEAN=1298.0167408607
STATISTICS_MINIMUM=1288.9107666016
STATISTICS_STDDEV=3.6695573380961
From: "Lime, Steve D (MNIT)" <steve.lime at state.mn.us>
Date: Thursday, December 13, 2018 at 10:45 AM
To: Paul Moen <pmoen at nd.gov>, "mapserver-users at lists.osgeo.org" <mapserver-users at lists.osgeo.org>
Subject: Re: PHP MapScript queryByPoint fails successive query.
CAUTION: This email originated from an outside source. Do not click links or open attachments unless you know they are safe.
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
More information about the MapServer-users
mailing list