gps.py 640 B

123456789101112131415161718192021222324252627
  1. #http://instantglobe.com/CRANES/GeoCoordTool.html
  2. import math
  3. R = 6371
  4. PI = 3.141592
  5. tc1 = 0
  6. lat2 = 44.909916*(PI/180)
  7. lon2 = 4.847728*(PI/180)
  8. lat1 = 45.178890*(PI/180)
  9. lon1 = 5.708217*(PI/180)
  10. drad = math.acos(math.sin(lat1)*math.sin(lat2) + math.cos(lat1)*math.cos(lat2)*math.cos(-lon1+lon2))
  11. dist = drad * R
  12. if math.sin(-lon2+lon1)<0 :
  13. tc1=math.acos((math.sin(lat2)-math.sin(lat1)*math.cos(drad))/(math.sin(drad)*math.cos(lat1)))
  14. else :
  15. tc1=2*3.1415-math.acos((math.sin(lat2)-math.sin(lat1)*math.cos(drad))/(math.sin(drad)*math.cos(lat1)))
  16. print(tc1*(180/PI),dist)
  17. #dist 73.9248
  18. #angle 65.83°deg