Hi All,

I'm using php mapscript and I'm trying to identify features using queryByPoint 
at the point of the users click.  I have two layers I'm interested in querying. 
 If there are features in the first layer(line) at the click point, then I want 
to show those attributes, otherwise I want to show the attributes of the second 
layer(polygon).  The possibility exists that the user could click on a point 
where no features exist in either layer.  The script looks like this:

$buffer = 25.0;
$layer = $map->getLayerByName("Pipes");
@$layer->queryByPoint($queryPoint, MS_SINGLE, $buffer);
$results = $layer->getNumResults();
if ($results > '1')  {
     //Get Pipeline information
     $oResult = $layer->getResult(0);
     $layer->open();
     $oShape = $layer->getShape($oResult->tileindex, $oResult->shapeindex);

     //Get attributes and output info
        
} else {
     $layer = $map->getLayerByName("Parcels");
     @$layer->queryByPoint($queryPoint, MS_SINGLE, 0);
     $results = $layer->getNumResults();
     if ($results > '0')  {
          //Get roll number
          $oResult = $layer->getResult(0);
          $layer->open();
          $oShape = $layer->getShape($oResult->tileindex, $oResult->shapeindex);

          //Get attributes and output info

        } else {
            
          //Output nothing
      }
}

The problem is, I don't get the expected results.  I very rarely get any 
features returned from the first layer, and I always get results from the 
second layer, even if there isn't a feature at the click point.  I have 
verified that coordinates being calculated are correct.  Both layers have 
templates defined in the mapfile.

When I click directly on a line from the first layer in the map, with a buffer 
of 25.0, I should get the feature I have clicked on, but I always get the 
underlying polygon.  When I click on a gap between polygons with a buffer of 0, 
I should get no results, but I always get one of the polygons close by.

Any help is much appreciated!

Rob McCulley
GIS Coordinator
County of Vermilion-River No. 24

Reply via email to