Add Trahan trip route
This commit is contained in:
parent
8017e4d88b
commit
bd31c08c16
5 changed files with 91 additions and 0 deletions
41
util/process_owntracks_geojson_to_line.py
Normal file
41
util/process_owntracks_geojson_to_line.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
import math
|
||||
import sys
|
||||
|
||||
# https://stackoverflow.com/a/19412565
|
||||
# returns distance in kilometers
|
||||
def distance(lat1, lon1, lat2, lon2):
|
||||
R = 6373.0 # Approximate radius of earth in km
|
||||
|
||||
lat1 = math.radians(52.2296756)
|
||||
lon1 = math.radians(21.0122287)
|
||||
lat2 = math.radians(52.406374)
|
||||
lon2 = math.radians(16.9251681)
|
||||
|
||||
dlon = lon2 - lon1
|
||||
dlat = lat2 - lat1
|
||||
|
||||
a = math.sin(dlat / 2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2)**2
|
||||
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
|
||||
|
||||
return R * c
|
||||
|
||||
data = json.load(sys.stdin)
|
||||
|
||||
coordinates = []
|
||||
|
||||
for feature in data['features']:
|
||||
if feature['properties']['acc'] < 500:
|
||||
coordinates.append(feature['geometry']['coordinates'])
|
||||
# TODO: auto prune unnecessary points (e.g. too close to previous points?)
|
||||
|
||||
print(json.dumps({
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": coordinates,
|
||||
},
|
||||
}))
|
||||
Loading…
Add table
Add a link
Reference in a new issue