Opened 13 years ago

Closed 10 years ago

Last modified 10 years ago

#3853 closed defect (fixed)

Data types change converting from MID/MIF to SHP

Reported by: zoltan Owned by: chaitanya
Priority: normal Milestone: 1.11.1
Component: OGR_SF Version: unspecified
Severity: normal Keywords: MITAB
Cc: warmerdam, Daniel Morissette, aboudreault, lpercich

Description (last modified by warmerdam)

When converting a SHP to a MID-MIF format, the data precision is lost. EG: Integer (10) becomes Integer [not Integer (10) to show longint] in the MIF file. On return from MID-MIF to Shape, I force the MIF file to contain Integer (10) in the schema, and it arrives in SHP as a Real value. Note that it is a technical requirement from our client that the Integer Length is reflected as 10 (and not zero), if it is "10" in the MIF file.

This is holding up a delivery dataset to a client, but I do understand if this cannot be solved soon.

3 Attachments (viewed via qgis 1.5.0)

original_SHP_schema.jpg is original client data.

After exporting from QGIS as midmif, the resulting MIF file contains:

Columns 25
  FEAT_TYPE_ Integer
  OPERATIONA Integer
  .
  .
  GID Integer

etc....[note no "5" or "10" after the "Integer"]

re_read_midmif.jpg Is as the midmif files are opened by QGIS 1.5.0

shp_from_midmif.jpg After saving above midmif as SHP, exiting, then re-opening QGIS to read the resulting SHP file. Note that they are all "Integer 10" instead of some being "Integer 5", as our client is insisting.

Thanks & regards, Zoltan

Attachments (4)

shp_from_midmif.jpg (132.4 KB ) - added by zoltan 13 years ago.
re_read_midmif.jpg (133.2 KB ) - added by zoltan 13 years ago.
original_SHP_schema.jpg (131.9 KB ) - added by zoltan 13 years ago.
ogr_mitab_width.diff (3.4 KB ) - added by lpercich 11 years ago.
Fix: MapInfo max decimal field width is 20

Download all attachments as: .zip

Change History (14)

by zoltan, 13 years ago

Attachment: shp_from_midmif.jpg added

by zoltan, 13 years ago

Attachment: re_read_midmif.jpg added

by zoltan, 13 years ago

Attachment: original_SHP_schema.jpg added

comment:1 by warmerdam, 13 years ago

Cc: warmerdam Daniel Morissette aboudreault added
Description: modified (diff)
Keywords: MITAB added
Milestone: 1.8.0
Owner: changed from warmerdam to chaitanya
Severity: blockernormal

Chaitanya,

Please work on this promptly. Disregard the shapefile aspects - I believe they are already adequately addressed. The key is to ensure that OGR recognises the field width for integer fields, and treats Decimal(n,0) as integer, not real.

I think the provided dataset demonstrates Integer(n) fields. I will email you with a dataset containing Decimal(n,0) fields for you to test with.

I imagine changes will need to go upstream to MITAB though I presume the issue is primarily with the OGRLayer wrapper for MITAB. Work with Alan and/or Daniel on mitab updates.

Please manufacture a small test for the test suite to verify corrections one you have them.

comment:2 by chaitanya, 12 years ago

Resolution: fixed
Status: newclosed

Fixed a couple of data type errors in MIF and TAB format in trunk (r24135) and branches/1.9 (r24136).

comment:3 by warmerdam, 12 years ago

Resolution: fixed
Status: closedreopened

Note that most, if not all code in the ogr/mitab directory comes from the upstream mitab library and the changes need to be applied there. Reopening in case that has not occurred.

comment:4 by chaitanya, 12 years ago

I see that Daniel is cc'ed to this ticket. Daniel, Can you pass this up to the mitab library?

by lpercich, 11 years ago

Attachment: ogr_mitab_width.diff added

Fix: MapInfo max decimal field width is 20

comment:5 by lpercich, 11 years ago

Hi all,

changeset [24136] introduced a problem: MapInfo (at least up to version 7.5) only supports a maximum width of 20 and a maximum precision of 16 in decimal fields. If we convert a shapefile having a decimal(30,15) field in mapinfo TAB format, MapInfo crashes in the attempt to open that file. This anomalous TAB file can be opened with OGR-based tools like QGIS.

I attached a patch to add a check for maximum allowed width. It fixes the problem for me, and I could run the tests successfully.

One workaround (without applying the fix) is exporting in MIF format: the MIF is imported without problems in MapInfo, and the width of the decimal field is set to 20.

comment:6 by lpercich, 11 years ago

Cc: lpercich added

comment:7 by Daniel Morissette, 11 years ago

The MIF format doesn't allow the syntax "Integer (10)". It has been reported to me that files mif/mid with this syntax produced by GDAL 1.9.x are rejected by MapInfo.

This will require more investigation and testing...

comment:8 by Even Rouault, 10 years ago

Another probably related ticket : #5253

comment:9 by Even Rouault, 10 years ago

Milestone: 1.8.11.11.1
Resolution: fixed
Status: reopenedclosed

trunk r27525, branches/1.11 r27526 "MITAB: don't write field width for integer fields in .mif, which is incompatible with MapInfo (#3853)"

comment:10 by Daniel Morissette, 10 years ago

Thank you @rouault

Note: See TracTickets for help on using tickets.