Odd query results on Point layer

Frank Warmerdam warmerdam at POBOX.COM
Thu Sep 13 11:12:19 EDT 2007


Lawrence Hartpence wrote:
> Hello,
> 
> I have a point layer which is actually a database with X & Y fields.  When I
> perform use query mode and select points, the results I get don't match the
> point I am selecting.  Could someone help me understand what I am doing wrong?
> 
> Lawrence
> 
> http://gismap/JasperMaps/cgi-bin/mapserv.exe?&program=%2FJasperMaps%2Fcgi-bin%2Fmapserv.exe&map=C%3A%5CInetpub%5Cwwwroot%5Cmapdocs%5CSeptic.map&zoomsize=2&layers=ortho+Septic+Parcels+Lots+ROW+Survey+Section+Sub+ParcelPt+Water+Shields+Highways+Roads+Watershed+County+Towns&mode=browse&slayer=Parcels&imgxy=320+240&imgext=1680507.39+547052.00+1844030.00+680312.51&mapshape=&imgshape=&imgbox=&qstring=&qlayer=Parcels&qitem=&shapeindex=&savequery=
> 
> Here is the point layer in my MAP file:
> 
> LAYER
>         CONNECTION "<OGRVRTDataSource>
>         <OGRVRTLayer  name='Septic'>
>         <SrcDataSource>ODBC:@Septic</SrcDataSource>
>         <SrcLayer>tblSewersyAllHistoricInfo</SrcLayer>
>         <GeometryField encoding='PointFromColumns' x='X' y='Y'/>
>         <GeometryType>wkbPoint</GeometryType>
>         </OGRVRTLayer>
>         </OGRVRTDataSource>"

Lawrence,

I'm afraid this is an FAQ though possible not actually answered
in the FAQ.  The problem is that MapServer depends on being able
to pull query results by feature id, but the feature ids provided
by the ODBC provider are not consistent and vary depending on the
current spatial and attribute filters in place.

The solution is to change your VRT definition to identify an
integer field in the source features as a unique and consistent
feature id. Assuming you have a column in your table called "septic_id"
that is integer and unique for all rows, you could change your
definition to something like:

          CONNECTION "<OGRVRTDataSource>
          <OGRVRTLayer  name='Septic'>
          <SrcDataSource>ODBC:@Septic</SrcDataSource>
          <SrcLayer>tblSewersyAllHistoricInfo</SrcLayer>
          <GeometryField encoding='PointFromColumns' x='X' y='Y'/>
          <GeometryType>wkbPoint</GeometryType>
          <FID>septic_id</FID>
          </OGRVRTLayer>
          </OGRVRTDataSource>"

If this helps, and you are grateful, perhaps you could spend a bit
of time digging around in the mapserver web site finding a good place
to add this sort of information.  If you provide a good location and
particular text, you can email me privately and I'll add.  I often have
trouble finding the right place to put hints such that they will be
encountered by users with a problem.  Presumably you will have a better
perspective on the matter. :-)

Good luck,
-- 
---------------------------------------+--------------------------------------
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