[mapserver-users] PHP mapscript querybyrect()

Charlie Allgrove charlie.allgrove at connectionservices.com
Fri Jul 9 10:44:39 EDT 2010


Hi

Could anyone shed some light on a problem I have with querybyrect() using
PHP Mapscript please?

I'm trying to get the number of points within a known boundary (from a
google map). The map file is apparently working, as I have it generating
tiles for overlaying on a google map. The Shapefile is (for the sake of
example) xxx.shp containing a layer 'xxx' (see ogrinfo output below)

The PHP code I'm using is here, but I consistently get this error:
Warning: [MapServer Error]: msQueryByRect(): No matching record(s) found. in
/var/www/yyy/zzz/qryMap.php on line 44

The shapefiles are in /var/www/yyy/zzz/data/ (and the SHAPEPATH in the map
file is set to 'data')

I'm kinda new to this - so I might have missed something, but can anyone
shed any light on what I've missed and/or am doing wrong? 

Many thanks in advance,

Charlie

PHP extract:

<snip>
$lstrMapPath = "/var/www/yyy/zzz/xxx.map";

$lobjMap = ms_newMapObj($lstrMapPath);
$lobjRect = ms_newrectObj();
$lobjRect->setextent($lintBLLon,$lintBLLat,$lintTRLon,$lintTRLat);

$l='xxx';

$lobjLayer = $lobjMap->getLayerByName($l);
if(!$lobjLayer) {
  //die("Layer does not exist");
  echo "Couldn't find layer {$l}<br />";
  continue;
}
$lobjLayer->open();
echo "<strong>{$l}</strong><br />";
$lobjLayer->queryByRect($lobjMap->extent);
echo $lobjLayer->data."<br />"; //correctly shows the shapefilename
$lintCount = $lobjLayer->getNumResults();
echo "$l: {$lintCount}<br />";
$lobjLayer->close();
</snip>

OGRINFO:

>ogrinfo xxx.shp -so xxx
INFO: Open of `xxx.shp'
      using driver `ESRI Shapefile' successful.

Layer name: xxx
Geometry: Point
Feature Count: 759947
Extent: (-8.146110, 49.892400) - (1.758210, 60.800800)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_1984",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]
Postcode: String (80.0)
NoSpace: String (80.0)
Hubs: String (80.0)
Long_WGS84: String (80.0)
Lat_WGS84: String (80.0)



More information about the mapserver-users mailing list