Skip to content

Commit

Permalink
MITAB: don't write field width for integer fields in .mif, which is i…
Browse files Browse the repository at this point in the history
…ncompatible with MapInfo (#3853)
  • Loading branch information
rouault committed Jul 12, 2014
1 parent 87af4d1 commit 5fef72b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 6 additions & 3 deletions autotest/ogr/ogr_mitab.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,15 @@ def ogr_mitab_14():

data = [['AREA', ogr.OFTReal, 7, 4],
['VOLUME',ogr.OFTReal, 0, 0],
['LENGTH',ogr.OFTInteger,10,0],
['WIDTH', ogr.OFTInteger, 4,0]]
['LENGTH',ogr.OFTInteger,254,0],
['WIDTH', ogr.OFTInteger,254,0]]

for field in data:
fld = defn.GetFieldDefn(defn.GetFieldIndex(field[0]))
if fld.GetType() != field[1] or fld.GetWidth() != field[2] or fld.GetPrecision() != field[3]:
expected_with = field[2]
if fld.GetType() == ogr.OFTInteger:
expected_with = 0
if fld.GetType() != field[1] or fld.GetWidth() != expected_with or fld.GetPrecision() != field[3]:
gdaltest.post_reason( field[0] + ' field definition wrong.' )
return 'fail'

Expand Down
11 changes: 3 additions & 8 deletions gdal/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,13 +1104,8 @@ int MIFFile::WriteMIFHeader()
switch(m_paeFieldType[iField])
{
case TABFInteger:
if (poFieldDefn->GetWidth() == 0)
m_poMIFFile->WriteLine(" %s Integer\n",
poFieldDefn->GetNameRef());
else
m_poMIFFile->WriteLine(" %s Integer(%d)\n",
poFieldDefn->GetNameRef(),
poFieldDefn->GetWidth());
m_poMIFFile->WriteLine(" %s Integer\n",
poFieldDefn->GetNameRef());
break;
case TABFSmallInt:
m_poMIFFile->WriteLine(" %s SmallInt\n",
Expand Down Expand Up @@ -1778,7 +1773,7 @@ int MIFFile::AddFieldNative(const char *pszName, TABFieldType eMapInfoType,
*----------------------------------------------------------------*/
if (eMapInfoType == TABFDecimal && nWidth == 0)
nWidth=20;
else if (nWidth == 0)
else if (eMapInfoType == TABFChar && nWidth == 0)
nWidth=254; /* char fields */

/*-----------------------------------------------------------------
Expand Down

0 comments on commit 5fef72b

Please sign in to comment.