<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ok, I poked around, and found out that the "&amp;&amp;" operator means
BBOX overlap.<br>
So, to fix OGR, I changed ogrpgtablelayer.cpp line 449 from:<br>
<br>
<tt>&nbsp;&nbsp;&nbsp; m_poFilterGeom-&gt;getEnvelope( &amp;sEnvelope );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; osWHERE.Printf("WHERE %s &amp;&amp; SetSRID('BOX3D(%.12f %.12f,
%.12f %.12f)'::box3d,%d) ",<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pszGeomColumn,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sEnvelope.MinX, sEnvelope.MinY,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sEnvelope.MaxX, sEnvelope.MaxY,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nSRSId );</tt><br>
to:<br>
&nbsp;<tt>&nbsp; m_poFilterGeom-&gt;getEnvelope( &amp;sEnvelope );&nbsp; <br>
&nbsp;&nbsp; char * pszWKT = NULL;<br>
<br>
&nbsp;&nbsp; if( m_poFilterGeom-&gt;exportToWkt( &amp;pszWKT ) != OGRERR_NONE )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CPLError( CE_Failure, CPLE_AppDefined,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Could not export geometry to WKT");<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; osWHERE.Printf("WHERE %s &amp;&amp; SetSRID('BOX3D(%.12f %.12f,
%.12f %.12f)'::box3d,%d) AND intersects(%s, GeometryFromText('%s', %d))
",<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pszGeomColumn,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sEnvelope.MinX, sEnvelope.MinY,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sEnvelope.MaxX, sEnvelope.MaxY,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nSRSId,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pszGeomColumn,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pszWKT,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nSRSId<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CPLFree( pszWKT );</tt><br>
<br>
And it works fine, BUT looking at other providers (ea. MySQL) reveals
that this is a general flaw:<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sprintf( szWHERE,
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "WHERE MBRIntersects(GeomFromText('%s'), %s)",
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; szEnvelope,
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pszGeomColumn);
<br>
</tt><br>
This may also be fixed, but it seems that this is more a design choice
from OGR, rather than a flaw.<br>
<br>
Traian mentioned that there is utility functions in Fdo to check for
intersections.<br>
A real fix would be to update the OGRFeatureReader (in the provider),
to filter out elements that do not intersect, using Fdo utility
functions.<br>
<br>
I'm not that well into Fdo yet, so I don't know where to look for those
functions.<br>
<br>
<pre class="moz-signature" cols="72">Regards, Kenneth, GEOGRAF A/S

</pre>
<br>
<br>
Kenneth, GEOGRAF A/S skrev:
<blockquote cite="mid:4670F8EF.2030607@geograf.dk" type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
It should not work if you make a polygon selection.<br>
Tooltip and Click sends a square, so the envelope of the filter should
be the same as the filter<br>
  <pre class="moz-signature" cols="72">Regards, Kenneth, GEOGRAF A/S

  </pre>
  <br>
  <br>
Traian Stanev skrev:
  <blockquote
 cite="mid:0345418B84C1684C8467DC5A2D7EFF6A043B1726@msgusaebk01.autodesk.com"
 type="cite">
    <meta http-equiv="Content-Type" content="text/html; ">
    <meta content="MSHTML 6.00.6000.16481" name="GENERATOR">
    <div>&nbsp;</div>
    <div>Wait, from this it looks like it takes the BBOX (envelope) of
the filter and sends that to PostGIS...? That may explain things.</div>
    <div>&nbsp;</div>
    <div>&nbsp;</div>
    <div>&nbsp;</div>
    <blockquote dir="ltr" style="margin-right: 0px;">
      <div><font size="2">-----Original Message----- <br>
      <b>From:</b> <a moz-do-not-send="true"
 class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users-bounces@lists.osgeo.org">mapguide-users-bounces@lists.osgeo.org</a>&nbsp;on
behalf
of&nbsp;Kenneth, GEOGRAF A/S <br>
      <b>Sent:</b> Wed 6/13/2007 5:42 PM <br>
      <b>To:</b> MapGuide Users Mail List <br>
      <b>Cc:</b> <br>
      <b>Subject:</b> Re: [mapguide-users] OGR / GEOS selection problem<br>
      <br>
      </font></div>
It is actually forwarded to PostGIS:<br>
      <br>
      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OGREnvelope&nbsp; sEnvelope;<br>
      <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_poFilterGeom-&gt;getEnvelope( &amp;sEnvelope );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; osWHERE.Printf("WHERE %s &amp;&amp; SetSRID('BOX3D(%.12f %.12f,
%.12f %.12f)'::box3d,%d) ",<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pszGeomColumn,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sEnvelope.MinX, sEnvelope.MinY,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sEnvelope.MaxX, sEnvelope.MaxY,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nSRSId );<br>
      </tt><br>
      <br>
Not too good with PostGIS syntax, but since the m_poFilterGeom is the
filter used (a small square in this case) it reads:<br>
"Select from geometry_column where features are within the bbox of the
filer"<br>
      <br>
Which should be quite ok, unless they have a similar idea of optimizing
this to a BBOX test, as OGR does.<br>
      <br>
Anyway, I can confirm that Traians fix works with MapInfo TAB files,
but NOT with PostGIS :(<br>
      <br>
      <pre class="moz-signature" cols="72">Regards, Kenneth, GEOGRAF A/S
    </pre>
      <br>
      <br>
Traian Stanev skrev:
      <blockquote cite="" type="cite">
        <pre>To put test data into PostGres I use the tool that comes with it that
can import SHP files into the database.

I think it's called shp2pgsql.


Traian


-----Original Message-----
From: <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users-bounces@lists.osgeo.org">mapguide-users-bounces@lists.osgeo.org</a>
[<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="mailto:mapguide-users-bounces@lists.osgeo.org">mailto:mapguide-users-bounces@lists.osgeo.org</a>] On Behalf Of Kenneth,
GEOGRAF A/S
Sent: Wednesday, June 13, 2007 3:21 PM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] OGR / GEOS selection problem

I tried it with MapInfo TAB files, and it works fine.

Maciej, can you post an SQL dump of one of the PostGIS tables?

I have installed PostGIS on my machine for testing, but I have no data, 
and no luck getting Fdo2Fdo working with FDO OGR.

Regards, Kenneth, GEOGRAF A/S



Traian Stanev skrev:
  </pre>
        <blockquote type="cite">
          <pre>Well, I only tried it with SHP files and am pretty sure it fixed the
problem for SHP files (I did a before and after test, on a polygon
    </pre>
        </blockquote>
        <pre>that
  </pre>
        <blockquote type="cite">
          <pre>had the same problem as your screenshot). May be the PostGIS OGR
    </pre>
        </blockquote>
        <pre>driver
  </pre>
        <blockquote type="cite">
          <pre>does something else, like forward the spatial filter to PostGIS? In
    </pre>
        </blockquote>
        <pre>that
  </pre>
        <blockquote type="cite">
          <pre>case, may be I need to upgrade my PostGIS SDK...? Anybody know the
answer to that one?


Traian


-----Original Message-----
From: <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users-bounces@lists.osgeo.org">mapguide-users-bounces@lists.osgeo.org</a>
[<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="mailto:mapguide-users-bounces@lists.osgeo.org">mailto:mapguide-users-bounces@lists.osgeo.org</a>] On Behalf Of Maciej
Skorczewski
Sent: Wednesday, June 13, 2007 12:29 PM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] OGR / GEOS selection problem

