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.
This commit is contained in:
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

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),
})
});