|
Une des fonctions les plus communes de la géographie et des systèmes modernes, c'est le calcul de la distance géographique entre deux coordonnées de Longitude et de Latitude.
Il n'y a aucune nécessité de grande connaissance en trigonométrie pour arriver à se genre de calcul dans le format qu'on le souhaite, Km, Miles ou Miles Nautiques.
Ainsi, si vous savez les coordonnéss suivantes:
| Montréal |
45 31N |
73 34O |
| Paris |
48 50N |
2 20E |
A l'aide du code source GFA-Basic suivant, vous trouvez la réponse que vous souhaitez:
PRINT "Distance entre Montréal et Paris en Km: " + STR$(@CoordToDeltaKm(45, 31, "N", 73, 34, "O", 48, 50, "N", 2, 20, "E"))
PRINT "Distance entre Montréal et Paris en Miles: " + STR$(@CoordToDeltaStatuteMiles(45, 31, "N", 73, 34, "O", 48, 50, "N", 2, 20, "E"))
PRINT "Distance entre Montréal et Paris en Miles Nautique: " + STR$(@CoordToDeltaNauticalMiles(45, 31, "N", 73, 34, "O", 48, 50, "N", 2, 20, "E"))
FUNCTION CoordToDeltaKm(Q1Latitude, Q1LatiDeg, Q1LatiDirection$, Q1Longitude, Q1LongDeg, Q1LongDirection$, Q2Latitude, Q2LatiDeg, Q2LatiDirection$, Q2Longitude, Q2LongDeg, Q2LongDirection$)
a1 = (Q1Latitude + (Q1LatiDeg / 60)) * PI / 180
IF Q1LatiDirection$ = "N" THEN
a1 = -a1
ENDIF
b1 = (Q1Longitude + (Q1LongDeg / 60)) * PI / 180
IF Q1LongDirection$ = "O" THEN
b1 = -b1
ENDIF
a2 = (Q2Latitude + (Q2LatiDeg / 60)) * PI / 180
IF Q2LatiDirection$ = "N" THEN
a2 = -a2
ENDIF
b2 = (Q2Longitude + (Q2LongDeg / 60)) * PI / 180
IF Q2LongDirection$ = "O" THEN
b2 = -b2
ENDIF
RawDelta = ACOS(COS(a1) * COS(b1) * COS(a2) * COS(b2) + COS(a1) * SIN(b1) * COS(a2) * SIN(b2) + SIN(a1) * SIN(a2))
RETURN RawDelta * 6378
ENDFUNC
FUNCTION CoordToDeltaNauticalMiles (Q1Latitude, Q1LatiDeg, Q1LatiDirection$, Q1Longitude, Q1LongDeg, Q1LongDirection$, Q2Latitude, Q2LatiDeg, Q2LatiDirection$, Q2Longitude, Q2LongDeg, Q2LongDirection$)
a1 = (Q1Latitude + (Q1LatiDeg / 60)) * PI / 180
IF Q1LatiDirection$ = "N" THEN
a1 = -a1
ENDIF
b1 = (Q1Longitude + (Q1LongDeg / 60)) * PI / 180
IF Q1LongDirection$ = "O" THEN
b1 = -b1
ENDIF
a2 = (Q2Latitude + (Q2LatiDeg / 60)) * PI / 180
IF Q2LatiDirection$ = "N" THEN
a2 = -a2
ENDIF
b2 = (Q2Longitude + (Q2LongDeg / 60)) * PI / 180
IF Q2LongDirection$ = "O" THEN
b2 = -b2
ENDIF
RawDelta = ACOS(COS(a1) * COS(b1) * COS(a2) * COS(b2) + COS(a1) * SIN(b1) * COS(a2) * SIN(b2) + SIN(a1) * SIN(a2))
RETURN RawDelta * 3443.9
ENDFUNC
FUNCTION CoordToDeltaStatuteMiles (Q1Latitude, Q1LatiDeg, Q1LatiDirection$, Q1Longitude, Q1LongDeg, Q1LongDirection$, Q2Latitude, Q2LatiDeg, Q2LatiDirection$, Q2Longitude, Q2LongDeg, Q2LongDirection$)
a1 = (Q1Latitude + (Q1LatiDeg / 60)) * PI / 180
IF Q1LatiDirection$ = "N" THEN
a1 = -a1
ENDIF
b1 = (Q1Longitude + (Q1LongDeg / 60)) * PI / 180
IF Q1LongDirection$ = "O" THEN
b1 = -b1
ENDIF
a2 = (Q2Latitude + (Q2LatiDeg / 60)) * PI / 180
IF Q2LatiDirection$ = "N" THEN
a2 = -a2
ENDIF
b2 = (Q2Longitude + (Q2LongDeg / 60)) * PI / 180
IF Q2LongDirection$ = "O" THEN
b2 = -b2
ENDIF
RawDelta = ACOS(COS(a1) * COS(b1) * COS(a2) * COS(b2) + COS(a1) * SIN(b1) * COS(a2) * SIN(b2) + SIN(a1) * SIN(a2))
RETURN RawDelta * 3963.1
ENDFUNC
|
on obtiendra le résultat suivant:
Distance entre Montréal et Paris en Km: 5510.16761889
Distance entre Montréal et Paris en Miles: 3423.85470217
Distance entre Montréal et Paris en Miles Nautique: 2975.30044884
|
|