Add Whataburger layer
This commit is contained in:
parent
3e3eae869c
commit
da86da8877
|
@ -4,6 +4,7 @@ import kwikTripLayer from './kwik-trip/layer.js';
|
||||||
import menardsLayer from './menards/layer.js';
|
import menardsLayer from './menards/layer.js';
|
||||||
import milwaukeeBurgerCompanyLayer from './milwaukee-burger-company/layer.js';
|
import milwaukeeBurgerCompanyLayer from './milwaukee-burger-company/layer.js';
|
||||||
import waffleHouseLayer from './waffle-house/layer.js';
|
import waffleHouseLayer from './waffle-house/layer.js';
|
||||||
|
import whataburgerLayer from './whataburger/layer.js';
|
||||||
|
|
||||||
const chains = {
|
const chains = {
|
||||||
name: "Chains",
|
name: "Chains",
|
||||||
|
@ -32,6 +33,10 @@ const chains = {
|
||||||
name: "Waffle House",
|
name: "Waffle House",
|
||||||
layer: waffleHouseLayer,
|
layer: waffleHouseLayer,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Whataburger",
|
||||||
|
layer: whataburgerLayer,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
46
layers/chains/whataburger/get_data.py
Executable file
46
layers/chains/whataburger/get_data.py
Executable file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import re
|
||||||
|
|
||||||
|
response = requests.get('https://locations.whataburger.com/directory.html')
|
||||||
|
|
||||||
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||||||
|
state_links = soup.select('a.Directory-listLink')
|
||||||
|
|
||||||
|
locations = []
|
||||||
|
for state_link in state_links:
|
||||||
|
print(f"Fetching state data for {state_link.find('span').text}")
|
||||||
|
response = requests.get(f"https://locations.whataburger.com/{state_link['href']}")
|
||||||
|
|
||||||
|
# this _could_ break if there's a closing script tag in the script somehow, but I'm not too concerned
|
||||||
|
raw_state_data = re.search(r'<script class="js-map-data" type="text/data">(.*?)</script>', response.text)[1]
|
||||||
|
state_locations = json.loads(raw_state_data)['response']['entities']
|
||||||
|
|
||||||
|
for location in state_locations:
|
||||||
|
locations.append({
|
||||||
|
"type": "Feature",
|
||||||
|
"geometry": {
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [location['profile']['yextDisplayCoordinate']['long'], location['profile']['yextDisplayCoordinate']['lat']], # yes, [lon, lat] since it's [x, y]
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
'address': location['profile']['meta']['id'], # kinda?
|
||||||
|
# 'city': location_li.find('dd', class_="city-state-zip").text.split(',')[0],
|
||||||
|
# 'state': location_li.find('dd', class_="city-state-zip").text.split(', ')[1].split(' ')[0],
|
||||||
|
# 'zip': location_li.find('dd', class_="city-state-zip").text.split(' ')[-1],
|
||||||
|
'website': "https://locations.whataburger.com/" + location['url'],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
geojson = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": locations,
|
||||||
|
}
|
||||||
|
|
||||||
|
print(len(locations), "locations found")
|
||||||
|
|
||||||
|
with open("data.geojson", "w") as f:
|
||||||
|
f.write(json.dumps(geojson))
|
24
layers/chains/whataburger/layer.js
Normal file
24
layers/chains/whataburger/layer.js
Normal 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;
|
16
layers/chains/whataburger/pin.svg
Normal file
16
layers/chains/whataburger/pin.svg
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 384 512"
|
||||||
|
width="40px"
|
||||||
|
height="30px"
|
||||||
|
version="1.1"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
|
||||||
|
<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:#fd7800;fill-opacity:1" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 851 B |
Loading…
Reference in a new issue