home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / aprs72a.zip / MAPFIX14.BAS < prev    next >
BASIC Source File  |  1995-07-09  |  69KB  |  1,626 lines

  1. REM MAPFIX.bas PROGRAM.  SEE MAPFIX.TXT for HELP info
  2. REM
  3. '****  NEWEST   Yes, 1.4 is latest.  I began renumbering after 6.9
  4. Ver$ = "1.4"  ' Still was an occassional bug in F2 convert
  5. '       1.3     Fixed a bug in F2 CONVERT command and added label markers
  6. '       1.2     Added KILL LABEL command. (long needed!)
  7.  
  8. MaxNumMAPS = 150' Maximum number of maps allowed in MAPLIST
  9. MaxNumPoints = 3000  'APRS limit. Six times this many are permitted in MAPFIX
  10. MaxNumLABELS = 199 'was 99 prior to 68c
  11. MaxNumLines = 1900
  12. REM $DYNAMIC
  13.    ScrnType$ = "EGA": Ycen = 175: Yfactr = 1: YfacTXT = 350 / 350: SCREEN 9
  14.    COLOR 15, 0
  15.    REM for EGA test, Cfactr = 14: bln = 25
  16.    GBLn = 43: Cfactr = 8: bln = 43
  17.    WIDTH 80, 43
  18.  
  19.    PALETTE 6, 6
  20.    DIM Crsr(16)
  21.    CIRCLE (4, 3), 4, 14
  22.    GET (0, 0)-(8, 6), Crsr
  23.    REM PSET (40, 50), 10
  24.    REM PUT (40 - 4, 50 - 3), Crsr, XOR
  25.    REM LOCATE 23, 1: INPUT a$
  26. GOTO BEGIN
  27.  
  28. Info: COLOR 15, 2: CLS
  29.    PRINT "Ver 1.3/4  * Fixed F2 CONVERSION bug and added dots at LABEL locations "
  30.    PRINT "    1.2    * Added a long needed KILL LABEL command"
  31.    PRINT "    1.1    * F3,4,6,7,8,F10,11,12 hot keys Begin new Digitizer lines"
  32.    PRINT "           * Added Clear Single Point command that scans entire map for"
  33.    PRINT "             singlularities and kills them"
  34.    PRINT
  35.    PRINT "Ver 1.0  Added ^OVERLAY command for overlaying a map temporarily"
  36.    PRINT "         F3 sets compressed mode for Map save.  Saves 33% in file"
  37.    PRINT "         loading time.  Requires new MAP limits of X,2048 and Y,1024"
  38.    PRINT "         New ^LOAD command for beginning a new map"
  39.    PRINT
  40.    PRINT "Ver 6.8d Fixed GPS Track History plots for E. and S. Hemispheres"
  41.    PRINT
  42.    PRINT "Ver 6.5d This version ADDED two modes of MOUSE SUPPORT!  "
  43.    PRINT "         * CURSOR: Use F9 to open appropriate MOUSE port (must be MICROSOFT"
  44.    PRINT "           serial mouse).  Left button is ALT-ADD and right is FIND command."
  45.    PRINT
  46.    PRINT "         * POOR-MANS DIGITIZER: Use alt-O to OPEN COMM port & READ MOUSE.txt"
  47.    PRINT
  48.    PRINT
  49.    PRINT
  50.    PRINT "**********  MAPFIX can build and edit APRS maps in a variety of ways:  *****"
  51.    PRINT
  52.    PRINT " FREE-HAND: Good for filling in missing roads, but hard to make roads exact"
  53.    PRINT " CDROM:     Gets points from 2,000,000:1 and 100,000:1 USGS CD ROM. "
  54.    PRINT "            Both generate Mbytes worth of points that take a lot of time to"
  55.    PRINT "            filter down to a useable APRS size!"
  56.    PRINT " TABLET:    Connect a serial data digitizer tablet and draw!     BEST METHOD!"
  57.    PRINT " GPS DATA:  Replay any APRS GPS track history file and DRAW map lines over it"
  58.    PRINT " CONVERSION:Change origin or scale on-line (old function of MAPCNVRT.bas)"
  59.    PRINT " IMPORTING: Import features from other maps with auto-point conversion!"
  60.    PRINT
  61.    PRINT
  62.    PRINT
  63.    PRINT " FOR MORE DETAILS, BE SURE TO READ THE MAPFIX.TXT file!!!"
  64.    PRINT
  65.    PRINT
  66.    Display$ = "UNKnown"
  67.    RETURN
  68.  
  69. GetChar: a$ = "": DO UNTIL a$ <> "": a$ = INKEY$: LOOP: RETURN
  70.  
  71. BEGIN: GOSUB Info:
  72.    PRINT " HIT ANY KEY to proceed onto the HELP screen...";
  73.    GOSUB GetChar
  74.  
  75.    DIM x%(6 * MaxNumPoints), y%(6 * MaxNumPoints)
  76.    DIM LN$(MaxNumLines) ' (no limit in APRS)
  77.    nn = 2 * MaxNumLABELS
  78.    DIM ML$(nn), Mla(nn), Mlo(nn), MLr(nn) 'Map Labels, lengths and coordinates
  79.    nn = 2 * MaxNumMAPS
  80.    DIM MapName$(nn), LatCen(nn), LonCen(nn), MapMax(nn), Comment$(nn)
  81.    i = 1000
  82.    DIM HLAT(i), HLONG(i)'For lat/longs from big GPS history files
  83.  
  84. INIT: ON ERROR GOTO ErrorTrap
  85.    RdsOn = -1: Labls = -1:  KP = 1: Changed = 0: MapSize = 256
  86.    Redraw = -1: Acenter = 0: nmp = 0: z = 0: nml = 0: LNi = 0
  87.    Path$ = "C:\MAPS\S01_"
  88.  
  89. SCREEN , , 0, 0: Display$ = "HELP": GOSUB HELP: GOSUB LoadMap
  90. REM ON ERROR GOTO 0
  91.  
  92. Main: GOSUB DrwMPaCur
  93.   DO
  94. GoAgain: Fault = 0
  95.     IF Digitizer THEN
  96.        IF LOC(1) > 9 THEN
  97.           GOSUB GetXY
  98.           REM Here is where ANY digitizer input ADDS a point EXCEPT if it was
  99.           REM due to a button 3.  If button 3, then just the cursor moves.
  100.           REM To configure MAPFIX to recognize your buttons, see line 1105.
  101.           REM If you have no, or just 1 button, then F1 will simulate a button
  102.           REM 3 so you can use the digitizer to only move the cursor
  103.           IF JustCur OR Btn = 3 THEN
  104.              GOSUB Cursor: GOSUB DrwMpPt' Only move cursor and clear JustCur
  105.           ELSE GOSUB Cursor: GOSUB AddPoint'
  106.           END IF
  107.        END IF
  108.     END IF
  109.     a$ = ""
  110.     IF Mouse THEN
  111.        IF LOC(1) > 2 THEN
  112.        C$ = INPUT$(1, 1)
  113.        IF C$ > CHR$(191) THEN
  114.          a = ASC(C$) - 192
  115.          x = 0: y = 0
  116.          C$ = INPUT$(1, 1): IF C$ > CHR$(127) THEN x = ASC(C$) - 128
  117.          C$ = INPUT$(1, 1): IF C$ > CHR$(127) THEN y = ASC(C$) - 128
  118.          IF x > 31 THEN x = x - 64
  119.          IF y > 31 THEN y = y - 64
  120.          cpx = cpx - x * degpmh
  121.          cpy = cpy - y * degpmv
  122.          GOSUB Cursor
  123.          IF a > 31 THEN a = a - 32: a$ = CHR$(0) + CHR$(30)
  124.          IF a > 15 THEN a = a - 16: a$ = "F"
  125.        END IF
  126.      END IF
  127.     END IF
  128.     IF a$ = "" THEN a$ = INKEY$
  129.     IF a$ <> "" THEN
  130.        IF LEN(a$) = 1 THEN a$ = UCASE$(a$)
  131.        Key$ = a$
  132.        SELECT CASE a$
  133.        CASE "B": GOSUB BoxPPD
  134.        CASE "C": GOSUB Clr1Pts
  135.        CASE "D": GOSUB MapDIR
  136.        CASE "F": LnStrt = 0: StrtSrch = 1: GOSUB FindPoint
  137.        CASE "G": GOSUB CurToPoint: GOSUB CurDrwMap
  138.        CASE "H"
  139.           IF Display$ <> "HELP" THEN
  140.              SCREEN , , 0, 0: COLOR 15, 1: GOSUB HELP
  141.           ELSE GOSUB Info
  142.              LOCATE bln, 1: PRINT " H for HELP or SPACE BAR for map..."; : a$ = ""
  143.           END IF
  144.        CASE "K": GOSUB KillLabel
  145.        CASE "L": Labls = NOT Labls
  146.        CASE "M": GOSUB ListMAPlist
  147.        CASE "N": GOSUB NextLine: GOSUB Cursor
  148.        CASE "O": GOSUB DrwAndShow
  149.        CASE "P": GOSUB Previous: GOSUB Cursor
  150.        CASE "Q": GOSUB QUIT
  151.        CASE "R": z = 2: LnPtr = 1
  152.        CASE "S": GOSUB labels
  153.        CASE "T": GOSUB Scrunch
  154.        CASE "U": GOSUB GetUSGS
  155.        CASE " "
  156.                  Display$ = "MAP": Redraw = -1: USGS = 0:
  157.                  IF Scrn = 0 THEN SCREEN , , 1, 1: COLOR 15, 0
  158.                  IF Scrn = 1 THEN GOSUB DrwMPaCur
  159.                  Scrn = 1
  160.        CASE "+": z = z + 1: GOSUB MapPoint  ' moves to next map point
  161.        CASE "-": z = z - 1: GOSUB MapPoint  ' moves backwards
  162.        CASE CHR$(1): Acenter = NOT Acenter
  163.        CASE CHR$(3): GOSUB ChgColr
  164.        CASE CHR$(6): LnStrt = LnPtr: StrtSrch = z + 1: GOSUB FindPoint
  165.        CASE CHR$(12): GOTO INIT
  166.        CASE CHR$(15): OVERLAY = -1: Redraw = 0: GOSUB Import
  167.        CASE CHR$(18): Redraw = NOT Redraw: GOSUB Redraw
  168.        CASE CHR$(19): GOSUB SaveMap
  169.       
  170.        CASE "7": CDX = LONo: CDY = LATo: GOSUB DrwMPaCur 'ShiftHOME
  171.        CASE "6": cpx = cpx - 20 / (Sfac): GOSUB Cursor 'SHIFT Cursor by 4
  172.        CASE "4": cpx = cpx + 20 / (Sfac): GOSUB Cursor
  173.        CASE "8": cpy = cpy + 20 / (Sfac): GOSUB Cursor
  174.        CASE "2": cpy = cpy - 20 / (Sfac): GOSUB Cursor
  175.  
  176.        END SELECT
  177.       
  178.        B$ = "": IF LEN(a$) = 2 THEN B$ = RIGHT$(a$, 1): REM process arrow & special keys
  179.        SELECT CASE B$
  180.        REM CASE CHR$(1) TO CHR$(127): PRINT ASC(B$)
  181.        CASE "I": RS = RS * 2: GOSUB CurDrwMap: REM change scale
  182.        CASE "Q": RS = RS / 2: GOSUB CurDrwMap
  183.        CASE CHR$(132): RS = RS * 8: GOSUB CurDrwMap: REM change scale by factor of 4
  184.        CASE CHR$(118): RS = RS / 8: GOSUB CurDrwMap
  185.        CASE "G": GOSUB CurDrwMap 'Home key
  186.        
  187.        CASE "O": CDX = LonCen: CDY = LatCen: Acenter = 0: GOSUB DrwMPaCur'End Key
  188.        CASE "M": cpx = cpx - 4 / (Sfac): GOSUB Cursor
  189.        CASE "K": cpx = cpx + 4 / (Sfac): GOSUB Cursor
  190.        CASE "H": cpy = cpy + 4 / (Sfac): GOSUB Cursor
  191.        CASE "P": cpy = cpy - 4 / (Sfac): GOSUB Cursor
  192.        REM Here are the special MapFIx routines
  193.        CASE CHR$(30)                          'alt-A  (also left mouse button!)
  194.           SELECT CASE MsInit
  195.           CASE 0: GOSUB AddPoint              'alt-ADD point
  196.           CASE 4: LAb = cpy
  197.           CASE 3
  198.                 GOSUB BoxLine23: BEEP
  199.                 INPUT "Enter total LAT moved in Degrees"; z$
  200.                 degpmv = VAL(z$) / (Sfac * (cpy - LAb))
  201.           CASE 2: LOb = cpx
  202.           CASE 1
  203.                 GOSUB BoxLine23: BEEP
  204.                 INPUT "Enter total LONG moved in Degrees"; z$
  205.                 degpmh = VAL(z$) / (Sfac * (cpx - LOb))
  206.           END SELECT
  207.           IF MsInit THEN MsInit = MsInit - 1
  208.        
  209.        CASE CHR$(48): IF Digitizer THEN GOSUB NewFeature'alt-BEGIN
  210.        CASE CHR$(46): GOSUB NewCenter                   'alt-CENTER
  211.        CASE CHR$(32): GOSUB DelPT                       'alt-DELete point
  212.        CASE CHR$(34): GOSUB LoadHst                     'alt-GPS hstry file
  213.        CASE CHR$(23): GOSUB Import                      'alt-IMPORT
  214.        CASE CHR$(36): GOSUB Join                        'alt-JOIN
  215.        CASE CHR$(37): GOSUB KillF                       'alt-KILL Feature
  216.        CASE CHR$(38): GOSUB AddLabel                    'alt-add LABEL
  217.        CASE CHR$(50): GOSUB MakePT: IF Redraw THEN GOSUB DrawMap 'MOVE point to cursor
  218.        CASE CHR$(49): GOSUB NewFeature                  'alt-NEW Feature
  219.        CASE CHR$(24): GOSUB WhichDgtzr                  'alt-OPEN dgtzr COM
  220.        CASE CHR$(19): GOSUB MapRange                    'alt-RANGE
  221.        CASE CHR$(20): GOSUB TRIM                        'alt-TRIM
  222.        CASE CHR$(31): GOSUB Scrunch                     'alt-SCRUNCH
  223.        CASE CHR$(22): GOSUB GetUSGS                     'alt-U
  224.        CASE CHR$(59): JustCur = -1: GOSUB DrwMpPt       'F1
  225.        CASE CHR$(60): GOSUB MapCnvrt                    'F2
  226.        CASE CHR$(61)                                    'F3 for smaller Maps
  227.           IF MpLstLdd THEN
  228.              MapSize = MapSize / 2: IF MapSize < 1 THEN MapSize = 1
  229.              GOSUB ShowMaps
  230.           ELSE SavClr = 3: a$ = "Stream": GOSUB HotKey
  231.           END IF
  232.        CASE CHR$(62)                                    'F4 for larger Maps
  233.           IF MpLstLdd THEN
  234.              MapSize = MapSize * 2: IF MapSize > 1000 THEN MapSize = 1000
  235.              GOSUB DrwAndShow
  236.           ELSE SavClr = 4: GOSUB HotKey
  237.           END IF
  238.        CASE CHR$(63): Slower = NOT Slower                           'F5
  239.        CASE CHR$(64): SavClr = 6: a$ = "Border": GOSUB HotKey       'F6
  240.        CASE CHR$(65): SavClr = 7: a$ = "Minor road": GOSUB HotKey   'F7
  241.        CASE CHR$(66): SavClr = 8: a$ = "Railroad": GOSUB HotKey     'F8
  242.        CASE CHR$(67): GOSUB InitMouse                   'F9
  243.        CASE CHR$(68): SavClr = 10: a$ = "Interstate": GOSUB HotKey  'F10
  244.        CASE CHR$(84): SavClr = 11: a$ = "Water": GOSUB HotKey       'F11
  245.        CASE CHR$(85): SavClr = 12: a$ = "Major Road": GOSUB HotKey  'F12
  246.        CASE CHR$(86): Comp = -1: abort = 0                          'F3 shift
  247.             FOR i = 1 TO nmp
  248.                 IF x%(i) < 0 OR x%(i) > 2047 THEN abort = -1
  249.                 IF y%(i) < 0 OR y%(i) > 1023 THEN abort = -1
  250.             NEXT i
  251.             IF abort THEN
  252.                 LOCATE 20, 10: Comp = 0: abort = 0
  253.                 PRINT "POINTS OUT OF RANGE.  CANNOT COMPRESS"
  254.             ELSE Changed = Changed + 1
  255.             END IF
  256.             GOSUB Redraw
  257.        CASE CHR$(87): Comp = 0: GOSUB Redraw                       'F4 shift
  258.        CASE CHR$(91): GOSUB AddMark                                'F8 shift
  259.        END SELECT
  260.           
  261.     END IF
  262.   LOOP
  263.   SYSTEM 'you should never get here
  264.  
  265. KillLabel: j = 0: k = RS / 2000
  266.            FOR i = 1 TO nml
  267.                IF j THEN
  268.                     ML$(i - 1) = ML$(i): Mla(i - 1) = Mla(i)
  269.                     Mlo(i - 1) = Mlo(i): MLr(i - 1) = MLr(i)
  270.                ELSE
  271.                     IF ABS(cpx - Mlo(i)) < k THEN
  272.                        IF ABS(cpy - Mla(i)) < k THEN j = i
  273.                     END IF
  274.                END IF
  275.            NEXT
  276.            IF j <> 0 THEN nml = nml - 1: GOSUB DrawMap ELSE BEEP
  277.            RETURN
  278.  
  279. AddMark: a$ = "Ref Point": SavClr = 14
  280.    GOSUB BeginF: GOSUB MakePT
  281.    CUY = CUY - 6: GOSUB AddPoint
  282.    CUX = CUX + 10: GOSUB AddPoint
  283.    CUY = CUY + 6: GOSUB AddPoint
  284.    CUX = CUX - 10: GOSUB AddPoint
  285.    CUY = CUY - 6: GOSUB AddPoint
  286.    CUX = CUX + 5: CUY = CUY + 3: GOSUB Cursor
  287.    RETURN
  288.  
  289. WhichDgtzr: GOSUB BoxLine23
  290.    INPUT "Select (D)igitizer or (P)oor-Man's-Mouse-Mode"; a$
  291.    a$ = UCASE$(a$): IF a$ = "D" THEN GOSUB DigiInit: GOTO DrawMap
  292.    IF a$ <> "P" THEN RETURN
  293.    IF NOT Mouse THEN GOSUB InitMouse
  294.    CLS : LOCATE 6, 1
  295.    PRINT "POOR-MANS-MOUSE-MODE  (Digitizer)"
  296.    PRINT
  297.    PRINT "We must first calibrate the mouse movement with actual LAT/LONG movements."
  298.    PRINT "Perform the following steps in sequence.  If you mess up, START PROGRAM OVER!"
  299.    PRINT
  300.    PRINT "During this process, ignore the cursor on the screen."
  301.    PRINT
  302.    PRINT "Lift and move mouse to a low LATTITUDE mark.  Hit left button."
  303.    PRINT "     move mouse carefully up to an UPPER LATTITUDE mark.  Hit left button."
  304.    PRINT
  305.    PRINT "Lift and move mouse to a right LONGITUDE mark.  Hit left button."
  306.    PRINT "     move mouse carefully to a LEFT LONGITUDE mark.  Hit left button."
  307.    MsInit = 4
  308.    RETURN
  309.  
  310.  
  311.  
  312. InitMouse: GOSUB BoxLine23
  313.     INPUT "Mouse on COM 1, 2 or None"; a$
  314.     IF a$ = "1" OR a$ = "2" THEN
  315.        OPEN "com" + a$ + ":1200,n,8,1,CS0,DS0,CD0" FOR RANDOM AS #1
  316.        Mouse = -1
  317.        GOSUB BoxLine23
  318.        PRINT "Left button is alt-ADD.  Right button is FIND."; ""
  319.        degpmh = 1 / Sfac: degpmv = 1 / Sfac
  320.     END IF
  321.     RETURN
  322.  
  323. Redraw: LOCATE 1, 25
  324.     PRINT "LOAD TIME"; LEFT$(STR$(LdTime), 5); "   ";
  325.     IF Comp THEN PRINT "COMPRESSED    ";  ELSE PRINT "              ";
  326.     IF Redraw THEN PRINT "REDRAW ENABLED" ELSE PRINT "NO ReDraw...  "
  327.     RETURN
  328.  
  329. QUIT: CLS : BEEP: INPUT "Really quit MAPFIX (Y/N) [Y]"; a$
  330.     IF UCASE$(a$) = "N" THEN GOSUB DrawMap: RETURN
  331.     a$ = "Y"
  332.     IF Changed THEN
  333.        GOSUB BoxLine23
  334.        PRINT "**** MAP HAS BEEN MODIFIED"; Changed; "TIMES BUT NOT SAVED!!!  SAVE NOW? (Y)";
  335.        INPUT a$
  336.     IF UCASE$(a$) <> "N" THEN GOSUB SaveMap
  337.     END IF
  338.     SYSTEM
  339.  
  340. TRIM: GOSUB BoxLine23
  341.     CLS : PRINT "TRIM ALL POINTS AND LABELS OUTSIDE OF MAPRANGE"
  342.     PRINT
  343.     PRINT "This command removes all points and labels outside of the white map border"
  344.     PRINT
  345.     PRINT "map border (located with the alt-CENTER and alt-RANGE command."
  346.     PRINT : PRINT
  347.     PRINT "To avoid errors near the edge, make the CENTER/RANGE box about 10% larger"
  348.     PRINT
  349.     PRINT "You might consider stopping now and doing a SAVE (ctrl-S) before proceeding."
  350.     PRINT
  351.     PRINT "ALSO, THIS DOES NOT WORK FOR POINTS WITH NEGATIVE VALUES!  Be sure  your"
  352.     PRINT "selected area is below and to right of ORIGIN.  If not do an F2 CONVERT."
  353.     PRINT : PRINT
  354.     INPUT "Are you ready to proceed? (Y/N) (N)"; ans$
  355.     CDX = LonCen: CDY = LatCen: GOSUB DrwMPaCur
  356.     IF UCASE$(ans$) <> "Y" THEN RETURN
  357.     C = 0: LOCATE bln - 2, 1: PRINT "Processing...";
  358.     REM dx and dy are num pix of center of map
  359.     REM bx and by are borders of map based on MapRng
  360.     by = ppdv * MapRng / 60
  361.     bx = by / Lfac
  362.     z = 0
  363.     DO
  364.       z = z + 1
  365.       IF x%(z) = 0 THEN z = z + 2
  366.       IF x%(z) > dx + bx OR y%(z) > dy + by THEN bad = 1 ELSE bad = 0
  367.       IF x%(z) < dx - bx OR y%(z) < dy - by THEN bad = 1
  368.       IF bad THEN
  369.          REM IF x%(z - 1) <> 0 AND x%(z + 1) <> 0 THEN
  370.             GOSUB DelPT: z = z - 1
  371.             C = C + 1
  372.          REM END IF
  373.       END IF
  374.       IF z >= nmp - 4 THEN EXIT DO
  375.     LOOP
  376.     LOCATE bln - 2, 1: PRINT "Now removing labels...";
  377.     FOR i = 1 TO nml: REM now eliminate all labels outside
  378.         bad = 0: xm = MapRng / (60 * Lfac): ym = MapRng / 60
  379.         IF Mlo(i) > LonCen + xm OR Mla(i) > LatCen + ym THEN bad = 1
  380.         IF Mlo(i) < LonCen - xm OR Mla(i) < LatCen - ym THEN bad = 1
  381.         IF bad = 1 THEN
  382.            FOR j = i TO nml
  383.                ML$(j) = ML$(j + 1): Mla(j) = Mla(j + 1)
  384.                Mlo(j) = Mlo(j + 1): MLr(j) = MLr(j + 1)
  385.            NEXT j: nml = nml - 1: PRINT ".";
  386.         END IF
  387.     NEXT i
  388.     GOTO DrawMap
  389.    
  390. FindPoint: CurX = INT(.5 + dx + (CUX - 320) / (KP * Hfac))
  391.            CurY = INT(.5 + dy + (CUY - Ycen) / KP)
  392.  
  393.     GOSUB BoxLine23: PRINT "SEARCHING THROUGH ALL POINTS IN FILE...";
  394.     REM SaveZ = Z: SaveLNptr = LnPtr
  395. Agn: FOR j = 0 TO 30            ' Go through abt 20 times lookin pt.
  396.         IF j > 10 THEN j = j + 1' first with 0 delta, then bigger
  397.         PRINT ".";
  398.         LnCtr = LnStrt
  399.         FOR i = StrtSrch TO nmp
  400.             IF x%(i) = 0 THEN LnCtr = LnCtr + 1
  401.             IF LnCtr >= LNi THEN i = nmp
  402.             IF x%(i) > CurX - j AND x%(i) < CurX + j THEN
  403.                IF y%(i) > CurY - j AND y%(i) < CurY + j THEN
  404.                   z = i: LnPtr = LnCtr: GOSUB CurToPoint
  405.                   j = 99: i = nmp
  406.                END IF
  407.             END IF
  408.         NEXT i:
  409.     NEXT j
  410.     IF j < 99 AND Key$ = CHR$(6) THEN StrtSrch = 2: LnCtr = 1: Key$ = "F": GOTO Agn
  411.     IF j < 99 THEN PRINT "None found!": RETURN
  412.     GOSUB MapPoint: SavClr = 0
  413.     GOSUB Find1st: LineColor = 15: dots = &HCCCC: GOSUB DP
  414.     RETURN
  415.                  
  416. HotKey: IF NOT Digitizer THEN RETURN
  417.         GOSUB BeginF: GOSUB GetXY: GOSUB Cursor: GOSUB MakePT
  418.         RETURN
  419.  
  420. NewFeature: LOCATE bln - 1, 1: PRINT SPACE$(27); : GOSUB BoxLine23
  421.     INPUT "Enter reference name for new feature"; a$
  422.     IF a$ = "" THEN RETURN
  423.     GOSUB Rainbow: IF abort THEN RETURN
  424.     GOSUB BeginF
  425.     GOSUB BoxLine23
  426.     LOCATE bln, 1: PRINT SPACE$(80); : LOCATE bln, 1
  427.     IF RIGHT$(Key$, 1) = CHR$(48) THEN
  428.        PRINT "NOW USE DIGITIZER TO ADD NEW POINTS TO THIS FEATURE...";
  429.        GOSUB GetXY: GOSUB Cursor
  430.     ELSE
  431.        PRINT "NOW MOVE CURSOR AND USE ALT-A TO ADD POINTS TO THIS NEW FEATURE...";
  432.     END IF
  433.     GOSUB MakePT
  434.     RETURN
  435.  
  436. Rainbow: LOCATE bln, 1
  437.     FOR i = 0 TO 14
  438.         PRINT RIGHT$(" " + MID$(STR$(i + 1), 2), 2); "   ";
  439.         LINE (16 + i * 40, 335 * YfacTXT)-(40 + i * 40, 349 * YfacTXT), i + 1, BF
  440.     NEXT i
  441.     GOSUB BoxLine23
  442.     INPUT "Select color (4,7,10-Hwys 11-Water 12-Hwy 13-Spcl 14-City)"; B$
  443.     SavClr = VAL(B$): IF SavClr > 15 OR SavClr < 1 THEN abort = -1 ELSE abort = 0
  444.     RETURN
  445.  
  446.            
  447. BeginF: x%(nmp) = 0: y%(nmp) = SavClr   'Store feature color 0,c
  448.     LN$(LNi + 1) = LN$(LNi): LnPtr = LNi'Bump up present LN$ comment
  449.     LN$(LNi) = a$: LNi = LNi + 1'Store feature name
  450.     nmp = nmp + 1: z = nmp
  451.     nmp = nmp + 1: x%(nmp) = 0: y%(nmp) = 0'nmp points to ending 0,0
  452.     RETURN
  453.  
  454. CanclF: nmp = nmp - 2: z = Kz
  455.     LNi = LNi - 1: LN$(LNi) = LN$(LNi + 1): RETURN
  456.  
  457. NewCenter: LatCen = cpy: LonCen = cpx: Changed = Changed + 1: GOTO CurDrwMap
  458.  
  459. MapRange: GOSUB BoxLine23: INPUT "Enter map range"; a$
  460.     IF VAL(a$) <> 0 THEN MapRng = VAL(a$)
  461.     Changed = Changed + 1: GOTO DrwMPaCur
  462.  
  463. AddPoint: x% = dx + (CUX - 320) / (KP * Hfac)
  464.     IF x% = 0 THEN BEEP: PRINT "X=0!!!": RETURN
  465.     nmp = nmp + 1: z = z + 1
  466.     FOR i = nmp TO z STEP -1
  467.         x%(i) = x%(i - 1): y%(i) = y%(i - 1)
  468.     NEXT
  469.     GOSUB MakePT
  470.     IF SavClr = 0 AND Redraw THEN GOTO DrawMap
  471.     LineColor = SavClr
  472.     s = z - 1: GOTO DP
  473.  
  474. MakePT: x%(z) = dx + (CUX - 320) / (KP * Hfac)
  475.     y%(z) = dy + (CUY - Ycen) / KP
  476.     Changed = Changed + 1
  477.     GOTO MapPoint
  478.  
  479. CurToPoint:
  480.     cpx = CDX - (x%(z) - dx) / ppdv
  481.     cpy = CDY - (y%(z) - dy) / (ppdv * Yfactr)
  482.     GOTO Cursor
  483.  
  484. Clr1Pts: FOR i = 1 TO nmp
  485.              IF x%(i) = 0 THEN
  486.                 IF x%(i + 1) = 0 THEN z = i: GOSUB DelZ:
  487.              END IF
  488.          NEXT i: BEEP
  489.          RETURN
  490.  
  491. DelPT: GOSUB DelZ
  492.     REM if 1st pt, it stays as 1st pt
  493.  
  494.     IF x%(z) = 0 THEN z = z - 1: REM if end pt, it stays as end
  495.     IF x%(z + 1) = 0 AND x%(z - 1) = 0 THEN 'It is LAST point
  496.        GOSUB Kline: LnPtr = LnPtr - 1       'So Kill Line
  497.        GOSUB DelZ                           'And Kiil it
  498.        z = z - 1: GOSUB DelZ: z = z - 1     'Kill 0,color
  499.     END IF                                  'and -1 to end point
  500.     IF B$ = CHR$(32) AND Redraw THEN GOSUB DrawMap ELSE GOSUB MapPoint
  501.     RETURN
  502.  
  503. DelZ: nmp = nmp - 1
  504.       FOR i = z TO nmp
  505.           x%(i) = x%(i + 1): y%(i) = y%(i + 1)
  506.       NEXT: Changed = Changed + 1: RETURN
  507.  
  508. NextLine: IF z >= nmp - 1 THEN z = nmp - 1: BEEP: RETURN
  509.     DO UNTIL x%(z) = 0: z = z + 1: LOOP
  510.     IF z < nmp - 1 THEN z = z + 1: LnPtr = LnPtr + 1
  511.     SavClr = 0: GOTO MapPoint
  512.  
  513. Previous: DO UNTIL z = 1 OR x%(z) = 0: z = z - 1: LOOP
  514.     IF z > 3 THEN z = z - 1: LnPtr = LnPtr - 1
  515.     SavClr = 0: GOTO MapPoint
  516.  
  517. KillF: GOSUB Find1st: REM Stop at Beginning (0) point of the feature to kill
  518.     ni = s' Now scan for next feature
  519.     DO UNTIL x%(ni) = 0: ni = ni + 1: LOOP
  520.     REM now move down rest of array to fill
  521.     DO UNTIL ni = nmp + 1
  522.        x%(s - 1) = x%(ni): y%(s - 1) = y%(ni)
  523.        s = s + 1: ni = ni + 1
  524.     LOOP
  525.     nmp = nmp - (ni - (s - 1)): y%(nmp) = 0
  526.     GOSUB Kline
  527.     GOTO DrawMap
  528.     
  529. Find1st: s = z: DO UNTIL x%(s - 1) = 0: s = s - 1: LOOP
  530.          REM z = Bi + 1
  531.          RETURN
  532.  
  533. ChgColr: GOSUB Find1st: GOSUB Rainbow: IF abort THEN RETURN
  534.          y%(s - 1) = SavClr: Changed = Changed + 1
  535.          LineColor = SavClr
  536.          GOSUB DP
  537.          RETURN
  538.  
  539.  
  540. Kline: FOR i = LnPtr TO LNi
  541.            LN$(i) = LN$(i + 1)
  542.        NEXT i
  543.        LNi = LNi - 1
  544.        RETURN
  545.  
  546. MapPoint:
  547.      IF z < 2 THEN z = 2: LnPtr = 1: BEEP: SavClr = 0
  548.      IF z > nmp - 1 THEN z = z - 1: BEEP: SavClr = 0
  549.      IF x%(z) = 0 THEN
  550.         IF a$ = "-" THEN
  551.              LnPtr = LnPtr - 1: z = z - 1
  552.         ELSE LnPtr = LnPtr + 1: z = z + 1
  553.         END IF: SavClr = 0
  554.      END IF
  555.      IF LnPtr < 0 THEN LnPtr = 0
  556.      IF Display$ = "MAP" THEN
  557.           LOCATE bln - 3, 1
  558.           PRINT "Fture#"; LnPtr; TAB(12); LEFT$(LN$(LnPtr) + "            ", 12);
  559.      END IF
  560. DrwMpPt: IF Display$ <> "MAP" THEN RETURN
  561.      IF JustCur THEN pc = 12 ELSE pc = 15
  562.      CIRCLE (Xtest, Ytest), 10, 0 'Erase old circle
  563.      Xtest = 320 + KP * (x%(z) - dx) * Hfac
  564.      Ytest = Ycen + KP * (y%(z) - dy) * Yfactr
  565.      IF Acenter AND (Xtest > 600 OR Xtest < 40 OR Ytest > 300 OR Ytest < 40) THEN
  566.         GOSUB CurToPoint: GOSUB CurDrwMap
  567.         Xtest = 320 + KP * (x%(z) - dx) * Hfac
  568.         Ytest = Ycen + KP * (y%(z) - dy) * Yfactr
  569.      END IF
  570.      CIRCLE (Xtest, Ytest), 10, pc
  571.      
  572.      LOCATE bln - 2, 1: PRINT "MapPt#"; z;
  573.      IF z > 999 THEN PRINT TAB(13); "val:";  ELSE PRINT TAB(12); "vals:";
  574.      PRINT TAB(17); x%(z); TAB(23); y%(z)
  575.      RETURN
  576.  
  577. AddLabel: nml = nml + 1
  578.      Mla(nml) = cpy: Mlo(nml) = cpx
  579.      GOSUB BoxLine23: INPUT "Enter Label Name"; a$: ML$(nml) = a$
  580.      GOSUB BoxLine23: INPUT "Begin displaying label at what range?"; a$
  581.      a = VAL(a$): IF a <> 0 THEN MLr(nml) = a:  ELSE MLr(nml) = 2048
  582.      Changed = Changed + 1: GOTO labels
  583.  
  584. BoxLine23: LOCATE bln - 2, 1: PRINT SPACE$(80); : LOCATE bln - 2, 1: RETURN
  585.  
  586. ErrorTrap: Fault = ERR: 'Error handling routine
  587.      IF ERR = 57 THEN PRINT "  I/O-error-User-logoff"; : RESUME
  588.      IF ERR = 69 THEN PRINT "  Comm-buffer-overflow"; : RESUME
  589.      IF ERR = 53 THEN PRINT "  file-"; F$; "-not-found": CLOSE : RESUME NEXT
  590.      IF ERR = 62 THEN RESUME NEXT
  591.      IF ERR = 64 THEN RESUME NEXT
  592.      IF ERR = 52 THEN RESUME NEXT
  593.      IF ERR = 55 THEN RESUME NEXT
  594.      IF ERR = 2 THEN PRINT "SYNTAX-error"
  595.      IF ERR = 70 THEN PRINT " WRITE PROTECTED!...": RESUME NEXT
  596.      IF ERR = 76 THEN PRINT "Wrong Path!": RESUME NEXT
  597.      IF ERR = 71 THEN PRINT "no disk!": RESUME NEXT
  598.      RESET
  599.      PRINT : PRINT "Error beyond repair. Number = "; ERR;
  600.      INPUT "Hit RETURN to return to DOS"; a$
  601.      SYSTEM
  602.  
  603. MapDIR: CLS : PRINT "MAP FILES DIRECTORY": PRINT
  604.      PRINT "To display MAP files, enter the path to your xxxxxxx.MAP files."
  605.      PRINT "For example, the default '\APRS\MAPS\*.MAP' will show all maps in the APRS"
  606.      PRINT "directory.  Similarly '*.map' will search your present directory."
  607.      PRINT "For any other path, enter the full file specification.": PRINT
  608.      F$ = "\aprs\MAPS\*.map"
  609.      PRINT "Enter Filespec for searching the DIRECTORY ("; F$; ")";
  610.      INPUT a$: IF a$ <> "" THEN F$ = a$
  611.      PRINT : PRINT : FILES F$
  612.      RETURN
  613.  
  614.  
  615. LoadMap: 'Maps are drawn to the default EGA resolution of 640 x 400 (350)
  616. Again: GOSUB BoxLine23
  617.       
  618.     INPUT " Enter map FILENAME, or NEW, or ? for a list, or Q to quit)"; a$
  619.     a$ = UCASE$(a$): IF a$ = "" THEN GOTO Again
  620.     IF a$ = "Q" THEN SYSTEM
  621.     IF a$ = "?" THEN GOSUB MapDIR: GOTO Again
  622.     IF a$ = "NEW" THEN Key$ = "NEW": GOSUB NewMap: RETURN
  623.     a = INSTR(3, a$, "."): IF a = 0 THEN a$ = a$ + ".MAP"
  624.     Strtime = TIMER
  625.     MapFile$ = a$: F$ = MapFile$: OPEN F$ FOR INPUT AS #3
  626.     IF Fault = 53 THEN Fault = 0: PRINT : CLOSE #3: GOTO Again
  627.     GOSUB BoxLine23: PRINT " Loading "; F$; "..."
  628.     INPUT #3, LATo: LINE INPUT #3, LATtext$
  629.     INPUT #3, LONo: LINE INPUT #3, LONtext$
  630.     INPUT #3, ppdv: LINE INPUT #3, VS$'Pixels per degree horiz
  631.     INPUT #3, LatCen: LINE INPUT #3, LatCen$
  632.     INPUT #3, LonCen: LINE INPUT #3, LonCen$
  633.     INPUT #3, MapRng: LINE INPUT #3, MapRng$
  634.     INPUT #3, MinRng: LINE INPUT #3, MR$
  635.     LINE INPUT #3, TextLine$ ' Line of comments or instrutcitons
  636.     IF TextLine$ = "Compressed" THEN Comp = -1 ELSE Comp = 0
  637.     IF LEFT$(TextLine$, 14) = "Map generated " THEN Redraw = 0
  638.     RS = 2 ^ INT(LOG(MapRng) / LOG(2))'Rng is intgr of VERTrng
  639.     i = 0: LNi = 0:
  640.     REM ON ERROR GOTO 0
  641.     DO WHILE NOT EOF(3)
  642.        i = i + 1
  643.        IF Comp THEN
  644.             LINE INPUT #3, a$
  645.             IF a$ = " 0,0" THEN
  646.                  x%(i) = 0: y = 0
  647.             ELSEIF a$ = " 0,-1" THEN x%(i) = 0: y = -1
  648.             ELSE 'abc where c = .xxxxyyy
  649.                  '          x = 16*a + xxxx  and  y = 8*b +yyy
  650.                  C$ = RIGHT$(a$, 1): B$ = MID$(a$, 2, 1): a$ = LEFT$(a$, 1)
  651.                  cx% = INT((ASC(C$) - 27) / 8): cy% = (ASC(C$) - 27) - cx% * 8
  652.                  x%(i) = 16 * (ASC(a$) - 27) + cx%
  653.                  y%(i) = 8 * (ASC(B$) - 27) + cy%
  654.             END IF
  655.        ELSE INPUT #3, x%(i), y: y%(i) = y * Yfactr
  656.        END IF
  657.        IF x%(i) = 0 AND NOT EOF(3) THEN ' Get line color & store with x=0
  658.           INPUT #3, y%(i): LNi = LNi + 1: LINE INPUT #3, LN$(LNi)' Save line name
  659.           IF y = -1 THEN GOSUB LoadLabels ' All labels listed at end of file
  660.        END IF
  661.     LOOP: nmp = i  'nmp points to 0,-1 that ends all data (but the value
  662.                    'of X% and y% are 0,0 until file is saved.
  663.     CDY = LatCen: CDX = LonCen'Center display on ORIGIN
  664.     cpx = CDX: cpy = CDY 'Cursor Posn to Center of Display
  665.     z = 2: LnPtr = 1: REM start at first point and first line segment
  666.     CLOSE #3:     REM first X% value is map color.  2nd val is 1st pt
  667.     LdTime = TIMER - Strtime
  668.     RETURN
  669.  
  670.  
  671. LoadLabels: k = 0
  672.      DO WHILE NOT EOF(3)
  673.         k = k + 1: INPUT #3, ML$(k), Mla(k), Mlo(k), MLr(k)
  674.      LOOP
  675.      IF Mla(k) = 0 OR Mlo(k) = 0 THEN nml = k - 1 ELSE nml = k
  676.      RETURN
  677.        
  678. SaveMap: GOSUB BoxLine23
  679.    PRINT "Enter file name to save if other than "; MapFile$;
  680.    INPUT a$
  681.    IF a$ <> "" THEN
  682.       IF INSTR(a$, ".") = 0 THEN a$ = a$ + ".map"
  683.       MapFile$ = a$
  684.    END IF
  685.    F$ = MapFile$
  686.    GOSUB BoxLine23: PRINT "Saving map to file named "; F$; " ..."
  687.    OPEN F$ FOR OUTPUT AS #4
  688.    IF Fault = 70 OR Fault = 71 THEN Fault = 0: CLOSE #4: GOTO SaveMap
  689.    PRINT #4, LATo; ","; LATtext$
  690.    PRINT #4, LONo; ","; LONtext$
  691.    PRINT #4, ppdv; ","; VS$
  692.    PRINT #4, LatCen; ","; LatCen$
  693.    PRINT #4, LonCen; ","; LonCen$
  694.    PRINT #4, MapRng; ","; MapRng$
  695.    PRINT #4, MinRng; ","; MR$
  696.    j = 1: abort = 0
  697.    IF Comp THEN
  698.       REM ON ERROR GOTO 0
  699.       PRINT #4, "Compressed"
  700.       'abc where c = .xxxxyyy
  701.       '          x = 16*a + xxxx  and  y = 8*b +yyy
  702.       FOR i = 1 TO nmp
  703.           IF x%(i) <> 0 THEN 'WRITE #4, x%(i), INT((y%(i) / Yfactr) + .5)
  704.              a% = INT(x%(i) / 16): cx% = x%(i) - a% * 16
  705.              B% = INT(y%(i) / 8): cy% = y%(i) - B% * 8
  706.              C% = 8 * cx% + cy%
  707.              PRINT #4, CHR$(a% + 27); CHR$(B% + 27); CHR$(C% + 27)
  708.           END IF
  709.           IF i = nmp THEN PRINT #4, " 0,-1"
  710.           IF x%(i) = 0 AND i <> nmp THEN
  711.              PRINT #4, " 0,0"
  712.              PRINT #4, y%(i); ","; LN$(j): j = j + 1
  713.           END IF
  714.       NEXT i
  715.    ELSE
  716.       IF TextLine$ <> "Compressed" THEN PRINT #4, TextLine$ ELSE PRINT #4, "ASCII"
  717.       FOR i = 1 TO nmp
  718.           IF x%(i) <> 0 THEN WRITE #4, x%(i), INT((y%(i) / Yfactr) + .5)
  719.           IF i = nmp THEN PRINT #4, " 0,-1"  'Used to be AND X%(i)=0
  720.           IF x%(i) = 0 AND i <> nmp THEN
  721.              PRINT #4, "0,0"
  722.              PRINT #4, y%(i); ","; LN$(j): j = j + 1
  723.           END IF
  724.       NEXT i
  725.    END IF
  726.    PRINT #4, "0,"; LN$(LNi)
  727.    x = 4
  728.    IF ppdv > 60 THEN x = 5
  729.    IF ppdv > 240 THEN x = 6
  730.    IF ppdv > 900 THEN x = 7
  731.    IF ppdv > 2400 THEN x = 8
  732.    FOR k = 1 TO nml
  733.        PRINT #4, ML$(k); ",";
  734.        PRINT #4, LEFT$(LTRIM$(STR$(Mla(k))), x); ",";
  735.        PRINT #4, LEFT$(LTRIM$(STR$(Mlo(k))), x + 1); ",";
  736.        PRINT #4, LTRIM$(STR$(MLr(k)))
  737.    NEXT k: CLOSE #4: LOCATE bln - 1, 1:
  738.    Changed = 0
  739.    IF nmp > MaxNumPoints OR nml > MaxNumLABELS THEN
  740.       CLS : LOCATE 9, 29: PRINT "CAUTION!": PRINT : PRINT
  741.       IF nmp > MaxNumPoints THEN
  742.          PRINT "            The number of points,"; nmp; "is greater than"; MaxNumPoints
  743.       END IF
  744.       IF nml > MaxNumLABELS THEN
  745.          PRINT "            The number of LABELS,"; nml; "is greater than"; MaxNumLABELS
  746.       END IF
  747.       LOCATE 18, 12
  748.       PRINT " Therefore this map will not work with APRS (yet) "
  749.       LOCATE bln - 2, 1: INPUT "HIT Enter to continue..."; a$
  750.    END IF
  751.    GOTO DrwMPaCur
  752.  
  753. CurDrwMap: CDX = cpx: CDY = cpy: GOTO DrawMap: REM Re-center at CURSOR location
  754.  
  755. DrwMPaCur: cpx = CDX: cpy = CDY: GOSUB DrawMap
  756.            REM After drawing map, Put cursor at center
  757.            RETURN
  758.  
  759. DrawMap: IF USGS THEN RETURN
  760.     SCREEN , , 1, 1: Scrn = 1: CLS : CUX = 0
  761.     Display$ = "MAP"
  762.     COLOR 15, 0
  763.     WIDTH 80, GBLn: bln = GBLn
  764.    'Draw to range scale RS and center display CDX and CDY
  765.   
  766.    DO WHILE RS < 320 / ppdv: RS = RS * 2: LOOP
  767.    IF RS > 8192 THEN RS = 8192
  768.    KP = 100 * 100 / (RS * ppdv)' this is kinda arbitrary..??
  769.    Sfac = 50 * 200 / RS
  770.  
  771.    Lfac = COS(CDY / 57.296)
  772.    Hfac = (640 / 350) * (3 / 4) * Lfac
  773.    dx = ppdv * (LONo - CDX)
  774.    dy = ppdv * (LATo - CDY)
  775.         
  776.    LOCATE 1, 2: PRINT "Redrawing Map"
  777.    REM first put ORIGIN and 1024 by 75% of 2048 BOX (and CENTER) on the map
  778.    x0 = 320 - (dx * KP * Hfac): y0 = Ycen - (dy * KP * Yfactr)
  779.    xm = 320 + (1512 - dx) * KP * Hfac: ym = Ycen + (1024 - dy) * KP * Yfactr
  780.    REM 1512 is 3/4ths of 2048
  781.    LINE (x0, y0)-(xm, ym), 14, B
  782.    CMX = 320 + Sfac * (CDX - LonCen) * Hfac'new
  783.    CMY = Ycen + Sfac * (CDY - LatCen) * Yfactr
  784.    LINE (CMX - 27, CMY)-(CMX + 27, CMY), 15
  785.    LINE (CMX, CMY - 20)-(CMX, CMY + 20), 15
  786.    CIRCLE (CMX, CMY), 10, 15
  787.    CIRCLE (320 - dx * KP * Hfac, Ycen - KP * dy), 12, 14
  788.    s = 0: GOSUB MapPoint: REM Redraw MapPoint
  789.    StrtPt = 0
  790.    
  791. DP: 'Speeded this up by 33% but is harder to follow
  792.     HfacK = KP * Hfac
  793.     YfactrK = KP * Yfactr
  794.     FOR i = s TO nmp - 1
  795.        x = 320 + (x%(i) - dx) * HfacK
  796.        y = Ycen + (y%(i) - dy) * YfactrK
  797.        X1 = 320 + (x%(i + 1) - dx) * HfacK
  798.        Y1 = Ycen + (y%(i + 1) - dy) * YfactrK
  799.        IF StrtPt THEN
  800.           'x = 320 + (x%(i) - dx) * HfacK
  801.           'y = Ycen + (y%(i) - dy) * YfactrK
  802.           PSET (x, y), LineColor
  803.           CIRCLE (x, y), 2, 9: StrtPt = 0
  804.           LINE -(X1, Y1), LineColor, , dots
  805.        ELSE
  806.           IF x%(i + 1) <> 0 THEN
  807.              LINE -(X1, Y1), LineColor, , dots
  808.           ELSE
  809.              CIRCLE (x, y), 3, 10: StrtPt = -1
  810.              LineColor = y%(i + 1): i = i + 1
  811.              IF LineColor = 8 THEN dots = &HF0F0 ELSE dots = &HFFFF
  812.              IF LineColor = 0 OR LineColor = 15 THEN dots = &HCCCC: LineColor = 15
  813.              x = 320 + (x%(i + 1) - dx) * HfacK
  814.              y = Ycen + (y%(i + 1) - dy) * YfactrK
  815.              IF Display$ = "SHOW" AND LineColor > 8 THEN LineColor = LineColor - 8
  816.           END IF
  817.        END IF
  818.        IF i = z THEN SavClr = LineColor
  819.    NEXT i
  820.    GOSUB Cursor
  821.    GOSUB Redraw
  822.    GOSUB DrawHist: REM draw GPS history track
  823.    IF Key$ <> CHR$(0) + CHR$(30) THEN GOSUB ShowBox
  824.    IF Display$ = "SHOW" THEN
  825.       GOSUB ShowMaps
  826.    ELSE
  827.       LOCATE bln, 1: PRINT "Use +/- to move MAPpoint.  N/P for Next/Previous Feature.  H for HELP!.";
  828.       LOCATE 1, 71 ' was 61
  829.       PRINT "PTS"; nmp ' ; "= "; INT((nmp / MaxNumPoints) * 100); "%";
  830.       LOCATE 2, 71 ' was 61
  831.       PRINT "LBLS "; nml '; "= "; INT((nml / MaxNumLABELS) * 100); "%";
  832.       LOCATE 3, 71: PRINT "PPD"; ppdv
  833.       LOCATE 4, 71: PRINT "Rng"; LEFT$(STR$(MapRng), 5)
  834.    END IF
  835.  
  836. labels:
  837.    IF Labls THEN
  838.       FOR i = 1 TO nml ' Now plot labels on map
  839.       IF RS <= MLr(i) OR Key$ = "S" THEN
  840.          LET x = 320 + Sfac * (CDX - Mlo(i)) * Hfac'new
  841.          LET y = Ycen + Sfac * (CDY - Mla(i)) * Yfactr
  842.          CIRCLE (x, y), 1, 14
  843.          IF y > Cfactr * Yfactr AND y < bln * Cfactr * Yfactr AND x > 8 * (LEN(ML$(i)) + 1) AND x < 632 THEN
  844.             LOCATE y / (Cfactr * Yfactr), (x / 8) - LEN(ML$(i)): PRINT ML$(i);
  845.          END IF
  846.       END IF
  847.       NEXT i
  848.    END IF
  849.    GOSUB ShowMap
  850.    RETURN
  851.          
  852. ShowMap: REM this shows the map boarder of the loaded map
  853.     x = 320 + KP * (CDX - LonCen) * ppdv * Hfac'new
  854.     y = Ycen + KP * (CDY - LatCen) * ppdv * Yfactr
  855.       by = MapRng * Sfac * Yfactr / 60
  856.       bx = by * 640 / (400 * Yfactr) * Lfac'old
  857.       C = 15
  858.     LINE (x - bx, y - by)-(x + bx, y + by), C, B
  859.     RETURN
  860.  
  861. Cursor: JustCur = 0: IF pc = 12 THEN GOSUB DrwMpPt
  862.      REM circle(CUX, CUY), 4, 0
  863.      IF CUX > 4 AND CUY > 3 AND CUX < 635 AND CUY < 343 * Yfactr THEN PUT (CUX - 4, CUY - 3), Crsr, XOR
  864.      CUX = 320 + Sfac * (CDX - cpx) * Hfac'new
  865.      CUY = Ycen + Sfac * (CDY - cpy) * Yfactr
  866.      REM CIRCLE (CUX, CUY), 4, 14
  867.      IF CUX > 4 AND CUY > 3 AND CUX < 635 AND CUY < 343 * Yfactr THEN PUT (CUX - 4, CUY - 3), Crsr, XOR
  868.      IF cpx > 0 THEN
  869.           x = INT(cpx): xm = (cpx - x) * 60
  870.      ELSE x = INT(-cpx): xm = -(cpx + x) * 60
  871.      END IF
  872.      IF cpy > 0 THEN
  873.           y = INT(cpy): ym = (cpy - y) * 60
  874.      ELSE y = INT(-cpy): ym = -(cpy + y) * 60
  875.      END IF
  876.      x$ = RIGHT$(STR$(x), 3) + " "
  877.      LOCATE 1, 2: PRINT "RNG"; RIGHT$("   " + STR$(RS), 4) + " Miles"
  878.      LOCATE 2, 2: PRINT "LAT "; y; MID$(STR$(ym) + "   ", 2, 5)
  879.      LOCATE 3, 2: PRINT "LON "; x$; MID$(STR$(xm) + "   ", 2, 5)
  880.      
  881.      LOCATE bln - 1, 1: PRINT "Cursor coordnts:"; TAB(17);
  882.      PRINT INT(.5 + dx + (CUX - 320) / (KP * Hfac)); TAB(23); INT(.5 + dy + (CUY - Ycen) / KP);
  883.      REM LOCATE BLn-1, 55: PRINT "Degrees: ";
  884.      REM PRINT LEFT$(STR$(CPY) + " ", 7); LEFT$(STR$(CPX) + "   ", 7);
  885.      LOCATE 1, 16: PRINT "Decimal";
  886.      LOCATE 2, 15: PRINT LEFT$(STR$(cpy) + " ", 8);
  887.      LOCATE 3, 15: PRINT LEFT$(STR$(cpx) + "   ", 8);
  888.      LINE (0, 0)-(178, 3 * Cfactr * Yfactr), 12, B'Box around it
  889.      LINE (0, 0)-(116, 3 * Cfactr * Yfactr), 12, B'Box around it
  890.      LET a$ = "": LET B$ = "": RETURN
  891.  
  892. HELP: SCREEN , , 0, 0: Scrn = 0: CLS
  893.       REM WIDTH 80, 25: BLn = 25
  894.       COLOR 15, 1
  895.       LINE (0, 0)-(639, 18 * Yfactr), 14, BF
  896.       LOCATE 1, 20: PRINT " MAPFIX.bas HELP SCREEN Ver "; Ver$
  897.       LOCATE 3, 1
  898.       PRINT
  899.       PRINT " The ORIGIN, CENTER and BORDER are shown (but only the CENTER and RANGE in "
  900.       PRINT " MAPLIST.apr are actually used by APRS.  Labels are right justified to the point"
  901.       PRINT " just after the last letter.  CALLS & OBJECT names will be left justified."
  902.       PRINT ""
  903.       PRINT
  904.       PRINT " OPERATIONS          MAP FUNCTIONS         POINT FUNCTIONS     LABEL COMMANDS"
  905.       PRINT
  906.       PRINT " H - HELP SCREENS    @C- Change CENTER     @A - ADD point      S - SHOW labels"
  907.       PRINT " D - map DIRECTORY   @R- set map RANGE     @D - DELETE point  @L - add a LABEL"
  908.       PRINT "^S - SAVE MAP!!!     @T- TRIM border Pts   @K - Kill feature   L - LABELS off"
  909.       PRINT "^L - LOAD NEW map    @I- IMPORT from map   @M - MOVE point     K - KILL a Label"
  910.       PRINT "@G - GPS Overlay     ^O- OVERLAY a map     @N - NEW feature"
  911.       PRINT " C = CLEAR Sngle Pts  M- show MAPLIST      ^C - CHANGE Color"; ""
  912.       PRINT " Q - QUIT             O- OTHER map bordrs       "
  913.       PRINT ""
  914.       PRINT
  915.       PRINT " DISPLAY COMMANDS     POINTER MOVEMENTS   USGS CD ROM CMDS  DIGITIZER/MOUSE"
  916.       PRINT
  917.       PRINT " SPACE to draw map    N- Next Feature     B- BOX PPD area   @O- OPEN COMMS"
  918.       PRINT " ARROWS  (shft)       P- Prev Feature     U- USGS overlay   @B- BEGIN new line"
  919.       PRINT " PgUP/DN (ctrl)       G- Go to Pointer    T- Test Scruncher F1- MOVE cursor"
  920.       PRINT " HOME to Cursor       F- Find point      @S- SCRUNCH file        vice ADD pt"
  921.       PRINT " HOME(shft) to Orign ^F- Find another    @U- USGS Load!     F3,4,6,7,8,10,"
  922.       PRINT " END to map center    R- RESET to 1st Pt @J- JOIN lines     F1,2shftd=11,12"
  923.       PRINT "                     ^R- REDRAW on/off                        HOTKYS begin Ln"
  924.       PRINT "                     ^A- AUTOCENTER on/off                  F9- Init Mouse"
  925.       PRINT "                     +/- move Pointer"
  926.       PRINT
  927.       PRINT " F1 Temporarily re-defines Digitizer click to move cursor vice ADD point"
  928.       PRINT " F2 Convert Origin to new point and/or Pix/per/deg"
  929.       PRINT " F3 (SHFT) Save mapfile in COMPRESSED format"
  930.       PRINT " F4 (SHFT) Save mapfile in ASCII format"
  931.       PRINT " F5        Slow GPS overlay so U can see chronologically"
  932.       PRINT " F8 (shft) Adds MARKER to map.  Useful for re-calibrating MOUSE"
  933.       PRINT " F9        Init Mouse (Msoft serial mouse only)"
  934.       PRINT
  935.       PRINT : REM LINE (0, 190 * Yfactr)-(639, 190 * Yfactr), 15
  936.               
  937.       IF Display$ <> "HELP" THEN
  938.        LOCATE bln, 1
  939.        PRINT " HIT H AGAIN FOR MORE HELP SCREENS, OR SPACE BAR FOR MAP...";
  940.       END IF
  941.       Display$ = "HELP"
  942.       LINE (0, 0)-(634, 348 * Yfactr), 15, B
  943.       RETURN
  944.  
  945. LdMapLst: GOSUB BoxLine23: INPUT "FileSpec for MAPLIST.apr if not \APRS\MAPLIST.APR"; a$
  946.     IF a$ <> "" THEN F$ = a$ ELSE F$ = "\aprs\Maplist.apr"
  947.     OPEN F$ FOR INPUT AS #3: IF Fault <> 0 THEN RETURN
  948.     i = 1: NumGood = 0
  949.     INPUT #3, DfltY: LINE INPUT #3, a$
  950.     INPUT #3, DfltX: LINE INPUT #3, a$
  951.     INPUT #3, BestRng: LINE INPUT #3, a$: DfltR = BestRng
  952.     INPUT #3, GMToffset: LINE INPUT #3, a$
  953.     WHILE a$ <> "* BEGIN *": LINE INPUT #3, a$: WEND ' Skip comment block
  954.     WHILE NOT EOF(3) AND i <= UBOUND(MapName$)
  955.        INPUT #3, MapName$(i), LatCen(i), LonCen(i), MapMax(i)
  956.        LINE INPUT #3, Comment$(i)
  957.        IF LEFT$(MapName$(i), 1) <> "*" THEN NumGood = NumGood + 1
  958.        NumMaps = i: i = i + 1
  959.     WEND: CLOSE #3
  960.     IF NumGood >= MaxNumMAPS - 1 THEN
  961.        CLS : LOCATE 2, 5
  962.        PRINT "WARNING: Too many ACTIVE MAPS (more than"; MaxNumMAPS; ") in MAPLIST.map file for APRS"
  963.        LOCATE 4, 10: PRINT "Use EDITOR to suppress mapnames with an (*) that you don't need."
  964.        PRINT : PRINT : PRINT : MpLstLdd = -1
  965.        INPUT "HIT RETURN to continue"; a$
  966.     END IF
  967.     RETURN
  968.  
  969. ListMAPlist: IF NOT MpLstLdd THEN GOSUB LdMapLst
  970.    GOSUB ListHeader
  971.    FOR i = 1 TO NumMaps
  972.        IF i / 19 = INT(i / 19) THEN
  973.           LOCATE bln, 1: PRINT "HIT RETURN to continue"; : INPUT a$
  974.           GOSUB ListHeader
  975.        END IF
  976.        PRINT MapName$(i); TAB(14);
  977.        PRINT INT(LatCen(i) * 100) / 100; TAB(21); INT(LonCen(i) * 100) / 100;
  978.        PRINT TAB(29); MapMax(i); TAB(36); LEFT$(LTRIM$(Comment$(i)), 43)
  979.    NEXT i
  980.    
  981.    LOCATE bln, 1: PRINT "LIST COMPLETE. CONTINUE WITH NEXT MAPFIX COMMAND...";
  982.    RETURN
  983.  
  984. ListHeader: CLS
  985.    PRINT "MAPS in MAPLIST.map (*MAPS are suppressed)     [For now, use EDITOR to modify]"
  986.    PRINT :
  987.    PRINT "MAP NAME      LATcen LONcen  RANGE COmments"
  988.    PRINT "------------  ------ ------- ----- -------------------------------------------"
  989.    RETURN
  990.  
  991. DrwAndShow: IF NOT MpLstLdd THEN GOSUB LdMapLst
  992.             Display$ = "SHOW": GOSUB DrwMPaCur
  993.  
  994. ShowMaps: IF MapSize > RS / 2 THEN MapSize = RS / 2
  995.     LOCATE bln, 1: PRINT " Drawing all maps >"; MapSize;
  996.     PRINT "mi.  F3 to see smaller, F4 for bigger, SPACE to cancel.";
  997.     LINE (0, 336 * Yfactr)-(639, 349 * Yfactr), 14, B
  998.     FOR i = 1 TO NumMaps
  999.    
  1000.     x = 320 + Sfac * (CDX - LonCen(i)) * Hfac
  1001.     y = Ycen + Sfac * (CDY - LatCen(i)) * Yfactr
  1002.       dy = MapMax(i) * Sfac * Yfactr / 60
  1003.       dx = dy * 640 / (400 * Yfactr) * Lfac
  1004.       C = 15
  1005.       IF MapMax(i) > 32 THEN C = 14
  1006.       IF MapMax(i) > 64 THEN C = 12
  1007.       IF MapMax(i) > 128 THEN C = 11
  1008.       IF MapMax(i) > 256 THEN C = 13
  1009.           
  1010.     IF MapMax(i) > MapSize THEN
  1011.        LINE (x - dx, y - dy)-(x + dx, y + dy), C, B
  1012.        IF y + dy > Cfactr * Yfactr AND y + dy < bln * Cfactr * Yfactr THEN
  1013.           IF x + dx > 8 * (LEN(MapName$(i)) + 1) AND x + dx < 632 THEN
  1014.              LOCATE (y + dy) / (Cfactr * Yfactr), (x + dx) / 8 - LEN(MapName$(i))
  1015.              IF MapMax(i) > RS / 4 THEN PRINT MapName$(i);
  1016.           END IF
  1017.        END IF
  1018.     END IF
  1019.     NEXT i: RETURN
  1020.         
  1021. REM Next routines added by W7KKE for overlyaying GPS track histoiries
  1022.  
  1023. Hstdir: CLS : PRINT "HISTORY FILES DIRECTORY": PRINT
  1024.     PRINT "To display HST files, enter the path to your xxxxxxx.HST files."
  1025.     PRINT "For example, the default '\APRS\*.HST' will show all maps in the APRS"
  1026.     PRINT "directory.  Similarly '*.hst' will search your present QBasic directory."
  1027.     PRINT "For any other path, enter the full file specification.": PRINT
  1028.          
  1029.     PRINT "Enter Filespec for searching the DIRECTORY (\aprs\*.hst)";
  1030.     INPUT F$: IF F$ = "" THEN F$ = "\aprs\*.hst"
  1031.     IF INSTR(F$, ".") = 0 THEN F$ = F$ + ".HST"
  1032.     PRINT : PRINT : FILES F$
  1033.     RETURN
  1034.  
  1035. LoadHst: GOSUB BoxLine23
  1036.     INPUT "Which history file to load (ENTER for list, Q to quit)"; F$
  1037.     IF UCASE$(F$) = "Q" THEN RETURN
  1038.     IF F$ = "" THEN GOSUB Hstdir: GOTO LoadHst
  1039.     a = INSTR(3, F$, "."): IF a = 0 THEN F$ = F$ + ".hst"
  1040.     Fault = 0: F$ = UCASE$(F$): OPEN F$ FOR INPUT AS #3
  1041.    
  1042.     IF Fault = 53 OR Fault = 62 THEN Fault = 0: RETURN
  1043.     GOSUB BoxLine23: PRINT "Loading track history from "; F$
  1044.       
  1045.     DO WHILE NOT EOF(3)
  1046.        i = i + 1
  1047.        INPUT #3, a$
  1048.        HLAT(i) = VAL(MID$(a$, 26, 2)) + (VAL(MID$(a$, 28, 5)) / 60)
  1049.        HLONG(i) = VAL(MID$(a$, 35, 3)) + (VAL(MID$(a$, 38, 5)) / 60)
  1050.        IF MID$(a$, 33, 1) = "S" THEN HLAT(i) = -HLAT(i)
  1051.        IF MID$(a$, 43, 1) = "E" THEN HLONG(i) = -HLONG(i)
  1052.        maxhist = i
  1053.      LOOP
  1054.      CLOSE #3: Histloaded = -1
  1055.      GOSUB BoxLine23: PRINT "File loading is complete.  GPS data is plotted."
  1056.      REM fall through...
  1057.  
  1058. DrawHist:  'put history track on map
  1059.      IF Histloaded THEN
  1060.         size = 3: IF RS < 2 THEN size = size * 2 / RS
  1061.         FOR i = 1 TO maxhist
  1062.             HMX = 320 + KP * (CDX - HLONG(i)) * ppdv * Hfac'new
  1063.             HMY = Ycen + KP * (CDY - HLAT(i)) * ppdv * Yfactr
  1064.             CIRCLE (HMX, HMY), size, 13
  1065.             IF Slower THEN FOR zz = 1 TO 1500: NEXT zz
  1066.         NEXT i
  1067.      END IF
  1068.      RETURN
  1069.  
  1070. NewMap: CLS : PRINT "BEGINNING A NEW MAP FROM SCRATCH...": PRINT
  1071.    PRINT "All points in an APRS map are measured to the right and down from an origin."
  1072.    PRINT
  1073.    PRINT
  1074.    INPUT "Enter the LATITUDE  of the ORIGIN in degrees , minutes (DD, mm.xx)"; LATo, LAm
  1075.    PRINT
  1076.    INPUT "Enter the LONGITUDE of the ORIGIN in degrees , minutes (DDD, mm.xx)"; LONo, LOm
  1077.    LATo = LATo + SGN(LATo) * LAm / 60
  1078.    LONo = LONo + SGN(LONo) * LOm / 60
  1079.    PRINT
  1080.    PRINT
  1081.    PRINT
  1082.    PRINT "Choose the number of pixels per degree to set the map scale:"
  1083.    PRINT
  1084.    PRINT "Approximate size              Range from center  Resolution Pixels/Deg"
  1085.    PRINT "----------------              -----------------  ---------- ----------"
  1086.    PRINT "Typical state                        128 mi       400 yds      240"
  1087.    PRINT "Several County region                 64 mi       200 yds      450"
  1088.    PRINT "Typical VHF range                     32 mi       100 yds      900"
  1089.    PRINT "Big metro area     1:100,000 scale    16 mi       160 ft      1800"
  1090.    PRINT "Four 7.5 min maps                      8 mi        80 ft      3600"
  1091.    PRINT "One 7.5 min map    1: 24,000 scale     4 mi        40 ft      7200"
  1092.    PRINT ""
  1093.    INPUT "Enter desired Pixels/Deg"; ppdB
  1094.    IF ppdB = 0 THEN GOTO NewMap
  1095.    REM In following lines, 500 is half of 999 (maximum nominal value for pts)
  1096.    LatCen = LATo - (500 * Yfactr / ppdB)
  1097.    LonCen = LONo - (756 / ppdB) 'had been 500. Now .75 of 2048 % 2
  1098.    GOSUB StartMap: ppdv = ppdB
  1099.    CLS : PRINT "YOU ARE NOW READY TO DRAW A NEW MAP...": PRINT : PRINT
  1100.    PRINT
  1101.    PRINT "The YELLOW box shows the maximum values permitted for this ORIGIN and SCALE."
  1102.    PRINT
  1103.    PRINT "The PURPLE box shows the same limits, but moves with the current map center."
  1104.    PRINT
  1105.    PRINT "The WHITE  box shows the current map range to be entered into MAPLIST.xxx."
  1106.    PRINT
  1107.    PRINT
  1108.    PRINT "USING CURSOR WITHOUT DIGITIZER:  Move coursor to starting point for a NEW"
  1109.    PRINT "feature and hit ALT-N.  Then enter new feature name (for reference purposes)"
  1110.    PRINT "and continue moving cursor to the next point and hit ALT-A to add more points."
  1111.    PRINT "Continue in this fashion, using ALT-N whenever you want to begin a NEW feature."
  1112.    PRINT
  1113.    PRINT
  1114.    PRINT "USING A DIGITIZER:  First, use ALT-O once to OPEN the digitizer COM port.  Then"
  1115.    PRINT "use ALT-B to BEGIN each new map feature.  Enter the name and color of the new"
  1116.    PRINT "feature.  Then use the digitizer mouse to add more points."
  1117.    PRINT : PRINT : PRINT
  1118.    PRINT "Add LABELS on the map at the current cursor location by using the ALT-L key. "
  1119.    PRINT
  1120.    PRINT
  1121.    PRINT "When you are finished, be sure to SAVE the map using the CTRL-S command..."
  1122.    PRINT : PRINT : PRINT
  1123.    PRINT "FOR HELP, REMEMBER THE  H  KEY!"
  1124.    PRINT : PRINT : PRINT "Hit ENTER to proceed..."; : INPUT a$
  1125.    RETURN
  1126.  
  1127. StartMap: REM This called by NEW and in middle of USGS build
  1128.    LatCen$ = "LAT of CENTER": LonCen$ = "LON of CENTER"
  1129.    MapRng = 60 * 500 * Yfactr / ppdB: REM 500 is half of full map size
  1130.    MapRng$ = "Map range from center"
  1131.    VS$ = "Pixels per degree"
  1132.    MinRng = 1: MR$ = "Reserved"
  1133.    TextLine$ = "NEW Map generated by MAPFIX.bas routine..."
  1134.    IF Key$ = "NEW" THEN RS = 2 ^ INT(LOG(MapRng) / LOG(2))'Rng is intgr of VERTrng
  1135.    CDX = LonCen: CDY = LatCen: cpx = CDX: cpy = CDY
  1136.    nmp = 1: nml = 0
  1137.    LNi = 1: LN$(1) = "Labels begin here"
  1138.    RETURN
  1139.  
  1140.  
  1141. DigiInit:
  1142.    CLS : PRINT : Digitizer = -1: MpLstLdd = 0
  1143.    PRINT "DIGITIZER INITIALIZATION:"
  1144.    PRINT
  1145.    PRINT "This routine will replace many CURSOR functions with the Digitizer's MOUSE."
  1146.    PRINT "Assuming your digitizer can output an X,Y,C format."
  1147.    PRINT
  1148.    PRINT "Only Mercator projection charts will give absolutely accurate results.  Other"
  1149.    PRINT "types, Lambert Conformal, Conical, etc will induce distortions."
  1150.    PRINT
  1151.    PRINT : PRINT
  1152.    PRINT "The digitizr should operate at 9600,N,8,1 in POINT mode with 200 LPI resolution."
  1153.    PRINT "The FORMAT outputs X,Y,C values separated by commas (C is for button pressed."
  1154.    PRINT
  1155.    PRINT "Set up the digitizer according to your model's instructions.  For the model"
  1156.    PRINT "23360, use the drawing board menu by pressing the mouse button 0 on the SETUP"
  1157.    PRINT "label so that the LED is ON.  Then move the mouse to each other label and"
  1158.    PRINT "use the 0 button to toggle the value ON or off as follows:"
  1159.    PRINT
  1160.    PRINT "POINT is ON                             PARITY 7/8 and 1 are ON "
  1161.    PRINT "BAUDRATE 3 is ON                        FORMAT is ON ON off ON"
  1162.    PRINT "DATA RATE doesn't matter                RESOLUTION off off ON"
  1163.    PRINT : PRINT
  1164.    INPUT "Is DIGITIZER connected to COM1 or COM2 (1)"; a$
  1165.    IF a$ <> "2" THEN a$ = "COM1" ELSE a$ = "COM2"
  1166.    INPUT "9600 baud.  Is digitizer set for 7 or 8 bits (8)"; B$
  1167.    IF B$ = "7" THEN B$ = "E,7" ELSE B$ = "N,8"
  1168.    Port$ = a$ + ":9600," + B$ + ",1,cs0,ds0,cd0"
  1169.    OPEN Port$ FOR RANDOM AS #1
  1170.    
  1171.  
  1172.    CLS : PRINT "FIRST LETS TEST THE DIGITIZER, AND GET THE MAP ON STRAIGHT.": PRINT
  1173.    PRINT "Move your mouse (or pen) and hit the 0 button (or touch tablet) to see if the"
  1174.    PRINT "digitizer is outputting in the desired format.  While doing this, it is a good"
  1175.    PRINT "idea to verify that your map is on straight.  The Y values from the mouse"
  1176.    PRINT "should give the same values for the same LATITUDE line on both the right and"
  1177.    PRINT "left edges of the map.  If not, move your map to get it horizontal."
  1178.    PRINT
  1179.    PRINT "OUTPUT FORMAT:"
  1180.    PRINT
  1181.    PRINT "XXXXX,YYYYY,APn (Only the X and Y values are used (4 or 5 digits is ok)"
  1182.    PRINT "                (APn can be anything.  But if you press the 4th key on a 4"
  1183.    PRINT "                (button mouse, this will be a 3 and will only move cursor,"
  1184.    PRINT "                (and NOT add a point."
  1185.    PRINT
  1186.    LOCATE bln, 1: PRINT "Hit ENTER and press 0 button on mouse to continue...";
  1187.    LOCATE 13, 1
  1188.    DO UNTIL INKEY$ <> "": LINE INPUT #1, a$: PRINT a$: LOOP
  1189.   
  1190.    CLS : PRINT
  1191.    PRINT "NEXT YOU MUST ESTABLISH THE SCALE OF YOUR DIGITIZER."
  1192.    PRINT
  1193.    PRINT "The scale is established by two points, the first near the"
  1194.    PRINT "upper left corner, the second near the lower right corner."
  1195.    PRINT
  1196.    PRINT "To get the best accuracy on maps not exactly MERCATOR, use points within the "
  1197.    PRINT "area where you are working, not on the extreme corners.  IE:  choose points"
  1198.    PRINT "that are in the center of the upper left quadrant and the lower right quadrant."
  1199.    PRINT
  1200.    PRINT "To establish the upper left reference point:"
  1201.    INPUT "     Enter lat  (deg,min)"; LATref1, M
  1202.    LATref1 = LATref1 + SGN(LATref1) * M / 60
  1203.    INPUT "     Enter long (deg,min)"; LONref1, M
  1204.    LONref1 = LONref1 + SGN(LONref1) * M / 60
  1205.    PRINT
  1206.  
  1207.    PRINT "Place the mouse on the upper left point and press the 0 button."
  1208.    LINE INPUT #1, a$: SOUND 150, 3
  1209.         digix1 = 5000 - VAL(LEFT$(a$, 5))
  1210.         digiy1 = VAL(MID$(a$, 7, 5))
  1211.         PRINT "Digitizer reads "; digix1, digiy1; " for this point.": PRINT
  1212.  
  1213.    PRINT "NOW Establish the lower right reference point:"
  1214.    INPUT "      Enter lat  (deg,min)"; LATref2, M
  1215.    LATref2 = LATref2 + SGN(LATref2) * M / 60
  1216.    INPUT "      Enter long (deg,min)"; LONref2, M
  1217.    LONref2 = LONref2 + SGN(LONref2) * M / 60
  1218.    PRINT
  1219.    PRINT "Place digitizer pen on lower right point."
  1220.    LINE INPUT #1, a$: SOUND 150, 3
  1221.         digix2 = 5000 - VAL(LEFT$(a$, 5))
  1222.         digiy2 = VAL(MID$(a$, 7, 5))
  1223.         PRINT "Digitizer reads "; digix2, digiy2; " for this point.": PRINT
  1224.  
  1225.    REM Find delta lat/long between reference points
  1226.    REM Calculate degrees per x/y unit
  1227.         degx# = (LONref1 - LONref2) / (digix1 - digix2)
  1228.         degy# = (LATref1 - LATref2) / (digiy1 - digiy2)
  1229.  
  1230.    CLS : PRINT "YOU ARE NOW READY TO USE THE DIGITIZER TO ENTER POINTS INTO MAPFIX..."
  1231.    PRINT
  1232.    PRINT "The digitizer works just about like the cursor and arrow keys in MAPFIX.  Any"
  1233.    PRINT "point identified by the digitizer will be ADDED just as if you had hit ALT-A."
  1234.    PRINT "All points are added to a feature after the current MapPoint identified by the"
  1235.    PRINT "white circle. "
  1236.    PRINT
  1237.    PRINT "With the digitizer, do NOT use the ALT-N NEW command which always begins at the"
  1238.    PRINT "current cursor location.  For the digitizer, use ALT-B to BEGIN a new feature."
  1239.    PRINT "You will be asked to identify the name and color of the new feature.  From then"
  1240.    PRINT "on, just move the digitizer mouse (or pen) to ADD new points.  "
  1241.    PRINT
  1242.    PRINT "If your digitizer mouse has 4 buttons, use the first (left) button for ADDing "
  1243.    PRINT "points, use the 4th (right) button to just move the cursor with no action."
  1244.    PRINT "With point-pens or single button mice, press F1 and the next use of the Pen "
  1245.    PRINT "will just move the cursor, NOT add a point."
  1246.    PRINT : PRINT
  1247.    INPUT "Hit ENTER to continue with MAPFIX..."; a$
  1248.    RETURN
  1249.  
  1250. GetXY: LINE INPUT #1, a$: SOUND 150, 3
  1251.    a = INSTR(a$, ","): IF a = 0 THEN RETURN
  1252.        x = 5000 - VAL(LEFT$(a$, a - 1))
  1253.    B = INSTR(a + 1, a$, ","): IF B = 0 THEN B = LEN(a$)
  1254.        y = VAL(MID$(a$, a + 1, B - (a)))
  1255.    Btn = VAL(RIGHT$(a$, 1)): REM Here is where I get the BUTTON value
  1256.                              REM as the right-most character fm the digitizer
  1257.    cpy = ((y - digiy2) * degy#) + LATref2
  1258.    cpx = ((x - digix2) * degx#) + LONref2
  1259.    IF LOC(1) <> 0 THEN a$ = INPUT$(LOC(1), #1)'Clear input buffer
  1260.    RETURN
  1261.  
  1262. BoxPPD:  GOSUB BoxLine23: INPUT "Enter the desired PPD (enter 0 to eliminate purple box)"; a$
  1263.          IF a$ <> "" THEN ppdB = VAL(a$): gotthem = 0' To force re-evaluation
  1264. ShowBox: IF ppdB > 1 THEN
  1265.              y = (30000 / ppdB) * Sfac * Yfactr / 60 'had been 30000 thn 36000
  1266.              x = y * 820 / (400 * Yfactr) * Lfac 'had been 640 then 560
  1267.              LINE (CUX - x, CUY - y)-(CUX + x, CUY + y), 13, B
  1268.             GOSUB BoxLine23
  1269.             PRINT "Purple box shows the largest APRS map that can be made with that scale.       "
  1270.          END IF
  1271.          RETURN
  1272.         
  1273. GetUSGS: REM This used for both U=OVERLAY and by ALT-U = USGS BUILD!
  1274.    Redraw = 0: USGS = -1: ni = 0: nt = 0: j = 0: NumLines = 0
  1275.    IF Key$ <> "U" THEN
  1276.       IF ppdB = 0 THEN GOSUB BoxPPD
  1277.       ppdv = ppdB
  1278.       IF gotthem = 0 THEN
  1279.          LATo = CDY + (500 * Yfactr / ppdv)
  1280.          LONo = CDX + (756 / ppdv) 'had been 500 (now .75 of 2048)/2
  1281.          LE = 1: OE = 1
  1282.          gotthem = 1
  1283.       END IF
  1284.       GOSUB BoxLine23: PRINT "Round-off LAT ORIGIN of "; LATo; : INPUT a$
  1285.             IF a$ <> "" THEN LATo = VAL(a$)
  1286.       GOSUB BoxLine23: PRINT "Round-off LON ORIGIN of "; LONo; : INPUT a$
  1287.             IF a$ <> "" THEN LONo = VAL(a$)
  1288.       GOSUB BoxLine23: INPUT "LATitude extent (100%)"; a$
  1289.             IF a$ <> "" THEN LE = VAL(a$) / 100
  1290.       GOSUB BoxLine23: INPUT "LONgitude extent (100%)"; a$
  1291.             IF a$ <> "" THEN OE = VAL(a$) / 100
  1292.       dx = ppdv * (LONo - CDX)
  1293.       dy = ppdv * (LATo - CDY)
  1294.       KP = 100 * 100 / (RS * ppdv)
  1295.       LatCen = CDY: LonCen = CDX: GOSUB StartMap
  1296.       LATtext$ = "Decimal LAT  of map ORIGIN"
  1297.       LONtext$ = "Decimal LONG of map ORIGIN"
  1298.       TextLine$ = "Map generated by MAPFIX from USGS 2,000,000:1 CD ROM (data valid mid-1980's)"
  1299.    END IF
  1300.    Slope = 1.2: REM IF ppdV < 600 THEN Slope = 1.5 ELSE Slope = 1.2
  1301.    SlopeI = 1 / Slope
  1302.    IF ppdv < 610 THEN mindel = .004 ELSE mindel = 2.4 / ppdv
  1303.    REM this .004 seems to be magic for 2,000,000 source data
  1304.  
  1305.    Lmax = 500 + 500 * LE: Lmin = 501 - 500 * LE 'Max=1000 and Min =1
  1306.    Omax = 756 + 756 * OE: Omin = 757 - 756 * OE 'Max=1512 and min =1
  1307.    IF Lmin < 1 THEN Lmin = 1
  1308.    IF Omin < 1 THEN Omin = 1
  1309.  
  1310.    GOSUB BoxLine23: PRINT "Which category (AB,CF,PB,RD,RR,ST,WB) ("; Cat$; ")";
  1311.    INPUT a$
  1312.    IF a$ <> "" THEN
  1313.       a = INSTR(a$, "."): IF a = 0 THEN a$ = a$ + ".GRF"
  1314.       Cat$ = a$
  1315.    END IF
  1316.    LOCATE bln - 1, 1: PRINT "MAPFIX will add the CATEGORY (RD,ST,WB,etc).GRF to the PATH\FILENAME above.    ";
  1317.    GOSUB BoxLine23: PRINT "Enter DRIVE:PATH\filename up to CATEGORY ("; Path$; ")";
  1318.    INPUT a$
  1319.    IF a$ <> "" THEN Path$ = a$
  1320.   
  1321.    USGS$ = Path$ + Cat$
  1322.    TY$ = UCASE$(LEFT$(Cat$, 2))
  1323.    LowMax = 99: HiMin = 0
  1324.    SELECT CASE TY$
  1325.       CASE "RD", "PB", "AB", "CF", "RR": MaxRnk = 99: MinRNk = 0
  1326.       CASE "WB": MaxRnk = 20: MinRNk = 0: LowMax = 0: HiMin = 5
  1327.       CASE "ST": MaxRnk = 50: MinRNk = 5: LowMax = 16: HiMin = 43
  1328.                ' Does not include canals
  1329.                ' Make minRNK=7 normal, 10 Alaska, 3 alaska for full map
  1330.    END SELECT
  1331.    OPEN USGS$ FOR INPUT AS #3
  1332.    IF Fault <> 0 THEN RETURN
  1333.    REM PRINT "raw data format.....", "   LineID", "#-Rnk-Atbts", "  NumPts"
  1334.    LOCATE 5, 72: PRINT "RNG"; INT(30000 / ppdv): LOCATE bln - 1, 1
  1335.    IF Key$ = "U" THEN
  1336.       PRINT "While USGS OVERLAYED, do not redraw map or you will have to do it again...";
  1337.    ELSE PRINT "Blue circles start lines, Green Box ends.  Red points discarded, Yellow Kept!";
  1338.    END IF
  1339.    LOCATE 1, 71: PRINT "PTS     ";
  1340.    LOCATE 2, 71: PRINT "USED    ";
  1341.    LOCATE 3, 71: PRINT "LINE    ";
  1342.    LOCATE 4, 71: PRINT "USED    ";
  1343.    LOCATE 6, 72: PRINT "RNK";
  1344.  
  1345.  DO UNTIL EOF(3) OR LNi = MaxNumLines - 1
  1346.    IF INKEY$ <> "" THEN EXIT DO
  1347.    NumLines = NumLines + 1
  1348.    LOCATE 1, 75: PRINT nt
  1349.    LOCATE 2, 75: PRINT ni
  1350.    LOCATE 3, 75: PRINT NumLines
  1351.    LOCATE 4, 75: PRINT LNi
  1352.    a$ = INPUT$(20, 3): REM PRINT a$;
  1353.         LnID$ = LEFT$(a$, 7)
  1354.         Rank$ = MID$(a$, 8, 2): Rank = VAL(Rank$): LOCATE 6, 75: PRINT Rank
  1355.         Npts$ = MID$(a$, 10, 6): Npts = VAL(Npts$)
  1356.         AtCd$ = MID$(a$, 16, 5)
  1357.         a$ = LTRIM$(LnID$) + "-" + Rank$ + "-" + AtCd$
  1358.         REM PRINT , LnID$, a$, Npts$
  1359.    IF Rank < 24 THEN SavClr = 4 ELSE SavClr = 7
  1360.    IF Rank < 20 THEN SavClr = 12
  1361.    IF Rank < 14 THEN SavClr = 10
  1362.    IF TY$ = "WB" THEN SavClr = 11
  1363.    IF TY$ = "ST" THEN SavClr = 3
  1364.    IF TY$ = "CF" THEN SavClr = 14
  1365.    IF TY$ = "RR" THEN SavClr = 8
  1366.    IF TY$ = "PB" THEN SavClr = 6
  1367.    IF YT$ = "AB" THEN SavClr = 14
  1368.    LineOK = 0: IF Key$ <> "U" THEN GOSUB BeginF
  1369.    REM IF ppdV < 610 THEN mindel = .004 ELSE mindel = 2.4 / ppdV
  1370.    REM this .004 seems to be magic for 2,000,000 source data
  1371.    FOR i = 1 TO Npts
  1372.     a$ = INPUT$(20, 3)
  1373.     IF Rank > MaxRnk OR Rank < MinRNk THEN IF Rank > 2 OR TY$ <> "ST" THEN GOTO Skp
  1374.     IF Rank > LowMax AND Rank < HiMin THEN GOTO Skp
  1375.     REM IF VAL(Rank$) > 99 THEN GOTO Skp
  1376.     LA = VAL(LEFT$(a$, 2)) + VAL(MID$(a$, 3, 2)) / 60 + VAL(MID$(a$, 5, 2)) / 3600
  1377.     LO = VAL(MID$(a$, 8, 3)) + VAL(MID$(a$, 11, 2)) / 60 + VAL(MID$(a$, 13, 2)) / 3600
  1378.     IF Key$ = "U" THEN
  1379.         REM Following lines used to limit points if just doing an OVERLAY only
  1380.         IF LA > CDY + RS / 60 OR LA < CDY - RS / 50 THEN GOTO Skp 'off screen
  1381.         IF LO > CDX + RS / (35 * Hfac) OR LO < CDX - RS / (35 * Hfac) THEN GOTO Skp
  1382.         REM s$ = MID$(a$, 16, 5)
  1383.         REM PRINT S$, LA, LO
  1384.     END IF 'oops stack problem here if too many times...
  1385.     y% = (LATo - LA) * ppdv
  1386.     x% = (LONo - LO) * ppdv: IF x% = 0 THEN x% = -1
  1387.     IF Key$ <> "U" AND (x% > Omax OR x% < Omin) THEN GOTO Skp'this ignores points off PPD
  1388.     IF Key$ <> "U" AND (y% > Lmax OR y% < Lmin) THEN GOTO Skp'scale
  1389.     LineOK = -1
  1390.        X1 = 320 + KP * (x% - dx) * Hfac
  1391.        Y1 = Ycen + KP * (y% - dy) * Yfactr
  1392.        IF i > 2 THEN
  1393.           REM LINE (x, y)-(X1, Y1), 6
  1394.           dd = LO - LOb: IF dd = 0 THEN dd = .0000001
  1395.           dn = LA - LAb
  1396.           s = dn / dd' Note that 1>s>.01 for Xdelta of 1 to 100
  1397.           IF ABS(s) < .1 AND ABS(Lsp) < .1 THEN
  1398.              sd = 1
  1399.           ELSEIF ABS(s) > 10 AND ABS(Lsp) > 10 THEN sd = 1
  1400.           ELSEIF ABS(dd) < mindel AND ABS(dn) < mindel THEN sd = 1
  1401.           REM this had been .004 for 2,000,000 CD rom and ppdV 300 to 600
  1402.           REM now is 2.4/ppdV for 100,000
  1403.           ELSEIF s <> 0 THEN sd = Lsp / s
  1404.           ELSE sd = 0
  1405.           END IF
  1406.           IF sd > Slope OR sd < SlopeI OR i = Npts THEN
  1407.              PSET (x, y), 14
  1408.              IF Key$ <> "U" THEN GOSUB KeepLine
  1409.           ELSE PSET (x, y), 4
  1410.           END IF
  1411.           Lsp = s: nt = nt + 1
  1412.        ELSE Lsp = 0: CIRCLE (X1, Y1), 2, 9
  1413.           IF Key$ <> "U" THEN GOSUB KeepLine 'keeps first two lines
  1414.        END IF
  1415.        LAb = LA: LOb = LO
  1416.        x = X1: y = Y1
  1417.        
  1418. Skp: NEXT i
  1419.      IF Key$ <> "U" THEN
  1420.         IF LineOK THEN nmp = nmp - 1: z = z - 1: ni = ni + 1 ELSE GOSUB CanclF
  1421.      END IF
  1422.      LINE (x - 1, y - 1)-(x + 1, y + 1), 10, B ' Last Point
  1423.  LOOP
  1424.  IF LNi > MaxNumLines - 2 THEN LOCATE 12, 20: PRINT "PROCESSING STOPPED... TOO MANY LLINES!..."
  1425.    CLOSE #3
  1426.    IF x%(nmp) <> 0 THEN x%(nmp) = 0: y%(nmp) = 0
  1427.    GOSUB MakeNoise
  1428.    RETURN
  1429.  
  1430. KeepLine: x%(z) = x%: y%(z) = y%: nmp = nmp + 1: z = z + 1: ni = ni + 1: RETURN
  1431.  
  1432.  
  1433. Scrunch: i = 0: Pt = 0: nt = 0: ni = 0: GOSUB BoxLine23
  1434.     INPUT "Enter slope filter ratio 1.1 to 1.5 (typically 1.2)"; a$
  1435.     IF a$ = "" THEN Slope = 1.2 ELSE Slope = VAL(a$)
  1436.     DO UNTIL i >= nmp - 1
  1437.       i = i + 1
  1438.       X1 = 320 + KP * (x%(i) - dx) * Hfac
  1439.       Y1 = Ycen + KP * (y%(i) - dy) * Yfactr
  1440.       IF x%(i) <> 0 THEN
  1441.         Pt = Pt + 1
  1442.         IF Pt > 2 THEN
  1443.           REM LINE (x, y)-(x1, y1), 6
  1444.           dd = x - X1
  1445.           dn = y - Y1
  1446.           IF dd = 0 AND dn = 0 THEN
  1447.             sd = Slope: s = Lsp  'Here the points are identical
  1448.             CIRCLE (x, y), 9, 13
  1449.           ELSE
  1450.             IF dd = 0 THEN dd = .01
  1451.             dst = ((dd * dd) + (dn * dn)) ^ .5
  1452.             s = dn / dd' Note that 1>s>.01 for Xdelta of 1 to 100
  1453.             IF s = 0 THEN s = .05
  1454.             IF ABS(s) < .2 THEN s = .2 * SGN(s)
  1455.             IF ABS(s) > 5 THEN s = 5 * SGN(s)
  1456.             IF ABS(s) <= .2 AND ABS(Lsp) <= .2 THEN
  1457.                sd = 1
  1458.             ELSEIF ABS(s) >= 5 AND ABS(Lsp) >= 5 THEN sd = 1
  1459.             ELSE sd = Lsp / s
  1460.             END IF
  1461.             IF ABS(dd) > 50 * KP OR ABS(dn) > 30 * KP THEN sd = 0
  1462.             REM IF ABS(dd) < 5 OR ABS(dn) < 4 THEN sd = 1
  1463.           END IF
  1464.           IF sd > Slope OR sd < 1 / Slope OR x%(i + 1) = 0 OR NumRej > 4 THEN
  1465.             ni = ni + 1: CIRCLE (x, y), 1, 15: NumRej = 0
  1466.           ELSE PSET (x, y), 4: NumRej = NumRej + 1: Changed = Changed + 1
  1467.             IF Key$ <> "T" THEN
  1468.                i = i - 1: nmp = nmp - 1
  1469.                FOR ii = i TO nmp
  1470.                    x%(ii) = x%(ii + 1): y%(ii) = y%(ii + 1)
  1471.                NEXT ii
  1472.             END IF
  1473.           END IF
  1474.           Lsp = s: nt = nt + 1
  1475.         ELSE Lsp = 0: nt = nt + 1: ni = ni + 1: CIRCLE (X1, Y1), 4, 9
  1476.         END IF
  1477.       ELSE Pt = 0: nt = nt + 1: ni = ni + 1
  1478.         LOCATE 1, 71: PRINT "PTS "; nt
  1479.         LOCATE 2, 71: PRINT "SAVD"; ni
  1480.       END IF
  1481.       x = X1: y = Y1
  1482.     LOOP
  1483.     GOTO MakeNoise
  1484.  
  1485. Join: REM Search for end=begin point values and CONCATONATE if equal!
  1486.    LnPtr = 0: i = 0: k = 0: GOSUB BoxLine23: PRINT "Lines joined: ";
  1487.    DO UNTIL i >= nmp
  1488.       i = i + 1
  1489.        IF x%(i) = x%(i + 2) AND y%(i) = y%(i + 2) AND y%(i + 1) = LColor THEN
  1490.           nmp = nmp - 2: LNi = LNi - 1: k = k + 1: LOCATE bln - 2, 15: PRINT k
  1491.           FOR j = i + 1 TO nmp: x%(j) = x%(j + 2): y%(j) = y%(j + 2): NEXT j
  1492.           FOR j = LnPtr TO LNi: LN$(j) = LN$(j + 1): NEXT j
  1493.        ELSEIF x%(i) = 0 THEN LColor = y%(i): LnPtr = LnPtr + 1
  1494.        END IF
  1495.    LOOP: GOSUB DrawMap
  1496.    GOTO MakeNoise
  1497.  
  1498. MapCnvrt: CLS
  1499.    INPUT "Enter desired SCALE in pixels-per-deg (ENTER to abort)"; a$
  1500.    IF a$ = "" THEN RETURN
  1501.    PPDD = VAL(a$): Changed = Changed + 1
  1502.    INPUT "Enter New Latitude of origin"; a$
  1503.    IF a$ = "" THEN Nlat = LATo ELSE Nlat = VAL(a$)
  1504.    INPUT "Enter New Longitude of origin"; a$
  1505.    IF a$ = "" THEN Nlon = LONo ELSE Nlon = VAL(a$)
  1506.      ChgFac = PPDD / ppdv
  1507.      LOfset = LONo - Nlon
  1508.      LAfset = LATo - Nlat
  1509.  
  1510.      PRINT : PRINT "Now processing map points."
  1511.  
  1512.      FOR i = 1 TO nmp'DO WHILE NOT EOF(3)
  1513.          IF x%(i) <> 0 THEN
  1514.             x%(i) = ChgFac * (x%(i) - ppdv * LOfset)
  1515.             y%(i) = ChgFac * (y%(i) - ppdv * LAfset)
  1516.             IF x%(i) = 0 THEN x%(i) = 1: PRINT "ZERO value of X!  Converted to 1,"; y%
  1517.         ELSEIF y%(i) = -1 THEN i = nmp 'shuldnt occur since -1 is NOT in array
  1518.         END IF                         'but is only writen at end of file
  1519.      NEXT i
  1520.      PRINT
  1521.      PRINT : PRINT "CONVERSION SUCCESSFUL."
  1522.      INPUT "Hit ENTER to continue.."; a$
  1523.      LATo = Nlat
  1524.      LONo = Nlon
  1525.      ppdv = PPDD
  1526.      Display$ = "MAP": Redraw = -1: USGS = 0: GOSUB DrwMPaCur
  1527.      RETURN
  1528.  
  1529. Import: 'Also this does OVERLAY CtrlO
  1530.    IF (CDX <> LonCen OR CDY <> LatCen) AND NOT OVERLAY THEN
  1531.       CDX = LonCen: CDY = LatCen: GOSUB DrwMPaCur
  1532.       'Cuz TRIM calcs are based on range from CDX,CDY vice alt-CENTER
  1533.    END IF: IF Import$ = "" THEN Import$ = "    "
  1534.    LOCATE 42, 1: PRINT "IMPORT ALL FEATURES (of one color) FROM ANOTHER MAP THAT FIT INSIDE THIS MAP'S";
  1535.    LOCATE 43, 1: PRINT "BORDER.  POINTS ARE AUTOMATICALLY CONVERTED TO THE CURRENT SCALE AND ORIGIN.  ";
  1536.    LOCATE 41, 1: PRINT "Enter map filename ("; Import$; ")";
  1537.    INPUT a$
  1538.    IF a$ <> "" THEN
  1539.       Import$ = a$
  1540.       IF INSTR(a$, ".") = 0 THEN Import$ = Import$ + ".MAP"
  1541.    END IF: F$ = Import$
  1542.    Fault = 0: OPEN Import$ FOR INPUT AS #2
  1543.    IF Fault <> 0 THEN RETURN
  1544.    LOCATE bln - 3, 1
  1545.    INPUT "Color of feature to import (1 to 15) or ALL"; a$
  1546.    IF UCASE$(a$) = "ALL" OR a$ = "" THEN All = -1 ELSE All = 0
  1547.    IF a$ <> "" THEN Fcolr = VAL(a$)
  1548.    INPUT #2, LATa: LINE INPUT #2, a$:
  1549.    INPUT #2, LONa: LINE INPUT #2, a$: IF Nlon = 0 THEN Nlon = LONa
  1550.    INPUT #2, OppdV: LINE INPUT #2, a$'Pix-per-deg-Vert
  1551.    INPUT #2, oLatCen: LINE INPUT #2, a$
  1552.    INPUT #2, oLonCen: LINE INPUT #2, a$
  1553.    INPUT #2, oMapRng: LINE INPUT #2, a$
  1554.    INPUT #2, oMinRnga: LINE INPUT #2, a$
  1555.    LINE INPUT #2, a$
  1556.    IF a$ = "Compressed" THEN PRINT "OOPS, Cannot use a map in COMPRESSED format!"
  1557.    IF a$ = "Compressed" THEN BEEP: CLOSE #2: RETURN
  1558.    i = 0
  1559.    REM now make offset and scale calculations
  1560.    Nfac = ppdv / OppdV
  1561.    LOfset = LONa - LONo
  1562.    LAfset = LATa - LATo
  1563.     by = ppdv * MapRng / 60 ' These the same as TRIM borders
  1564.     bx = by / Lfac
  1565.     s = nmp'start for RE-DRAW at end of this routine
  1566.     x% = 1: y% = 1' To get around first test
  1567.     DO WHILE NOT EOF(2)
  1568.       IF x% = 0 AND y% = 0 THEN
  1569.          StrtPt = -1
  1570.          INPUT #2, LColor: LINE INPUT #2, a$'get color and name
  1571.          IF LColor = Fcolr OR All THEN
  1572.             IF NOT OVERLAY THEN
  1573.                x%(nmp) = 0: y%(nmp) = LColor ' over top of previous 0,0 at nmp
  1574.                LNi = LNi + 1: LN$(LNi) = a$
  1575.             END IF
  1576.             NofPts = 0' helps us not delete pts until line has at least 2 pts
  1577.             DO
  1578.                INPUT #2, x%, y%
  1579.                IF NOT OVERLAY THEN nmp = nmp + 1: Changed = Changed + 1
  1580.                IF x% = 0 THEN EXIT DO
  1581.                x = Nfac * (x% - OppdV * LOfset)
  1582.                y = Nfac * (y% - OppdV * LAfset)
  1583.                IF x = 0 THEN
  1584.                   x = 1
  1585.                   IF NOT OVERLAY THEN PRINT "ZERO value of X!  Converted to 1,"; y%
  1586.                END IF
  1587.                IF NOT OVERLAY THEN x%(nmp) = x: y%(nmp) = y
  1588.                IF x > dx + bx OR y > dy + by THEN bad = 1 ELSE bad = 0
  1589.                IF x < dx - bx OR y < dy - by THEN bad = 1
  1590.                IF bad AND NofPts > 1 THEN
  1591.                   IF NOT OVERLAY THEN nmp = nmp - 1
  1592.                ELSE NofPts = NofPts + 1
  1593.                     Xc = 320 + (x - dx) * HfacK
  1594.                     Yc = Ycen + (y - dy) * YfactrK
  1595.                     IF StrtPt THEN
  1596.                        PSET (Xc, Yc), LColor
  1597.                        CIRCLE (Xc, Yc), 2, 9: StrtPt = 0
  1598.                     ELSE
  1599.                        LINE -(Xc, Yc), LColor
  1600.                     END IF
  1601.                END IF
  1602.             LOOP
  1603.             IF NofPts = 2 AND bad AND NOT OVERLAY THEN LNi = LNi - 1: nmp = nmp - 3
  1604.             IF NOT OVERLAY THEN
  1605.                x%(nmp) = 0: y%(nmp) = 0
  1606.             ELSE CIRCLE (Xc, Yc), 3, 10
  1607.             END IF
  1608.          END IF
  1609.       ELSE INPUT #2, x%, y%
  1610.       END IF
  1611.       IF x% = 0 AND y% = -1 THEN EXIT DO
  1612.    LOOP
  1613.    FOR i = 40 TO 43: LOCATE i, 1: PRINT SPACE$(80); : NEXT
  1614.    LOCATE 41, 1: PRINT "All map points converted..."
  1615.       DO WHILE NOT EOF(2)
  1616.       LINE INPUT #2, a$
  1617.       LOOP: CLOSE #2
  1618.       IF NOT OVERLAY THEN GOSUB DP
  1619.       OVERLAY = 0
  1620.        
  1621. MakeNoise: SOUND 800, 4: SOUND 1500, 3: SOUND 500, 2
  1622.    RETURN
  1623.  
  1624. END
  1625.  
  1626.