[Mapserver-users] problem QueryByPoint
Norbert Thieme
norbert.thieme at ilmenau.baw.de
Wed Jul 7 03:29:46 PDT 2004
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
More information about the MapServer-users
mailing list