MySQL decimal field rounded to nearest integer

Stephane Lessard LESSARDST at DFO-MPO.GC.CA
Wed Feb 23 09:49:21 EST 2005


Frank,

>
>
> First, to confirm, you see this problem when using ogr to
> access MySQL tables via ODBC, is that right?  So the issue is
> with decimal field handling in the OGR ODBC driver?

That is correct.

>
> An "ogrinfo" report for the table in question - along with a
> Mysql dump of the field definitions would be helpful ...
> ideally in a GDAL/OGR bugzilla report.

Here's what ogrinfo returns for 5 fields:

Longueur (Real) =        5
Largeur (Real) =        5
Profondeur (Real) =       11
Secteur (Integer) = 3
URL (String) = http://www.marinfo.gc.ca/GEDSite/PDF/Q5173-04.pdf

And here's the definition from MySQL:

'Longueur', 'decimal(8,3)'
'Largeur', 'decimal(8,3)'
'Profondeur', 'decimal(8,3)'
'Secteur', 'int(11)'
'URL', 'varchar(255)'

>
> The code responsible for field type classification for OGRs
> ODBC driver is in:
>
>   gdal/ogr/ogrsf_frmts/odbc/ogrodbclayer.cpp
>
> The method is OGRODBCLayer::BuildFeatureDefn().
>
> There is handling specifically for the ODBC types
> SQL_INTEGER, SQL_DECIMAL, SQL_FLOAT, SQL_REAL and SQL_DOUBLE.
>  All others are treated as strings.
> The SQL_DECIMAL is supposed to be treated as a generic
> floating point value.
>
> I need to establish:
>  o What OGR field type is getting used for the field.
>  o What ODBC (SQL_*)  field type code OGR is getting from ODBC
>     for the field.
>
> Also, could you confirm what version of GDAL/OGR you are using?
> 1.2.5?

1.2.5 it is.

>
> Best regards,

Thanks a lot!

> --
> ---------------------------------------+----------------------
> ----------
> ---------------------------------------+------
> 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    | Geospatial
> Programmer for Rent
>



More information about the mapserver-users mailing list