Add Country Kitchen layer

This commit is contained in:
Chandler Swift 2023-07-28 06:50:50 -05:00
parent da86da8877
commit bfef3a2c71
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
4 changed files with 138 additions and 0 deletions

View file

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

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;

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -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,