Add states, plus who's visited where
This commit is contained in:
parent
0b88a77b15
commit
3e3eae869c
|
@ -8,6 +8,7 @@ import arenasLayer from './nhl-arenas/layer.js';
|
|||
import bikepackingLayer from './bikepacking/layer.js';
|
||||
import chains from './chains/index.js';
|
||||
import census_bureau from './census-bureau/index.js';
|
||||
import states from './states/index.js';
|
||||
|
||||
const layerCategories = [
|
||||
{ // Base maps
|
||||
|
@ -73,6 +74,7 @@ const layerCategories = [
|
|||
},
|
||||
chains,
|
||||
census_bureau,
|
||||
states,
|
||||
];
|
||||
|
||||
export default layerCategories;
|
||||
|
|
9
layers/states/get_data.sh
Executable file
9
layers/states/get_data.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
for resolution in 20m 5m 500k; do
|
||||
curl --silent --remote-name https://www2.census.gov/geo/tiger/GENZ2022/shp/cb_2022_us_state_${resolution}.zip
|
||||
unzip cb_2022_us_state_${resolution}.zip
|
||||
ogr2ogr -f GeoJSON us-states-${resolution}.geojson cb_2022_us_state_${resolution}.shp
|
||||
sed -i '/^"crs":/d' us-states-${resolution}.geojson # TODO: handle this projection properly
|
||||
rm cb_2022_us_state_${resolution}.*
|
||||
done
|
90
layers/states/index.js
Normal file
90
layers/states/index.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
import GeoJSON from 'ol/format/GeoJSON.js';
|
||||
import VectorLayer from 'ol/layer/Vector.js';
|
||||
import VectorSource from 'ol/source/Vector.js';
|
||||
|
||||
import highResStates from './us-states-500k.geojson?url';
|
||||
import medResStates from './us-states-5m.geojson?url';
|
||||
import lowResStates from './us-states-20m.geojson?url';
|
||||
|
||||
import { Fill, Stroke, Style, Text } from 'ol/style.js';
|
||||
|
||||
function style(feature){
|
||||
return new Style({
|
||||
text: new Text({
|
||||
text: feature.get('NAME'),
|
||||
}),
|
||||
fill: new Fill({
|
||||
color: 'rgba(255,255,255,0.4)',
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: '#3399CC',
|
||||
width: 1.25,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
const layers = {
|
||||
name: "US States",
|
||||
layers: [
|
||||
{
|
||||
name: "All (high-res)",
|
||||
layer: new VectorLayer({
|
||||
source: new VectorSource({
|
||||
url: highResStates,
|
||||
format: new GeoJSON(),
|
||||
}),
|
||||
style: style,
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "All (medium-res)",
|
||||
layer: new VectorLayer({
|
||||
source: new VectorSource({
|
||||
url: medResStates,
|
||||
format: new GeoJSON(),
|
||||
}),
|
||||
style: style,
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "All (low-res)",
|
||||
layer: new VectorLayer({
|
||||
source: new VectorSource({
|
||||
url: lowResStates,
|
||||
format: new GeoJSON(),
|
||||
}),
|
||||
style: style,
|
||||
}),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
import visitedStatesLists from './visited.js';
|
||||
|
||||
for (let [visitor, visitedStates] of Object.entries(visitedStatesLists)) {
|
||||
layers.layers.push({
|
||||
name: "Visited by " + visitor,
|
||||
layer: new VectorLayer({
|
||||
source: new VectorSource({
|
||||
url: lowResStates,
|
||||
format: new GeoJSON(),
|
||||
}),
|
||||
style: function(feature){
|
||||
return new Style({
|
||||
text: new Text({
|
||||
text: feature.get('NAME'),
|
||||
}),
|
||||
fill: new Fill({
|
||||
color: visitedStates.includes(feature.get('STUSPS')) ? 'rgba(128,255,128,0.4)' : 'rgba(255,127,127,0.4)',
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: '#3399CC',
|
||||
width: 1.25,
|
||||
}),
|
||||
});
|
||||
}
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
export default layers;
|
122
layers/states/visited.js
Normal file
122
layers/states/visited.js
Normal file
|
@ -0,0 +1,122 @@
|
|||
const visitedStatesLists = {
|
||||
Chandler: [
|
||||
'AK',
|
||||
'AL',
|
||||
'AR',
|
||||
'AZ',
|
||||
// 'CA',
|
||||
'CO',
|
||||
// 'CT',
|
||||
'DE',
|
||||
'FL',
|
||||
'GA',
|
||||
// 'HI',
|
||||
'IA',
|
||||
// 'ID',
|
||||
'IL',
|
||||
'IN',
|
||||
'KS',
|
||||
// 'KY',
|
||||
'LA',
|
||||
'MA',
|
||||
'MD',
|
||||
'ME',
|
||||
'MI',
|
||||
'MN',
|
||||
'MO',
|
||||
'MS',
|
||||
'MT',
|
||||
'NC',
|
||||
'ND',
|
||||
'NE',
|
||||
'NH',
|
||||
// 'NJ',
|
||||
'NM',
|
||||
// 'NV',
|
||||
'NY',
|
||||
'OH',
|
||||
'OK',
|
||||
'OR',
|
||||
'PA',
|
||||
'RI',
|
||||
// 'SC',
|
||||
'SD',
|
||||
'TN',
|
||||
'TX',
|
||||
// 'UT',
|
||||
'VA',
|
||||
'VT',
|
||||
'WA',
|
||||
'WI',
|
||||
// 'WV',
|
||||
'WY',
|
||||
],
|
||||
Käthe: [
|
||||
'AL',
|
||||
'AR',
|
||||
// 'AK',
|
||||
'AZ',
|
||||
'CA',
|
||||
'CO',
|
||||
// 'CT',
|
||||
'DE',
|
||||
'FL',
|
||||
'GA',
|
||||
'HI',
|
||||
'IA',
|
||||
'ID',
|
||||
'IL',
|
||||
'IN',
|
||||
'KS',
|
||||
// 'KY',
|
||||
'LA',
|
||||
'MA',
|
||||
'MD',
|
||||
'ME',
|
||||
'MI',
|
||||
'MN',
|
||||
'MO',
|
||||
'MS',
|
||||
'MT',
|
||||
'NC',
|
||||
'ND',
|
||||
'NE',
|
||||
// 'NH',
|
||||
// 'NJ',
|
||||
// 'NM',
|
||||
'NV',
|
||||
'NY',
|
||||
'OH',
|
||||
'OK',
|
||||
'OR',
|
||||
'PA',
|
||||
// 'RI',
|
||||
// 'SC',
|
||||
'SD',
|
||||
'TN',
|
||||
'TX',
|
||||
// 'UT',
|
||||
'VA',
|
||||
// 'VT',
|
||||
'WA',
|
||||
// 'WV',
|
||||
'WI',
|
||||
'WY',
|
||||
],
|
||||
Eric: [
|
||||
'AZ',
|
||||
'CO',
|
||||
'FL',
|
||||
'IA',
|
||||
'KS',
|
||||
'MN',
|
||||
'MO',
|
||||
'ND',
|
||||
'NE',
|
||||
'NM',
|
||||
'SD',
|
||||
'WI',
|
||||
],
|
||||
}
|
||||
|
||||
export default visitedStatesLists;
|
Loading…
Reference in a new issue