Add MN Adventure Trails

main
Chandler Swift 2024-09-02 12:23:40 -05:00
parent 5ade88be5e
commit 142f8bbe6a
Signed by: chandlerswift
GPG Key ID: A851D929D52FB93F
4 changed files with 72 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import trips from './trips/index.js';
import dot_cams from './dot-cams/index.js';
import survey_markers from './survey-markers/index.js';
import tjx from './tjx/index.js';
import minnesotaAdventureTrails from './minnesota-adventure-trails/index.js';
const layerCategories = [
{ // Base maps
@ -90,6 +91,7 @@ const layerCategories = [
},
]
},
minnesotaAdventureTrails,
survey_markers,
dot_cams,
trips,

View File

@ -0,0 +1,2 @@
*.kmz
routes.js

View File

@ -0,0 +1,28 @@
#!/bin/sh
# SEMAT: https://www.google.com/maps/d/u/0/viewer?mid=1fd5DwCNSTNyd2ijSa3FcKTXfn85wFD8
# NEMAT: https://www.google.com/maps/d/u/0/viewer?mid=19EWOYHcIlO9HX3Xwc6peFxMwdhsEt78
# NCMAT: https://www.google.com/maps/d/u/0/viewer?mid=1qtnoqH2w_E4QT8rDYStKw_S1TWI-cRw
cd $(dirname $0)
for file in *.kmz; do
zcat "$file" | ogr2ogr -f GeoJSON "$(basename "$file" .kmz).geojson" /vsistdin/ -skipfailures
done
# hack hack hack
truncate -s 0 routes.js
i=0
for file in ./*.geojson; do
echo "import _file$i from '$file?url';" >> routes.js
i=$((i+1))
done
echo >> routes.js
echo "export default {" >> routes.js
i=0
for file in ./*.geojson; do
basename=$(basename "$file" .geojson)
echo " \"$basename\": _file$i," >> routes.js
i=$((i+1))
done
echo "};" >> routes.js

View File

@ -0,0 +1,40 @@
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 data from './routes.js';
const trails = {
name: "Minnesota Adventure Trails",
details: `<a href="https://minnesotaadventuretrails.com/">https://minnesotaadventuretrails.com/</a>`,
layers: [],
};
for (let [chain, url] of Object.entries(data)) {
const colors = '0,0,0';
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),
})
});
},
});
trails.layers.push({
name: chain,
layer: vectorLayer,
});
}
trails.layers.sort((a, b) => a.name > b.name ? 1 : -1); // Names are always unique
export default trails;