Tistory 태그: ,,,

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

 

Mapinfo MapXtreme 2008 관련 개발 가이드 문서와 Object Model OVerview 파일

Developer Guide PDF File : MapXtreme2008_DevGuide.pdf

Object Model Overview PDF File : MapXtreme2008ObjectModelPoster.pdf

 

이 글은 스프링노트에서 작성되었습니다.

'GIS > MapInfo' 카테고리의 다른 글

Free TAB to SHP source code  (0) 2010.04.22
MAPINFO_MAPCATALOG 생성  (0) 2008.07.16

MAPINFO를 사용하시는 분들이라면 뭘 의미하는지 잘 아시리라 판단되어집니다.

 

 CREATE TABLE MAPINFO.MAPINFO_MAPCATALOG
(
  SPATIALTYPE       FLOAT(126),
  TABLENAME         CHAR(32 BYTE),
  OWNERNAME         CHAR(32 BYTE),
  SPATIALCOLUMN     CHAR(32 BYTE),
  DB_X_LL           FLOAT(126),
  DB_Y_LL           FLOAT(126),
  DB_X_UR           FLOAT(126),
  DB_Y_UR           FLOAT(126),
  COORDINATESYSTEM  CHAR(254 BYTE),
  SYMBOL            CHAR(254 BYTE),
  XCOLUMNNAME       CHAR(32 BYTE),
  YCOLUMNNAME       CHAR(32 BYTE),
  RENDITIONTYPE     INTEGER,
  RENDITIONCOLUMN   CHAR(32 BYTE),
  RENDITIONTABLE    CHAR(32 BYTE),
  NUMBER_ROWS       INTEGER
)
;

 


CREATE UNIQUE INDEX MAPINFO.MAPCATALOG_IDX ON MAPINFO.MAPINFO_MAPCATALOG
(TABLENAME, OWNERNAME)
;

 

 

GRANT DELETE, INSERT, SELECT, UPDATE ON  MAPINFO.MAPINFO_MAPCATALOG TO PUBLIC;

 

이 글은 스프링노트에서 작성되었습니다.

+ Recent posts