querybypoint problem with inline layer (php/mapscript)

Didrik Pinte dpinte at ITAE.BE
Tue Aug 28 08:08:33 PDT 2007


Hi,

I've got a strange problem with queryByPoint on a dynamically created
layer. I get the correct shapeindex after running the query with
MS_SINGLE parameter. But when calling the getShape method, I always
receive :

Fatal error: [MapServer Error]: msINLINELayerGetShape(): No inline
feature with this index. in [...]

I correctly set the tileindex of getShape to -1 according to the
documentation but this does not solve the problem.

Googling a bit did not help. So if someone has a trick to solve the
problem, i'll be very happy.

Here are some details :

The layer is created that way : 

    $point = $obj->get_point();
    // create new shapeObj (still must be a line for points layer ...)
    $shp = ms_newShapeObj(MS_SHAPE_LINE);
    $pt = ms_newLineObj();
    $pt->addXY($point->x,$point->y);
    $pt->addXY($point->x,$point->y);
    $shp->add($pt);
    $shp->classindex = 0;
    $shp->set('text', $obj->get_id());
    $shp->set('index', $obj->get_id());
    $lyr->addFeature($shp);

Then it's queried that way : 


   $map_extent = set_extent_from_post($map, $_POST["extent"]);

    // transform pixel to geo coords :
    $cx = Pix2Geo($_POST["mapa_x"], 0, $map->height, $map_extent[0],
$map_extent[2], 0);
    $cy = Pix2Geo($_POST["mapa_y"], 0, $map->width , $map_extent[1],
$map_extent[3], 1);   
    $mpoint = ms_newPointObj();
    $mpoint->SetXY($cx, $cy);
    // find into layer the most closed point
    $layer->set("toleranceunits",MS_METERS);
    $res = $layer->queryByPoint($mpoint, MS_SINGLE, 100);
    if ($res == MS_SUCCESS){
        echo "Identification succeeded <br />";
        echo $layer->getNumResults();
        $layer->open();       
        $rslt  =  $layer->getResult(0);       
        $shape = $layer->getShape(-1, $rslt->shapeindex);
        print_r($shape->values);
        $shape->free();
        $layer->close();
    } elseif ($res == MS_FAILURE) {
        echo "Nothing to identify ...";        
    }

I can provide more details if needed.

Thanks in advance for any help.

Didrik

-- 
Didrik Pinte <dpinte at itae.be>
Information Technologies for the Agro-Environment
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20070828/19fe83f1/attachment.sig>


More information about the MapServer-users mailing list