[Mapserver-users] problem QueryByPoint

passera passera.ext at culture.gouv.fr
Thu Jul 8 01:42:10 PDT 2004


passera a écrit :

> Norbert Thieme a écrit :
>
>> passera schrieb:
>>
>>> Hello,
>>> I'm a student french and my english is very bad.
>>> My problem are the function QueryByPoint and QueryByRect.
>>> I do not manage to recover information in the .dbf .
>>>
>>>
>>> My mapfile is:
>>>
>>> LAYER
>>>       NAME immeuble
>>>       TYPE polygon
>>>       STATUS ON
>>>       DATA IMMEUBLE41
>>>       CLASSITEM "SDAP_X"
>>> *      * CLASS
>>>             COLOR 0 0 0
>>>             OUTLINECOLOR 0 0 0
>>>             NAME "Immeuble"
>>>             SYMBOL 0
>>>             TEMPLATE "query.html"
>>>        END
>>> END
>>>
>>>
>>> My .php is:
>>>
>>> $layer = $map->getlayerbyname("immeuble");
>>> $point = 
>>> pixeltogeo($map,$HTTP_POST_VARS["mapa_x"],$HTTP_POST_VARS["mapa_y"]);
>>> $queryfound = $map->querybypoint($point,MS_SINGLE,-1);
>>> if ($queryfound == MS_SUCESS){
>>>       $count_results = $layer->getnumresults();
>>>       print($count_results);
>>> }
>>> if ($queryfound == MS_FAILURE){
>>>       print("failure");
>>> }
>>>
>>> // $queryfound is every time equal MS_FAILURE
>>>
>>>
>>> Please help
>>> _______________________________________________
>>> Mapserver-users mailing list
>>> Mapserver-users at lists.gis.umn.edu
>>> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>>
>>>
>>
>> Hi,
>>
>> Try something like this:
>>
>> if (@$layer->queryByPoint($q_point, $q_mode, 0) == MS_SUCCESS) // you 
>> can leave the @ to see the messages
>> {
>>   $res_count = $layer->getnumresults();
>>   for ($i = 0; $i < $res_count; $i++)
>>   {
>>     $result = $layer->getResult($i);
>>     $layer->open();
>>     $items = $layer->getitems(); // get the names of the fields - you 
>> only need this once per layer
>>     $data_shp = $layer->getshape($result->tileindex, 
>> $result->shapeindex); // get the shapeobj - each result has a shape-, 
>> tile- and classindex
>>     $layer->close();
>>     $data_val = $data_shp->values; // get the values from the shapeobj
>>   }
>> }
>>
>> Regards,
>> Norbert
>>
>>
> Thank you very much. My problem was : $layer->queryByPoint($q_point, 
> $q_mode, 0) and me I wrote $map->queryByPoint($q_point, $q_mode, 0).
> $layer = layerObj  --> right for use querybypoint
> $map = mapObj  --> wrong for use querybypoint
>
Correction I had forgotten to put $layer->set("status",1);   Sorry



More information about the MapServer-users mailing list