Virtual layer access OGR ODBC problem

Frank Warmerdam warmerdam at POBOX.COM
Tue Oct 10 11:24:46 PDT 2006


Yewondwossen Assefa wrote:
> Hi There,
> 
>  I am trying to access an ODBC database using the ogr virtual  layer 
> access (using shp2img). The layer seems to be defined properly as far as 
> I know. It looks something like :
> 
> ...
> CONNECTION "<OGRVRTDataSource>
>   <OGRVRTLayer name='AL05AK0001'>
>   <SrcDataSource>ODBC:@sos_test</SrcDataSource>
>   <SrcSQL>SELECT * FROM t_ResEau_Station_Data WHERE Site_Number = 
> 'AL05AK0001'</SrcSQL>
>   <GeometryType>wkbPoint</GeometryType>
>   <GeometryType>wkbPoint</GeometryType>
>   <LayerSRS>WGS84</LayerSRS>
>   <GeometryField encoding='PointFromColumns' x='Longitude' y='Latitude'/>
>   </OGRVRTLayer>
>   </OGRVRTDataSource>"
> 
> The error message is the following :
> 
> msOGRFileNextShape(): OGR error. Attempt to use STRING field `Longitude' 
> with numeric comparison `>'. <br>
> 
> If I just use the SrcLayer instead of the SrcSQL, It seems to work ok :
> 
> <SrcDataSource>ODBC:@sos_test</SrcDataSource>
>  <SrcLayer>t_ResEau_Station_Data</SrcLayer>
>   <GeometryType>wkbPoint</GeometryType>
>   <LayerSRS>WGS84</LayerSRS>
>   <GeometryField encoding='PointFromColumns' x='Longitude' y='Latitude'/>
> 
> 
>  From what I understand this occures when comparing the x,y values to 
> the map bbox to see if the element fits in the map. I am using gdal/ogr 
> from CVS (updated few days ago).

Assefa,

The problem seems to relate to the VRT (OVF) driver trying to apply
spatial constraints to the Latitude and Longitude columns.  I am
guessing these fields aren't actually numeric?  I'm a bit surprised
to see that it occurs with SrcSQL, but not with SrcLayer.

I believe, as a work around, you can set the useSpatialSubquery='FALSE'
attribute on GeometryField.

eg.
<GeometryField encoding='PointFromColumns' useSpatialSubquery='FALSE'
                x='Longitude' y='Latitude'/>

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