[mapserver-dev] A problem with NQUERY and OGR datasources

Brent Fraser bfraser at geoanalytic.com
Thu Jul 23 14:00:20 EDT 2009



The problem:
------------
   When using doing an NQUERY with a MAPSHAPE on a point layer with a connection 
of OGR/VRT/ODBC/SQLServer and geometry defined as WKT, I get the wrong records 
returned (but I always get the right NUMBER of records).  Changing the geometry to:
     <GeometryField encoding='PointFromColumns' x='SRF_LONG' y='SRF_LAT'/>
gives the same wrong results so its not restricted to WKT.

   However, adding my own "spatial filter" in the OGR connection

     <SrcSQL>SELECT * from vWM_wells_v1 WHERE
        SRF_LONG &gt; %VIEW_MIN_LONG% AND SRF_LONG &lt; %VIEW_MAX_LONG% AND
        SRF_LAT  &gt; %VIEW_MIN_LAT%  AND SRF_LAT  &lt; %VIEW_MAX_LAT%
     </SrcSQL>

gives the right results.


The cause?:
---------------
   I suspect this is due to mapserver asking OGR to do two queries for NQUERY 
(or any other type of template-related query).  The first query is to get a list 
of record ids after applying the spatial filter.  The second is in 
msReturnTemplateQuery to get the attributes for the records, but no spatial 
filter appears to be applied.  So for example the 21st record in the second 
query is actually different than the 21st record in the first query.

   My debug session was rather hurried so I may have missed something.  Is this 
a known problem?

My config:
----------
MapServer version 5.2.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF
  OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER
  SUPPORTS=THREADS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE

C:\ms4w\Apache\cgi-bin>ogrinfo  --version
GDAL 1.6.0, released 2008/12/04

Best Regards,
Brent Fraser





More information about the mapserver-dev mailing list