1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
| #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# merge: fusionne des valeurs proches
def merge (vlist, radius):
"""
merges values in vlist lower than radius
"""
values = sorted(vlist)
merged = list()
index = 0
while index < len(values):
value = values[index]
merged.append(value)
index += 1
while index < len(values):
next_value = values[index]
# TRON console
print(
"value:", value,
"next_value:", next_value,
"delta:", round(next_value - value, 3)
)
if abs(next_value - value) > radius:
break
# end if
index += 1
# end while
# end while
return merged
# end def
latitude_degres_init = [
50.90778, 51.19047, 50.75686, 51.17059, 50.2414, 50.90233,
51.11861, 50.57397, 51.34806, 50.87667, 50.45392, 50.74944,
51.09472, 50.65397, 50.58583, 51.165, 50.51472, 51.18767,
50.897, 50.90828, 50.91139, 50.89, 50.46269, 50.82058, 50.63175,
50.64431, 51.19683, 50.96472, 50.92028, 50.82403, 50.48953,
51.22031, 51.16742, 50.478, 50.74722, 50.29917, 50.60222,
51.00306, 50.64917, 50.70944, 50.77933, 50.87997, 51.1825,
50.59278, 50.72306, 51.37083, 51.29131, 50.13, 50.63667,
50.87944, 51.23611, 49.52333, 49.83194, 50.63917, 51.195,
50.83806, 51.16667, 50.9125, 50.75194, 50.25389, 50.94528,
49.74167, 50.3725, 50.92694, 50.14389, 50.59306, 50.44278,
50.83306, 50.66278, 51.26944, 49.97861, 50.71957, 50.69389,
50.49694, 50.3775, 50.69583, 50.68917, 51.36585, 50.66222,
49.77583, 50.07778, 50.47333, 50.41778, 50.61806, 50.80639,
51.19056, 50.25278, 50.46944, 50.36722, 50.66958, 50.28278,
49.60111, 50.6825, 49.60833, 50.26667, 50.73944, 51.18944,
50.75783, 51.16833, 50.90139, 51.34083, 49.89167, 50.15278,
50.46, 50.57591, 51.09033, 50.24333, 50.94861, 50.75556,
51.30528, 51.18083, 50.81722, 51.12, 50.63639, 50.90139,
50.85278, 50.48806, 51.19889, 50.4575, 50.03583, 50.9475,
50.4825, 50.79194, 50.03417, 50.78167, 50.5525, 50.52972,
51.14417, 51.39417, 50.97, 51.26472, 51.01528
]
longitude_degres_init = [
4.13889, 4.47258, 4.76874, 5.46609, 4.65326, 4.53808, 4.84222,
3.83287, 3.35528, 5.13444, 4.44139, 4.64167, 2.65167, 5.47042,
5.71028, 4.18389, 5.62361, 4.46828, 4.51964, 4.50189, 4.49472,
4.49442, 4.46653, 3.21822, 5.43281, 5.44844, 2.86161, 3.49611,
4.61617, 3.22486, 4.55539, 3.01161, 4.56622, 5.91303, 3.71861,
6.13222, 6.25194, 4.17167, 5.84889, 3.21444, 4.28136, 4.36214,
5.44889, 5.25139, 4.60111, 3.36694, 4.27945, 4.37278, 6.20722,
4.02778, 3.6575, 6.35861, 5.33139, 5.90611, 4.99861, 5.50611,
4.57139, 3.63694, 4.77417, 5.54139, 3.61583, 5.86972, 6.285,
3.9925, 5.37361, 6.23806, 5.79417, 4.15861, 5.15361, 3.40667,
6.16639, 4.96746, 4.29083, 5.7625, 6.34833, 6.13639, 6.14028,
4.33761, 4.91417, 5.02111, 5.80694, 3.63333, 5.10194, 4.05667,
5.04528, 4.83833, 5.77389, 6.33639, 6.36611, 4.84704, 6.28861,
5.42056, 5.66556, 5.58417, 6.25, 3.48611, 4.46028, 4.767,
5.46972, 4.48444, 4.50417, 5.22389, 4.38722, 4.45278, 3.83098,
2.65283, 4.64583, 4.39194, 3.86389, 4.39056, 5.22083, 3.20444,
5.30722, 5.44278, 4.48444, 3.14722, 4.76889, 2.86222, 3.82028,
5.40417, 5.59056, 5.91028, 5.20167, 5.44, 4.95778, 5.855,
3.49444, 3.47556 , 4.95917, 5.375, 4.75333, 5.52639
]
# init dictionnaire de référence (latitude: longitude)
gps_locations = dict(zip(latitude_degres_init, longitude_degres_init))
# fusion des latitudes
latitudes = merge(gps_locations.keys(), radius=0.5)
print("\nsorted and merged latitudes:", latitudes)
clean_up = dict()
for latitude in latitudes:
clean_up[latitude] = gps_locations[latitude]
# end for
# update GPS locations
gps_locations = clean_up
print("\nnew GPS locations (latitude: longitude):\n\n", gps_locations)
# fusion des longitudes
longitudes = merge(gps_locations.values(), radius=0.5)
print("\nsorted and merged longitudes:", longitudes)
clean_up = dict()
for latitude, longitude in gps_locations.items():
if longitude in longitudes:
clean_up[latitude] = longitude
longitudes.remove(longitude)
# end if
# end for
# update GPS locations
gps_locations = clean_up
del clean_up
# résultats
latitudes = gps_locations.keys()
longitudes = gps_locations.values()
print("\nnew GPS locations (latitude: longitude):\n\n", gps_locations) |
Partager