def toRad(v): # l = left side of '.' # r = right side of '.' l = v[0].split('.')[0] r = v[0].split('.')[1] if len(l) == 4: deg = float(l[:2]) m = float(l[2:] + '.' + r) else: deg = float(l[:3]) m = float(l[3:] + '.' + r) vDeg = deg + (m / 60) return radians(vDeg)
coords = [] with open(fich) as fp: for line in iter(fp.readline, ''): # print (line) data = line.split(' ') lat = float(data[0]) lon = float(data[1]) track = float(data[2]) coords.append( (lat, lon, (lat - 50.0) * 1000, (lon + 5.0) * 10000, track)) pangle = 0.0 panglea = 0.0 ptrack = 0.0 for i in range(0, len(coords) - 1): lat0 = radians(coords[i][0]) lon0 = radians(coords[i][1]) lat1 = radians(coords[i + 1][0]) lon1 = radians(coords[i + 1][1]) angle = compassAngle(lat0, lon0, lat1, lon1) lat0a = radians(coords[i][2]) lon0a = radians(coords[i][3]) lat1a = radians(coords[i + 1][2]) lon1a = radians(coords[i + 1][3]) anglea = compassAngle(lat0a, lon0a, lat1a, lon1a) track = coords[i + 1][4] print("%f (%f)\t%f (%f)\t%f (%f)" % (angle, angle - pangle, anglea, anglea - panglea, track, track - ptrack))
from pygeodesy.utily import radians, degrees from math import atan, cos from pdb import set_trace as st """ GggppssX-11 lignes 2 et 3 48.164788333|-4.046563333|333.09|2020-01-25T14:19:20.000Z|29.786|0.005|93.7|3|19.32| 48.16503|-4.04674|335.04|2020-01-25T14:19:21.000Z|29.658|0.005|92.6|3|19.32| """ l0 = 48.164788333 ll0 = -4.046563333 l1 = 48.16503 ll1 = -4.04674 lat0 = radians(48.164788333) lon0 = radians(-4.046563333) lat1 = radians(48.16503) lon1 = radians(-4.04674) def toTuple(angle): # convertit un angle en tuple de (Deg, min, sec) deg = int(angle) rDeg = (angle - deg) * 60 if rDeg < 0: rDeg = rDeg * -1 mins = int(rDeg) sec = (rDeg - mins) * 60 return (deg, mins, sec)