Hello List,

I have a MapBasic tool that I downloaded from Directions Magazine.  It
converts a tfw file that can only be read in ArcView into a MI table.  It is
a great tool, but I've been attempting to customize it to my own needs.
First, I added a push button which worked fine.  Now, I'm trying to set the
map projection automatically so that I don't have to pick it each time.  The
map projection I want is U.S. State Plane Coordinate System, NAD 83, Units
feet, Texas, South Central.  Nothing I try seems to work.  My MapBasic
skills are not very good so I'm sure that's part of the problem.  If anyone
could help with this problem I'd greatly appreciate it.  I've included the
code below:

'* TFWRead.MB
'*    A raster registration tool for opening raster images using .TFW files
'*
'*************************************************************************
'*************************************************************************
'Include statements
'*************************************************************************
include "mapbasic.def"

'** Declares
Declare Sub Main()
Declare Sub TFWRead()

Sub Main()
'** Create Buttonpad
Create ButtonPad "TFW Tool" As
        Pushbutton
        Calling TFWRead
        Fixed

End Sub

Sub TFWRead()
dim sTFWFileName as string
sTFWFileName = FileOpenDlg(ApplicationDirectory$() ,  "" ,  "TFW" ,  
"Select the .TFW file needed to register image:" )
if ""=sTFWFileName then
  end program
end if
open file sTFWFileName for input as #1
dim f_dX1, f_dY1, f_dX2, f_dY2, f_X0, f_Y0, f_X1, f_Y1, f_X2, f_Y2 as float
input #1, f_dX1
input #1, f_dY1
input #1, f_dX2
input #1, f_dY2
input #1, f_X0
input #1, f_Y0
f_X1 = f_X0 + f_dX1
f_Y1 = f_Y0 + f_dY1
f_X2 = f_X0 + f_dX2
f_Y2 = f_Y0 + f_dY2

dim sBaseFileName as string
sBaseFileName = PathToFilename$(sTFWFileName)
sBaseFileName = left$(sBaseFileName,len(sBaseFileName)-4)  'strip off the
extension

dim sTabFileName as string
sTabFileName = PathToDirectory$(sTFWFileName) + sBaseFileName + ".TAB"
dim bContinue as logical
if FileExists(sTabFileName) then
  bContinue = Ask("Overwrite the existing " + sTabFileName + "?", "OK",
"Cancel")
  if not bContinue then
    end program
  end if
end if
Dim strCSys as string
strCSys = ChooseProjection$("", True)
open file sTabFileName for output as #2
print #2, "!table"
print #2, "!version 300"
print #2, "!charset WindowsLatin1"
print #2, ""
print #2, "Definition Table"
print #2, "  File """ + sBaseFileName + ".tif"""
print #2, "  Type ""RASTER"""
print #2, "  (" + format$(f_X0,"#.########") + "," +
format$(f_Y0,"#.########")
+ ") (0,0) Label ""Pt 1"","
print #2, "  (" + format$(f_X1,"#.########") + "," +
format$(f_Y1,"#.########")
+ ") (1,0) Label ""Pt 2"","
print #2, "  (" + format$(f_X2,"#.########") + "," +
format$(f_Y2,"#.########")
+ ") (0,1) Label ""Pt 3"""
print #2, "  " + strCSys
close file #2
open table sTabFileName
map from TableInfo(0,TAB_INFO_NAME)

End Sub
 
Thanks,

Michael Goldberg
City of San Antonio Planning Department
Data Management & CAD
[EMAIL PROTECTED]
(210) 207-6533

----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to