Distribute data with layers instead of data/ dir

This was originally done to make the gitignoring easier, but ended up
being somewhat more complex when trying to include files, so they're
moving out closer to the point of use.
main
Chandler Swift 2023-07-25 19:12:30 -05:00
parent c74edcb8c0
commit 7957523c3c
Signed by: chandlerswift
GPG Key ID: A851D929D52FB93F
21 changed files with 49 additions and 51 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
node_modules
dist
*.geojson
*.shp

View File

@ -14,4 +14,11 @@ build: # TODO: add get_data as a prereq
# this file much more often. Maybe as things stabilize!
.PHONY: get_data
get_data:
./data/get_all_data.sh
@find ./ -name "get_data.*" \! -executable | grep . >/dev/null \
&& echo "Non-executable files found; consider running:" \
&& find ./ -name "get_data.*" \! -executable -exec echo " " chmod +x {} \; \
&& exit 1 \
|| true
@find ./ -name "get_data.*" -executable \
-exec sh -c 'cd $$(dirname {}) && echo processing {}; ./$$(basename {}) | sed --unbuffered "s/^/ /"' \;

View File

@ -1,10 +0,0 @@
#!/bin/sh
cd $(dirname $0)
find ../ -name "get_data.*" \! -executable | grep . >/dev/null \
&& echo "Non-executable files found; consider running:" \
&& find ../ -name "get_data.*" \! -executable -exec echo chmod +x {} \; \
&& exit 1
find ../ -name "get_data.*" -executable -exec sh -c "echo processing {}; {} | sed --unbuffered 's/^/ /'" \;

View File

@ -1,3 +1,3 @@
#!/bin/sh
curl --silent --output amtrak-data.geojson https://maps.amtrak.com/services/MapDataService/stations/nationalRoute
curl --silent --output data.geojson https://maps.amtrak.com/services/MapDataService/stations/nationalRoute

View File

@ -4,19 +4,19 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style, Stroke} from 'ol/style.js';
import amtrakURL from '/data/amtrak-data.geojson?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
const amtrak_colors = '0,83,126'; // from their website's cookie banner, and other places
const colors = '0,83,126'; // from their website's cookie banner, and other places
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: amtrakURL,
url: url,
format: new GeoJSON,
}),
style: function(feature, resolution){
return new Style({
stroke: new Stroke({
color: `rgba(${amtrak_colors},${Math.min(1, Math.pow(resolution/10, 1/4))})`,
color: `rgba(${colors},${Math.min(1, Math.pow(resolution/10, 1/4))})`,
width: 10/Math.pow(resolution, 1/4),
})
});

View File

@ -2,4 +2,4 @@
# from https://ridewithgps.com/embeds?type=region&id=37
# also https://ridewithgps.com/route_set_overviews/37.json?include_details=1
curl --silent --output bikepacking-data.geojson https://ridewithgps.com/cos/route_set_overviews/simplified_route/37.json
curl --silent --output data.geojson https://ridewithgps.com/cos/route_set_overviews/simplified_route/37.json

View File

@ -4,7 +4,7 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style, Stroke} from 'ol/style.js';
import url from '/data/bikepacking-data.geojson?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
const colors = '0,0,0'; // from their website's cookie banner, and other places

View File

@ -66,5 +66,5 @@ geojson = {
"features": stores,
}
with open("culvers-data.geojson", "w") as f:
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))

View File

@ -5,18 +5,18 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js';
import culversURL from '/data/culvers-data.geojson?url'; // TODO: remove `?url`?
import pinURL from './pin.svg?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
import pin from './pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: culversURL,
url: url,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pinURL,
src: pin,
}),
}),
});

View File

@ -31,7 +31,7 @@ geojson = {
"features": stores,
}
with open("krispy-kreme-data.geojson", "w") as f:
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))
print(f"{len(locations)} locations found")

View File

@ -5,18 +5,18 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js';
import waffleHouseURL from '/data/krispy-kreme-data.geojson?url'; // TODO: remove `?url`?
import pinURL from './pin.svg?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
import pin from './pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: waffleHouseURL,
url: url,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pinURL,
src: pin,
}),
}),
});

View File

@ -4,7 +4,6 @@ import requests
import json
from bs4 import BeautifulSoup
print("Searching for Kwik Trip locations")
response = requests.get('https://www.kwiktrip.com/Maps-Downloads/Store-List')
# HACK HACK HACK
@ -44,5 +43,5 @@ geojson = {
"features": stores,
}
with open("kwik-trip-data.geojson", "w") as f:
with open("./data.geojson", "w") as f:
f.write(json.dumps(geojson))

View File

@ -5,18 +5,18 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js';
import kwikTripURL from '/data/kwik-trip-data.geojson?url'; // TODO: remove `?url`?
import pinURL from './pin.svg?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
import pin from './pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: kwikTripURL,
url: url,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pinURL,
src: pin,
}),
}),
});

View File

@ -52,7 +52,7 @@ geojson = {
"features": stores,
}
with open("menards-data.geojson", "w") as f:
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))
print(f"{len(menardses)} locations found")

View File

@ -5,18 +5,18 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js';
import menardsURL from '/data/menards-data.geojson?url'; // TODO: remove `?url`?
import pinURL from './pin.svg?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
import pin from './pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: menardsURL,
url: url,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pinURL,
src: pin,
}),
}),
});

View File

@ -4,8 +4,6 @@ import requests
import json
from bs4 import BeautifulSoup
print("Searching for Milwaukee Burger Company locations")
# Stolen from my machine, appears to work; sufficient and necessary to get
# around their firewall apparently?
UA={
@ -39,5 +37,7 @@ geojson = {
"features": locations,
}
with open("milwaukee-burger-company-data.geojson", "w") as f:
print(len(locations), "locations found")
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))

View File

@ -5,7 +5,7 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js';
import url from '/data/milwaukee-burger-company-data.geojson?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
import pin from './pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({

View File

@ -35,7 +35,7 @@ geojson = {
"features": stores,
}
with open("waffle-house-data.geojson", "w") as f:
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))
print(f"{len(locations)} locations found")

View File

@ -5,18 +5,18 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js';
import waffleHouseURL from '/data/waffle-house-data.geojson?url'; // TODO: remove `?url`?
import pinURL from './pin.svg?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
import pin from './pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: waffleHouseURL,
url: url,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pinURL,
src: pin,
}),
}),
});

View File

@ -93,5 +93,5 @@ geojson = {
"features": arenas,
}
with open("nhl-arenas-data.geojson", "w") as f:
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))

View File

@ -4,13 +4,13 @@ import GeoJSON from 'ol/format/GeoJSON.js';
import {Style, Stroke, Circle, Fill} from 'ol/style.js';
import arenaURL from '/data/nhl-arenas-data.geojson?url'; // TODO: remove `?url`?
import url from './data.geojson?url'; // TODO: remove `?url`?
import visitedArenas from './visited.js'
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: arenaURL,
url: url,
format: new GeoJSON,
}),
// TODO: use '✓' and '✗' (or maybe '✔' and '✘') (from https://en.wikipedia.org/wiki/List_of_Unicode_characters#Dingbats)