Question to Jon Wiliams GPS to GPS position calculation.
Archiver
Posts: 46,084
A groupie just gave me this Basic program that is calculating the
Bering from one GPS position to another.
I looked in to the basic code, and this is not that difficult, still
if you had any interest in this on a future BS2p project or
something, it would be nice to see this calculation be made in a
basic stamp.
What do you say?
I made a cut out section of the Basic program (below), so you can
take a look.
What problems do you see with this code, if it should be used in the
Stamp?
Stein
1390 Print "Creating Flight Plan: ": Print: Print
1400 INPUT "Departure Airport: ", look$
'1410 OPEN "flight" FOR RANDOM SHARED AS #1 LEN = 128
1410 Open "flight" For Random As #1 Len = 128
1420 FIELD 1, 15 AS ax$, 12 AS b$, 12 AS c$, 4 AS d$, 2 AS e$, 3 AS
f$, 8 AS g$, 6 AS h$, 6 AS i$, 40 AS k$, 4 AS l$
1430 code% = 1
1440 GET #1, code%
1450 If EOF(1) Then GoTo 1490
1460 If Left$(ax$, 4) = look$ Or Left$(ax$, 5) = look$ Or Left$(ax$,
6) = look$ Then GoTo 1590
1461 If Left$(ax$, 7) = look$ Or Left$(ax$, 8) = look$ Or Left$(ax$,
9) = look$ Then GoTo 1590
1462 If Left$(ax$, 10) = look$ Or Left$(ax$, 11) = look$ Or
Left$(ax$, 12) = look$ Or Left$(ax$, 13) = look$ Then GoTo 1590
1470 code% = code% + 1
1480 GoTo 1440
1490 Close 1
1500 CLS
1510 LOCATE 6, 6
1520 Print "Airport not found"
1530 Print: Print: Print "Press any key to continue"
1540 a$ = INKEY$
1550 If a$ = "" Then GoTo 1540
1560 GoTo 10
1570 GET #1, code%
1580 Close 1
1590 CLS
1600 LOCATE 2, 1
1610 Print "Departure Airport Data"
1620 Print: Print:
1630 LOCATE 5, 1
1640 Print "Airport: "; ax$
1645 dept$ = ax$
1650 LOCATE 5, 20
1660 Print "Latitude: "; b$
1670 LOCATE 5, 45
1680 Print "Longitude: "; c$
1690 LOCATE 6, 1
1700 Print "Elevation: "; d$
1710 LOCATE 6, 20
1720 Print "Runway: "; e$
1730 LOCATE 6, 45
1740 Print "Heading: "; f$
1750 LOCATE 7, 1
1760 Print "ILS: "; g$
1770 LOCATE 7, 20
1780 Print "DME: "; h$
1790 LOCATE 7, 45
1800 Print "ATIS: "; i$
1810 Print "Notes: "; k$
1815 mdep = Val(l$)
1820 Rem LAT CALCULATIONS
1830 If Right$(b$, 6) = "North " Then lb = Val(Left$(b$, 2))
1840 If Right$(b$, 6) = "North " Then lba = Val(Mid$(b$, 3, 3))
1850 If Right$(b$, 5) = "South" Then lb = Val(Left$(b$, 3))
1860 If Right$(b$, 5) = "South" Then lba = -Val(Mid$(b$, 4, 3))
1870 lba = lba / 60 * 100
1880 lb = lb + lba
1890 If Right$(c$, 5) = "West " Then mb = Val(Left$(c$, 3))
1900 If Right$(c$, 5) = "West " Then mba = Val(Mid$(c$, 4, 3))
1910 If Right$(c$, 4) = "East" Then mb = Val(Left$(c$, 4))
1920 If Right$(c$, 4) = "East" Then mba = -Val(Mid$(c$, 5, 3))
1930 mba = mba / 60 * 100
1940 mb = mb + mba
1950 Close 1
1960 GoTo 1970
1970 Print: Print
1980 INPUT "Destination Airport: ", look$
'1990 OPEN "flight" FOR RANDOM SHARED AS #1 LEN = 128
1990 Open "flight" For Random As #1 Len = 128
2000 FIELD 1, 15 AS ax$, 12 AS b$, 12 AS c$, 4 AS d$, 2 AS e$, 3 AS
f$, 8 AS g$, 6 AS h$, 6 AS i$, 40 AS k$, 4 AS l$
2010 code% = 1
2020 GET #1, code%
2030 If EOF(1) Then GoTo 2070
2040 If Left$(ax$, 4) = look$ Or Left$(ax$, 5) = look$ Or Left$(ax$,
6) = look$ Then GoTo 2170
2041 If Left$(ax$, 7) = look$ Or Left$(ax$, 8) = look$ Or Left$(ax$,
9) = look$ Then GoTo 2170
2042 If Left$(ax$, 10) = look$ Or Left$(ax$, 11) = look$ Or
Left$(ax$, 12) = look$ Or Left$(ax$, 13) = look$ Then GoTo 2170
2050 code% = code% + 1
2060 GoTo 2020
2070 Close 1
2080 CLS
2090 LOCATE 6, 6
2100 Print "Airport not found"
2110 Print: Print: Print "Press any key to continue"
2120 a$ = INKEY$
2130 If a$ = "" Then GoTo 2120
2140 GoTo 10
2150 GET #1, code%
2160 Close 1
2170 LOCATE 13, 1
2180 Print "Destination Airport Data"
2190 Print: Print
2200 LOCATE 15, 1
2210 Print "Airport: "; ax$
2220 LOCATE 15, 20
2230 Print "Latitude: "; b$
2240 LOCATE 15, 45
2250 Print "Longitude: "; c$
2260 LOCATE 16, 1
2270 Print "Elevation: "; d$
2280 LOCATE 16, 20
2290 Print "Runway: "; e$
2300 LOCATE 16, 45
2310 Print "Heading: "; f$
2320 LOCATE 17, 1
2330 Print "ILS: "; g$
2340 LOCATE 17, 20
2350 Print "DME: "; h$
2360 LOCATE 17, 45
2370 Print "ATIS: "; i$
2380 Print "Note: "; k$
2385 mdest = Val(l$): Print mdest
2390 If Right$(b$, 6) = "North " Then la = Val(Left$(b$, 2))
2400 If Right$(b$, 6) = "North " Then laa = Val(Mid$(b$, 3, 3))
2410 If Right$(b$, 5) = "South" Then la = Val(Left$(b$, 3)):
Print "LA "; la
2420 If Right$(b$, 5) = "South" Then laa = -Val(Mid$(b$, 4, 3))
2430 laa = laa / 60 * 100
2440 la = la + laa
2450 If Right$(c$, 5) = "West " Then ma = Val(Left$(c$, 3))
2460 If Right$(c$, 5) = "West " Then maa = Val(Mid$(c$, 4, 3))
2470 If Right$(c$, 4) = "East" Then ma = Val(Left$(c$, 4))
2480 If Right$(c$, 4) = "East" Then maa = -Val(Mid$(c$, 5, 3))
2490 maa = maa / 60 * 100
2500 ma = ma + maa
2510 Rem CLOSE 1
2520 Print
2530 INPUT "Are you ready to compute the flight plan? (Y/N)", u$
2540 If u$ = "Y" Or u$ = "y" Then GoTo 2560
2550 GoTo 10
2560 CLS
2570 LOCATE 8, 4
2580 INPUT "Enter your estimated groundspeed: ", SPEED
2590 CLS
2600 LOCATE 2, 25
2610 Print "Computing Flight Plan"
2620 Print: Print
2630 If lb > la Then b = lb - la
2640 If la > lb Then b = la - lb
2650 If mb > ma Then a = mb - ma
2660 If ma > mb Then a = ma - mb
2670 cx = (a * a) + (b * b)
2680 c = Sqr(cx)
' Intern use only
'2681 If a=0 then a=1
'2682 if b=0 then b=1
'2683 If c=0 then c=1
'2684 Locate 10,40:Print "a:";a
'2685 Locate 11,40:Print "b:";b
'2686 Locate 12,40:Print "c:";c
' *****************
2690 If mb > ma And lb > la Then GoTo 2760
2700 If mb < ma And lb > la Then GoTo 2740
2710 If mb > ma And lb < la Then GoTo 2740
2720 If mb < ma And lb < la Then GoTo 2760
2730 GoTo 2760
' Having problems with divided by zero. Probebly due to incorrect
input
2740 tangent = (a / c) / (b / c)
2750 GoTo 2770
2760 tangent = (b / c) / (a / c)
2770 course = Atn(tangent)
2780 course = course / 0.01743
2790 Rem if right$(c$,4)="East" then mb=mb-1
2800 Rem if right$(c$,4)="East" then ma=ma-1
2810 Rem if right$(b$,5)="South" then lb=lb-1
2820 Rem if right$(b$,5="South" then la=la-1
2830 If lb < la And mb > ma Then course = course
2840 If lb > la And mb < ma Then course = course + 180
2850 If lb < la And mb < ma Then course = course + 270
2860 If lb > la And mb > ma Then course = course + 90
2870 DISTANCE = c * 60
2880 Print "Course to "; ax$, "is: "; USING; "###.##"; course: Print
2890 Print "Distance to "; ax$, "is"; Int(DISTANCE); "nautical
miles": Print
2900 Print "Coordinates of "; ax$; " "; b$; " "; c$: Print
2910 Print "ILS Frequency is: "; g$: Print
2920 Print "VOR Frequency is: "; h$: Print
2930 Print "ATIS Frequency is: "; i$: Print
2940 Print "Landing on Runway: "; e$, "Heading: "; f$: Print
2950 Print "Field elevation is: "; d$: Print
2960 Print "Estimated time enroute is: "; USING; "##.##"; (Int
(DISTANCE)) / SPEED
2970 LOCATE 21, 36
2980 Print "Hours": Print
2990 Print "Press any key to continue"
3000 a$ = INKEY$
3010 If a$ = "" Then GoTo 3000
3020 GoSub 4780
3030 GoTo 10
Bering from one GPS position to another.
I looked in to the basic code, and this is not that difficult, still
if you had any interest in this on a future BS2p project or
something, it would be nice to see this calculation be made in a
basic stamp.
What do you say?
I made a cut out section of the Basic program (below), so you can
take a look.
What problems do you see with this code, if it should be used in the
Stamp?
Stein
1390 Print "Creating Flight Plan: ": Print: Print
1400 INPUT "Departure Airport: ", look$
'1410 OPEN "flight" FOR RANDOM SHARED AS #1 LEN = 128
1410 Open "flight" For Random As #1 Len = 128
1420 FIELD 1, 15 AS ax$, 12 AS b$, 12 AS c$, 4 AS d$, 2 AS e$, 3 AS
f$, 8 AS g$, 6 AS h$, 6 AS i$, 40 AS k$, 4 AS l$
1430 code% = 1
1440 GET #1, code%
1450 If EOF(1) Then GoTo 1490
1460 If Left$(ax$, 4) = look$ Or Left$(ax$, 5) = look$ Or Left$(ax$,
6) = look$ Then GoTo 1590
1461 If Left$(ax$, 7) = look$ Or Left$(ax$, 8) = look$ Or Left$(ax$,
9) = look$ Then GoTo 1590
1462 If Left$(ax$, 10) = look$ Or Left$(ax$, 11) = look$ Or
Left$(ax$, 12) = look$ Or Left$(ax$, 13) = look$ Then GoTo 1590
1470 code% = code% + 1
1480 GoTo 1440
1490 Close 1
1500 CLS
1510 LOCATE 6, 6
1520 Print "Airport not found"
1530 Print: Print: Print "Press any key to continue"
1540 a$ = INKEY$
1550 If a$ = "" Then GoTo 1540
1560 GoTo 10
1570 GET #1, code%
1580 Close 1
1590 CLS
1600 LOCATE 2, 1
1610 Print "Departure Airport Data"
1620 Print: Print:
1630 LOCATE 5, 1
1640 Print "Airport: "; ax$
1645 dept$ = ax$
1650 LOCATE 5, 20
1660 Print "Latitude: "; b$
1670 LOCATE 5, 45
1680 Print "Longitude: "; c$
1690 LOCATE 6, 1
1700 Print "Elevation: "; d$
1710 LOCATE 6, 20
1720 Print "Runway: "; e$
1730 LOCATE 6, 45
1740 Print "Heading: "; f$
1750 LOCATE 7, 1
1760 Print "ILS: "; g$
1770 LOCATE 7, 20
1780 Print "DME: "; h$
1790 LOCATE 7, 45
1800 Print "ATIS: "; i$
1810 Print "Notes: "; k$
1815 mdep = Val(l$)
1820 Rem LAT CALCULATIONS
1830 If Right$(b$, 6) = "North " Then lb = Val(Left$(b$, 2))
1840 If Right$(b$, 6) = "North " Then lba = Val(Mid$(b$, 3, 3))
1850 If Right$(b$, 5) = "South" Then lb = Val(Left$(b$, 3))
1860 If Right$(b$, 5) = "South" Then lba = -Val(Mid$(b$, 4, 3))
1870 lba = lba / 60 * 100
1880 lb = lb + lba
1890 If Right$(c$, 5) = "West " Then mb = Val(Left$(c$, 3))
1900 If Right$(c$, 5) = "West " Then mba = Val(Mid$(c$, 4, 3))
1910 If Right$(c$, 4) = "East" Then mb = Val(Left$(c$, 4))
1920 If Right$(c$, 4) = "East" Then mba = -Val(Mid$(c$, 5, 3))
1930 mba = mba / 60 * 100
1940 mb = mb + mba
1950 Close 1
1960 GoTo 1970
1970 Print: Print
1980 INPUT "Destination Airport: ", look$
'1990 OPEN "flight" FOR RANDOM SHARED AS #1 LEN = 128
1990 Open "flight" For Random As #1 Len = 128
2000 FIELD 1, 15 AS ax$, 12 AS b$, 12 AS c$, 4 AS d$, 2 AS e$, 3 AS
f$, 8 AS g$, 6 AS h$, 6 AS i$, 40 AS k$, 4 AS l$
2010 code% = 1
2020 GET #1, code%
2030 If EOF(1) Then GoTo 2070
2040 If Left$(ax$, 4) = look$ Or Left$(ax$, 5) = look$ Or Left$(ax$,
6) = look$ Then GoTo 2170
2041 If Left$(ax$, 7) = look$ Or Left$(ax$, 8) = look$ Or Left$(ax$,
9) = look$ Then GoTo 2170
2042 If Left$(ax$, 10) = look$ Or Left$(ax$, 11) = look$ Or
Left$(ax$, 12) = look$ Or Left$(ax$, 13) = look$ Then GoTo 2170
2050 code% = code% + 1
2060 GoTo 2020
2070 Close 1
2080 CLS
2090 LOCATE 6, 6
2100 Print "Airport not found"
2110 Print: Print: Print "Press any key to continue"
2120 a$ = INKEY$
2130 If a$ = "" Then GoTo 2120
2140 GoTo 10
2150 GET #1, code%
2160 Close 1
2170 LOCATE 13, 1
2180 Print "Destination Airport Data"
2190 Print: Print
2200 LOCATE 15, 1
2210 Print "Airport: "; ax$
2220 LOCATE 15, 20
2230 Print "Latitude: "; b$
2240 LOCATE 15, 45
2250 Print "Longitude: "; c$
2260 LOCATE 16, 1
2270 Print "Elevation: "; d$
2280 LOCATE 16, 20
2290 Print "Runway: "; e$
2300 LOCATE 16, 45
2310 Print "Heading: "; f$
2320 LOCATE 17, 1
2330 Print "ILS: "; g$
2340 LOCATE 17, 20
2350 Print "DME: "; h$
2360 LOCATE 17, 45
2370 Print "ATIS: "; i$
2380 Print "Note: "; k$
2385 mdest = Val(l$): Print mdest
2390 If Right$(b$, 6) = "North " Then la = Val(Left$(b$, 2))
2400 If Right$(b$, 6) = "North " Then laa = Val(Mid$(b$, 3, 3))
2410 If Right$(b$, 5) = "South" Then la = Val(Left$(b$, 3)):
Print "LA "; la
2420 If Right$(b$, 5) = "South" Then laa = -Val(Mid$(b$, 4, 3))
2430 laa = laa / 60 * 100
2440 la = la + laa
2450 If Right$(c$, 5) = "West " Then ma = Val(Left$(c$, 3))
2460 If Right$(c$, 5) = "West " Then maa = Val(Mid$(c$, 4, 3))
2470 If Right$(c$, 4) = "East" Then ma = Val(Left$(c$, 4))
2480 If Right$(c$, 4) = "East" Then maa = -Val(Mid$(c$, 5, 3))
2490 maa = maa / 60 * 100
2500 ma = ma + maa
2510 Rem CLOSE 1
2520 Print
2530 INPUT "Are you ready to compute the flight plan? (Y/N)", u$
2540 If u$ = "Y" Or u$ = "y" Then GoTo 2560
2550 GoTo 10
2560 CLS
2570 LOCATE 8, 4
2580 INPUT "Enter your estimated groundspeed: ", SPEED
2590 CLS
2600 LOCATE 2, 25
2610 Print "Computing Flight Plan"
2620 Print: Print
2630 If lb > la Then b = lb - la
2640 If la > lb Then b = la - lb
2650 If mb > ma Then a = mb - ma
2660 If ma > mb Then a = ma - mb
2670 cx = (a * a) + (b * b)
2680 c = Sqr(cx)
' Intern use only
'2681 If a=0 then a=1
'2682 if b=0 then b=1
'2683 If c=0 then c=1
'2684 Locate 10,40:Print "a:";a
'2685 Locate 11,40:Print "b:";b
'2686 Locate 12,40:Print "c:";c
' *****************
2690 If mb > ma And lb > la Then GoTo 2760
2700 If mb < ma And lb > la Then GoTo 2740
2710 If mb > ma And lb < la Then GoTo 2740
2720 If mb < ma And lb < la Then GoTo 2760
2730 GoTo 2760
' Having problems with divided by zero. Probebly due to incorrect
input
2740 tangent = (a / c) / (b / c)
2750 GoTo 2770
2760 tangent = (b / c) / (a / c)
2770 course = Atn(tangent)
2780 course = course / 0.01743
2790 Rem if right$(c$,4)="East" then mb=mb-1
2800 Rem if right$(c$,4)="East" then ma=ma-1
2810 Rem if right$(b$,5)="South" then lb=lb-1
2820 Rem if right$(b$,5="South" then la=la-1
2830 If lb < la And mb > ma Then course = course
2840 If lb > la And mb < ma Then course = course + 180
2850 If lb < la And mb < ma Then course = course + 270
2860 If lb > la And mb > ma Then course = course + 90
2870 DISTANCE = c * 60
2880 Print "Course to "; ax$, "is: "; USING; "###.##"; course: Print
2890 Print "Distance to "; ax$, "is"; Int(DISTANCE); "nautical
miles": Print
2900 Print "Coordinates of "; ax$; " "; b$; " "; c$: Print
2910 Print "ILS Frequency is: "; g$: Print
2920 Print "VOR Frequency is: "; h$: Print
2930 Print "ATIS Frequency is: "; i$: Print
2940 Print "Landing on Runway: "; e$, "Heading: "; f$: Print
2950 Print "Field elevation is: "; d$: Print
2960 Print "Estimated time enroute is: "; USING; "##.##"; (Int
(DISTANCE)) / SPEED
2970 LOCATE 21, 36
2980 Print "Hours": Print
2990 Print "Press any key to continue"
3000 a$ = INKEY$
3010 If a$ = "" Then GoTo 3000
3020 GoSub 4780
3030 GoTo 10
Comments
-- Jon Williams
-- Parallax
Original Message
From: