[mapserver-users] Fwd: queryByPoint - Street Layer ?
Hussain Hashmi
tohashmi at gmail.com
Mon Jul 6 22:27:52 PDT 2009
---------- Forwarded message ----------
From: mir m. Hashmi <mhashmi at sp.com.sa>
Date: Mon, Jul 6, 2009 at 4:11 PM
Subject: queryByPoint - Street Layer ?
To: "mapserver-users at lists.osgeo.org" <mapserver-users at lists.osgeo.org>
Hello
Can anyone please guide me on this issue.
My Objective is to get attribute values for any selected street (Line).
My client application is based on KaMap.
I have a similar solution for Polygons which works perfectly.
I am trying to query a street layer which gives me the following error.
Warning: [MapServer Error]: msQueryByPoint(): No matching record(s) found in
C:\... on line 84
Warning: [MapServer Error]: msShapefileOpen():
(/ms4w/maps/./city/./city/streets) in c:\... on line 84
MAPFILE
**********************
LAYER
NAME 'streets_Query'
GROUP 'streets_Query'
DATA './city/streets'
TYPE line
MAXSCALE 3001
STATUS ON
TOLERANCE 5
TEMPLATE './_templates/Streets_Identify.html'
METADATA
"queryable" "true"
searchfield "ANAME"
fields "ZIP_CODE"
END
END #end layer
PHP MAPSCRIPT
**********************
//------- Get Input Parameters.
if (isset($_REQUEST['map'])) {$szMap = $_REQUEST['map'];} else {echo "map
not defined"; die;}
if (isset($_REQUEST['coords'])) {$coords =
explode(',',$_REQUEST['coords']);} else {echo "coordinate not defined";
die;}
//------- Load Mapscript Module.
$szPHPMapScriptModule = 'php_mapscript.'.PHP_SHLIB_SUFFIX;
if (!extension_loaded('MapScript')) {
dl($szPHPMapScriptModule);
}
//------- Load Current Map file.
$szMapFile=str_replace('<<Map>>',$szMap,'/ms4w/maps/<<Map>>.map');
$oMap = ms_newMapObj($szMapFile);
//------- SETTING MAP EXTENT to query extent..
$mapExtent = $oMap->extent;
$oMap->setExtent($coords[0],$coords[1],
$coords[0]+0.000001,$coords[1]+0.000001);
//------- SETTING QUERY POINT
$point = ms_newPointObj();
$point->setXY($coords[0], $coords[1]);
//------- Initialize map query.
$oMap->preparequery();
//------- LOOP ON LAYERS and get identify results.
$tot = $oMap->numlayers;
for ($i = 0; $i < $tot; $i++) {
//------- get map layer.
$oLayer = $oMap->getLayer($i);
//------- Verify Layer type
if ($oLayer->name != 'streets_Query') continue;
//------- Validate if query succeeds.
$check_query = $oLayer->queryByPoint($point, MS_SINGLE, 0);
if ($check_query != MS_SUCCESS) {continue;}
//------- Open layer for data input.
$oLayer->open();
//------- Get the record values corresponding to a result tileindex.
$oResultCache = $oLayer->getResult(0);
$oShape = $oLayer->getShape($oResultCache->tileindex,
$oResultCache->shapeindex);
$aValues = $oShape->values;
//------- Get the field value.
echo $aValues['ZIP_CODE']; echo ";";
//------- FREE SHAPE
$oShape->free();
$oLayer->close();
break;
} // for i
Best regards,
Mir Hashmi
------------------------------
This message may contain confidential and/or privileged information. If you
have received this message in error,please notify us immediately by
responding to this e-mail and delete it from your system. Thanks for your
cooperation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090707/50e90dbd/attachment.htm>
More information about the MapServer-users
mailing list