[mapserver-users] PHP queryByRect problem.
Pedro A. Carrasco
pcarrasco at iver.es
Tue Jul 2 07:11:05 PDT 2002
Hi all,
I'm having a problem with the queryByRect function y PHP/Mapscript. My
code works fine with the queryByPoint, but if I try to use the queryByRect
it doesn't return any record. Here is a snippet of my code to do the
search:
---------------------------------------------------------------------
dl('php_mapscript.so');
$map = ms_newMapObj(_DATAPATH._GENMAPFILE);
//This function change the status to 1 on the layers
ActivaCapas('Servicios+Comercios+Construccion+Industria+Agrupaciones+Resto+P
oblac',$map);
$imgbox = str_replace(' ','+',$imgbox);
$arrimgbox = explode('+',$imgbox);
echo $imgbox.'<br>';
$ext = str_replace(' ','+',$ext);
$arrext = explode('+',$ext);
echo $ext.'<br>';
//Pix2Geo fron Gmap
$minx = Pix2Geo($arrimgbox[0],0,$imWidth,$arrext[0],$arrext[2],0);
$miny = Pix2Geo($arrimgbox[1],0,$imHeight,$arrext[1],$arrext[3],1);
$maxx = Pix2Geo($arrimgbox[2],0,$imWidth,$arrext[0],$arrext[2],0);
$maxy = Pix2Geo($arrimgbox[3],0,$imHeight,$arrext[1],$arrext[3],1);
$rect = ms_newrectobj();
$rect->set('minx',$minx);
$rect->set('miny',$miny);
$rect->set('maxx',$maxx);
$rect->set('maxy',$maxy);
//This query don't return any result
@$map->queryByRect($rect);
$resultado = array();
for($i = 0;$i < $map->numlayers; $i++)
{
$lyObj = $map->getLayer($i);
if($lyObj->status == 1)
{
$numResults = $lyObj->getNumResults();
echo $lyObj->name.'-->'.$lyObj->status.'-->'.$numResults.'<br>';
if($numResults == 0)
continue;
$lyObj->open($map->shapepath);
//Nombre de los campos de los que se sacan los datos
$selTables = $lyObj->getMetaData("DESCRIPTION");
$selTitulo = $lyObj->getMetaData("TITLE");
$selFields = explode(" ", $lyObj->getMetaData("RESULT_FIELDS"));
$res = '';
for($j = 0;$j < $numResults;$j++)
{
$oRes = $lyObj->getResult($j);
$oShape = $lyObj->getShape($oRes->tileindex,$oRes->shapeindex);
//Concatenamos los resultados
$res = $res.'|'.$oShape->values[$selFields[0]];
}
$lyObj->close();
$key = $selTables.'|'.$selTitulo;
echo $key.'-->';
echo $res.'<br>';
$resultado[$key] = $res;
}
}
return $resultado;
---------------------------------------------------------------------
Is there any problem with the code or is the PHP/Mapscript version?, I use
the following Mapscript and Mapserver versions:
MapScript Version ($Revision: 1.104 $ $Date: 2002/04/24 20:37:32 $)
MapServer version 3.6.0 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=TTF
INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=SHAPEFILE
and PHP 4.2.1 in a Debian Linux.
Thanks in advance.
Regards.
---------------------------------------------------------------------
Pedro A. Carrasco Ponce
IVER Sistemas de Información Geográfica
Dpto. Técnico
C/Salamanca, 50
46005 Valencia
Telf: +34 96 316 34 00
Fax: +34 96 316 2716
mail : pcarrasco at iver.es
web : http://www.iver.es
---------------------------------------------------------------------
More information about the MapServer-users
mailing list