File indexing completed on 2024-07-21 09:25:22

0001 ' Goode Homolosine - Interrupted for Continents

0002 ' Central longitude of map (Lambda0) = 0 Degrees

0003 '

0004 ' ===================================

0005 '

0006 '  Program Written by:

0007 '    Paul B. Anderson (804) 853-7595

0008 '    3214 Chalfin Ave.

0009 '    Norfolk, Va. 23513

0010 '

0011 ' ===================================

0012 '

0013 ' Main Map Formula From "AN ALBUM OF MAP PROJECTIONS"

0014 '                        by John P. Snyder & Philip M. Voxland, 1987.

0015 '                        (U.S. Geological Survey Professional Paper 1453)

0016 '

0017 ' Function MollweideFormula# (Used in Mollweide Iteration) is from:

0018 '                       "MAP PROJECTIONS -- A WORKING MANUAL"

0019 '                        by John P. Snyder, 1987.

0020 '                        (U.S. Geological Survey Professional Paper 1395)

0021 '

0022 ' ==============

0023 '  Declarations

0024 ' ==============

0025 '

0026 DECLARE SUB Alert ()
0027 DECLARE SUB CRTColorMenu ()
0028 DECLARE SUB DataPointsMenu ()
0029 DECLARE SUB DrawGrid ()
0030 DECLARE SUB DrawOutline ()
0031 DECLARE SUB DrawProjection (PolyLine%)
0032 DECLARE SUB FeaturesMenu ()
0033 DECLARE SUB GetMapData (FileName$)
0034 DECLARE SUB Goode (DeltaLambda#, Radius#, XCoord#, YCoord#)
0035 DECLARE SUB LatLongEntry (Title$, Note$)
0036 DECLARE SUB LatLongMenu ()
0037 DECLARE SUB LongitudeFOR (Begin#, Finish#, Incr#)
0038 DECLARE SUB MakeLatitudeLines (LatRange%, LatDetail%)
0039 DECLARE SUB MakeLongitudeLines (LatRange%, LongDetail!)
0040 DECLARE SUB PlotFileColorMenu ()
0041 DECLARE SUB ReadInfile (Byte%)
0042 DECLARE FUNCTION ArcCos# (n#)
0043 DECLARE FUNCTION ArcSin# (n#)
0044 DECLARE FUNCTION ArcTanH# (n#)
0045 DECLARE FUNCTION Atan2# (b#, a#)
0046 DECLARE FUNCTION Center% (Length%)
0047 DECLARE FUNCTION ConvertCoordToDecDeg# (coord#)
0048 DECLARE FUNCTION CoTan# (n#)
0049 DECLARE FUNCTION LN# (n#)
0050 DECLARE FUNCTION MollweideFormula# (ThetaPrime#, MPhi#)
0051 DECLARE FUNCTION Normalize# (LambdaVal#, Lambda0Val#)
0052 DECLARE FUNCTION PointCount& (PtCnt&)
0053 DECLARE FUNCTION PolyLineColor% (PolyLineHeader%)
0054 DECLARE FUNCTION Raise# (n#, Power#)
0055 DECLARE FUNCTION Round# (n#, PowerOfTen%)
0056 DECLARE FUNCTION Sec# (n#)
0057 DECLARE FUNCTION Sign# (n#)
0058 '

0059 ' ===========

0060 '  Constants

0061 ' ===========

0062 '

0063 CONST FALSE = 0
0064 CONST TRUE = NOT FALSE
0065 CONST SQRT2 = 1.414213562373095#             ' SQR(2)

0066 CONST DEG180 = 3.1415926535898#              ' PI

0067 CONST DEG90 = 1.5707963267949#               ' PI / 2

0068 CONST DEG360 = 6.2831853071796#              ' PI * 2

0069 CONST DEG45 = .7853981633974501#             ' PI / 4

0070 CONST RAD2DEG = 57.29577951308219#           ' 180 / PI

0071 CONST DEG2RAD = 1.745329251994333D-02        ' PI / 180

0072 CONST MIN2RAD = 2.908882086657222D-04        ' DEG2RAD / 60

0073 CONST MERGEPOINT = .710988432654746#         ' 40.73666 * DEG2RAD

0074 CONST TOLERANCE = .0000001# ' Tolerance value for Newton-Raphson routine

0075 CONST DTPINCR = .00001# ' Increment value for Delta Theta Prime

0076 '                          (inside Newton-Raphson routine)

0077 '

0078 ' additional Degree Values used in this projection

0079 ' Put Here to avoid repetitive calculation

0080 '

0081 CONST DEG10 = 10 * DEG2RAD
0082 CONST DEG20 = 20 * DEG2RAD
0083 CONST DEG30 = 30 * DEG2RAD
0084 CONST DEG40 = 40 * DEG2RAD
0085 CONST DEG50 = 50 * DEG2RAD
0086 CONST DEG60 = 60 * DEG2RAD
0087 CONST DEG80 = 80 * DEG2RAD
0088 CONST DEG100 = 100 * DEG2RAD
0089 CONST DEG140 = 140 * DEG2RAD
0090 CONST DEG160 = 160 * DEG2RAD
0091 
0092 CONST XCONST = .9003163161571041#            ' (8# ^ .5#) / Deg180#

0093 CONST MOLLRFACTOR = .0528#                   ' Reduction factor applied to

0094 '                                              Mollweide to match parallels

0095 '                                              of sinusoidal portion of

0096 '                                              the projection

0097 '

0098 CONST XCENTER = 320           ' VGA Center X

0099 CONST YCENTER = 240           ' VGA Center Y

0100 CONST ASPECT = 1              ' VGA mode 12 -- 640x480 aspect ratio = 1

0101 CONST CRTRADIUS = 100         ' Radius Value for CRT display

0102 CONST PLOTRADIUS = 1          ' Radius Value for Plot File

0103 CONST PLTXCENTER = 5588       ' (25.4 * 5.5#) / .025

0104 CONST PLTYCENTER = 4318       ' (25.4 * 4.25#) / .025

0105 CONST LAMBDA0 = 0             ' Central Longitude of map for Goode

0106 '                                 Homolosine Interrupted for Continental

0107 '                                 Lobes.

0108 '

0109 ' ============================

0110 ' TYPE Definition For PNT file

0111 ' ============================

0112 '

0113 TYPE PNTRecord
0114   Header AS INTEGER
0115   Lat AS INTEGER
0116   Lon AS INTEGER
0117 END TYPE
0118 '

0119 DIM SHARED PNTData AS PNTRecord
0120 '

0121 ' =========================================

0122 ' Type Definition for Global Variables (G.)

0123 ' =========================================

0124 '

0125 TYPE GlobalVariables
0126   CrtX AS DOUBLE             ' Intermediate value for X Coordinate

0127   CrtY AS DOUBLE             ' Intermediate value for Y Coordinate

0128   ModCrtX AS DOUBLE          ' Modified to be centered on CRT

0129   ModCrtY AS DOUBLE          ' Modified to be centered on CRT

0130   LastModCrtX AS DOUBLE
0131   LastModCrtY AS DOUBLE
0132   LastCrtY AS DOUBLE
0133   Lambda AS DOUBLE           ' Longitude in Radians

0134   Lambda2 AS DOUBLE          ' Central Longitude of Lobe

0135   Phi AS DOUBLE              ' Latitude in Radians

0136   Visible AS INTEGER         ' When True --> Draw PolyLine%

0137   Grid AS INTEGER            ' When True --> Draw Grid

0138   Outline AS INTEGER         ' When True --> Skip Lobe IF-Then statements

0139   MapDataLevel AS INTEGER    ' Levels 1 to 5

0140   ExtensionLobe1 AS INTEGER  ' When True --> Draw extension 1

0141   ExtensionsLobe2 AS INTEGER ' When True --> Draw extensions 2 & 3

0142   ColorVal AS INTEGER        ' CRT Color Out

0143   GridColor AS INTEGER       ' CRT Color for Grid

0144   CoastColor AS INTEGER      ' CRT Color for Coasts

0145   BorderColor AS INTEGER     ' CRT Color for Political Borders

0146   IslandColor AS INTEGER     ' CRT Color for Islands

0147   StateColor AS INTEGER      ' CRT Color U.S. State borders

0148   LakeColor AS INTEGER       ' CRT Color for Lakes

0149   RiverColor AS INTEGER      ' CRT Color for Rivers

0150   ProvinceColor AS INTEGER   ' CRT Color for Canadian Provinces

0151   AustColor AS INTEGER       ' CRT Color for Australian States

0152   MexicoColor AS INTEGER     ' CRT Color for Mexican States

0153   GridPen AS INTEGER         ' Grid color for Plot File

0154   CoastPen AS INTEGER        ' Coast color for Plot File

0155   BorderPen AS INTEGER       ' Border color for Plot File

0156   IslandPen AS INTEGER       ' Island color for Plot File

0157   StatePen AS INTEGER        ' State color for Plot File

0158   LakePen AS INTEGER         ' Lake color for Plot File

0159   RiverPen AS INTEGER        ' River color for Plot File

0160   ProvincePen AS INTEGER     ' Canadian Province color for Plot File

0161   AustPen AS INTEGER         ' Australian State color for Plot File

0162   MexicoPen AS INTEGER       ' Mexican State color for Plot File

0163   LastPlotPen AS STRING * 1  '

0164   PlotFile AS INTEGER        ' When True Plot to a File

0165   CoastSW AS INTEGER         ' When True Plot to Crt or file

0166   BorderSW AS INTEGER        ' When True Plot to Crt or file

0167   IslandSW AS INTEGER        ' When True Plot to Crt or file

0168   StateSW AS INTEGER         ' When True Plot to Crt or file

0169   LakeSW AS INTEGER          ' When True Plot to Crt or file

0170   RiverSW AS INTEGER         ' When True Plot to Crt or file

0171   ProvinceSW AS INTEGER      ' When True Plot to Crt or file

0172   AustSW AS INTEGER          ' When True Plot to Crt or file

0173   MexicoSW AS INTEGER        ' When True Plot to Crt or file

0174   LongStep AS INTEGER        ' Grid Longitude Increment

0175   LatStep AS DOUBLE          ' Grid Latitude Increment

0176   LongOption AS INTEGER      ' 1 - Longitude to pole, 2 - ends at +/-85 deg.

0177 END TYPE
0178 
0179 DIM SHARED G AS GlobalVariables
0180 '

0181 ' > variables used by GetPKDData example routines

0182 '

0183 ' for the *.PKD file format

0184 ' DIM SHARED Index AS DOUBLE

0185 ' DIM SHARED PointsInLine AS LONG

0186 ' DIM SHARED LonI AS DOUBLE

0187 ' DIM SHARED LatI AS DOUBLE

0188 ' DIM SHARED LonR AS DOUBLE

0189 ' DIM SHARED LatR AS DOUBLE

0190 ' DIM SHARED FeatureType AS INTEGER

0191 ' DIM SHARED LoopCount AS LONG

0192 ' DIM SHARED Infile$(23)

0193  
0194 '

0195 ' =========================

0196 '  Program starting values

0197 ' =========================

0198 '

0199 ' > Flags to tell the program when to draw the map inside the extensions

0200 '

0201 G.ExtensionLobe1 = FALSE
0202 G.ExtensionsLobe2 = FALSE
0203 '

0204 ' > Starting CRT colors for Geographical features

0205 '

0206 G.GridColor = 0       ' Black

0207 G.CoastColor = 0      ' Black

0208 G.BorderColor = 4     ' Red

0209 G.IslandColor = 0     ' Black

0210 G.StateColor = 4      ' Red

0211 G.LakeColor = 1       ' Blue

0212 G.RiverColor = 1      ' Blue

0213 '

0214 ' > Note: Color values for the following actually use U.S. State color

0215 '         they are not hooked into the CRT color menu

0216 '

0217 G.ProvinceColor = 4   ' Red

0218 G.AustColor = 4       ' Red

0219 G.MexicoColor = 4     ' Red

0220 '

0221 ' > Starting Plot File colors for Geographical features (Used by Corel Draw)

0222 '

0223 G.GridPen = 1         ' Black

0224 G.CoastPen = 1        ' Black

0225 G.BorderPen = 3       ' Red

0226 G.IslandPen = 1       ' Black

0227 G.StatePen = 3        ' Red

0228 G.LakePen = 2         ' Blue

0229 G.RiverPen = 2        ' Blue

0230 '

0231 ' > Note: Color values for the following actually use U.S. State color

0232 '         they are not hooked into the Pen color menu

0233 '

0234 G.ProvincePen = 3     ' Red

0235 G.AustPen = 3         ' Red

0236 G.MexicoPen = 3       ' Red

0237 '

0238 ' > Starting Geographical Features (All ON)

0239 '

0240 G.CoastSW = TRUE
0241 G.BorderSW = TRUE
0242 G.IslandSW = TRUE
0243 G.StateSW = TRUE
0244 G.LakeSW = TRUE
0245 G.RiverSW = TRUE
0246 G.ProvinceSW = TRUE
0247 G.AustSW = TRUE
0248 G.MexicoSW = TRUE
0249 '

0250 ' > Starting Latitude and longitude increment -- Traditional View

0251 '

0252 G.LongStep = 10#
0253 G.LatStep = 10#
0254 G.LongOption = 2
0255 '

0256 ' > Starting Database level

0257 '

0258 G.MapDataLevel = 3
0259 '

0260 ' > Plotting Variables, Plot Size = A

0261 '

0262 G.PlotFile = TRUE
0263 Plotpass% = 0 'WARNING:  Will not write over existing file while in program.

0264 '

0265 '                       --------------- HOWEVER -------------------

0266 '                       IF you EXIT the program and then restart it

0267 '                       It WILL write over existing Plot files!!!!!

0268 '                       -------------------------------------------

0269 '

0270 UserQuits% = FALSE  ' Don't Quit yet

0271 
0272 VIEW PRINT 1 TO 25
0273 '

0274 ' { Main Program }

0275 '

0276 DO
0277   MenuItem% = 0 ' No Menu Items Selected

0278   COLOR 7, 9
0279   CLS
0280 '

0281   LOCATE 2, 29: PRINT "======================="
0282   LOCATE 3, 30: PRINT "W O R L D   V I E W S"
0283   LOCATE 4, 29: PRINT "======================="
0284   LOCATE 6, 24: PRINT "Map Projection Library, Volume 1"
0285   LOCATE 8, 24: PRINT " 1. Draw"
0286   LOCATE 16, 30: PRINT "World Views' Options"
0287   LOCATE 18, 12: PRINT " 2. Change CRT Color of Geographical Features"
0288   LOCATE 19, 12: PRINT " 3. Turn Geographical Features On/Off "
0289   LOCATE 20, 12: PRINT " 4. Modify Latitude/Longitude Display"
0290   LOCATE 21, 12: PRINT " 5. Increase/Decrease Amount of Points to Plot"
0291   LOCATE 22, 12: PRINT " 6. Change Plot File Pen Colors of Geographical Features"
0292   LOCATE 24, 21
0293   INPUT "Select Menu Item (1-6) or 0 to Quit: ", MenuItem%
0294 '

0295   SELECT CASE MenuItem%
0296 '

0297     CASE 0
0298       UserQuits% = TRUE
0299 
0300     CASE 1
0301     ' Draw the Map

0302       Title$ = " Goode Homolosine Projection "
0303       Note$ = "Central Longitude of Map is 0 Degrees"
0304       CALL LatLongEntry(Title$, Note$)
0305 '

0306       IF G.PlotFile THEN
0307         Plotpass% = Plotpass% + 1
0308         PlotFile$ = "C:\WV\WVPLOT" + LTRIM$(STR$(Plotpass%)) + ".PLT"
0309         OPEN PlotFile$ FOR OUTPUT AS #1
0310         PRINT #1, "IN; IP0,0,11176,8636; SP0;"
0311         PRINT #1, "SC-5498,5498,-4249,4249;"
0312         PRINT #1, "VS4; PT 0.1; SP1;"
0313         G.LastPlotPen = "1"
0314       END IF
0315 
0316       SCREEN 12 ' Switch to VGA 480/640, 16 COLOR mode

0317       VIEW (0, 0)-(639, 479), 7
0318 '

0319       COLOR 10
0320       Col% = Center%(LEN(Title$))
0321       LOCATE 1, Col%: PRINT Title$;
0322 
0323       CALL DrawOutline
0324  
0325 '     CALL GetPKDData

0326  
0327       IF G.Grid THEN CALL DrawGrid
0328       IF G.CoastSW THEN CALL GetMapData("PCoast.pnt")
0329       IF G.IslandSW THEN CALL GetMapData("PIsland.pnt")
0330       IF G.LakeSW THEN CALL GetMapData("Plake.pnt")
0331       IF G.RiverSW THEN CALL GetMapData("River.pnt")
0332       IF G.BorderSW THEN CALL GetMapData("PBorder.pnt")
0333       IF G.StateSW THEN CALL GetMapData("PUSA48.pnt")
0334       IF G.ProvinceSW THEN CALL GetMapData("PCanProv.pnt")
0335       IF G.AustSW THEN CALL GetMapData("PAust.pnt")
0336       IF G.MexicoSW THEN CALL GetMapData("PMexico.pnt")
0337 
0338       G.ExtensionLobe1 = TRUE
0339       IF G.CoastSW THEN CALL GetMapData("PCoast.pnt")
0340       IF G.IslandSW THEN CALL GetMapData("PIsland.pnt")
0341 
0342       G.ExtensionLobe1 = FALSE
0343       G.ExtensionsLobe2 = TRUE
0344  
0345       IF G.CoastSW THEN CALL GetMapData("PCoast.pnt")
0346       IF G.IslandSW THEN CALL GetMapData("PIsland.pnt")
0347  
0348       G.ExtensionsLobe2 = FALSE
0349  
0350       IF G.PlotFile THEN
0351         PRINT #1, "PU 0,0; SP00;"
0352         CLOSE #1
0353       END IF
0354 
0355       CALL Alert ' BEEP

0356  
0357       COLOR 12
0358       LOCATE 1, Col%: PRINT Title$;
0359     
0360       DO
0361         Brk$ = INKEY$
0362       LOOP UNTIL Brk$ > ""
0363    
0364       SCREEN 0  'Switch back to Text mode

0365       VIEW PRINT 1 TO 25
0366    
0367     CASE 2
0368     ' Change Line Color of Geographical features

0369       CALL CRTColorMenu
0370         
0371     CASE 3
0372     ' Turn Geographical features OFF or ON

0373       CALL FeaturesMenu
0374 '

0375     CASE 4
0376     ' Change Latitude and Longitude Values

0377       CALL LatLongMenu
0378 '

0379     CASE 5
0380     ' Change the Amount of Database Latitude and Longitude Values to plot

0381       CALL DataPointsMenu
0382 '

0383     CASE 6
0384     ' Change the Line color of the Geographical features sent to the plot file

0385       CALL PlotFileColorMenu
0386 '

0387     CASE ELSE
0388       PRINT CHR$(7);
0389 
0390   END SELECT '{ MenuItem. }

0391 '

0392 LOOP UNTIL UserQuits%
0393 '

0394 END
0395 
0396 SUB Alert
0397 ' { Sounds a tone when map is complete. }

0398 
0399   SOUND 880, 36.4
0400 
0401 END SUB ' { Alert. }

0402 
0403 FUNCTION ArcCos# (n#) STATIC
0404 '

0405 IF n# <> 0 THEN
0406   ArcCos# = ATN(Raise#(1 - (n# * n#), .5) / n#) + DEG180 * (n# - ABS(n#)) / (2 * n#)
0407 ELSE
0408   n# = 0
0409 END IF
0410 '

0411 END FUNCTION '{ ArcCos#. }

0412 
0413 FUNCTION ArcSin# (n#) STATIC
0414 '

0415   IF ABS(n#) < 1 THEN
0416     ArcSin# = ATN(n# / Raise#(1 - (n# * n#), .5))
0417     EXIT FUNCTION
0418   END IF
0419 
0420   IF n# = 1 THEN
0421     ArcSin# = DEG90
0422     EXIT FUNCTION
0423   END IF
0424 
0425   IF n# = -1 THEN
0426     ArcSin# = -DEG90
0427   END IF
0428 '

0429 END FUNCTION ' { ArcSin#. }

0430 
0431 FUNCTION ArcTanH# (n#) STATIC
0432 '

0433     AT1# = ABS(n#)
0434 '

0435     IF AT1# < 1 THEN
0436       AT2# = .5 * LN#((1 + AT1#) / (1 - AT1#))
0437       ArcTanH# = AT2# * Sign#(n#)
0438     END IF
0439 '

0440 END FUNCTION ' { ArcTanH#.}

0441 
0442 FUNCTION Atan2# (b#, a#)
0443 '

0444 IF a# = 0 THEN
0445   IF b# > 0 THEN
0446     Atan2# = DEG90
0447   ELSEIF b# < 0 THEN
0448     Atan2# = -DEG90
0449   ELSE
0450     Atan2# = 0
0451   END IF
0452 '

0453 ELSEIF b# = 0 THEN
0454   IF a# < 0 THEN
0455     Atan2# = DEG180
0456   ELSE
0457     Atan2# = 0
0458   END IF
0459 '

0460 ELSE
0461   IF a# < 0 THEN
0462     IF b# > 0 THEN
0463       Atan2# = ATN(b# / a#) + DEG180
0464     ELSE
0465       Atan2# = ATN(b# / a#) - DEG180
0466     END IF
0467 '

0468   ELSE
0469     Atan2# = ATN(b# / a#)
0470   END IF
0471 END IF
0472 '

0473 END FUNCTION '{ ATan2#. }

0474 
0475 FUNCTION Center% (Length%)
0476 '

0477     IF Length% MOD 2 = 0 THEN
0478       Column% = 40 - (Length% \ 2)
0479     ELSE
0480       Column% = (40 - (Length% \ 2)) + 1
0481     END IF
0482 '

0483     Center% = Column%
0484 '

0485 END FUNCTION '{ Center$. }

0486 
0487 FUNCTION ConvertCoordToDecDeg# (coord#)
0488 ' Used by GetPKDData subroutine

0489 '

0490   ConvertCoordToDecDeg# = coord# / 3600
0491 '

0492 END FUNCTION '{ ConvertCoordToDecDeg#. }

0493 
0494 FUNCTION CoTan# (n#)
0495 '

0496   Sine# = SIN(n#)
0497   IF ABS(Sine#) <= .0001 THEN
0498     PRINT "Error: CoTan#(n#) Where n# <= 0"
0499     SYSTEM
0500   ELSE
0501     CoTan# = COS(n#) / Sine#
0502   END IF
0503 '

0504 END FUNCTION '{ CoTan#. }

0505 
0506 SUB CRTColorMenu
0507 '

0508 ExitMenu% = FALSE
0509 '

0510 DO
0511   CLS
0512   LOCATE 2, 18: PRINT "** Change CRT Color of Geographical Features **"
0513   LOCATE 4, 36: PRINT "Color Codes"
0514   LOCATE 5, 22: PRINT "0 - Black"
0515   LOCATE 6, 22: PRINT "1 - Blue    6 - Brown      11 - Lt. Cyan "
0516   LOCATE 7, 22: PRINT "2 - Green   7 - White      12 - Lt. Red  "
0517   LOCATE 8, 22: PRINT "3 - Cyan    8 - Dk. Grey   13 - Lt. Magenta"
0518   LOCATE 9, 22: PRINT "4 - Red     9 - Lt. Blue   14 - Yellow"
0519   LOCATE 10, 22: PRINT "5 - Magenta 10 - Lt. Green 15 - Br. White"
0520   LOCATE 12, 28: PRINT "1. Grid Color is:"; G.GridColor
0521   LOCATE 13, 28: PRINT "2. Coast Color is:"; G.CoastColor
0522   LOCATE 14, 28: PRINT "3. Border Color is:"; G.BorderColor
0523   LOCATE 15, 28: PRINT "4. Island Color is:"; G.IslandColor
0524   LOCATE 16, 28: PRINT "5. State Border Color is:"; G.StateColor
0525   LOCATE 17, 28: PRINT "6. Lake Color is:"; G.LakeColor
0526   LOCATE 18, 28: PRINT "7. River Color is:"; G.RiverColor
0527   LOCATE 20, 14
0528   INPUT "Select Option (1-7) or 0 to Return to Main Menu: ", Menu%
0529      
0530   SELECT CASE Menu%
0531 '

0532     CASE 0
0533       ExitMenu% = TRUE
0534 '

0535     CASE 1
0536       LOCATE 20, 1: PRINT SPACE$(80)
0537       LOCATE 20, 14
0538       INPUT "Change Grid Color to (0-15):", NewColor%
0539 '

0540       IF NewColor% >= 0 AND NewColor% < 16 THEN
0541         G.GridColor = NewColor%
0542       ELSE
0543         PRINT CHR$(7)
0544       END IF
0545 '

0546     CASE 2
0547       LOCATE 20, 1: PRINT SPACE$(80)
0548       LOCATE 20, 14
0549       INPUT "Change Coastline Color to (0-15):", NewColor%
0550 '

0551       IF NewColor% >= 0 AND NewColor% < 16 THEN
0552         G.CoastColor = NewColor%
0553       ELSE
0554         PRINT CHR$(7)
0555       END IF
0556 '

0557     CASE 3
0558       LOCATE 20, 1: PRINT SPACE$(80)
0559       LOCATE 20, 14
0560       INPUT "Change Border Color to (0-15):", NewColor%
0561 '

0562       IF NewColor% >= 0 AND NewColor% < 16 THEN
0563         G.BorderColor = NewColor%
0564       ELSE
0565         PRINT CHR$(7)
0566       END IF
0567 '

0568     CASE 4
0569       LOCATE 20, 1: PRINT SPACE$(80)
0570       LOCATE 20, 14
0571       INPUT "Change Island Color to (0-15):", NewColor%
0572 '

0573       IF NewColor% >= 0 AND NewColor% < 16 THEN
0574         G.IslandColor = NewColor%
0575       ELSE
0576         PRINT CHR$(7)
0577       END IF
0578 '

0579     CASE 5
0580       LOCATE 20, 1: PRINT SPACE$(80)
0581       LOCATE 20, 14
0582       INPUT "Change State Border Color to (0-15):", NewColor%
0583 '

0584       IF NewColor% >= 0 AND NewColor% < 16 THEN
0585         G.StateColor = NewColor%
0586       ELSE
0587         PRINT CHR$(7)
0588       END IF
0589 '

0590     CASE 6
0591       LOCATE 20, 1: PRINT SPACE$(80)
0592       LOCATE 20, 14
0593       INPUT "Change Lake Color to (0-15):", NewColor%
0594 '

0595       IF NewColor% >= 0 AND NewColor% < 16 THEN
0596         G.LakeColor = NewColor%
0597       ELSE
0598         PRINT CHR$(7)
0599       END IF
0600 '

0601     CASE 7
0602       LOCATE 20, 1: PRINT SPACE$(80)
0603       LOCATE 20, 14
0604       INPUT "Change River Color to (0-15):", NewColor%
0605 '

0606       IF NewColor% >= 0 AND NewColor% < 16 THEN
0607         G.RiverColor = NewColor%
0608       ELSE
0609         PRINT CHR$(7)
0610       END IF
0611 '

0612     CASE ELSE
0613       PRINT CHR$(7)
0614 '

0615     END SELECT '{ Menu. }

0616 '

0617   LOOP UNTIL ExitMenu%
0618 '

0619 END SUB ' { CRTColor. }

0620 
0621 SUB DataPointsMenu
0622 '

0623 ExitMenu% = FALSE
0624 '

0625 DO
0626   CLS
0627 '

0628   LOCATE 2, 16: PRINT "** Increase/Decrease Amount of Points to Plot **"
0629   LOCATE 4, 27: PRINT "Current Database Level is"; G.MapDataLevel
0630   LOCATE 6, 25: PRINT "1. 179,331 X-Y Coordinate Pairs"
0631   LOCATE 7, 25: PRINT "2. 109,992 X-Y Coordinate Pairs"
0632   LOCATE 8, 25: PRINT "3. 27,393 X-Y Coordinate Pairs"
0633   LOCATE 9, 25: PRINT "4. 14,867 X-Y Coordinate Pairs"
0634   LOCATE 10, 25: PRINT "5. 5,365 X-Y Coordinate Pairs"
0635   LOCATE 12, 18
0636   PRINT "Select Option (1-5) to Change Database Level"
0637   LOCATE 13, 18
0638   INPUT "    or 0 to Return to Previous Menu: ", Menu%
0639 ' 

0640   SELECT CASE Menu%
0641 '   

0642     CASE 0
0643       ExitMenu% = TRUE
0644 '

0645     CASE 1 TO 5
0646       G.MapDataLevel = Menu%
0647 '   

0648     CASE ELSE
0649       PRINT CHR$(7)
0650 '

0651   END SELECT '{ Menu. }

0652 '

0653   LOOP UNTIL ExitMenu%
0654 '

0655 END SUB '{ DataPointsMenu. }

0656 
0657 SUB DrawGrid
0658 '

0659   G.LastModCrtX = 0
0660   G.LastModCrtY = 0
0661   G.ColorVal = G.GridColor
0662 
0663   LatRange% = 90     '

0664   LatDetail% = 5     ' Since Latitude Lines are straight no need to change

0665   LongDetail! = .25  ' For Faster Screen Draws this variable can be increased

0666   '                    For "Publication" Quality vector Graphics try .1#

0667   '                    (slows screen draws and large increase

0668   '                    in plot file size)

0669 '

0670 '

0671 ' > If G.LongOption is 1 - All Longitude lines converge at pole

0672 '   If G.LongOption is 2 - Only draw longitude lines to within 5 Degrees

0673 '                          of the pole (Default value)

0674 '

0675   SELECT CASE G.LongOption
0676 
0677     CASE IS = 1
0678       LatStop% = 90
0679 '

0680     CASE IS = 2
0681       LatStop% = 85
0682 ' 

0683   END SELECT '{ G.LongOption. }

0684 '

0685   CALL MakeLongitudeLines(LatStop%, LongDetail!)
0686   CALL MakeLatitudeLines(LatRange%, LatDetail%)
0687 '

0688 END SUB '{ DrawGrid. }

0689 
0690 SUB DrawOutline STATIC
0691 '

0692   G.Outline = TRUE
0693   G.ColorVal = G.GridColor
0694   G.LastModCrtX = 0
0695  
0696   PolyLine% = TRUE
0697   Increment# = DEG2RAD / 4
0698    
0699   G.Lambda = -DEG180
0700   G.Lambda2 = -DEG160
0701   CALL LongitudeFOR(-DEG90, 0, Increment#)
0702   G.Lambda2 = -DEG100
0703   CALL LongitudeFOR(0, DEG90, Increment#)
0704 '

0705 ' ==================

0706 ' Insert 1 Longitude

0707 ' ==================

0708 '

0709   G.Lambda = -DEG10
0710   G.Lambda2 = -DEG100
0711   CALL LongitudeFOR(DEG90, DEG60, -Increment#)
0712 '

0713 ' =================================

0714 ' Insert 1 Latitude (Bottom Border)

0715 ' =================================

0716 '

0717   G.Phi = DEG60
0718   G.Lambda2 = -DEG100
0719   G.Lambda = -DEG10
0720 '

0721   DO
0722     CALL DrawProjection(PolyLine%)
0723     G.Lambda = G.Lambda - Increment#
0724     IF G.Lambda < -DEG40 THEN EXIT DO
0725   LOOP
0726 '

0727 ' =================================

0728 '

0729 ' =================================

0730 '

0731   G.Lambda = -DEG40
0732   G.Lambda2 = -DEG100
0733   CALL LongitudeFOR(DEG60, 0, -Increment#)
0734   G.Lambda2 = DEG30
0735   CALL LongitudeFOR(0, DEG60, Increment#)
0736 '

0737 ' =================================

0738 ' Insert 2 Latitude (Bottom Border)

0739 ' =================================

0740 '

0741   G.Phi = DEG60
0742   G.Lambda2 = DEG30
0743   G.Lambda = -DEG40
0744 
0745   DO
0746     CALL DrawProjection(PolyLine%)
0747     G.Lambda = G.Lambda - Increment#
0748     IF G.Lambda < -DEG50 THEN EXIT DO
0749   LOOP
0750 '

0751 ' ==================

0752 ' Insert 2 Longitude

0753 ' ==================

0754 '

0755   G.Lambda = -DEG50
0756   G.Lambda2 = DEG30
0757   CALL LongitudeFOR(DEG60, DEG90, Increment#)
0758 '

0759 ' ==================

0760 ' Insert 3 Longitude

0761 ' ==================

0762 '

0763   G.Lambda = -DEG160
0764   G.Lambda2 = DEG30
0765   CALL LongitudeFOR(DEG90, DEG50, -Increment#)
0766 '

0767 ' =================================

0768 ' Insert 3 Latitude (Bottom Border)

0769 ' =================================

0770 '

0771   G.Phi = DEG50
0772   G.Lambda2 = DEG30
0773   G.Lambda = -DEG160
0774 
0775   DO
0776     CALL DrawProjection(PolyLine%)
0777     G.Lambda = G.Lambda - Increment#
0778     IF G.Lambda < -DEG180 THEN EXIT DO
0779   LOOP
0780 
0781 ' ==================

0782 '

0783 ' ==================

0784 '

0785   G.Lambda = DEG180
0786   G.Lambda2 = DEG30
0787   CALL LongitudeFOR(DEG50, 0, -Increment#)
0788   G.Lambda2 = DEG140
0789   CALL LongitudeFOR(0, -DEG90, -Increment#)
0790 
0791   G.Lambda = DEG80
0792   G.Lambda2 = DEG140
0793   CALL LongitudeFOR(-DEG90, 0, Increment#)
0794   G.Lambda2 = DEG20
0795   CALL LongitudeFOR(0, -DEG90, -Increment#)
0796 
0797   G.Lambda = -DEG20
0798   G.Lambda2 = DEG20
0799   CALL LongitudeFOR(-DEG90, 0, Increment#)
0800   G.Lambda2 = -DEG60
0801   CALL LongitudeFOR(0, -DEG90, -Increment#)
0802  
0803   G.Lambda = -DEG100
0804   G.Lambda2 = -DEG60
0805   CALL LongitudeFOR(-DEG90, 0, Increment#)
0806   G.Lambda2 = -DEG160
0807   CALL LongitudeFOR(0, -DEG90, -Increment#)
0808    
0809   PolyLine% = FALSE
0810   CALL DrawProjection(PolyLine%)
0811  
0812   G.Outline = FALSE '*

0813 '

0814 END SUB '{ DrawOutline. }

0815 
0816 SUB DrawProjection (PolyLine%) STATIC
0817 '

0818 IF G.ExtensionLobe1 THEN
0819   G.Outline = FALSE
0820   LongDeg# = CSNG(G.Lambda * RAD2DEG)
0821  
0822   IF LongDeg# >= -40 AND LongDeg# <= -10 THEN
0823     IF CSNG(G.Phi * RAD2DEG) >= 60 THEN
0824       G.Lambda2 = -DEG100
0825       G.Outline = TRUE
0826     END IF
0827   END IF
0828 
0829   IF LongDeg# >= -180 AND LongDeg# <= -160 THEN
0830     IF CSNG(G.Phi * RAD2DEG) >= 50 THEN
0831       G.Lambda2 = DEG30
0832       G.Outline = TRUE
0833     END IF
0834   END IF
0835   IF G.Outline = FALSE THEN EXIT SUB
0836 END IF
0837 
0838 IF G.ExtensionsLobe2 THEN
0839   G.Outline = FALSE
0840   LongDeg# = CSNG(G.Lambda * RAD2DEG)
0841   IF LongDeg# >= -50 AND LongDeg# <= -40 THEN
0842     IF CSNG(G.Phi * RAD2DEG) >= 60 THEN
0843       G.Lambda2 = DEG30
0844       G.Outline = TRUE
0845     END IF
0846   END IF
0847   IF G.Outline = FALSE THEN EXIT SUB
0848 END IF
0849        
0850 CALL Goode(G.Lambda, CRTRADIUS, G.CrtX, G.CrtY)
0851        
0852 IF G.PlotFile THEN
0853   CALL Goode(G.Lambda, PLOTRADIUS, PlotX#, PlotY#)
0854   PlotX# = ((25.4# * PlotX#) / .025#) '+ PltXCenter#

0855   PlotY# = ((25.4# * PlotY#) / .025#) '+ PltYCenter#

0856 END IF
0857 '

0858 G.ModCrtX = FIX((G.CrtX * ASPECT) + XCENTER)
0859 G.ModCrtY = CINT(YCENTER) - FIX(G.CrtY)
0860 '

0861 IF PolyLine% = FALSE THEN G.Visible = FALSE
0862 '

0863 ' > This statement eliminates the stray lines going from top to bottom

0864 ' > for the Transverse Mercator and Cassini Projections

0865 '

0866 IF ABS(G.ModCrtY - G.LastModCrtY) > 120 THEN G.Visible = FALSE
0867 '

0868 ' > This statement eliminates the stray lines for the Azimuthal Projections

0869 '

0870 IF ABS(G.LastModCrtX - G.ModCrtX) > 120 THEN G.Visible = FALSE
0871        
0872 IF G.LastModCrtX < -2000 OR G.ModCrtX < -2000 THEN G.Visible = FALSE
0873         
0874 IF G.Visible THEN
0875   Y2# = (G.ModCrtY - G.LastModCrtY) * (G.ModCrtY - G.LastModCrtY)
0876   X2# = (G.ModCrtX - G.LastModCrtX) * (G.ModCrtX - G.LastModCrtX)
0877   Distance# = Raise#(X2# + Y2#, .5)
0878   IF ABS(Distance#) > 20 THEN
0879     G.Visible = FALSE
0880   END IF
0881 END IF
0882         
0883 IF G.PlotFile THEN
0884   IF G.Visible THEN
0885     PRINT #1, "PD"; STR$(CINT(PlotX#)); ","; STR$(CINT(PlotY#)); ";"
0886   ELSE
0887     PRINT #1, "PU"; STR$(CINT(PlotX#)); ","; STR$(CINT(PlotY#)); ";"
0888   END IF
0889 END IF
0890        
0891 IF G.Visible THEN
0892   LINE (G.LastModCrtX, G.LastModCrtY)-(G.ModCrtX, G.ModCrtY), G.ColorVal
0893 END IF
0894 
0895 G.Visible = TRUE
0896 G.LastModCrtX = G.ModCrtX
0897 G.LastModCrtY = G.ModCrtY
0898 '

0899 END SUB ' { DrawProjection. }

0900 
0901 SUB FeaturesMenu
0902 '

0903 ExitMenu% = FALSE
0904 '

0905 DO
0906   CLS
0907 '

0908   LOCATE 2, 19
0909   PRINT "** Turn Geographical Features On or Off **"
0910 '   

0911   LOCATE 5, 22: PRINT "1. Coastlines are";
0912   IF G.CoastSW THEN
0913     PRINT " On "
0914   ELSE
0915     PRINT " Off"
0916   END IF
0917 '   

0918   LOCATE 6, 22: PRINT "2. Islands are";
0919   IF G.IslandSW THEN
0920     PRINT " On "
0921   ELSE
0922     PRINT " Off"
0923   END IF
0924 '   

0925   LOCATE 7, 22: PRINT "3. Lakes are";
0926   IF G.LakeSW THEN
0927     PRINT " On "
0928   ELSE
0929     PRINT " Off"
0930   END IF
0931 '   

0932   LOCATE 8, 22: PRINT "4. Rivers are";
0933   IF G.RiverSW THEN
0934     PRINT " On "
0935   ELSE
0936     PRINT " Off"
0937   END IF
0938 '   

0939   LOCATE 9, 22: PRINT "5. Country Borders are";
0940   IF G.BorderSW THEN
0941     PRINT " On "
0942   ELSE
0943     PRINT " Off"
0944   END IF
0945 '  

0946   LOCATE 10, 22: PRINT "6. U.S. State Borders are";
0947   IF G.StateSW THEN
0948     PRINT " On "
0949   ELSE
0950     PRINT " Off"
0951   END IF
0952 '   

0953   LOCATE 11, 22: PRINT "7. Canadian Province Borders are";
0954   IF G.ProvinceSW THEN
0955     PRINT " On "
0956   ELSE
0957     PRINT " Off"
0958   END IF
0959 ' 

0960   LOCATE 12, 22: PRINT "8. Austrailian State Borders are";
0961   IF G.AustSW THEN
0962     PRINT " On "
0963   ELSE
0964     PRINT " Off"
0965   END IF
0966 '   

0967   LOCATE 13, 22: PRINT "9. Mexican State Borders are";
0968   IF G.AustSW THEN
0969     PRINT " On "
0970   ELSE
0971     PRINT " Off"
0972   END IF
0973 '

0974   LOCATE 16, 23: PRINT "Select Option (1-9) to toggle Feature"
0975 '

0976   LOCATE 17, 37: PRINT "- Or -"
0977 '

0978   LOCATE 18, 24: INPUT "0 to Return to Previous Menu: ", Menu%
0979 '   

0980   SELECT CASE Menu%
0981 '     

0982     CASE 0
0983       ExitMenu% = TRUE
0984 '

0985     CASE 1
0986       IF G.CoastSW THEN
0987         G.CoastSW = FALSE
0988       ELSE
0989         G.CoastSW = TRUE
0990       END IF
0991 '

0992     CASE 2
0993       IF G.IslandSW THEN
0994         G.IslandSW = FALSE
0995       ELSE
0996         G.IslandSW = TRUE
0997       END IF
0998 '

0999     CASE 3
1000       IF G.LakeSW THEN
1001         G.LakeSW = FALSE
1002       ELSE
1003         G.LakeSW = TRUE
1004       END IF
1005 '   

1006     CASE 4
1007       IF G.RiverSW THEN
1008         G.RiverSW = FALSE
1009       ELSE
1010         G.RiverSW = TRUE
1011       END IF
1012 '   

1013     CASE 5
1014       IF G.BorderSW THEN
1015         G.BorderSW = FALSE
1016       ELSE
1017         G.BorderSW = TRUE
1018       END IF
1019 '  

1020     CASE 6
1021       IF G.StateSW THEN
1022         G.StateSW = FALSE
1023       ELSE
1024         G.StateSW = TRUE
1025       END IF
1026 '

1027     CASE 7
1028       IF G.ProvinceSW THEN
1029         G.ProvinceSW = FALSE
1030       ELSE
1031         G.ProvinceSW = TRUE
1032       END IF
1033 '     

1034     CASE 8
1035       IF G.AustSW THEN
1036         G.AustSW = FALSE
1037       ELSE
1038         G.AustSW = TRUE
1039       END IF
1040 '   

1041     CASE 9
1042       IF G.MexicoSW THEN
1043         G.MexicoSW = FALSE
1044       ELSE
1045         G.MexicoSW = TRUE
1046       END IF
1047 '

1048     CASE ELSE
1049       PRINT CHR$(7)
1050 '

1051   END SELECT '{ Menu. }

1052 '

1053   LOOP UNTIL ExitMenu%
1054 '

1055 END SUB '{ FeaturesMenu. }

1056 
1057 SUB GetFullCoords (LonI#, LatI#)
1058 ' Used by GetPKDData subroutine

1059 '

1060 STATIC Temp#
1061 STATIC Temp2#
1062 '

1063 ' Longitude Degree1

1064 CALL ReadInfile(Byte%)
1065 Temp# = Byte%
1066 Temp# = Temp# * 7200!
1067 '

1068 ' Longitude Degree2

1069 CALL ReadInfile(Byte%)
1070 Temp2# = Byte%
1071 Temp# = Temp# + (Temp2# * 3600!)
1072 '

1073 ' Longitude Minutes

1074 CALL ReadInfile(Byte%)
1075 Temp2# = Byte%
1076 Temp# = Temp# + (Temp2# * 60!)
1077 '

1078 ' Longitude Seconds

1079 CALL ReadInfile(Byte%)
1080 Temp2# = Byte%
1081 Temp# = Temp# + Temp2#
1082 LonI# = Temp#
1083 '

1084 ' Latitude Degrees

1085 Temp# = 0
1086 Temp2# = 0
1087 CALL ReadInfile(Byte%)
1088 Temp# = Byte%
1089 Temp# = Temp# * 3600!
1090 '

1091 ' Latitude Minutes

1092 CALL ReadInfile(Byte%)
1093 Temp2# = Byte%
1094 Temp# = Temp# + (Temp2# * 60!)
1095 '

1096 ' Latitude Seconds

1097 CALL ReadInfile(Byte%)
1098 Temp2# = Byte%
1099 Temp# = Temp# + Temp2#
1100 LatI# = Temp#
1101 '

1102 END SUB '{ GetFullCoords. }

1103 
1104 SUB GetMapData (FileName$) STATIC
1105 '

1106 G.Visible = FALSE
1107 G.LastModCrtX = 0
1108 
1109 OPEN "C:\WORK\" + FileName$ FOR RANDOM AS #2 LEN = LEN(PNTData)

1110 

1111 TotalRecords& = LOF(2) / LEN(PNTData)

1112 

1113 FOR RecordCounter& = 1 TO TotalRecords&

1114 

1115   GET #2, RecordCounter&, PNTData

1116 

1117   IF PNTData.Header >= G.MapDataLevel THEN

1118  

1119     IF PNTData.Header > 5 THEN

1120       G.ColorVal = PolyLineColor%(PNTData.Header)

1121       PolyLine% = FALSE

1122     ELSE

1123       PolyLine% = TRUE

1124     END IF

1125 

1126     G.Phi = PNTData.Lat * MIN2RAD

1127     G.Lambda = PNTData.Lon * MIN2RAD

1128    

1129     CALL DrawProjection(PolyLine%)

1130  

1131   END IF

1132 

1133 NEXT RecordCounter&

1134 

1135 CLOSE #2

1136 

1137 END SUB '{ GetMapData. }

1138 

1139 SUB GetMP1Data

1140 ' This module contains both the GetMP1Data and ParseWord Subroutines.

1141 ' They are not hooked into the program, but are provided in case the user

1142 ' wishes to install them and create his or her own coordinate database.

1143 '

1144 ' An *.MP1 file is nothing more than an ASCII file that can be

1145 ' created with a Text editor containing  Latitude in Decimal Degrees

1146 ' then Longitude in Decimal Degrees separated by a comma or a space.

1147 ' Comments can also be included on each line as long as they are set

1148 ' off by an apostrophe (') and are at the end of the line.

1149 '

1150 ' The first set of coordinates in the file are understood to be the beginning

1151 ' of the first PolyLine%. A new PolyLine% is indicated by a blank line at the

1152 ' beginning of the series of coordinates making up the new line.

1153 '

1154 ' OPEN "C:EXAMPLE.PRN" FOR INPUT AS #1

1155 '

1156 '    G.Visible = False

1157 '    G.LastModCRTX = 0

1158 '    SEEK #1, 1

1159 '

1160 '   WHILE NOT EOF(1)

1161 '

1162 '     LINE INPUT #1, MP1Rec$

1163 '

1164 '     CALL ParseWord(MP1Rec$, TLat$)

1165 '     LatR = VAL(TLat$) * Deg2Rad

1166 '

1167 '     CALL ParseWord(MP1Rec$, TLong$)

1168 '     LongR = VAL(TLong$) * Deg2Rad

1169 '

1170 '     IF VAL(TLong$) = 0 AND VAL(TLat$) = 0 THEN

1171 '       PolyLine% = False

1172 '       LINE INPUT #1, MP1Rec$

1173 '

1174 '       CALL ParseWord(MP1Rec$, TLat$)

1175 '       LatR = VAL(TLat$) * Deg2Rad

1176 '

1177 '       CALL ParseWord(MP1Rec$, TLong$)

1178 '       LongR = VAL(TLong$) * Deg2Rad

1179 '

1180 '     ELSE

1181 '       PolyLine% = True

1182 '     END IF

1183 '     CALL DrawProjection(PolyLine%)

1184 

1185 '   WEND

1186 '

1187 'END SUB '{ GetMP1Data. }

1188 '

1189 ' SUB ParseWord (PointLine$, Coord$) STATIC

1190 ' Subroutine to Parse text for *.MP1 Format

1191 '

1192 '   Sep$ = " ,"

1193 '   Coord$ = ""

1194 '   PointLine$ = RTRIM$(LTRIM$(PointLine$))

1195 '   LenPointLine% = LEN(PointLine$)

1196 '   IF PointLine$ = "" OR PointLine$ = "'" THEN

1197 '     EXIT SUB

1198 '   END IF

1199 '   FOR Cnt1% = 1 TO LenPointLine%

1200 '     IF INSTR(Sep$, MID$(PointLine$, Cnt1%, 1)) = 0 THEN

1201 '       EXIT FOR

1202 '     END IF

1203 '   NEXT Cnt1%

1204 '   FOR Cnt2% = Cnt1% TO LenPointLine%

1205 '     IF INSTR(Sep$, MID$(PointLine$, Cnt2%, 1)) THEN ' = 0

1206 '       EXIT FOR

1207 '     END IF

1208 '   NEXT Cnt2%

1209 '   FOR Cnt3% = Cnt2% TO LenPointLine%

1210 '     IF INSTR(Sep$, MID$(PointLine$, Cnt3%, 1)) = 0 THEN

1211 '       EXIT FOR

1212 '     END IF

1213 '   NEXT Cnt3%

1214 '   IF Cnt1% > LenPointLine% THEN

1215 '     PointLine$ = ""

1216 '     EXIT SUB

1217 '   END IF

1218 '   IF Cnt2% > LenPointLine% THEN

1219 '     Coord$ = MID$(PointLine$, Cnt1%)

1220 '     PointLine$ = ""

1221 '     EXIT SUB

1222 '   END IF

1223 '     Coord$ = MID$(PointLine$, Cnt1%, Cnt2% - Cnt1%)

1224 '     IF Cnt3% > LenPointLine% THEN

1225 '       PointLine$ = ""

1226 '     ELSE

1227 '       PointLine$ = MID$(PointLine$, Cnt3%)

1228 '     END IF

1229 '

1230 ' END SUB ' { ParseWord. }

1231 END SUB '{ GetMP1Data. }

1232 
1233 SUB GetNextCoords (LonI AS DOUBLE, LatI AS DOUBLE)
1234 ' Used by GetPKDData subroutine

1235 '

1236 'Extract Longitude Delta

1237 CALL ReadInfile(Byte%)
1238 LonI = LonI + Byte%
1239 '

1240 'Extract Latitude Delta

1241 CALL ReadInfile(Byte%)
1242 LatI = LatI + Byte%
1243 '

1244 END SUB '{GetNextCoords}

1245 
1246 SUB GetPKDData
1247 
1248 ' extracts data from *.PKD files

1249 ' This uses the South America Database Only

1250 
1251 ' G.Visible = False

1252 ' PreviousScreenX# = 0#

1253 
1254 ' Infile$(1) = "SAC1.PKD"

1255 ' Infile$(2) = "SAC2.PKD"

1256 ' Infile$(3) = "SAC3.PKD"

1257 ' Infile$(4) = "SAC4.PKD"

1258 ' Infile$(5) = "SAC7.PKD"

1259 ' Infile$(6) = "SAC8.PKD"

1260 ' Infile$(7) = "SAC9.PKD"

1261 ' Infile$(8) = "SAC13.PKD"

1262 ' Infile$(9) = "SAC14.PKD"

1263 ' Infile$(10) = "SAC10.PKD"

1264 ' Infile$(11) = "SAB01.PKD"

1265 ' Infile$(12) = "SAB2.PKD"

1266 ' Infile$(13) = "SAB3.PKD"

1267 ' Infile$(14) = "SAR1.PKD"

1268 ' Infile$(15) = "SAR2.PKD"

1269 ' Infile$(16) = "SAR3.PKD"

1270 ' Infile$(17) = "SAR4.PKD"

1271 ' Infile$(18) = "SAR5.PKD"

1272 ' Infile$(19) = "SAR06.PKD"

1273 ' Infile$(20) = "SAR7.PKD"

1274 ' Infile$(21) = "SAR8.PKD"

1275 ' Infile$(22) = "SAR10.PKD"

1276 
1277 ' FOR Infil% = 1 TO 22

1278 ' OPEN "C:\SA\" + Infile$(Infil%) FOR BINARY AS #1

1279 '

1280 ' DO

1281 ' CALL ReadInfile(FeatureType)

1282 
1283 ' IF MID$(Infile$(Infil%), 3, 1) = "C" THEN G.ColorVal = 0

1284 ' IF MID$(Infile$(Infil%), 3, 1) = "B" THEN G.ColorVal = 4

1285 ' IF MID$(Infile$(Infil%), 3, 1) = "R" THEN G.ColorVal = 1

1286 '

1287 ' PointsInLine& = PointCount&(PtCnt&)

1288 '

1289 ' CALL GetFullCoords(LonI, LatI) ' - Max Place Holder (Max not used in program)

1290 '

1291 ' CALL GetFullCoords(LonI, LatI) ' - Min Place Holder (Min not used in Program)

1292 '

1293 ' PolyLine% = False

1294 
1295 ' CALL GetFullCoords(LonI, LatI) ' - Use First Coordinate

1296 
1297 ' LonR = ConvertCoordToDecDeg#(LonI)

1298 ' LatR = ConvertCoordToDecDeg#(LatI)

1299 
1300 ' G.Phi = LatR * Deg2Rad

1301 ' G.Lambda = LonR * Deg2Rad

1302 ' CALL DrawProjection(PolyLine%)

1303 '

1304 ' PointsInLine& = PointsInLine& - 1

1305 '

1306 ' PolyLine% = True

1307 ' FOR LoopCount = 1 TO PointsInLine&

1308 '

1309 ' CALL GetNextCoords(LonI, LatI) '- Use next coordinates

1310 ' LonR = ConvertCoordToDecDeg#(LonI)

1311 ' LatR = ConvertCoordToDecDeg#(LatI)

1312  
1313 ' G.Phi = LatR * Deg2Rad

1314 ' G.Lambda = LonR * Deg2Rad

1315 ' CALL DrawProjection(PolyLine%)

1316 '

1317 ' NEXT LoopCount

1318 '

1319 ' LOOP UNTIL Index = LOF(1)

1320 '

1321 ' Index = 0

1322 ' CLOSE #1

1323 ' NEXT Infil%

1324 '

1325 END SUB '{ GetPKDData. }

1326 
1327 SUB Goode (DeltaLambda#, Radius#, XCoord#, YCoord#) STATIC
1328 '

1329 ' When drawing the outline and the extensions there are a number

1330 ' of duplications that would be drawn over each other if the following

1331 ' groups of IF-THEN statements were used. It was easier to define the

1332 ' necessary Lobe Central Longitude (G.Lambda2) values in the Outline

1333 ' and DrawProjection (extensions) subroutines and use the Outline

1334 ' variable as a flag to skip over the following IF-THENs.

1335  
1336   IF G.Outline THEN
1337     GOTO XYPlot
1338   END IF
1339  
1340 IF G.Phi >= 0 THEN
1341   IF (G.Lambda > -DEG180) AND (G.Lambda <= -DEG40) THEN
1342     G.Lambda2 = -DEG100
1343     GOTO XYPlot
1344   END IF
1345 
1346   IF (G.Lambda > -DEG40) AND (G.Lambda <= DEG180) THEN
1347     G.Lambda2 = DEG30
1348     GOTO XYPlot
1349   END IF
1350 END IF
1351 
1352   IF (G.Lambda >= -DEG180) AND (G.Lambda <= -DEG100) THEN
1353     G.Lambda2 = -DEG160
1354     GOTO XYPlot
1355   END IF
1356 
1357   IF (G.Lambda >= -DEG100) AND (G.Lambda <= -DEG20) THEN
1358     G.Lambda2 = -DEG60
1359     GOTO XYPlot
1360   END IF
1361 
1362   IF (G.Lambda >= -DEG20) AND (G.Lambda <= DEG80) THEN
1363     G.Lambda2 = DEG20
1364     GOTO XYPlot
1365   END IF
1366 
1367   IF (G.Lambda >= DEG80) AND (G.Lambda <= DEG180) THEN
1368     G.Lambda2 = DEG140
1369     GOTO XYPlot
1370   END IF
1371 '

1372 ' ----------------------------------

1373 '

1374 XYPlot:
1375 ' The DeltaLambda# value is computed at the top of the DrawProjection

1376 ' subroutine to place the Longitude (G.Lambda#) Value into the correct

1377 ' quadrant of the map in relation to the center of the full map. It is

1378 ' used here to establish the same Longitude relationship for the lobe.

1379  
1380   Lambda1# = Normalize#(DeltaLambda#, G.Lambda2)
1381 
1382   IF ABS(G.Phi) < MERGEPOINT THEN ' (40.73666# * Deg2Rad)

1383     ' Sinusoidal Projection

1384     XCoord# = Radius# * Lambda1# * COS(G.Phi)
1385     YCoord# = Radius# * G.Phi
1386   ELSE
1387 '   Part of the MollweideFormula# Function

1388 '   Placed here to reduce amount of calculations

1389     SinPhi# = DEG180 * SIN(G.Phi)
1390 '

1391 '   This subroutine uses Newton-Raphson iteration to derive the Theta# value

1392 '

1393 '   Mollweide Projection

1394     Start# = G.Phi * .5
1395     DeltaThetaPrime# = Start#
1396     DO
1397       FirstGuess# = MollweideFormula#(DeltaThetaPrime#, SinPhi#)
1398       DeltaThetaPrime# = DeltaThetaPrime# + DTPINCR#
1399 '     MollweideFormula# is a user defined function - use The Menu Bar - View

1400 '     Menu to find it.

1401       SecondGuess# = (MollweideFormula#(DeltaThetaPrime#, SinPhi#) - FirstGuess#) / DTPINCR#
1402       Start# = Start# - FirstGuess# / SecondGuess#
1403       DeltaThetaPrime# = Start#
1404     LOOP WHILE ABS(MollweideFormula#(DeltaThetaPrime#, SinPhi#)) >= TOLERANCE#
1405 '

1406     Theta# = DeltaThetaPrime# * .5
1407 '

1408     XCoord# = Radius# * XCONST * Lambda1# * COS(Theta#)
1409     YCoord# = Radius# * (SQRT2 * SIN(Theta#) - MOLLRFACTOR * Sign#(G.Phi))
1410 '

1411   END IF
1412 '

1413 ' In addition to the extensive use of IF-THEN statements to define the

1414 ' Boundries and Central Longitudes of each lobe, the TRICK to

1415 ' Interrupting and recentering a projection is in the following

1416 ' line of code. As you know the Homolosine consists of 2 projections that

1417 ' are merged at 40 Deg. 44 Min. and 11.89 Sec.(40.73666# Decimal Deg.).

1418 ' The X Coordinate formula of the center projection (Sinusoidal) is copied

1419 ' and modified by making the G.Phi# (Latitude) value always equal to 0 (Cosine

1420 ' of 0 is 1) and using the central longitude (G.Lambda2#) of the lobe the

1421 ' Current Longitude (G.Lambda#) value is within. This value is then added to

1422 ' the Normal X coordinate output of both projections.

1423 '

1424 '     Normal X OUT  | Modified X coord of center Projection

1425   XCoord# = XCoord# + (G.Lambda2 * Radius#)
1426    
1427 ' This line of code is used to turn off PolyLine%s that cross into different

1428 ' lobes. It could be better (When crossing the equator)!

1429  
1430   IF (PreviousPhi# > 0 AND G.Phi < 0) OR (PreviousPhi# < 0 AND G.Phi > 0) THEN
1431     G.Visible = TRUE
1432   ELSE
1433     IF (PreviousLambda2# <> G.Lambda2) THEN
1434       G.Visible = FALSE
1435     END IF
1436   END IF
1437 '

1438   PreviousPhi# = G.Phi
1439   PreviousLambda2# = G.Lambda2
1440 '

1441 END SUB '{ Goode. }

1442 
1443 SUB LatLongEntry (Title$, Note$)
1444 '

1445   CLS
1446  
1447   IF Title$ <> "" THEN
1448     Col = Center%(LEN(Title$))
1449     LOCATE 2, Col: PRINT Title$
1450   END IF
1451 '

1452   IF Note$ <> "" THEN
1453     Col = Center%(LEN(Note$))
1454     LOCATE 4, Col: PRINT Note$
1455   END IF
1456 '

1457    LOCATE CSRLIN + 1, 20
1458 '

1459    INPUT "Do you want Grid Lines (Y/N)? ", Answer$
1460    Answer$ = UCASE$(Answer$)
1461   
1462    IF Answer$ = "Y" OR Answer$ = "" THEN
1463      G.Grid = TRUE
1464    ELSE
1465      G.Grid = FALSE
1466    END IF
1467 
1468 '

1469    LOCATE CSRLIN + 1, 19
1470    INPUT "Send Output to Plot File (Y/N)? ", Answer$
1471    Answer$ = UCASE$(Answer$)
1472   
1473    IF Answer$ = "Y" THEN
1474      G.PlotFile = TRUE
1475    ELSE
1476      G.PlotFile = FALSE
1477    END IF
1478 
1479 '

1480 END SUB '{ LatLongEntry. }

1481 
1482 SUB LatLongMenu
1483 '

1484 ExitMenu% = FALSE
1485 
1486 DO
1487   CLS
1488 '

1489   LOCATE 2, 20
1490   PRINT "** Modify Latitude/ Longitude Display **"
1491 '

1492   SELECT CASE G.LongOption
1493    
1494     CASE 1
1495       LOCATE 4, 17
1496       PRINT "Currently all Longitude lines converge at Pole"
1497           
1498     CASE 2
1499       LOCATE 4, 11
1500       PRINT "Currently all Longitude lines end 5 Degrees away from Pole"
1501           
1502   END SELECT '{ G.LongOption. }

1503         
1504   LOCATE 6, 12
1505   PRINT "1. Change Latitude increment (Currently"; G.LatStep; "Degrees)"
1506  
1507   LOCATE 7, 12
1508   PRINT "2. Change Longitude increment (Currently"; G.LongStep; "Degrees)"
1509  
1510   LOCATE 8, 12
1511   PRINT "3. All Longitude lines converge at Pole"
1512  
1513   LOCATE 9, 12
1514   PRINT "4. Longitude lines end 5 Degrees away from Pole"
1515  
1516   LOCATE 11, 14
1517   INPUT "Select Option (1-4) or 0 to Return to Previous Menu: ", Menu%
1518 '

1519   SELECT CASE Menu%
1520 '    

1521     CASE 0
1522       ExitMenu% = TRUE
1523 '

1524     CASE 1
1525       LOCATE 12, 1: PRINT SPACE$(80)
1526       LOCATE 13, 1: PRINT SPACE$(80)
1527      
1528       LOCATE 12, 20
1529       INPUT "Change Latitude Increment to (5 to 90): ", Increment%
1530      
1531       IF Increment% >= 5 AND Increment% <= 90 THEN
1532         G.LatStep = Increment%
1533       ELSE
1534         PRINT CHR$(7)
1535       END IF
1536 '

1537     CASE 2
1538       LOCATE 12, 1: PRINT SPACE$(80)
1539       LOCATE 13, 1: PRINT SPACE$(80)
1540      
1541       LOCATE 12, 19
1542       INPUT "Change Longitude Increment to (5 to 90): ", Increment%
1543      
1544       IF Increment% >= 5 AND Increment% <= 90 THEN
1545         G.LongStep = Increment%
1546       ELSE
1547         PRINT CHR$(7)
1548       END IF
1549 '   

1550     CASE 3
1551       G.LongOption = 1
1552 '      

1553     CASE 4
1554       G.LongOption = 2
1555 '

1556     CASE ELSE
1557       PRINT CHR$(7)
1558 '

1559   END SELECT '{ Menu. }

1560 '

1561   LOOP UNTIL ExitMenu%
1562 '

1563 END SUB '{ LatLongMenu. }

1564 
1565 FUNCTION LN# (n#) STATIC
1566 '

1567 IF n# > 0 THEN
1568   LN# = LOG(n#)
1569 ELSE
1570   PRINT "Error: LN#(n#) Where n# <= 0# "
1571   SYSTEM
1572 END IF
1573 '

1574 END FUNCTION ' { LN#. }

1575 
1576 SUB LongitudeFOR (Begin#, Finish#, Incr#) STATIC
1577 '

1578   PolyLine% = TRUE
1579  
1580   FOR LatGrid# = Begin# TO Finish# STEP Incr#
1581     G.Phi = LatGrid#
1582     CALL DrawProjection(PolyLine%)
1583   NEXT LatGrid#
1584 '

1585 END SUB '{ LongitudeFOR. }

1586 
1587 SUB MakeLatitudeLines (LatRange%, LatDetail%)
1588 '

1589   G.Outline = TRUE
1590   FOR LatGrid% = LatRange% TO -LatRange% STEP -1
1591    
1592     IF ABS(LatGrid%) < 90 THEN
1593    
1594       Even% = (LatGrid% MOD G.LatStep = 0)
1595       IF Even% THEN
1596         G.Phi = LatGrid% * DEG2RAD
1597         PolyLine% = FALSE
1598         CALL DrawProjection(PolyLine%)
1599         PolyLine% = TRUE
1600 
1601         IF LatGrid% <= 0 THEN
1602 '

1603 '       > Southern Lobe 1

1604 '

1605           G.Lambda2 = -DEG160
1606           PolyLine% = FALSE
1607           CALL DrawProjection(PolyLine%)
1608           PolyLine% = TRUE
1609      
1610           FOR LongGrid% = -180 TO -100 STEP 5
1611             G.Lambda = LongGrid% * DEG2RAD
1612             CALL DrawProjection(PolyLine%)
1613           NEXT LongGrid%
1614 '

1615 '       > Southern Lobe 2

1616 '

1617           G.Lambda2 = -DEG60
1618           PolyLine% = FALSE
1619           CALL DrawProjection(PolyLine%)
1620           PolyLine% = TRUE
1621      
1622           FOR LongGrid% = -100 TO -20 STEP 5
1623             G.Lambda = LongGrid% * DEG2RAD
1624             CALL DrawProjection(PolyLine%)
1625           NEXT LongGrid%
1626 '

1627 '       > Southern Lobe 3

1628 '

1629           G.Lambda2 = DEG20
1630           PolyLine% = FALSE
1631           CALL DrawProjection(PolyLine%)
1632           PolyLine% = TRUE
1633      
1634           FOR LongGrid% = -20 TO 80 STEP 5
1635             G.Lambda = LongGrid% * DEG2RAD
1636             CALL DrawProjection(PolyLine%)
1637           NEXT LongGrid%
1638 '

1639 '       > Southern Lobe 4

1640 '

1641           G.Lambda2 = DEG140
1642           PolyLine% = FALSE
1643           CALL DrawProjection(PolyLine%)
1644           PolyLine% = TRUE
1645      
1646           FOR LongGrid% = 80 TO 180 STEP 5
1647             G.Lambda = LongGrid% * DEG2RAD
1648             CALL DrawProjection(PolyLine%)
1649           NEXT LongGrid%
1650      
1651         ELSE
1652 '

1653 '       > Northern Lobe 1

1654 '

1655           G.Lambda2 = -DEG100
1656           IF LatGrid% < 60 THEN
1657             PolyLine% = FALSE
1658             CALL DrawProjection(PolyLine%)
1659             PolyLine% = TRUE
1660        
1661             FOR LongGrid% = -180 TO -40 STEP 5
1662               G.Lambda = LongGrid% * DEG2RAD
1663               CALL DrawProjection(PolyLine%)
1664             NEXT LongGrid%
1665           ELSE
1666             PolyLine% = FALSE
1667             CALL DrawProjection(PolyLine%)
1668             PolyLine% = TRUE
1669        
1670             FOR LongGrid% = -180 TO -10 STEP 5
1671               G.Lambda = LongGrid% * DEG2RAD
1672               CALL DrawProjection(PolyLine%)
1673             NEXT LongGrid%
1674           END IF
1675 '

1676 '       > Northern Lobe 2

1677 '

1678           G.Lambda2 = DEG30
1679           IF LatGrid% < 50 THEN
1680             PolyLine% = FALSE
1681             CALL DrawProjection(PolyLine%)
1682             PolyLine% = TRUE
1683        
1684             FOR LongGrid% = -40 TO 180 STEP 5
1685               G.Lambda = LongGrid% * DEG2RAD
1686               CALL DrawProjection(PolyLine%)
1687             NEXT LongGrid%
1688           END IF
1689 
1690           IF LatGrid% >= 50 AND LatGrid% < 60 THEN
1691             PolyLine% = FALSE
1692             CALL DrawProjection(PolyLine%)
1693             PolyLine% = TRUE
1694        
1695             FOR LongGrid% = -40 TO 180 STEP 5
1696               G.Lambda = LongGrid% * DEG2RAD
1697               CALL DrawProjection(PolyLine%)
1698             NEXT LongGrid%
1699        
1700             FOR LongGrid% = -180 TO -160 STEP 5
1701               G.Lambda = LongGrid% * DEG2RAD
1702               CALL DrawProjection(PolyLine%)
1703             NEXT LongGrid%
1704           END IF
1705      
1706           IF LatGrid% >= 60 THEN
1707             PolyLine% = FALSE
1708             CALL DrawProjection(PolyLine%)
1709             PolyLine% = TRUE
1710        
1711             FOR LongGrid% = -50 TO 180 STEP 5
1712               G.Lambda = LongGrid% * DEG2RAD
1713               CALL DrawProjection(PolyLine%)
1714             NEXT LongGrid%
1715        
1716             FOR LongGrid% = -180 TO -160 STEP 5
1717               G.Lambda = LongGrid% * DEG2RAD
1718               CALL DrawProjection(PolyLine%)
1719             NEXT LongGrid%
1720           END IF
1721         END IF
1722       END IF
1723     END IF
1724 
1725   NEXT LatGrid%
1726   G.Outline = FALSE
1727 '

1728 END SUB
1729 
1730 SUB MakeLongitudeLines (LatRange%, LongDetail!)
1731 '

1732 ' ===========================================

1733 ' Extension 3 (Right side of Northern Lobe 2)

1734 ' ===========================================

1735 '

1736   G.Outline = TRUE
1737   G.Lambda2 = DEG30
1738  
1739   FOR LongGrid% = -160 TO -180 STEP -1
1740     Even% = (LongGrid% MOD G.LongStep = 0)
1741     IF Even% THEN
1742       IF LongGrid% >= -180 AND LongGrid% < -160 THEN
1743         G.Lambda = LongGrid% * DEG2RAD
1744         PolyLine% = FALSE
1745 '

1746         FOR LatGrid! = LatRange% TO 50 STEP -LongDetail!
1747           G.Phi = LatGrid! * DEG2RAD
1748           CALL DrawProjection(PolyLine%)
1749           PolyLine% = TRUE
1750         NEXT LatGrid!
1751       END IF
1752    END IF
1753   NEXT LongGrid%
1754  
1755   G.Outline = FALSE
1756 '

1757 ' ===============================================

1758 ' Longitude Lines from 180 degrees to -40 Degrees

1759 ' ===============================================

1760 '

1761   FOR LongGrid% = 180 TO -40 STEP -1
1762    
1763     IF LongGrid% < 180 THEN
1764       Even% = (LongGrid% MOD G.LongStep = 0)
1765       IF Even% THEN
1766         IF LongGrid% = -40 THEN
1767           G.Lambda2 = DEG30
1768           G.Outline = TRUE
1769         ELSE
1770           G.Outline = FALSE
1771         END IF
1772 
1773         G.Lambda = LongGrid% * DEG2RAD
1774         PolyLine% = FALSE
1775 '

1776         North# = LatRange% * DEG2RAD
1777         South# = -LatRange% * DEG2RAD
1778     
1779         IF LatRange% = 85 THEN
1780           IF G.Lambda = DEG30 THEN
1781             North# = DEG90
1782           END IF
1783  
1784           IF G.Lambda = DEG140 THEN
1785             South# = -DEG90
1786           END IF
1787 
1788           IF G.Lambda = DEG20 THEN
1789             South# = -DEG90
1790           END IF
1791         END IF
1792      
1793         IF LongGrid% = -40 THEN
1794           South# = DEG60
1795         END IF
1796        
1797         IF LongGrid% = 80 OR LongGrid% = -20 THEN
1798           South# = 0
1799         END IF
1800        
1801         CALL LongitudeFOR(North#, South#, -LongDetail! * DEG2RAD)
1802       END IF
1803     END IF
1804   NEXT LongGrid%
1805 '

1806 ' ===========

1807 ' Extension 2 (Left side of Northern Lobe 2)

1808 ' ===========

1809 '

1810   G.Outline = TRUE
1811   G.Lambda2 = DEG30#
1812 
1813   FOR LongGrid% = -40 TO -50 STEP -1
1814     Even% = (LongGrid% MOD G.LongStep = 0)
1815     IF Even% THEN
1816       IF LongGrid% > -50 AND LongGrid% < -40 THEN
1817         G.Lambda = LongGrid% * DEG2RAD
1818         PolyLine% = FALSE
1819 '

1820         FOR LatGrid! = LatRange% TO 60 STEP -LongDetail!
1821           G.Phi = LatGrid! * DEG2RAD
1822           CALL DrawProjection(PolyLine%)
1823           PolyLine% = TRUE
1824         NEXT LatGrid!
1825       END IF
1826     END IF
1827   NEXT LongGrid%
1828 '

1829 ' ===========================================

1830 ' Extension 1 (Right side of Northern Lobe 1)

1831 ' ===========================================

1832 '

1833   G.Outline = TRUE
1834   G.Lambda2 = -DEG100
1835 
1836   FOR LongGrid% = -10 TO -40 STEP -1
1837     Even% = (LongGrid% MOD G.LongStep = 0)
1838     IF Even% THEN
1839       IF LongGrid% > -40 AND LongGrid% < -10 THEN
1840         G.Lambda = LongGrid% * DEG2RAD
1841         PolyLine% = FALSE
1842 '

1843         FOR LatGrid! = LatRange% TO 60 STEP -LongDetail!
1844           G.Phi = LatGrid! * DEG2RAD
1845           CALL DrawProjection(PolyLine%)
1846           PolyLine% = TRUE
1847         NEXT LatGrid!
1848       END IF
1849     END IF
1850 '

1851   NEXT LongGrid%
1852   G.Outline = FALSE
1853 '

1854 ' ==============================================

1855 ' Longitude Lines from 0 degrees to -180 Degrees

1856 ' ==============================================

1857 '

1858   FOR LongGrid% = -40 TO -180 STEP -1
1859   
1860     IF LongGrid% = -180 THEN EXIT FOR ' no real need to redraw -180

1861 
1862     Even% = (LongGrid% MOD G.LongStep = 0)
1863     IF Even% THEN
1864       IF LongGrid% <= -40 THEN
1865         G.Lambda = LongGrid% * DEG2RAD
1866         PolyLine% = FALSE
1867 '

1868         North# = LatRange% * DEG2RAD
1869         South# = -LatRange% * DEG2RAD
1870      
1871         IF LatRange% = 85 THEN
1872           IF G.Lambda = -DEG100 THEN
1873             North# = DEG90
1874           END IF
1875   
1876           IF G.Lambda = -DEG60 THEN
1877             South# = -DEG90
1878           END IF
1879 
1880           IF G.Lambda = -DEG160 THEN
1881             South# = -DEG90
1882           END IF
1883         END IF
1884       
1885         IF LongGrid% = -100 THEN
1886           South# = 0
1887         END IF
1888        
1889         CALL LongitudeFOR(North#, South#, -LongDetail! * DEG2RAD)
1890    
1891       END IF
1892     END IF
1893 '

1894   NEXT LongGrid%
1895 '

1896 END SUB '{ MakeLongitudeLines. }

1897 
1898 FUNCTION MollweideFormula# (ThetaPrime#, MPhi#) STATIC
1899 ' From John Snyder's "Map Projections -- A Working Manual"

1900 ' Used by the Newton-Raphson iteration in the Mollweide portion

1901 ' of the Map subroutine

1902 '

1903   MollweideFormula# = -(ThetaPrime# + SIN(ThetaPrime#) - MPhi#) / (1 + COS(ThetaPrime#))
1904 '

1905 END FUNCTION '{ MollweideFormula#. }

1906 
1907 FUNCTION Normalize# (LambdaVal#, Lambda0Val#) STATIC
1908 '

1909 ' This subroutine is responsible for placing the Longitude (Lambda)

1910 ' value into the correct part of the map in relation to the selected

1911 ' Central Longitude (Lambda0) of the map.

1912 '

1913 LambdaDiff# = LambdaVal# - Lambda0Val#
1914 
1915 DO WHILE ABS(LambdaDiff#) > DEG180
1916   IF LambdaDiff# < 0 THEN
1917     LambdaDiff# = LambdaDiff# + DEG360
1918   ELSE
1919     LambdaDiff# = LambdaDiff# - DEG360
1920   END IF
1921 LOOP
1922 
1923 Normalize# = LambdaDiff#
1924 '

1925 END FUNCTION ' { Normalize#. }

1926 
1927 SUB PlotFileColorMenu
1928 '

1929 ExitMenu% = FALSE
1930 '

1931 DO
1932   CLS
1933 '

1934   LOCATE 2, 11
1935   PRINT "** Change Plot File Pen Colors of Geographical Features **"
1936   LOCATE 4, 33: PRINT "Pen Color Codes"
1937   LOCATE 6, 29: PRINT "1 - Black  5 - Magenta"
1938   LOCATE 7, 29: PRINT "2 - Blue   6 - Yellow"
1939   LOCATE 8, 29: PRINT "3 - Red    7 - Cyan"
1940   LOCATE 9, 29: PRINT "4 - Green  8 - Brown"
1941         
1942   LOCATE 12, 27: PRINT "1. Grid Pen is:"; G.GridPen
1943   LOCATE 13, 27: PRINT "2. Coast Pen is:"; G.CoastPen
1944   LOCATE 14, 27: PRINT "3. Country Border Pen is:"; G.BorderPen
1945   LOCATE 15, 27: PRINT "4. Island Pen is:"; G.IslandPen
1946   LOCATE 16, 27: PRINT "5. State Border Pen is:"; G.StatePen
1947   LOCATE 17, 27: PRINT "6. Lake Pen is:"; G.LakePen
1948   LOCATE 18, 27: PRINT "7. River Pen is:"; G.RiverPen
1949   LOCATE 20, 14
1950   INPUT "Select Option (1-7) or 0 to Return to Main Menu: ", Menu%
1951     
1952   SELECT CASE Menu%
1953 '

1954     CASE 0
1955       ExitMenu% = TRUE
1956 
1957     CASE 1
1958       LOCATE 20, 1: PRINT SPACE$(80)
1959       LOCATE 20, 26
1960       INPUT "Change Grid Pen to (1-8):", NewPen%
1961       IF NewPen% >= 1 AND NewPen% < 9 THEN
1962         G.GridPen = NewPen%
1963       ELSE
1964         PRINT CHR$(7)
1965       END IF
1966 '

1967     CASE 2
1968       LOCATE 20, 1: PRINT SPACE$(80)
1969       LOCATE 20, 23
1970       INPUT "Change Coastline Pen to (1-8):", NewPen%
1971       IF NewPen% >= 1 AND NewPen% < 9 THEN
1972         G.CoastPen = NewPen%
1973       ELSE
1974         PRINT CHR$(7)
1975       END IF
1976 '

1977     CASE 3
1978       LOCATE 20, 1: PRINT SPACE$(80)
1979       LOCATE 20, 21
1980       INPUT "Change Country Border Pen to (1-8):", NewPen%
1981       IF NewPen% >= 1 AND NewPen% < 9 THEN
1982         G.BorderPen = NewPen%
1983       ELSE
1984         PRINT CHR$(7)
1985       END IF
1986 '

1987     CASE 4
1988       LOCATE 20, 1: PRINT SPACE$(80)
1989       LOCATE 20, 25
1990       INPUT "Change Island Pen to (1-8):", NewPen%
1991       IF NewPen% >= 1 AND NewPen% < 9 THEN
1992         G.IslandPen = NewPen%
1993       ELSE
1994         PRINT CHR$(7)
1995       END IF
1996 '

1997     CASE 5
1998       LOCATE 20, 1: PRINT SPACE$(80)
1999       LOCATE 20, 22
2000       INPUT "Change State Border Pen to (1-8):", NewPen%
2001       IF NewPen% >= 1 AND NewPen% < 9 THEN
2002         G.StatePen = NewPen%
2003       ELSE
2004         PRINT CHR$(7)
2005       END IF
2006 '

2007     CASE 6
2008       LOCATE 20, 1: PRINT SPACE$(80)
2009       LOCATE 20, 26
2010       INPUT "Change Lake Pen to (1-8):", NewPen%
2011       IF NewPen% >= 1 AND NewPen% < 9 THEN
2012         G.LakePen = NewPen%
2013       ELSE
2014         PRINT CHR$(7)
2015       END IF
2016 '

2017     CASE 7
2018       LOCATE 20, 1: PRINT SPACE$(80)
2019       LOCATE 20, 26
2020       INPUT "Change River Pen to (1-8):", NewPen%
2021       IF NewPen% >= 1 AND NewPen% < 9 THEN
2022         G.RiverPen = NewPen%
2023       ELSE
2024         PRINT CHR$(7)
2025       END IF
2026 '

2027     CASE ELSE
2028       PRINT CHR$(7)
2029 
2030   END SELECT '{ Menu. }

2031 '

2032 LOOP UNTIL ExitMenu%
2033 '

2034 END SUB '{ PlotFileColorMenu. }

2035 
2036 FUNCTION PointCount& (PtCnt&)
2037 ' Used by GetPKDData subroutine

2038 '

2039   CALL ReadInfile(Byte%)
2040   PtCnt& = Byte% * 100
2041   CALL ReadInfile(Byte%)
2042   PtCnt& = PtCnt& + Byte%
2043   PointCount& = PtCnt&
2044 '

2045 END FUNCTION '{ PointCount&. }

2046 
2047 FUNCTION PolyLineColor% (PolyLineHeader%) STATIC
2048 '

2049 SELECT CASE PolyLineHeader%
2050 '

2051   CASE 1000 TO 1999
2052 '   Coast

2053     PolyLineColor% = G.CoastColor
2054     PlotPen$ = LTRIM$(STR$(G.CoastPen))
2055 '

2056   CASE 2000 TO 2999
2057 '   Country Borders

2058     PolyLineColor% = G.BorderColor
2059     PlotPen$ = LTRIM$(STR$(G.BorderPen))
2060        
2061   CASE 3000 TO 3999
2062 '   Canadian Provinces

2063     PolyLineColor% = G.StateColor
2064     PlotPen$ = LTRIM$(STR$(G.StatePen))
2065       
2066   CASE 4000 TO 4999
2067 '   U.S. State borders

2068     PolyLineColor% = G.StateColor
2069     PlotPen$ = LTRIM$(STR$(G.StatePen))
2070        
2071   CASE 5000 TO 5999
2072 '   Islands

2073     PolyLineColor% = G.IslandColor
2074     PlotPen$ = LTRIM$(STR$(G.IslandPen))
2075        
2076   CASE 6000 TO 6999
2077 '   Lakes

2078     PolyLineColor% = G.LakeColor
2079     PlotPen$ = LTRIM$(STR$(G.LakePen))
2080        
2081   CASE 7000 TO 7999
2082 '   Rivers

2083     PolyLineColor% = G.RiverColor
2084     PlotPen$ = LTRIM$(STR$(G.RiverPen))
2085         
2086   CASE 8000 TO 8999
2087 '   Australian States

2088     PolyLineColor% = G.StateColor
2089     PlotPen$ = LTRIM$(STR$(G.StatePen))
2090 '

2091 END SELECT '{ PlineHeader. }

2092    
2093 IF G.PlotFile THEN
2094   IF G.LastPlotPen <> PlotPen$ THEN
2095     PRINT #1, "SP" + PlotPen$ + ";"
2096   END IF
2097 
2098   G.LastPlotPen = PlotPen$
2099 END IF
2100 '

2101 END FUNCTION '{ PolyLineColor%. }

2102 
2103 FUNCTION Raise# (n#, Power#)
2104 ' Raise a number to a power

2105 ' (even negative numbers raised to a non-integer power)

2106 '

2107 IF n# = 0 THEN
2108   IF Power# = 0 THEN
2109     Raise# = 1
2110   ELSE
2111     Raise# = 0
2112   END IF
2113 ELSE
2114   Raise# = Sign#(n#) * EXP(Power# * LN#(ABS(n#)))
2115 END IF
2116 '

2117 END FUNCTION '{ Raise. }

2118 
2119 SUB ReadInfile (Byte%)
2120 STATIC Rec AS STRING * 1
2121 ' Used by GetPKDData subroutine

2122 '

2123  Index = Index + 1 'Record Count

2124  GET #1, , Rec
2125  Byte% = ASC(Rec)
2126 '

2127 ' Convert to Signed Char

2128  IF Byte% > 127 THEN
2129    Byte% = Byte% - 256
2130  END IF
2131 '

2132 END SUB '{ ReadInFile. }

2133 
2134 FUNCTION Round# (n#, PowerOfTen%) STATIC
2135 '

2136 pTen# = 10 ^ PowerOfTen%
2137 RTemp# = INT(n# / pTen# + .5) * pTen#
2138 Temp$ = STR$(RTemp#)
2139 Temp$ = MID$(Temp$, 1, ABS(PowerOfTen%) + 4)
2140 Round# = VAL(Temp$)
2141 '

2142 END FUNCTION
2143 
2144 FUNCTION Sec# (n#)
2145 '

2146 Cosine# = COS(n#)
2147 IF ABS(Cosine#) <= 0# THEN
2148   PRINT "Error: Sec#(n#) where n# ="; n#
2149   PRINT "       Cosine# ="; Cosine#
2150   SYSTEM
2151 ELSE
2152   Sec# = (1 / Cosine#)
2153 END IF
2154 
2155 END FUNCTION
2156 
2157 FUNCTION Sign# (n#)
2158 ' Return -1 if n# < 0, or +1 if n# >= 0

2159 '

2160 IF n# = 0 THEN
2161   Sign# = 1
2162 ELSE
2163   Sign# = ABS(n#) / n#
2164 END IF
2165 '

2166 END FUNCTION '{ Sign. }

2167