<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>

<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6618.4">
<TITLE>Re: [mapguide-internals] ogr postgis layer problems</TITLE>
</HEAD>
<BODY dir=ltr>
<DIV>Hi Frank,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I am applying the FID filter as an attribute filter, using the following 
call:</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>
<P>layer-&gt;SetAttributeFilter(mbattrsql);</P>
<P>where layer is an OGRLayer. After that in the case of Select I call 
layer-&gt;ResetReading() before reading the resulting features. I basically 
treat the string representation of the FDO attribute&nbsp;filter (mbattrsql) as 
a valid OGR filter. I don't know what OGR does underneath, may be it uses 
ExecuteSQL -- you tell me. I do acknowledge that&nbsp;doing this&nbsp;for 
attribute filters is extremely hopeful (meaning that the assumption that it 
works is based on pure&nbsp;belief in miracles&nbsp;:-), but I did do some 
limited testing and other&nbsp;attribute filters&nbsp;worked&nbsp;well as layer 
filters in MapGuide.</P>
<P>In general I spent very little time&nbsp;on the filter handling in the OGR 
provider since I didn't have much time and wasn't sure how useful it would be. 
I'm willing to fix it up if it turns out to be the problem. In particular, I 
didn't bother to support queries which are more than a combination of one 
spatial filter and one attribute filter -- which is about par for most MapGuide 
operations.</P>
<P>&nbsp;</P>
<P>Traian</P>
<P>P.S. the provider Paul is using is compiled with GDAL 1.3.2.</P>
<P>&nbsp;</P></FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV><FONT size=2>-----Original Message----- <BR><B>From:</B> 
  mapguide-internals-bounces@lists.osgeo.org&nbsp;on behalf of&nbsp;Frank 
  Warmerdam (External) <BR><B>Sent:</B> Wed 1/31/2007 12:31 AM <BR><B>To:</B> 
  MapGuide Internals Mail List <BR><B>Cc:</B> <BR><B>Subject:</B> Re: 
  [mapguide-internals] ogr postgis layer problems<BR><BR></FONT></DIV>
  <P><FONT size=2>Traian Stanev wrote:<BR>&gt; What you are describing seems to 
  me to lead to a bug in the OGR provider<BR>&gt; in the case where a filter is 
  used that is a combination of a spatial<BR>&gt; filter and FID filter, which 
  is what the selection rendering code uses<BR>&gt; to get the features that 
  have to draw as selected overlay. Since the<BR>&gt; selection itself seems to 
  work for you, my guess is that the provider<BR>&gt; messes something up during 
  such a query that results in a confusion<BR>&gt; during subsequent 
  queries.<BR>&gt; My guess could be wrong though... To narrow it down, I can 
  look over the<BR>&gt; code and check for obvious flaws (I don't have the time 
  to install<BR>&gt; PostGIS right now), and you can try connecting to an SHP 
  file with the<BR>&gt; OGR provider to see if selection works for that. Another 
  thing you can<BR>&gt; try is run the server in interactive mode and check for 
  any console<BR>&gt; output. The provider (and OGR itself) will sometimes 
  printf stuff to the<BR>&gt; console.<BR><BR>Paul,<BR><BR>I think Traian's 
  approach is good.&nbsp; See if you can reproduce the problem<BR>with other 
  providers to isolate whether it is a systematic problem, or<BR>a driver 
  specific problem.<BR><BR>Traian - does the OGR provider use ExecuteSQL() at 
  all to get results?<BR>Setting attributes filters on ExecuteSQL() results 
  often didn't work<BR>before the 1.4.0 release of GDAL/OGR.&nbsp; So if the FID 
  filter is being<BR>applied as an attribute filter and you are using 
  ExecuteSQL() to get<BR>the resultset this might explain it.<BR><BR>Best 
  regards,<BR>--<BR>---------------------------------------+--------------------------------------<BR>I 
  set the clouds in motion - turn up&nbsp;&nbsp; | Frank Warmerdam, 
  warmerdam@pobox.com<BR>light and sound - activate the windows | <A 
  href="http://pobox.com/~warmerdam">http://pobox.com/~warmerdam</A><BR>and 
  watch the world go round - Rush&nbsp;&nbsp;&nbsp; | President OSGeo, <A 
  href="http://osgeo.org">http://osgeo.org</A><BR><BR>_______________________________________________<BR>mapguide-internals 
  mailing list<BR>mapguide-internals@lists.osgeo.org<BR><A 
  href="http://lists.osgeo.org/mailman/listinfo/mapguide-internals">http://lists.osgeo.org/mailman/listinfo/mapguide-internals</A><BR></FONT></P></BLOCKQUOTE>

</BODY>
</HTML>