Compare commits

...

3 commits

Author SHA1 Message Date
e39c23a102
Add remote deployment option
From outside my network, I should route through the jump host.
2026-03-08 20:08:33 -05:00
1e3b67ebdd
Download fcc tower data in script rather than expecting it present 2026-03-03 22:35:59 -06:00
c9b033a61e
Add layer for FCC tower registrations 2026-03-03 22:28:13 -06:00
6 changed files with 140 additions and 0 deletions

View file

@ -2,6 +2,10 @@
deploy: build deploy: build
rsync --archive --verbose --delete dist/ root@bert:/srv/www/maps.chandlerswift.com/ rsync --archive --verbose --delete dist/ root@bert:/srv/www/maps.chandlerswift.com/
.PHONY: deploy-remote
deploy-remote: build
rsync --archive --verbose --delete dist/ root@bert-jump:/srv/www/maps.chandlerswift.com/
.PHONY: clean .PHONY: clean
clean: clean:
rm -r dist rm -r dist

View file

@ -0,0 +1 @@
https://data.fcc.gov/download/pub/uls/complete/r_tower.zip

View file

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

16
layers/fcc/towers/pin.svg Normal file
View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 384 512"
width="40px"
height="30px"
version="1.1"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="m 384,192 c 0,87.4 -117,243 -168.3,307.2 -12.3,15.3 -35.1,15.3 -47.4,0 C 116.1,435 0,279.4 0,192 0,85.96 85.96,0 192,0 245.96029,0 294.73775,22.275796 329.62577,58.136607 363.27205,92.721042 384,139.94065 384,192 Z"
style="fill:#fd7800;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 851 B

90
layers/fcc/towers/process.py Executable file
View file

@ -0,0 +1,90 @@
#!/usr/bin/env nix-shell
#! nix-shell -i python3 -p python3
import csv
import io
import json
import zipfile
import urllib.request
fieldnames = {
"CO": ("Record Type", "Content Indicator", "File Number", "Registration Number", "Unique System Identifier",
"Coordinate Type", "Latitude Degrees", "Latitude Minutes", "Latitude Seconds", "Latitude Direction",
"Latitude_Total_Seconds", "Longitude Degrees", "Longitude Minutes", "Longitude Seconds",
"Longitude Direction", "Longitude Total Seconds", "Array Tower Position", "Array Total Tower"),
}
filenames = ["CO", "EN", "HS", "RA", "RE", "SC"]
files = {}
resp = urllib.request.urlopen("https://data.fcc.gov/download/pub/uls/complete/r_tower.zip")
with zipfile.ZipFile(io.BytesIO(resp.read())) as z:
for filename in filenames:
with z.open(f"{filename}.dat", "r") as f, io.TextIOWrapper( # Avoids `_csv.Error: iterator should return strings, not bytes (the file should be opened in text mode)`
f, encoding="utf-8", newline="", errors="replace"
) as text_f:
contents = []
# csv expects text rows; TextIOWrapper decodes bytes from the zip member
reader = csv.DictReader(text_f, delimiter="|", fieldnames=fieldnames.get(filename))
for row in reader:
contents.append(row)
files[filename] = contents
# CO data example:
#{
# 'Record Type': 'CO',
# 'Content Indicator': 'REG',
# 'File Number': 'A0016772',
# 'Registration Number': '1014003',
# 'Unique System Identifier': '99845',
# 'Coordinate Type': 'T',
# 'Latitude Degrees': '18',
# 'Latitude Minutes': '26',
# 'Latitude Seconds': '18.0',
# 'Latitude Direction': 'N',
# 'Latitude_Total_Seconds': '66378.0',
# 'Longitude Degrees': '66',
# 'Longitude Minutes': '29',
# 'Longitude Seconds': '53.0',
# 'Longitude Direction': 'W',
# 'Longitude Total Seconds': '239393.0',
# 'Array Tower Position': '',
# 'Array Total Tower': ''
# }
towers = []
for w in files["CO"]:
if w['Longitude Degrees'] == '' or w['Latitude Degrees'] == '':
print(f"Skipping tower with missing coordinates: {w}")
continue
towers.append({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
(float(w['Longitude Degrees']) +
float(w['Longitude Minutes']) / 60 +
float(w['Longitude Seconds']) / 3600) *
(-1 if w['Longitude Direction'] == 'W' else 1),
(float(w['Latitude Degrees']) +
float(w['Latitude Minutes']) / 60 +
float(w['Latitude Seconds']) / 3600) *
(1 if w['Latitude Direction'] == 'N' else -1),
], # yes, [lon, lat] since it's [x, y]
},
"properties": {
"File Number": w['File Number'],
"Registration Number": w['Registration Number'],
"Unique System Identifier": w['Unique System Identifier'],
},
})
print(f"""{len(towers)} towers found""")
geojson = {
"type": "FeatureCollection",
"features": towers,
}
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))

View file

@ -23,6 +23,7 @@ import minnesotaAdventureTrails from './minnesota-adventure-trails/index.js';
import cropHistory from './crop-history/index.js'; import cropHistory from './crop-history/index.js';
import mnAmbulanceServiceAreas from './mn-ambulance-service-areas/layer.js'; import mnAmbulanceServiceAreas from './mn-ambulance-service-areas/layer.js';
import upsServiceAreas from './ups/index.js'; import upsServiceAreas from './ups/index.js';
import fccTowersLayer from './fcc/towers/layer.js';
const layerCategories = [ const layerCategories = [
{ // Base maps { // Base maps
@ -93,6 +94,10 @@ const layerCategories = [
layer: bikepackingLayer, layer: bikepackingLayer,
}, },
mnAmbulanceServiceAreas, mnAmbulanceServiceAreas,
{
name: "FCC Towers",
layer: fccTowersLayer,
}
] ]
}, },
upsServiceAreas, upsServiceAreas,