[#91] TestOGRTable.test_Column(s) fail: 'double' != 'int'

Date:
2006-04-17 13:56
Priority:
3
State:
Open
Submitted by:
Bernhard Reiter (bernhard)
Assigned to:
Nobody (None)
Category:
none
Version:
none
Resolution:
none
Summary:
TestOGRTable.test_Column(s) fail: 'double' != 'int'

Detailed description
FAIL: Extensions.ogr.test.test_OGRShapestore.TestOGRTable.test_Column
----------------------------------------------------------------------
Traceback (most recent call last):
File "/mobilehome/bernhard/hacking/thuban/root/trunk/thuban/test/../Extensions/ogr/test/test_OGRShapestore.py", line 197, in test_Column
self.assertEquals(self.table.Column(0).type, FIELDTYPE_INT)
File "/usr/lib/python2.3/unittest.py", line 302, in failUnlessEqual
raise self.failureException, \
AssertionError: 'double' != 'int'

======================================================================
FAIL: Extensions.ogr.test.test_OGRShapestore.TestOGRTable.test_Columns
----------------------------------------------------------------------
Traceback (most recent call last):
File "/mobilehome/bernhard/hacking/thuban/root/trunk/thuban/test/../Extensions/ogr/test/test_OGRShapestore.py", line 191, in test_Columns
self.assertEquals(self.table.Columns()[0].type, FIELDTYPE_INT)
File "/usr/lib/python2.3/unittest.py", line 302, in failUnlessEqual
raise self.failureException, \
AssertionError: 'double' != 'int'

----------------------------------------------------------------------
Debian GNU/Linux ppc

Thuban 1.1 svn-20060412
ChangeLog 2006-04-12

Currently using:
wxPython 2.4.2.4
Python 2.3.5
PySQLite 1.0.1
SQLite 2.8.16
GDAL 1.3.1.0
psycopg - not available

Internal encoding: ISO8859-1

Compiled for:
GTK 1.2.10
proj 4.4.9

Extensions:
SVG Export 1.0.0+cvs
Message  ↓
Date: 2006-05-19 08:47
Sender: Bernhard Reiter

http://shapelib.maptools.org/dbf_api.html
Section DBFGetFieldInfo() has a table:

typedef enum {
FTString, /* fixed length string field */
FTInteger, /* numeric field with no decimals */
FTDouble, /* numeric field with decimals */
FTLogical, /* logical field. */
FTInvalid /* not a recognised field type */
} DBFFieldType;

So according to this definition, this is FTInteger
for shapelib. Is Frank Warmerdam contradicting himself?
:) Maybe we need to ask. Or poke in the newer versions of shapelib.

Date: 2006-05-19 08:42
Sender: Bernhard Reiter

I am a bit unsure, because I think shapelib also handles dbf files and there must be a real spec somewhere
that marks the type of the field.

This would mean not only to fix the testcase, but also to fix the type constant we are using so far. I did not have time to think about the consequences of doing so.
Otherwise: OGR support is pretty new, why not just fix the testcase?

Date: 2006-05-17 10:32
Sender: Didrik Pinte

This can be the interesting changelog :

* Revision 1.58 2005/03/14 15:18:54 fwarmerdam
* Treat very wide fields with no decimals as double. This is
* more than 32bit integer fields.

in ogr/ogrs_frmts/shape/dbfopen.c

I have now way of knowing what ogr official version is linked with this.

Date: 2006-05-16 17:34
Sender: Bernhard Reiter

This is interesting, maybe the old version was wrong,
but thus would mean, if we fix the testcase,
this would fail on older ogr versions.
Best would be to find the fix in the ogr changelog.

Date: 2006-05-16 13:56
Sender: Didrik Pinte

ArcGIS 9.1 reports the FNODE_ as a double field (precision 11, scale 0).

This solves the bug. OGR is coherent with ArcGIS 9. My guess is that the type in the test case must be corrected to double and not int.

Do you prefer to have another test with another software or library ?

Date: 2006-05-16 08:53
Sender: Bernhard Reiter

It think the testcase runs fine in earlier versions.
It might be that ogr reports the wrong type,
this would be consistant with ogrinfo,
but we would need to compare it to the type within the file.

Date: 2006-05-16 07:52
Sender: Didrik Pinte

The problem is in the TestCase. It's not a bug.

Using ogrinfo on the roads-line.shp file, we get the following answer :

did@geru-itae:~/projets/python/thuban/thuban/Data/iceland$ ogrinfo -su roads-line.shp roads-line
INFO: Open of `roads-line.shp'
using driver `ESRI Shapefile' successful.

Layer name: roads-line
Geometry: Line String
Feature Count: 839
Extent: (-24.450359, 63.426830) - (-13.556688, 66.520111)
Layer SRS WKT:
(unknown)
FNODE_: Real (11.0)
TNODE_: Real (11.0)
LPOLY_: Real (11.0)
RPOLY_: Real (11.0)
LENGTH: Real (12.3)
RDLINE_: Real (11.0)
RDLINE_ID: Real (11.0)
RDLNTYPE: Integer (2.0)
RDLNSTAT: Integer (2.0)


So the FNODE_ feature is a double and not an int.

Does the test case for the ogr extensions works fine with a previous version of ogr ? I have only tested it with 1.3.x version.

Can someone test it with a gdal 1.1.8 for example ?

Date: 2006-04-17 13:59
Sender: Bernhard Reiter

The failure was also noticed by Didrik on Windows
with gdal 1.3.1

This failrue could not be observed with gdal 1.2.6,
it might as well be a gdal problem.

No attached documents

No changes have been made to this item