Add Country Kitchen layer
This commit is contained in:
parent
da86da8877
commit
bfef3a2c71
50
layers/chains/country-kitchen/get_data.py
Executable file
50
layers/chains/country-kitchen/get_data.py
Executable 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))
|
24
layers/chains/country-kitchen/layer.js
Normal file
24
layers/chains/country-kitchen/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;
|
59
layers/chains/country-kitchen/pin.svg
Normal file
59
layers/chains/country-kitchen/pin.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 15 KiB |
|
@ -1,3 +1,4 @@
|
||||||
|
import countryKitchenLayer from './country-kitchen/layer.js';
|
||||||
import culversLayer from './culvers/layer.js';
|
import culversLayer from './culvers/layer.js';
|
||||||
import krispyKremeLayer from './krispy-kreme/layer.js';
|
import krispyKremeLayer from './krispy-kreme/layer.js';
|
||||||
import kwikTripLayer from './kwik-trip/layer.js';
|
import kwikTripLayer from './kwik-trip/layer.js';
|
||||||
|
@ -9,6 +10,10 @@ import whataburgerLayer from './whataburger/layer.js';
|
||||||
const chains = {
|
const chains = {
|
||||||
name: "Chains",
|
name: "Chains",
|
||||||
layers: [
|
layers: [
|
||||||
|
{
|
||||||
|
name: "Country Kitchen",
|
||||||
|
layer: countryKitchenLayer,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Culver's",
|
name: "Culver's",
|
||||||
layer: culversLayer,
|
layer: culversLayer,
|
||||||
|
|
Loading…
Reference in a new issue