Opened 16 years ago
Closed 14 years ago
#2493 closed defect (fixed)
GDAL thinks string field is an integer field in GML layer
Reported by: | jbronn | Owned by: | chaitanya |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | 1.5.2 |
Severity: | normal | Keywords: | gml |
Cc: | warmerdam |
Description
The attached GML file has features that have three fields, 'dbl', 'int', and 'str' that are of real, integer, and string types, respectively. The 'str' field is reported as being of integer type instead of being string type.
>>> from osgeo import ogr >>> ds = ogr.Open('test_point.gml') >>> lyr = ds[0] >>> ldefn = lyr.GetLayerDefn() >>> [ldefn.GetFieldDefn(i).GetFieldTypeName(ldefn.GetFieldDefn(i).GetType()) for i in range(ldefn.GetFieldCount())] ['Real', 'Integer', 'Integer'] # Should be ['Real', 'Integer', 'String']
The GML file (and xsd) were generated from using ogr2ogr -F GML
on an existing shapefile.
Attachments (6)
Change History (14)
by , 16 years ago
Attachment: | test_point.gml added |
---|
by , 16 years ago
Attachment: | test_point.xsd added |
---|
comment:1 by , 15 years ago
Cc: | added |
---|---|
Component: | default → OGR_SF |
Owner: | changed from | to
comment:2 by , 15 years ago
The GMLReader::ParseXSD() method was not handling attribute values in the .xsd file that have a prefix. I am attaching a patch that ignores the prefix.
By the way, the attached test_point.xsd file has the second type listed as decimal(Real) and will be treated as such.
Frank, I have tried to handle the issue during type-name verification, but there are more such verifications further down the road. So, I am just skipping the prefix part right after extracting the 'type' attribute value.
by , 15 years ago
Attachment: | parsexsd.cpp.diff added |
---|
Fixes the problem with ignoring the .xsd file with 'type' attribute values with prefixes
comment:3 by , 15 years ago
The patch looks fine, but now the hard part is to extend the GML test script to test this capability - presumably including some new (small) test data.
by , 15 years ago
Attachment: | test_point.2.gml added |
---|
Data file for the test to be added to 'autotest/ogr/data' folder
by , 15 years ago
Attachment: | test_point.2.xsd added |
---|
Data file for the test to be added to 'autotest/ogr/data' folder
comment:4 by , 15 years ago
Status: | new → assigned |
---|
comment:5 by , 15 years ago
comment:6 by , 15 years ago
Chaitanya,
Yes, please apply the update in the 1.6 and 1.5 branch. We do not normally port back the test suite additions - just the code change.
comment:8 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Chaitanya,
I *think* the GML driver will read the .xsd file if it is in the OGR produced "OGR simple features GML" format. Assuming that is true, could you look into whether we can exact the attribute field types from it in such a way that the field types are preserved with datasets like this?
We would need to add appropriate tests to the python test suite.