[mapserver-users] queryByShape returns too many results

Donald Kerr donald.kerr at dkerr.co.uk
Wed Feb 20 14:21:05 PST 2013


Bob,

 

I seem to recall having an issue with what's returned from a WFS and
TOLERANCE. Now, do not ask me to explain the following as I cannot remember
what or why but I have the following in my map file and I think it may be
related to the issue you highlight. Ignore "6.0.2" as I am using 6.2 Beta 4.

 

TOLERANCE 0

TOLERANCEUNITS pixels # "pixels" broken in Mapserver 6.0.2 - TOLERANCE has
to be zero for WFS BBOX to work properly

 

Regards,

 

Donald

 

 

From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Bistrais, Bob
Sent: 20 February 2013 22:09
To: Lime, Steve D (MNIT); mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] queryByShape returns too many results

 

Seems to be line layers.  I reset the tolerance in the map file to 0.1,
toleranceunits pixels, but still getting a few records outside of the
selection polygon.  I'm confident the projection is OK.  Is there someplace
else I should check tolerance?

 

From: Lime, Steve D (MNIT) [mailto:Steve.Lime at state.mn.us] 
Sent: Wednesday, February 20, 2013 4:49 PM
To: Bistrais, Bob; mapserver-users at lists.osgeo.org
Subject: RE: queryByShape returns too many results

 

It shouldn't matter the shape type. Could it be projection related? Perhaps
tolerance related? 

 

Steve

 

  _____  

From: Bistrais, Bob [Bob.Bistrais at maine.gov]
Sent: Wednesday, February 20, 2013 3:34 PM
To: Lime, Steve D (MNIT); mapserver-users at lists.osgeo.org
Subject: RE: queryByShape returns too many results

Thanks Steve.  

 

Interestingly, the process you showed me works great with my point data.
But with line or poly data, I am getting some results outside of the
polygon.  But, using the nextShape() method works properly with these.  

 

I can but some if/then code in to examine the results based on feature type.
But it would be interesting to know why one way works best for points, the
other for lines/polys.  

 

From: Lime, Steve D (MNIT) [mailto:Steve.Lime at state.mn.us] 
Sent: Wednesday, February 20, 2013 4:06 PM
To: Bistrais, Bob; mapserver-users at lists.osgeo.org
Subject: RE: queryByShape returns too many results

 

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: mapserver-users-bounces at lists.osgeo.org
[mapserver-users-bounces at lists.osgeo.org] on behalf of Bistrais, Bob
[Bob.Bistrais at maine.gov]
Sent: Wednesday, February 20, 2013 2:38 PM
To: mapserver-users at lists.osgeo.org
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;

                                }

                }

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20130220/6b8ed111/attachment.htm>


More information about the MapServer-users mailing list