OGRErr IMapInfoFile::CreateField( OGRFieldDefn *poField, int bApproxOK ) { TABFieldType eTABType; int nWidth; if( GetTABType( poField, &eTABType, &nWidth ) < 0 ) return OGRERR_FAILURE; if( AddFieldNative( poField->GetNameRef(), eTABType, nWidth, poField->GetPrecision(), FALSE, FALSE, bApproxOK ) > -1 ) return OGRERR_NONE; else return OGRERR_FAILURE; }
OGRErr IMapInfoFile::CreateField( OGRFieldDefn *poField, int bApproxOK ) { TABFieldType eTABType; int nWidth = poField->GetWidth(); if( poField->GetType() == OFTInteger ) { eTABType = TABFInteger; if( nWidth == 0 ) nWidth = 12; } else if( poField->GetType() == OFTReal ) { eTABType = TABFFloat; if( nWidth == 0 ) nWidth = 32; } else if( poField->GetType() == OFTString ) { eTABType = TABFChar; if( nWidth == 0 ) nWidth = 254; else nWidth = MIN(254,nWidth); } else { CPLError( CE_Failure, CPLE_AppDefined, "IMapInfoFile::CreateField() called with unsupported field" " type %d.\n" "Note that Mapinfo files don't support list field types.\n", poField->GetType() ); return OGRERR_FAILURE; } if( AddFieldNative( poField->GetNameRef(), eTABType, nWidth, poField->GetPrecision() ) > -1 ) return OGRERR_NONE; else return OGRERR_FAILURE; }