diff --git a/autotest/ogr/ogr_mitab.py b/autotest/ogr/ogr_mitab.py index cc1f971a3..2ec5950f2 100755 --- a/autotest/ogr/ogr_mitab.py +++ b/autotest/ogr/ogr_mitab.py @@ -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' diff --git a/gdal/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp b/gdal/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp index 0fd8030bb..6d97c8350 100644 --- a/gdal/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp +++ b/gdal/ogr/ogrsf_frmts/mitab/mitab_miffile.cpp @@ -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", @@ -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 */ /*-----------------------------------------------------------------