home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
gamefly
/
fsgriduk.arj
/
FS-GRID.BAS
next >
Wrap
BASIC Source File
|
1991-02-01
|
6KB
|
211 lines
' FS-GRID
' A program to create a file of FS grid intersections in OS coordinates
' There is also a mode (if CHT% is on) which creates files for a survey
' plotting system which I use.
' Andy Zienkiewicz 1991
' My switch !
CHT% = 0
IF INSTR(UCASE$(COMMAND$), "/C") THEN CHT% = -1
GOSUB SetVariables
GOSUB GetParameters
IF CHT% THEN
GOSUB MakeCHTFile
ELSE
GOSUB MakeIntersectionFile
END IF
END
SetVariables:
SCREEN 0
DEFDBL A-Z
IF CHT% THEN
OutFile$ = "FS.CHT"
ELSE
OutFile$ = "FS.GRD"
END IF
' Set constants for OS2FS convertion
' Input file FS-OS.DAT contains a list of points, each with
' FS coords and OS coords. Three points are selected to
' bound an area where conversions are to be done and have
' a "*" on the line before.
DatFile$ = "FS-OS.DAT"
OPEN DatFile$ FOR RANDOM AS #1
IF LOF(1) = 0 THEN
CLOSE : PRINT : PRINT DatFile$; " not found.": PRINT : END
END IF
CLS : CLOSE
OPEN DatFile$ FOR INPUT AS #1
DO
DO
LINE INPUT #1, i$
LOOP UNTIL LEFT$(i$, 1) = "*"
n% = n% + 1
PointName$(n%) = LTRIM$(MID$(i$, 2))
INPUT #1, FSn(n%), FSe(n%), OSe(n%), OSn(n%)
LOOP UNTIL EOF(1) OR n% = 3
CLOSE
qqC = ((OSe(2) - OSe(3)) * (FSe(1) - FSe(3)) - (OSe(1) - OSe(3)) * (FSe(2) - FSe(3))) / ((FSn(3) - FSn(1)) * (FSe(2) - FSe(3)) - (FSn(3) - FSn(2)) * (FSe(1) - FSe(3)))
qqB = ((OSe(1) - OSe(3)) + qqC * (FSn(3) - FSn(1))) / (FSe(1) - FSe(3))
qqA = OSe(1) - qqB * FSe(1) - qqC * FSn(1)
qqR = ((OSn(2) - OSn(3)) * (FSe(1) - FSe(3)) - (OSn(1) - OSn(3)) * (FSe(2) - FSe(3))) / ((FSn(3) - FSn(1)) * (FSe(2) - FSe(3)) - (FSn(3) - FSn(2)) * (FSe(1) - FSe(3)))
qqQ = ((OSn(1) - OSn(3)) + qqR * (FSn(3) - FSn(1))) / (FSe(1) - FSe(3))
qqP = OSn(1) - qqQ * FSe(1) - qqR * FSn(1)
RETURN
GetParameters:
CLS
PRINT
PRINT " FS-Grid Andy Zienkiewicz 1991"
PRINT
PRINT " This program creates a file of OS coordinates representing"
PRINT " the intersections of a Flight Simulator grid. This can be"
PRINT " plotted on any OS map (or an overlay) for fast reading of"
PRINT " FS Coordinates."
PRINT
PRINT " The transformation data comes from the file "; DatFile$
PRINT " and is currently using the three points:-"
PRINT
PRINT TAB(25); PointName$(1)
PRINT TAB(25); PointName$(2)
PRINT TAB(25); PointName$(3)
PRINT
PRINT
INPUT " Enter minimum FS northing "; FSnMin
INPUT " Enter maximum FS northing "; FSnMax
PRINT
INPUT " Enter minimum FS easting "; FSeMin
INPUT " Enter maximum FS easting "; FSeMax
PRINT
DO
INPUT " Enter FS grid interval "; GridInt
LOOP UNTIL GridInt > 0
PRINT
' Round GridInt to 1,2,5 * 10^?
lg = LOG(GridInt) / LOG(10)
char = INT(lg)
mant = lg - char
IF mant < .15 THEN
mant = 0
ELSEIF mant < .5 THEN
mant = .30103
ELSEIF mant < .85 THEN
mant = .69897
ELSE
mant = 0
char = char + 1
END IF
GridInt = 10 ^ (char + mant)
' Swap mixed min & max
IF FSnMin > FSnMax THEN SWAP FSnMin, FSnMax
IF FSnMin = FSnMax THEN FSnMax = FSnMin + GridInt
IF FSeMin > FSeMax THEN SWAP FSeMin, FSeMax
IF FSeMin = FSeMax THEN FSeMax = FSeMin + GridInt
' Round out mins & maxs
FSnMin = INT(FSnMin / GridInt) * GridInt
FSnMax = INT(FSnMax / -GridInt) * -GridInt
FSeMin = INT(FSeMin / GridInt) * GridInt
FSeMax = INT(FSeMax / -GridInt) * -GridInt
CLS
PRINT
PRINT "Grid intersections will be sent to "; OutFile$; " as shown:-";
FOR y% = 0 TO 5
FOR x% = 0 TO 5
LOCATE y% * 3 + 4, x% * 7 + 25: PRINT "┼";
NEXT x%
NEXT y%
LOCATE 19, 18: PRINT USING "#####N"; FSnMin;
LOCATE 20, 20: PRINT USING "#####E"; FSeMin;
LOCATE 4, 18: PRINT USING "#####N"; FSnMax;
LOCATE 20, 55: PRINT USING "#####E"; FSeMax;
LOCATE 18, 25: PRINT CHR$(27); : PRINT USING "#### "; GridInt; : PRINT CHR$(26);
LOCATE 16, 28: PRINT CHR$(24);
LOCATE 19, 28: PRINT CHR$(25);
PRINT
LOCATE 22, 10
PRINT "Continue? (Y/N) ";
DO
i$ = UCASE$(INKEY$)
LOOP UNTIL i$ = "Y" OR i$ = "N"
IF i$ = "N" THEN PRINT : PRINT : END
RETURN
MakeIntersectionFile:
LOCATE , 1: PRINT TAB(50); : LOCATE , 1
OPEN OutFile$ FOR OUTPUT AS #1
FOR FSe = FSeMin TO FSeMax STEP GridInt
FOR FSn = FSnMin TO FSnMax STEP GridInt
GridCount% = GridCount% + 1
GOSUB ConvertFS2OS
LOCATE , 1: PRINT "Grid cross No."; GridCount%; " at ";
PRINT USING "#####N, #####E ######E, ######N"; FSn; FSe; OSe; OSn;
PRINT #1, USING "#####N, #####E ######E, ######N"; FSn; FSe; OSe; OSn
NEXT FSn
PRINT #1,
NEXT FSe
CLOSE
LOCATE , 1: PRINT TAB(70); : LOCATE , 1
PRINT "Done."
RETURN
MakeCHTFile:
' Type(2=line), Code(=0), Colour(=COLOR), Dash(0=solid)
LineHead$ = "2 0 2 0"
LOCATE , 1: PRINT TAB(50); : LOCATE , 1
OPEN OutFile$ FOR OUTPUT AS #1
' Draw S-N lines
FOR FSe = FSeMin TO FSeMax STEP GridInt
PRINT #1, LineHead$
FOR FSn = FSnMin TO FSnMax STEP GridInt
GridCount% = GridCount% + 1
GOSUB ConvertFS2OS
LOCATE , 1: PRINT "Grid cross No."; GridCount%; " at ";
PRINT USING "#####N, #####E ######E, ######N"; FSn; FSe; OSe; OSn;
PRINT #1, USING " ######.# ######.#"; OSe; OSn
NEXT FSn
PRINT #1, " 0 0"
NEXT FSe
' Draw E-W lines
FOR FSn = FSnMin TO FSnMax STEP GridInt
PRINT #1, LineHead$
FOR FSe = FSeMin TO FSeMax STEP GridInt
GridCount% = GridCount% + 1
GOSUB ConvertFS2OS
LOCATE , 1: PRINT "Grid cross No."; GridCount%; " at ";
PRINT USING "#####N, #####E ######E, ######N"; FSn; FSe; OSe; OSn;
PRINT #1, USING " ######.# ######.#"; OSe; OSn
NEXT FSe
PRINT #1, " 0 0"
NEXT FSn
CLOSE
LOCATE , 1: PRINT TAB(70); : LOCATE , 1
PRINT "Done."
RETURN
ConvertFS2OS: ' Convert OS grid to FS grid
OSe = qqA + qqB * FSe + qqC * FSn
OSn = qqP + qqQ * FSe + qqR * FSn
RETURN