diff --git a/layers/511mn/layer.js b/layers/511mn/layer.js deleted file mode 100644 index af140b4..0000000 --- a/layers/511mn/layer.js +++ /dev/null @@ -1,24 +0,0 @@ -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 url from './data.geojson?url'; // TODO: remove `?url`? -import pin from './pin.svg?url'; // TODO: remove `?url`? - -const vectorLayer = new VectorLayer({ - source: new VectorSource({ - url: url, - format: new GeoJSON, - }), - style: new Style({ - image: new Icon({ - anchor: [0.5, 1], - src: pin, - }), - }), -}); - -export default vectorLayer; diff --git a/layers/511mn/pin.svg b/layers/511mn/pin.svg deleted file mode 100644 index fb93212..0000000 --- a/layers/511mn/pin.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - diff --git a/layers/511mn/process_data.py b/layers/511mn/process_data.py deleted file mode 100644 index 4d3bf3e..0000000 --- a/layers/511mn/process_data.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -import requests -import json -import re - -with open("query.graphql") as f: - QUERY = f.read() - -PAYLOAD = [ - { - "query": QUERY, - "variables": { - "input": { - # Cover the whole state (this is pretty overkill, admittedly) - "north":53.23294, - "south":40.40589, - "east":-78.6823, - "west":-107.24675, - "zoom":9, - "layerSlugs": ["normalCameras"], - "nonClusterableUris": ["dashboard"] - }, - "plowType":"plowCameras", - } - } -] - -res = requests.post('https://511mn.org/api/graphql', json=PAYLOAD) -res.raise_for_status() - -camera_views = res.json()[0]['data']['mapFeaturesQuery']['mapFeatures'] - -cameras = [] - -viewCount = 0 - -for c in camera_views: - if len(c['features']) != 1: - print(c) - raise Exception(f"Unexpected number of features: {len(c['features'])}") - - if re.match(r"Show [\d]* cameras", c['tooltip']): - raise Exception(f"Not zoomed in enough! Finding aggregate cameras: {c}") - - viewCount += len(c['views']) - cameras.append({ - "type": "Feature", - "geometry": c['features'][0]['geometry'], - "properties": { - 'address': c['tooltip'], - 'website': c['views'][0]['url'], - 'originalData': c, - }, - }) - -geojson = { - "type": "FeatureCollection", - "features": cameras, -} - -with open("data.geojson", "w") as f: - f.write(json.dumps(geojson)) - -print(f"{len(cameras)} locations found") -print(f"{viewCount} total views") diff --git a/layers/511mn/query.graphql b/layers/511mn/query.graphql deleted file mode 100644 index d032daa..0000000 --- a/layers/511mn/query.graphql +++ /dev/null @@ -1,40 +0,0 @@ -query MapFeatures($input: MapFeaturesArgs!, $plowType: String) { - mapFeaturesQuery(input: $input) { - mapFeatures { - bbox - tooltip - uri - features { - id - geometry - properties - } - ... on Event { - priority - } - __typename - ... on Camera { - views(limit: 5) { - uri - ... on CameraView { - url - } - category - } - } - ... on Plow { - views(limit: 5, plowType: $plowType) { - uri - ... on PlowCameraView { - url - } - category - } - } - } - error { - message - type - } - } -} diff --git a/layers/index.js b/layers/index.js index e29b26c..4ae7f7b 100644 --- a/layers/index.js +++ b/layers/index.js @@ -14,7 +14,6 @@ import cellular from './cellular.js'; import light_pollution from './light_pollution.js'; import state_land from './state-land/index.js'; import trips from './trips/index.js'; -import _511mncamerasLayer from './511mn/layer.js'; const layerCategories = [ { // Base maps @@ -76,11 +75,6 @@ const layerCategories = [ name: "Bikepacking.com Routes", layer: bikepackingLayer, }, - { - name: "511MN Cameras", - layer: _511mncamerasLayer, - enabled: true, - } ] }, trips, diff --git a/main.js b/main.js index aa623af..0ac7688 100644 --- a/main.js +++ b/main.js @@ -79,9 +79,10 @@ for (let category of layerCategories) { } function objectToTable(o) { - // TODO: hack hack hack let table = ``; + // TODO: hack hack hack for (let [key, value] of Object.entries(o)) { + console.log(`typeof ${value} = ${typeof value}`); if (typeof value === "object") { value = objectToTable(value); } @@ -102,10 +103,11 @@ map.on('click', function (evt) { if (!feature) { return; } - - // exclude geometry -- https://stackoverflow.com/a/208106 + + // https://stackoverflow.com/a/208106 const {geometry: _, ...featureData} = feature.values_; content.innerHTML = objectToTable(featureData); popupOverlay.setPosition(evt.coordinate); + console.log(feature); });