Traian


i have still this same error...

take a look on screen.

<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://imagepolis.com/images/20070613819095046.JPG">http://imagepolis.com/images/20070613819095046.JPG</a>

<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://imagepolis.com/images/20070613818181055.JPG">http://imagepolis.com/images/20070613818181055.JPG</a>

<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://imagepolis.com/images/20070613434408347.JPG">http://imagepolis.com/images/20070613434408347.JPG</a>


Maciek

ps. and i still can't use SetSelectionXML...

    </pre>
        </blockquote>
        <pre><a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://www.nabble.com/SetSelectionXML-on-layer-from-database-%28PostgreS">http://www.nabble.com/SetSelectionXML-on-layer-from-database-%28PostgreS</a>
  </pre>
        <blockquote type="cite">
          <pre>QL-%3EPostgGIS%29-tf3900386s16610.html

(tiny of this url to forum)
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://tiny.pl/fdtn">http://tiny.pl/fdtn</a>


maciek skorczewski



_______________________________________________
mapguide-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>


_______________________________________________
mapguide-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
  
    </pre>
        </blockquote>
        <pre>_______________________________________________
mapguide-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>


_______________________________________________
mapguide-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
  </pre>
      </blockquote>
    </blockquote>
    <pre wrap=""><hr size="4" width="90%">
_______________________________________________
mapguide-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
  </pre>
  </blockquote>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>