<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=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@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;}
@font-face
        {font-family:"DejaVu Sans Mono";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","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
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It’s a limitation in older versions of MapServer where specific backend optimizations were scattered about the WMS/WFS code. Most of those optimizations address
 the most common use cases – I guess this wasn’t one of them. It’s surprising that at worst the extent of the supplied geometry isn’t passed (I see a comment in the WFS code about this). The specific filter intersection test is applied on the MapServer side
 – the results are correct, performance can suffer though.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">This is being addresses in MapServer 7.0 where more complete filter translation functions are being supported (RFC 91).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Steve<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span 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>Steve.Toutant@inspq.qc.ca<br>
<b>Sent:</b> Monday, January 26, 2015 8:55 AM<br>
<b>To:</b> mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> [mapserver-users] Mapserver doesn't send good filter to postgis<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Sorry my first post was with an inapprpriate title......</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">I'm using mapserver 6.4.1 and postgis 2.1</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">using OpenLayers 2.13.1 I draw a small polygon that I use for a within spatial filter of a WFS getfeature request. The problem is that mapserver is not sending this polygon to postgis, it is sending
 the extent of the mapfile as filter...</span> <br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">The wfs POST Request (created and send by OpenLayers client)</span>
<br>
<span style="font-size:7.5pt;font-family:"DejaVu Sans Mono","serif";color:#2F2F2F"><ogc:Filter xmlns:ogc="</span><a href="http://www.opengis.net/ogc"><span style="font-size:7.5pt;font-family:"DejaVu Sans Mono","serif"">http://www.opengis.net/ogc</span></a><span style="font-size:7.5pt;font-family:"DejaVu Sans Mono","serif";color:#2F2F2F">"><ogc:Within><ogc:PropertyName>msGeometry</ogc:PropertyName><gml:Polygon
 xmlns:gml="</span><a href="http://www.opengis.net/gml"><span style="font-size:7.5pt;font-family:"DejaVu Sans Mono","serif"">http://www.opengis.net/gml</span></a><span style="font-size:7.5pt;font-family:"DejaVu Sans Mono","serif";color:#2F2F2F">" srsName="urn:ogc:def:crs:EPSG::3857"><gml:exterior><gml:LinearRing><gml:posList>-8081644.2511244
 5835062.56996 -8081707.5505384 5834980.1612889 -8081638.2794815 5834913.2788892 -8081533.1785677 5834988.5215889 -8081644.2511244 5835062.56996</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></ogc:Within></ogc:Filter></span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">In Mapserver log, I see</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">FLTLayerApplyPlainFilterToLayer():  ([shape]  within  fromText('POLYGON ((-8081644.2511243997141719 5835062.5699599999934435, -8081707.5505384001880884 5834980.1612889003008604, -8081638.2794815003871918
 5834913.2788891997188330, -8081533.1785677000880241 5834988.5215889001265168, -8081644.2511243997141719 5835062.5699599999934435))'))</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Then a few lines later, I see that it is not sending the polygon received as filter</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">select .......  where geom_p && ST_GeomFromText('POLYGON((-9239517 5465442,-9239517 9349764,-5565974 9349764,-5565974 5465442,-9239517 5465442))',3857);</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">See the polygon definition is different, postgis receive the extent defined in the mapfile</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">EXTENT -9239517 5465442 -5565974 9349764</span>
<br>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">And, in postgis log I see this query, See the</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">select ....... where geom_p && ST_GeomFromText('POLYGON((-9239517 5465442,-9239517 9349764,-5565974 9349764,-5565974 5465442,-9239517 5465442))',3857);</span>
<br>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Why Mapserver is not sending the polygon received as filter to postgis?</span>
<br>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Thanks!</span> <o:p>
</o:p></p>
<p><i><span style="color:#0080FF">Steve Toutant, M. Sc.</span></i><br>
Analyste en géomatique<br>
Secteur environnement<br>
Direction de la santé environnementale et de la toxicologie<br>
Institut national de santé publique du Québec<br>
Tél.: 418 646-6777 poste 30015<br>
Téléc.: 418 644-4593<u><span style="color:blue"><br>
<a href="mailto:steve.toutant@inspq.qc.ca">steve.toutant@inspq.qc.ca</a><br>
</span></u><a href="http://www.inspq.qc.ca/">http://www.inspq.qc.ca</a><u><span style="color:blue"><br>
</span></u><a href="http://www.monclimatmasante.qc.ca/">http://www.monclimatmasante.qc.ca</a>
<o:p></o:p></p>
<p><i>Pour me rejoindre par courrier</i><br>
Service de l'infrastructure et du réseau<br>
Direction des technologies de l'information<br>
Ministère de la Sécurité Publique<br>
2525 boul. Laurier, 2e étage<br>
Tour Laurentides<br>
Québec, G1V 2L2 <o:p></o:p></p>
</div>
</body>
</html>