<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:System;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:System;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
p.msochpdefault, li.msochpdefault, div.msochpdefault
        {mso-style-name:msochpdefault;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Calibri","sans-serif";}
span.emailstyle17
        {mso-style-name:emailstyle17;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.emailstyle19
        {mso-style-name:emailstyle19;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.balloontextchar0
        {mso-style-name:balloontextchar;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle23
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle24
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Bob,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>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.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><b><span style='font-size:12.0pt;font-family:"System","sans-serif"'><o:p> </o:p></span></b></p><p class=MsoNormal style='text-autospace:none'><b><span style='font-size:12.0pt;font-family:"System","sans-serif"'>TOLERANCE 0<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"System","sans-serif"'>TOLERANCEUNITS pixels # "pixels" broken in Mapserver 6.0.2 - TOLERANCE has to be zero for WFS BBOX to work properly</span></b><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Donald<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> mapserver-users-bounces@lists.osgeo.org [mailto:mapserver-users-bounces@lists.osgeo.org] <b>On Behalf Of </b>Bistrais, Bob<br><b>Sent:</b> 20 February 2013 22:09<br><b>To:</b> Lime, Steve D (MNIT); mapserver-users@lists.osgeo.org<br><b>Subject:</b> Re: [mapserver-users] queryByShape returns too many results<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>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?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Lime, Steve D (MNIT) [<a href="mailto:Steve.Lime@state.mn.us">mailto:Steve.Lime@state.mn.us</a>] <br><b>Sent:</b> Wednesday, February 20, 2013 4:49 PM<br><b>To:</b> Bistrais, Bob; <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br><b>Subject:</b> RE: queryByShape returns too many results<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>It shouldn't matter the shape type. Could it be projection related? Perhaps tolerance related? <o:p></o:p></span></p><div><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>Steve<o:p></o:p></span></p><div><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;font-family:"Times New Roman","serif";color:black'><o:p> </o:p></span></p><div class=MsoNormal align=center style='text-align:center'><span lang=EN-US style='font-size:12.0pt;font-family:"Times New Roman","serif";color:black'><hr size=2 width="100%" align=center></span></div><div id=divRpF528646><p class=MsoNormal style='margin-bottom:12.0pt'><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'> Bistrais, Bob [Bob.Bistrais@maine.gov]<br><b>Sent:</b> Wednesday, February 20, 2013 3:34 PM<br><b>To:</b> Lime, Steve D (MNIT); <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br><b>Subject:</b> RE: queryByShape returns too many results</span><span lang=EN-US style='font-size:12.0pt;font-family:"Times New Roman","serif";color:black'><o:p></o:p></span></p></div><div><div><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Thanks Steve.  </span><span lang=EN-US style='color:black'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><span lang=EN-US style='color:black'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>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.  </span><span lang=EN-US style='color:black'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><span lang=EN-US style='color:black'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>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.  </span><span lang=EN-US style='color:black'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'> </span><span lang=EN-US style='color:black'><o:p></o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'> Lime, Steve D (MNIT) [<a href="mailto:Steve.Lime@state.mn.us">mailto:Steve.Lime@state.mn.us</a>] <br><b>Sent:</b> Wednesday, February 20, 2013 4:06 PM<br><b>To:</b> Bistrais, Bob; <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br><b>Subject:</b> RE: queryByShape returns too many results</span><span lang=EN-US style='color:black'><o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US style='color:black'> <o:p></o:p></span></p><div><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>You don't use the nextShape() method to retrieve shapes as a result of a query. Here's the pseudo code:</span><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'> </span><span lang=EN-US style='color:black'><o:p></o:p></span></p><div><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'> </span><span lang=EN-US style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>$layer->queryByShape($q_shape);</span><span lang=EN-US style='color:black'><o:p></o:p></span></p></div><div><table class=MsoNormalTable border=0 cellpadding=0><tr><td style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal><span style='font-size:12.0pt'>for($i=0; $i < $layer->getNumResults(); $i++) {<br>  $shape = $layer->getShape($layer->getResult($i));<br>  .. do something with the shape ..<br>}</span><o:p></o:p></p></td></tr><tr><td style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:12.0pt'><br>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).</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><br><br>Steve</span><o:p></o:p></p></td><td style='padding:.75pt .75pt .75pt .75pt'></td></tr></table></div><div><div><div class=MsoNormal align=center style='text-align:center'><span lang=EN-US style='font-size:12.0pt;font-family:"Times New Roman","serif";color:black'><hr size=2 width="100%" align=center></span></div><div id=divRpF783239><p class=MsoNormal style='margin-bottom:12.0pt'><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'> <a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a> [mapserver-users-bounces@lists.osgeo.org] on behalf of Bistrais, Bob [Bob.Bistrais@maine.gov]<br><b>Sent:</b> Wednesday, February 20, 2013 2:38 PM<br><b>To:</b> <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a><br><b>Subject:</b> [mapserver-users] queryByShape returns too many results</span><span lang=EN-US style='color:black'><o:p></o:p></span></p></div><div><div><p class=MsoNormal><span lang=EN-US style='color:black'>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.  <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>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.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                $layer->queryByShape($q_shape);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                while($shape = $layer->nextShape()) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                                # if we have a projection, convert the shape into latlong<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                                if($q_shape->intersects($shape) == MS_TRUE or $shape->containsShape($q_shape) == MS_TRUE) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                                                if($projection != NULL) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                                                                $shape->project($projection, $LATLONG_PROJ);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                                                }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                                                $foundShapes[] = $shape;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                                }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'>                }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:black'> <o:p></o:p></span></p></div></div></div></div></div></div></div></div></div></div></div></body></html>