Add airports layer
This commit is contained in:
parent
5553b815f6
commit
69e777033e
4 changed files with 83 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -7,5 +7,6 @@ layers/survey-markers/states.js
|
||||||
layers/tjx/data/chains.js
|
layers/tjx/data/chains.js
|
||||||
layers/crop-history/data/counties.js
|
layers/crop-history/data/counties.js
|
||||||
layers/mn-sales-tax/data/history.js
|
layers/mn-sales-tax/data/history.js
|
||||||
|
layers/airports/data/types.js
|
||||||
.direnv
|
.direnv
|
||||||
venv
|
venv
|
||||||
|
|
|
||||||
40
layers/airports/get_data.py
Executable file
40
layers/airports/get_data.py
Executable file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import csv
|
||||||
|
import io
|
||||||
|
import json
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
index_imports = []
|
||||||
|
|
||||||
|
resp = urllib.request.urlopen("https://davidmegginson.github.io/ourairports-data/airports.csv")
|
||||||
|
airports = list(csv.DictReader(io.TextIOWrapper(resp)))
|
||||||
|
types = set([a['type'] for a in airports])
|
||||||
|
|
||||||
|
for airport_type in types:
|
||||||
|
|
||||||
|
geojson = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [],
|
||||||
|
}
|
||||||
|
|
||||||
|
for airport in airports:
|
||||||
|
if airport['type'] == airport_type:
|
||||||
|
geojson['features'].append({
|
||||||
|
"type": "Feature",
|
||||||
|
"geometry": {
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [float(airport['longitude_deg']), float(airport['latitude_deg'])]
|
||||||
|
},
|
||||||
|
"properties": airport, # TODO
|
||||||
|
})
|
||||||
|
|
||||||
|
with open(f'data/{airport_type}.geojson', 'w') as f:
|
||||||
|
f.write(json.dumps(geojson))
|
||||||
|
|
||||||
|
with open("data/types.js", 'w') as f:
|
||||||
|
for airport_type in types:
|
||||||
|
f.write(f"import {airport_type} from './{airport_type}.geojson?url';\n")
|
||||||
|
f.write('\nexport default {\n')
|
||||||
|
for airport_type in types:
|
||||||
|
f.write(f" {airport_type}: {airport_type},\n")
|
||||||
|
f.write("};\n")
|
||||||
40
layers/airports/index.js
Normal file
40
layers/airports/index.js
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
import GeoJSON from 'ol/format/GeoJSON.js';
|
||||||
|
import VectorLayer from 'ol/layer/Vector.js';
|
||||||
|
import VectorSource from 'ol/source/Vector.js';
|
||||||
|
|
||||||
|
import types from './data/types.js';
|
||||||
|
|
||||||
|
import { Circle, Fill, Stroke, Style } from 'ol/style.js';
|
||||||
|
|
||||||
|
const layers = {
|
||||||
|
name: "Airports",
|
||||||
|
layers: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let [name, url] of Object.entries(types)) {
|
||||||
|
const layer = new VectorLayer({
|
||||||
|
source: new VectorSource({
|
||||||
|
url,
|
||||||
|
format: new GeoJSON,
|
||||||
|
}),
|
||||||
|
style: new Style({
|
||||||
|
image: new Circle({
|
||||||
|
radius: name == 'large_airport' ? 10 : name == "small_airport" ? 3 : 5,
|
||||||
|
fill: new Fill({
|
||||||
|
color: 'rgba(255,255,255,0.4)',
|
||||||
|
}),
|
||||||
|
stroke: new Stroke({
|
||||||
|
color: 'red',
|
||||||
|
width: name == 'large_airport' ? 4 : 2,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
layers.layers.push({
|
||||||
|
name,
|
||||||
|
layer,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default layers;
|
||||||
|
|
@ -26,6 +26,7 @@ import upsServiceAreas from './ups/index.js';
|
||||||
import fccTowersLayer from './fcc/towers/layer.js';
|
import fccTowersLayer from './fcc/towers/layer.js';
|
||||||
import mnSalesTaxLayers from './mn-sales-tax/index.js';
|
import mnSalesTaxLayers from './mn-sales-tax/index.js';
|
||||||
import versatilesLayers from './versatiles.js';
|
import versatilesLayers from './versatiles.js';
|
||||||
|
import airports from './airports/index.js';
|
||||||
|
|
||||||
const layerCategories = [
|
const layerCategories = [
|
||||||
{ // Base maps
|
{ // Base maps
|
||||||
|
|
@ -118,6 +119,7 @@ const layerCategories = [
|
||||||
tjx,
|
tjx,
|
||||||
cropHistory,
|
cropHistory,
|
||||||
mnSalesTaxLayers,
|
mnSalesTaxLayers,
|
||||||
|
airports,
|
||||||
];
|
];
|
||||||
|
|
||||||
export default layerCategories;
|
export default layerCategories;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue