Add Zorbaz

Requested-By: Isaac
This commit is contained in:
Chandler Swift 2025-04-14 22:51:58 -05:00
parent 9f79a4054b
commit a44550dc0c
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
4 changed files with 102 additions and 0 deletions

View file

@ -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,
},
],
};

View file

@ -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")

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 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;

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 384 512"
width="40px"
height="30px"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<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:#FFDE00;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 499 B