diff --git a/layers/index.js b/layers/index.js index cc506d3..3489b2d 100644 --- a/layers/index.js +++ b/layers/index.js @@ -7,6 +7,7 @@ import arenasLayer from './nhl-arenas/layer.js'; import menardsLayer from './menards/layer.js'; import culversLayer from './culvers/layer.js'; import kwikTripLayer from './kwik-trip/layer.js'; +import waffleHouseLayer from './waffle-house/layer.js'; const layerCategories = [ { @@ -70,7 +71,11 @@ const layerCategories = [ { name: "Kwik Trip/Kwik Star", layer: kwikTripLayer, - } + }, + { + name: "Waffle House", + layer: waffleHouseLayer, + }, ] } ]; diff --git a/layers/waffle-house/get_data.py b/layers/waffle-house/get_data.py new file mode 100755 index 0000000..fa81d22 --- /dev/null +++ b/layers/waffle-house/get_data.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import requests +import re +import json + +res = requests.get('https://locations.wafflehouse.com/') + +content = res.text + +locations = re.search(r'', content)[1] + +locations = json.loads(locations)['props']['pageProps']['locations'] + +stores = [] + +for location in locations: + stores.append({ + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [float(location['longitude']), float(location['latitude'])], # yes, [lon, lat] since it's [x, y] + }, + "properties": { + 'address': location['addressLines'][0].title(), + 'city': location['city'].title(), + 'state': location['state'], + 'zip': location['postalCode'], + 'website': location['websiteURL'], + }, + }) + +geojson = { + "type": "FeatureCollection", + "features": stores, +} + +with open("waffle-house-data.geojson", "w") as f: + f.write(json.dumps(geojson)) + +print(f"{len(locations)} locations found") diff --git a/layers/waffle-house/layer.js b/layers/waffle-house/layer.js new file mode 100644 index 0000000..988ffaa --- /dev/null +++ b/layers/waffle-house/layer.js @@ -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 waffleHouseURL from '/data/waffle-house-data.geojson?url'; // TODO: remove `?url`? +import pinURL from '/layers/waffle-house/pin.svg?url'; // TODO: remove `?url`? + +const vectorLayer = new VectorLayer({ + source: new VectorSource({ + url: waffleHouseURL, + format: new GeoJSON, + }), + style: new Style({ + image: new Icon({ + anchor: [0.5, 1], + src: pinURL, + }), + }), +}); + +export default vectorLayer; diff --git a/layers/waffle-house/pin.svg b/layers/waffle-house/pin.svg new file mode 100644 index 0000000..a37cb75 --- /dev/null +++ b/layers/waffle-house/pin.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + +