Add Trahan trip route
This commit is contained in:
parent
8017e4d88b
commit
bd31c08c16
|
@ -13,6 +13,7 @@ import national_land from './national-land/index.js';
|
|||
import cellular from './cellular.js';
|
||||
import light_pollution from './light_pollution.js';
|
||||
import state_land from './state-land/index.js';
|
||||
import trips from './trips/index.js';
|
||||
|
||||
const layerCategories = [
|
||||
{ // Base maps
|
||||
|
@ -76,6 +77,7 @@ const layerCategories = [
|
|||
},
|
||||
]
|
||||
},
|
||||
trips,
|
||||
chains,
|
||||
census_bureau,
|
||||
states,
|
||||
|
|
13
layers/trips/index.js
Normal file
13
layers/trips/index.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import ncAug2023 from './trahan-north-carolina-august-2023/layer.js'
|
||||
|
||||
const trips = {
|
||||
name: "Trips",
|
||||
layers: [
|
||||
{
|
||||
name: "North Carolina 2023-08 with Trahans",
|
||||
layer: ncAug2023,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default trips;
|
9
layers/trips/trahan-north-carolina-august-2023/get_data.sh
Executable file
9
layers/trips/trahan-north-carolina-august-2023/get_data.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
FROM="2023-08-24T12:45:00.000Z"
|
||||
TO="2023-09-01T21:50:00.000Z"
|
||||
URL="https://whereis.chandlerswift.com/api/0/locations?from=$FROM&to=$TO&format=geojson&user=chandler&device=oneplus6t"
|
||||
|
||||
curl --silent "$URL" \
|
||||
| python "$(dirname $0)/../../../util/process_owntracks_geojson_to_line.py" \
|
||||
> data.geojson
|
26
layers/trips/trahan-north-carolina-august-2023/layer.js
Normal file
26
layers/trips/trahan-north-carolina-august-2023/layer.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
import VectorLayer from 'ol/layer/Vector';
|
||||
import {Vector as VectorSource} from 'ol/source.js';
|
||||
import GeoJSON from 'ol/format/GeoJSON.js';
|
||||
|
||||
import {Style, Stroke} from 'ol/style.js';
|
||||
|
||||
import url from './data.geojson?url'; // TODO: remove `?url`?
|
||||
|
||||
const colors = '135, 0, 226'; // Käthe says lavender
|
||||
|
||||
const vectorLayer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
url: url,
|
||||
format: new GeoJSON,
|
||||
}),
|
||||
style: function(feature, resolution){
|
||||
return new Style({
|
||||
stroke: new Stroke({
|
||||
color: `rgba(${colors},${Math.min(1, Math.pow(resolution/10, 1/4))})`,
|
||||
width: 10/Math.pow(resolution, 1/4),
|
||||
})
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default vectorLayer;
|
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…
Reference in a new issue