diff --git a/layers/chains/index.js b/layers/chains/index.js index aa88209..e58f4ae 100644 --- a/layers/chains/index.js +++ b/layers/chains/index.js @@ -10,6 +10,7 @@ import punchPizzaLayer from './punch-pizza/layer.js'; import raisingCanesLayer from './raising-canes/layer.js'; import waffleHouseLayer from './waffle-house/layer.js'; import whataburgerLayer from './whataburger/layer.js'; +import zorbazLayer from './zorbaz/layer.js'; const chains = { name: "Chains", @@ -62,6 +63,10 @@ const chains = { name: "Whataburger", layer: whataburgerLayer, }, + { + name: "Zorbaz", + layer: zorbazLayer, + }, ], }; diff --git a/layers/chains/zorbaz/get_data.py b/layers/chains/zorbaz/get_data.py new file mode 100755 index 0000000..962450f --- /dev/null +++ b/layers/chains/zorbaz/get_data.py @@ -0,0 +1,61 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i python3 +#! nix-shell -p python3 python3Packages.selenium geckodriver + +import json +import time +from selenium import webdriver +from selenium.webdriver.firefox.options import Options +from selenium.webdriver.support.ui import WebDriverWait + +options = Options() +options.headless = True +options.add_argument("--headless") # apparently options.headless = True isn't working? + +driver = webdriver.Firefox(options=options) + +try: + url = "https://www.zorbaz.com/locationz" + driver.get(url) + + # Wait for POPMENU_APOLLO_STATE to be available + WebDriverWait(driver, 10).until( + lambda d: d.execute_script("return typeof POPMENU_APOLLO_STATE !== 'undefined'") + ) + + apollo_state_json = driver.execute_script("return JSON.stringify(POPMENU_APOLLO_STATE);") + +finally: + driver.quit() + +zorbazez = [] +for k, v in json.loads(apollo_state_json).items(): + if not k.startswith('RestaurantLocation:'): + continue + zorbazez.append({ + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [float(v['lng']), float(v['lat'])], # yes, [lon, lat] since it's [x, y] + }, + "properties": { + "Phone": v['displayPhone'], + "Address": v['fullAddress'], + "Email": v['email'], + "customLocationContent": v['customLocationContent'], + "Hours": v['schemaHours'], + # "openingRanges": [{ + # "__ref": "RestaurantLocationOpeningRange:99114" + # }], + }, + }) + +geojson = { + "type": "FeatureCollection", + "features": zorbazez, +} + +with open("data.geojson", "w") as f: + f.write(json.dumps(geojson)) + +print(f"{len(zorbazez)} locations found") diff --git a/layers/chains/zorbaz/layer.js b/layers/chains/zorbaz/layer.js new file mode 100644 index 0000000..af140b4 --- /dev/null +++ b/layers/chains/zorbaz/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/zorbaz/pin.svg b/layers/chains/zorbaz/pin.svg new file mode 100644 index 0000000..227f12c --- /dev/null +++ b/layers/chains/zorbaz/pin.svg @@ -0,0 +1,12 @@ + + + +