<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2658.24">
<TITLE>RE: [UMN_MAPSERVER-USERS] Problem with Mapserver Virtual Spatial Data (ogr)</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>OGR tries to automatically detect the primary key of a table. This does not always work automatically. The reason could be for instance the data type used for your primary key, or maybe a small flaw in the driver's code. Another example, using ODBC on Access, there is trouble detecting the primary key because of a not implemented ODBC function in the Microsoft driver. </FONT></P>
<P><FONT SIZE=2>Best regards,</FONT>
<BR><FONT SIZE=2>Bart</FONT>
</P>
<P><FONT SIZE=2>-----Oorspronkelijk bericht-----</FONT>
<BR><FONT SIZE=2>Van: UMN MapServer Users List</FONT>
<BR><FONT SIZE=2>[<A HREF="mailto:MAPSERVER-USERS@LISTS.UMN.EDU">mailto:MAPSERVER-USERS@LISTS.UMN.EDU</A>]Namens Christian Wilmes</FONT>
<BR><FONT SIZE=2>Verzonden: vrijdag 19 mei 2006 8:40</FONT>
<BR><FONT SIZE=2>Aan: MAPSERVER-USERS@LISTS.UMN.EDU</FONT>
<BR><FONT SIZE=2>Onderwerp: Re: [UMN_MAPSERVER-USERS] Problem with Mapserver Virtual</FONT>
<BR><FONT SIZE=2>Spatial Data (ogr)</FONT>
</P>
<BR>
<P><FONT SIZE=2>Hi Frank,</FONT>
</P>
<P><FONT SIZE=2>thank you very much for your help!</FONT>
</P>
<P><FONT SIZE=2>With the line</FONT>
<BR><FONT SIZE=2>CONFIG "PGSQL_OGR_FID" "fieldname" </FONT>
<BR><FONT SIZE=2>in the Map section everything works very well.</FONT>
</P>
<P><FONT SIZE=2>But now I've still got one more question, just an understanding one. I've got testet the "Virtual Spatial Data" with a MySQL Database a few days ago and there everything works well without a line like that. Where could be the reason?</FONT></P>
<P><FONT SIZE=2>Best Regards</FONT>
<BR><FONT SIZE=2>Christian</FONT>
</P>
<BR>
<P><FONT SIZE=2>-------- Original-Nachricht --------</FONT>
<BR><FONT SIZE=2>Betreff: Re: [UMN_MAPSERVER-USERS] Problem with Mapserver Virtual Spatial Data (ogr)</FONT>
<BR><FONT SIZE=2>Datum: Thu, 18 May 2006 16:55:40 -0400</FONT>
<BR><FONT SIZE=2>Von: Frank Warmerdam <warmerdam@POBOX.COM></FONT>
<BR><FONT SIZE=2>An: MAPSERVER-USERS@LISTS.UMN.EDU</FONT>
</P>
<P><FONT SIZE=2>> Christian Wilmes wrote:</FONT>
<BR><FONT SIZE=2>> > Hello,</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > first of all sorry for cross posting, but I've got no idea where I have</FONT>
<BR><FONT SIZE=2>> to</FONT>
<BR><FONT SIZE=2>> > search the mistake so I post it to the GDAL and the Mapserver</FONT>
<BR><FONT SIZE=2>> Mailinglist.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > I'm trying to publish a WFS-Server. The Data (only Point-Data) are in a</FONT>
<BR><FONT SIZE=2>> > PostgreSQL-Database (no PostGIS!). So the connection to the data is over</FONT>
<BR><FONT SIZE=2>> > "Virtual Spatial Data". The getCapabilities and DescribeFeatureType</FONT>
<BR><FONT SIZE=2>> request</FONT>
<BR><FONT SIZE=2>> > both work very well. Only the GML-Document getting with the getFeature</FONT>
<BR><FONT SIZE=2>> > request is not correct. The number of features in the GML-Document are</FONT>
<BR><FONT SIZE=2>> > correct too every time, but the features are not in the Bounding Box.</FONT>
<BR><FONT SIZE=2>> The</FONT>
<BR><FONT SIZE=2>> > features in the GML-Document are always the feature which are on the top</FONT>
<BR><FONT SIZE=2>> of</FONT>
<BR><FONT SIZE=2>> > the table they come from. Only the number of feature is correct. The MBR</FONT>
<BR><FONT SIZE=2>> > (Minimum Boundig Rectangle) on the top of the GML-Document amasingly the</FONT>
<BR><FONT SIZE=2>> > correct one. So it don't fit to the features in the document. Testing</FONT>
<BR><FONT SIZE=2>> the</FONT>
<BR><FONT SIZE=2>> > connection with "ogrinfo" and a Boundig-Box is working correct. If I'm</FONT>
<BR><FONT SIZE=2>> > trying to make a WMS-Server with the same Data and the same OGR-file it</FONT>
<BR><FONT SIZE=2>> > works very well.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Christian,</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> I believe the problem is that OGR is not successfully identifying a column</FONT>
<BR><FONT SIZE=2>> in the table to use as a "feature id". For WFS queries the results are</FONT>
<BR><FONT SIZE=2>> fetched in two passes for various historical reasons. The first pass</FONT>
<BR><FONT SIZE=2>> results in a fetch of the feature ids of the features, and the second</FONT>
<BR><FONT SIZE=2>> pass fetches features by id. Unfortunately, if OGR cannot select a good</FONT>
<BR><FONT SIZE=2>> unique feature id column, then it assigns them serially. The first pass</FONT>
<BR><FONT SIZE=2>> has the spatial query "in place" so the resulting fids are 1, 2, 3, etc.</FONT>
<BR><FONT SIZE=2>> But the second pass does not have the spatial filter in place, so it ends</FONT>
<BR><FONT SIZE=2>> up returning the wrong features.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Ideally you would ensure you have a single integer column setup as a</FONT>
<BR><FONT SIZE=2>> primary index for your postgres table. If that is the case it *should*</FONT>
<BR><FONT SIZE=2>> get used as the fid.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> If not, you may be able to include the following line in your MAP file</FONT>
<BR><FONT SIZE=2>> (in the MAP section, not the layer):</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> CONFIG "PGSQL_OGR_FID=fieldname"</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> to indicate what fieldname should get used as FID. This should be</FONT>
<BR><FONT SIZE=2>> available with GDAL/OGR 1.3.2.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> PS. the much talked about one-pass-query would resolve this problem.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Good luck,</FONT>
<BR><FONT SIZE=2>> -- </FONT>
<BR><FONT SIZE=2>> ---------------------------------------+--------------------------------------</FONT>
<BR><FONT SIZE=2>> I set the clouds in motion - turn up | Frank Warmerdam,</FONT>
<BR><FONT SIZE=2>> warmerdam@pobox.com</FONT>
<BR><FONT SIZE=2>> light and sound - activate the windows | <A HREF="http://pobox.com/~warmerdam" TARGET="_blank">http://pobox.com/~warmerdam</A></FONT>
<BR><FONT SIZE=2>> and watch the world go round - Rush | President OSGF, <A HREF="http://osgeo.org" TARGET="_blank">http://osgeo.org</A></FONT>
</P>
<P><FONT SIZE=2>-- </FONT>
</P>
<BR>
<P><FONT SIZE=2>Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer!</FONT>
<BR><FONT SIZE=2> Kostenlos downloaden: <A HREF="http://www.gmx.net/de/go/smartsurfer" TARGET="_blank">http://www.gmx.net/de/go/smartsurfer</A></FONT>
<BR><FONT SIZE=2> </FONT>
</P>
<BR>
Disclaimer
************************************************************************
Aan dit bericht kunnen geen rechten worden ontleend. Dit bericht is
uitsluitend bestemd voor de geadresseerde. Als u dit bericht per abuis
hebt ontvangen, wordt u verzocht het te vernietigen en de afzender te
informeren. Wij adviseren u om bij twijfel over de juistheid of de
volledigheid van de mail contact met afzender op te nemen.
This message shall not constitute any rights or obligations.
This message is intended solely for the addressee.
If you have received this message in error, please delete it and
notify the sender immediately. When in doubt whether this message
is correct or complete, please contact the sender.
************************************************************************
<BR>
</BODY>
</HTML>