Virtual Spatial Data & QUERY control ? Wrong result

Frank Warmerdam warmerdam at POBOX.COM
Fri Apr 13 06:52:30 PDT 2007


Jan De Belder wrote:
> Hi all,
> 
> Is there a way to use query or nquery on a virtual spatial data layer in
> MAPSERVER ? I cannot get this to work.
> 
> Description of my setup:
> *windows xp pro, IIS & mapserver (latest ms4w).
> *I have a working virtual spatial data layer in my mapfile, with appropriate
> labelling
> *I have a lightweigth AJAX client which can identify (NQUERY) all layers and
> gives correct results
> 
> Problem
> * when using the identify (NQUERY) on a virtual spatial data point, the
> query always returns the FIRST record in the ODBC source, not the one that
> is clicked on by the pointclick (Mind you, when I use exactly the same data
> in a shapefile, the identify works, and labelling on the virtual spatial
> data points also works).
> 
> 
> http://mapserver.gis.umn.edu/docs/howto/ogr_howto/#queries-through-ogr-format
> states that OGR queries should works the same as shapefiles. Does this not
> apply to Virtual Spatial Data layers ?

Jan,

The classic reason for this is underdetermined feature ids.  In normal use
the OGR ODBC driver will assign feature ids sequentially to records in a
result set.  If the spatial or attribute filter changes then the new result
set is still numbers sequentially.

MapServer uses feature ids (FIDs) to fetch query results, so it is
imperative for features ids to remain consistent for this to work.

If you have a column in your ODBC table which is effectively an integer
identifier that can be used as a unique FID, then you should add it to the
virtual data source description.  Add <FID>columnname</FID>.

See this for details:

   http://www.gdal.org/ogr/drv_vrt.html

I hope this helps.

BTW, if we eventually re-engineer the MapServer query mechanism to hold
the query result set in memory instead of having to refetch them by fid
this problem will go away - as well as a dramatic improvement in performance
in some circumstances.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the MapServer-users mailing list