[mapserver-users] wrong type cast for OGRVRT datasource

Lime, Steve D (MNIT) Steve.Lime at state.mn.us
Tue Nov 25 13:31:13 PST 2014


Huub: What does your layer definition look like?

From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Huub Fleuren
Sent: Monday, November 17, 2014 8:01 AM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] wrong type cast for OGRVRT datasource

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/20141125/0fdb3468/attachment.html>


More information about the mapserver-users mailing list