[mapserver-users] wrong type cast for OGRVRT datasource
Huub Fleuren
huub.gis at gmail.com
Mon Nov 17 06:01:00 PST 2014
Hi List,
De following OGRVRT datasource is used to define a Mapserver layer on an
ODBC connection to a MSACCESS tabel that contains x and y values. This
works fine.
CONNECTION "<OGRVRTDataSource>
<OGRVRTLayer name='kpxy'>
<SrcDataSource>ODBC:admin/admin at MyMSACCESSDatabase
</SrcDataSource>
<SrcSQL>SELECT * FROM kpxy</SrcSQL>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding='PointFromColumns' x='x' y='y'/>
<Field name='kp_nr' type='String' />
<Field name='kp_id' type='String' />
<Field name='sort' type='String' />
<Field name='x' type='Integer' />
<Field name='y' type='Integer' />
</OGRVRTLayer>
</OGRVRTDataSource>"
Now we need a WFS on this, and we should be able to select a record based
on a field value.
A WFS-Filter might look like
<Filter><PropertyIsEqualTo><PropertyName>kp_nr</PropertyName><Literal>06864</Literal></PropertyIsEqualTo></Filter>
The error is described by the following
<ServiceException code="NoApplicableCode" locator="mapserv">
msWFSGetFeature(): WFS server error. FLTApplyFilterToLayer() failed
msOGRFileNextShape(): OGR error. Type mismatch or improper type of
arguments to = operator.
</ServiceException>
So, the kp_nr field is not of type integer in the underlying database. The
Literal states 06864, which at least looks like an int.
Take a look at the datasource again.
The fields kp_id and kp_nr are defined as String, not Integer.
I take it that Mapserver cannot determine the correct type from the Literal
which looks like an int
But now I explicitly defined the type in the MAP file.
<Field name='kp_nr' type='String' />
I proved this case by looking up a Literal on the same property that
actually contains a real Character. No errors
So Mapserver tries to 'see' the datatype instead of looking it up. I can
imagine you need to do that if you cannot access the database but in this
case the datatype of this field is given. No need to gamble datatypes
between records...
Should i file a bug report?
Regards, Huub
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20141117/63b969a3/attachment.htm>
More information about the MapServer-users
mailing list