Title: SUM: Trying to set Map projection in MapBasic

Thanks to Steve Wallace, Ahmet Dabanli, and Jacques Paris who responded to my question.  The responses I got we're basically the same and it definitely worked.  Here is the solution:

replace this line: strCSys = ChooseProjection$("", True)

with this line: strCSys = "CoordSys Earth Projection 3, 74, 8, -99, 27.8333333333, 28.3833333333, 30.2833333333, 1968500, 13123333.33 Bounds (-221593659.468, -172632102.019) (225530659.468, 274492216.916)"

The entire code is 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 = "CoordSys Earth Projection 3, 74, 8, -99, 27.8333333333, 28.3833333333, 30.2833333333, 1968500, 13123333.33 Bounds (-221593659.468, -172632102.019) (225530659.468, 274492216.916)"

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


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

Reply via email to