def ogr_mitab_17(): if gdaltest.mapinfo_drv is None: return 'skip' import ogr_gml_read if ogr_gml_read.ogr_gml_1() != 'success': return 'skip' import test_cli_utilities if test_cli_utilities.get_test_ogrsf_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp') if ret.find('INFO') == -1 or ret.find('ERROR') != -1: print(ret) return 'fail' ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' tmp/wrk.mif') if ret.find('INFO') == -1 or ret.find('ERROR') != -1: print(ret) return 'fail' return 'success'
def ogr_mitab_14(): if gdaltest.mapinfo_drv is None: return 'skip' import ogr_gml_read if ogr_gml_read.ogr_gml_1() != 'success': return 'skip' if test_cli_utilities.get_ogr2ogr_path() is None: return 'skip' try: os.stat('tmp/testlyrdef.mif') ogr.GetDriverByName('MapInfo File').DeleteDataSource( 'tmp/testlyrdef.mif') except: pass gdaltest.runexternal( test_cli_utilities.get_ogr2ogr_path() + ' -f "MapInfo File" -dsco FORMAT=MIF tmp/testlyrdef.mif ../ogr/data/testlyrdef.gml' ) ds = ogr.Open('tmp/testlyrdef.mif') #Check if the width and precision are as preserved. lyr = ds.GetLayer('testlyrdef') if lyr is None: gdaltest.post_reason('Layer missing.') return 'fail' defn = lyr.GetLayerDefn() data = [['AREA', ogr.OFTReal, 7, 4], ['VOLUME', ogr.OFTReal, 0, 0], ['LENGTH', ogr.OFTInteger, 254, 0], ['WIDTH', ogr.OFTInteger, 254, 0]] for field in data: fld = defn.GetFieldDefn(defn.GetFieldIndex(field[0])) 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' ds.Destroy() ogr.GetDriverByName('MapInfo File').DeleteDataSource('tmp/testlyrdef.mif') return 'success'
def ogr_mitab_14(): if gdaltest.mapinfo_drv is None: return 'skip' import ogr_gml_read if ogr_gml_read.ogr_gml_1() != 'success': return 'skip' if test_cli_utilities.get_ogr2ogr_path() is None: return 'skip' try: os.stat('tmp/testlyrdef.mif') ogr.GetDriverByName('MapInfo File').DeleteDataSource('tmp/testlyrdef.mif') except: pass gdaltest.runexternal(test_cli_utilities.get_ogr2ogr_path() + ' -f "MapInfo File" -dsco FORMAT=MIF tmp/testlyrdef.mif ../ogr/data/testlyrdef.gml') ds = ogr.Open('tmp/testlyrdef.mif') #Check if the width and precision are as preserved. lyr = ds.GetLayer('testlyrdef') if lyr is None: gdaltest.post_reason( 'Layer missing.' ) return 'fail' defn = lyr.GetLayerDefn() data = [['AREA', ogr.OFTReal, 7, 4], ['VOLUME',ogr.OFTReal, 0, 0], ['LENGTH',ogr.OFTInteger,254,0], ['WIDTH', ogr.OFTInteger,254,0]] for field in data: fld = defn.GetFieldDefn(defn.GetFieldIndex(field[0])) 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' ds.Destroy() ogr.GetDriverByName('MapInfo File').DeleteDataSource('tmp/testlyrdef.mif') return 'success'