Title: Message
This is how IMUT is used with Delphi. You can use it as pseudocode for a MapBasic application:
 
function TForm1.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;
 
 

HTH

Jakob Lanstorp
Software Consultant
Geographical Information & IT

COWI A/S
Odensevej 95
DK-5260 Odense S

Tel  +45 6311 4900
Fax  +45 6311 4949
Mob  +45 5050 8087
E-mail [EMAIL PROTECTED]
http://www.cowi.dk
http://www.cowi.com

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Llewellyn, David
Sent: Monday, November 14, 2005 8:45 AM
To: [email protected]
Subject: [Mapinfo-l] Programmatic MapInfo TAB to Shapefile translation

Hi all,

Does anyone know of a way to run a MapInfo TAB to Shapefile translation via MapBasic?

Or is there a command line way to invoke the Universal Tanslator?

This would save a fair bit of manual work using the Universal Translator.

Thanks.

David Llewellyn

Geospatial Specialist

Regional Team (West)

NNTT Principal Registry, Perth

Phone: 08 9268 7477

Email: [EMAIL PROTECTED]

***This Email, together with any attachments is intended for the

addressee only.
If you have received this Email in error please inform the sender

immediately by return Email.
Alternatively you can ring the National Native Title Tribunal on

the toll free number 1800 640 501 and report the error.
Please delete the Email and any copies from your computer and/or

computer network. The Tribunal does not warrant that this email

is virus free.
The Tribunal has also implemented content filtering of Emails to

restrict inappropriate and spam emails being received. Other emails

which may contain viruses may also be blocked. In either case, and

in any case the email may not reach its intended recipient. If the

email is important you may wish to see confirmation of its receipt

by placing that request in the text of the email. Please resend the

email if you haven't received that confirmation as requested. ***
_______________________________________________
Mapinfo-l mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to