Virtual layer access OGR ODBC problem

Yewondwossen Assefa assefa at DMSOLUTIONS.CA
Tue Oct 10 12:08:10 PDT 2006


Frank Warmerdam wrote:
> 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,

The useSpatialSubquery='FALSE' seems to do the trick, although I need to 
do more tests.
  Not sure if the fields are numeric:

   * if I do an ogrinfo the Latitude/Longitude is reported as being String
   * if I do access the db using php and echo the field types, I get 
Latitude DECIMAL and Longitude DECIMAL

  I will report if there are other issues.

  Thanks.


-- 
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst

Email: assefa at dmsolutions.ca
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------



More information about the MapServer-users mailing list