You don't use the nextShape() method to retrieve shapes as a result of a query.
Here's the pseudo code:
$layer->queryByShape($q_shape);
for($i=0; $i < $layer->getNumResults(); $i++) {
$shape = $layer->getShape($layer->getResult($i));
.. do something with the shape ..
}
As part of query operations the bounding box of $q_shape was used to select
candidate shapes (that's why nextShape() is returning what is does).
Steve
________________________________
From: [email protected]
[[email protected]] on behalf of Bistrais, Bob
[[email protected]]
Sent: Wednesday, February 20, 2013 2:38 PM
To: [email protected]
Subject: [mapserver-users] queryByShape returns too many results
I am working on a spatial query module (actually, modifying an existing
GeoMoose module) which uses queryByShape to take a previously selected feature
from one layer, and use it to select features from another layer. Both layers
are shapefiles, the query layer is of course polygon, the selection layer is
points in this case.
When I do the query I am finding too many results are returned- there are many
features outside the query polygon which are selected, well beyond the polygon
boundary. The selected features might possibly be within the BBOX of the
polygon, but I only want what’s within the polygon.
$layer->queryByShape($q_shape);
while($shape = $layer->nextShape()) {
# if we have a projection, convert the shape
into latlong
if($q_shape->intersects($shape) == MS_TRUE or
$shape->containsShape($q_shape) == MS_TRUE) {
if($projection != NULL) {
$shape->project($projection, $LATLONG_PROJ);
}
$foundShapes[] = $shape;
}
}
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users