Since I need to export MapInfo vector TAB files to ESRI SHP within an MapX application, I have developed a Delphi function doing so with Universal Translator from MapInfo Pro.
I am not aware of any copyrights from MapInfo Corp and Safe.com. It would be nice if MapX was distributed with the IMUT.exe from Universal Translator of MapInfo Pro.
If you copy UE directory from MI Pro the following function will do the job.
{ ============================================================================ }
function Tab2Shp(srcfile, destfile : String) : Boolean;
//Convert a source MapInfo tab file to a destination ESRI shape file with external Universal Translator macro
var
str : String; //String holder
pathIMUT : String; //Path to external FME application
pathSrc : String; //PAth to Source file (MapInfo TAB vector files)
pathDest : String; //Path to destination files (ESRI SHP vector files)
tabnam : String; //Source table name
tmpdat : string; //Temp dat file for IMUT
sParam : string; //Parametre to INUT.EXE
FileStream : TFileStream; //Used to write hggtemp2.dat
StringList : TStringList;
begin
Result := False;
//Step 1: Gernerate FME script - Run command line:
pathIMUT := ExtractFilePath(Application.ExeName)+'UT\';
pathSrc := ExtractFilePath(srcfile);
pathSrc := Copy(pathSrc,1,Length(pathSrc)-1) + '/'; //Change trailing \ to /
pathSrc := AnsiQuotedStr(pathSrc,#34); //Add Quoates and trailing space
tmpdat := AnsiQuotedStr('hggtemp1.dat',#34);
pathDest := ExtractFilePath(destfile);
tabnam := Copy(ExtractFileName(srcfile),1,Length(ExtractFileName(srcfile))-4); //Get MapInfo Tabelname
sParam := 'CFGenerate MAPINFO SHAPE ' + pathSrc + ' ' + tmpdat + ' LOG_STANDARDOUT YES +ID ' + tabnam;
//Batch = IMUT.EXE CFGenerate MAPINFO SHAPE "C:\HGG\Code\UT\MIdir/" "hggtemp1.dat" LOG_STANDARDOUT YES +ID "komg2002"
ShellExecute(Application.Handle,'OPEN',PChar(pathIMUT+'IMUT.EXE'),PChar(sParam),PChar(pathIMUT),SW_HIDE);
//Step 2: Create control file - Named hggtemp2.dat
StringList := TStringList.Create;
StringList.Add('MACRO _EXTENSION TAB');
StringList.Add('MACRO _BASENAME ' + tabnam);
StringList.Add('MACRO _FULLBASENAME ' + tabnam);
StringList.Add('MACRO SourceDataset ' + pathSrc);
pathDest := Copy(pathDest,1,Length(pathDest)-1); // Remove trailing slash
StringList.Add('MACRO DestDataset ' + pathDest);
StringList.Add('INCLUDE hggtemp1.dat'); //Add double quoates
tabnam := AnsiQuotedStr(tabnam,#34); //Get MapInfo Tabelname
StringList.Add('MAPINFO_IDs ' + tabnam);
StringList.Add('MAPINFO_IN_IDs ' + tabnam);
StringList.SaveToFile(pathIMUT+'hggtemp2.dat');
StringList.Free;
//Step 3: Final executation - Command line: imut.exe hggtemp2.dat
sParam := 'hggtemp2.dat';
ShellExecute(Application.Handle,'OPEN',PChar(pathIMUT+'IMUT.EXE'),PChar(sParam),PChar(pathIMUT),SW_HIDE);
Result := True;
end;
Get Delphi 6 source and sample application from
http://www.lanstorp.com/Files/Tab2Shp.zip
출처 : http://community.mapinfo.com/forums/thread.jspa?threadID=3457
'GIS > MapInfo' 카테고리의 다른 글
Pitney Bowes Mapinfo - MapXtreme 2008 v6.8 for Windows Developer Guide / Object Model Overview PDF Document File (0) | 2008.09.10 |
---|---|
MAPINFO_MAPCATALOG 생성 (0) | 2008.07.16 |