38 lines
1.3 KiB
Bash
Executable file
38 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# TODO: use https://geodesy.noaa.gov/pub/DS_ARCHIVE/BETA_PRODUCTS/ instead
|
|
# I should have used this in the first place, but it took me a long time to find
|
|
|
|
mkdir -p data
|
|
|
|
mkdir -p tmp
|
|
cd tmp
|
|
for state in $(curl https://geodesy.noaa.gov/cgi-bin/sf_archive.prl | grep "<option" | cut -d '"' -f2); do
|
|
lowercase_state=$(echo $state | tr '[:upper:]' '[:lower:]')
|
|
curl -o $state.zip "https://geodesy.noaa.gov/cgi-bin/sf_archive.prl?StateSelected=${state}&CompressType=Zipped"
|
|
unzip $state.zip
|
|
ogr2ogr -f GeoJSON ../data/$lowercase_state.geojson $lowercase_state.shp
|
|
sed -i '/^"crs":/d' ../data/$lowercase_state.geojson # TODO: handle this projection properly
|
|
done
|
|
cd ..
|
|
rm -r tmp
|
|
|
|
# hack hack hack
|
|
#
|
|
# If I write this to one big file, I can't take advantage of any lazy loading
|
|
# for performance reasons, so I'm constrained to having a bunch of files. I
|
|
# can't programmatically import those, since es6 imports don't allow for that.
|
|
# So, codegen it is (and fairly gross codegen at that!).
|
|
truncate -s 0 states.js
|
|
for file in ./data/*; do
|
|
basename=$(basename $file .geojson)
|
|
echo "import _$basename from '$file?url';" >> states.js
|
|
done
|
|
echo >> states.js
|
|
echo "export default {" >> states.js
|
|
for file in ./data/*; do
|
|
basename=$(basename $file .geojson)
|
|
echo " $basename: _$basename," >> states.js
|
|
done
|
|
echo "};" >> states.js
|