diff --git a/layers/chains/country-kitchen/get_data.py b/layers/chains/country-kitchen/get_data.py new file mode 100755 index 0000000..ad81cbb --- /dev/null +++ b/layers/chains/country-kitchen/get_data.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 + +import requests +import json +import re + +# Stolen from my machine, appears to work; sufficient and necessary to get +# around their firewall apparently? +UA={ + "User-Agent": 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0' +} + +response = requests.get('https://countrykitchenrestaurants.com/locations/', headers=UA) + +data = re.search(r'jQuery\(document\).ready\(function\(\$\) \{var map1 = \$\("#map1"\).maps\((.*)\).data\("wpgmp_maps"\);\}\);', response.text) +data = json.loads(data[1]) + +locations = [] +for location in data['places']: + if "coming soon" in location['title'].lower(): + continue + if location['title'] == "Dodgeville, WI": + # currently location['location']['country'] == 'WI', and no location['location']['state'] -- D'oh! + location['location']['state'] = 'WI' + try: + locations.append({ + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [float(location['location']['lng']), float(location['location']['lat'])], # yes, [lon, lat] since it's [x, y] + }, + "properties": { + 'address': location['address'], + 'city': location['location']['city'], + 'state': location['location']['state'], + 'zip': location['location']['postal_code'], + }, + }) + except: + print(location) + +geojson = { + "type": "FeatureCollection", + "features": locations, +} + +print(len(locations), "locations found") + +with open("data.geojson", "w") as f: + f.write(json.dumps(geojson)) diff --git a/layers/chains/country-kitchen/layer.js b/layers/chains/country-kitchen/layer.js new file mode 100644 index 0000000..af140b4 --- /dev/null +++ b/layers/chains/country-kitchen/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 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/chains/country-kitchen/pin.svg b/layers/chains/country-kitchen/pin.svg new file mode 100644 index 0000000..ef37b03 --- /dev/null +++ b/layers/chains/country-kitchen/pin.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + diff --git a/layers/chains/index.js b/layers/chains/index.js index d27025c..d12b301 100644 --- a/layers/chains/index.js +++ b/layers/chains/index.js @@ -1,3 +1,4 @@ +import countryKitchenLayer from './country-kitchen/layer.js'; import culversLayer from './culvers/layer.js'; import krispyKremeLayer from './krispy-kreme/layer.js'; import kwikTripLayer from './kwik-trip/layer.js'; @@ -9,6 +10,10 @@ import whataburgerLayer from './whataburger/layer.js'; const chains = { name: "Chains", layers: [ + { + name: "Country Kitchen", + layer: countryKitchenLayer, + }, { name: "Culver's", layer: culversLayer,