Add Krispy Kreme layer

This commit is contained in:
Chandler Swift 2023-07-24 22:52:40 -05:00
parent ca24e3b6ea
commit be8cf4e5f0
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
4 changed files with 82 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import menardsLayer from './menards/layer.js';
import culversLayer from './culvers/layer.js';
import kwikTripLayer from './kwik-trip/layer.js';
import waffleHouseLayer from './waffle-house/layer.js';
import krispyKremeLayer from './krispy-kreme/layer.js';
const layerCategories = [
{
@ -76,6 +77,10 @@ const layerCategories = [
name: "Waffle House",
layer: waffleHouseLayer,
},
{
name: "Krispy Kreme",
layer: krispyKremeLayer,
},
]
}
];

37
layers/krispy-kreme/get_data.py Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env python3
import requests
import re
import json
res = requests.get('https://api.krispykreme.com/shops/?latitude=44.7601&longitude=-93.2748&count=1000&shopFeatureFlags=0&includeGroceryStores=false&includeShops=true')
locations = json.loads(res.text)
stores = []
for location in locations:
stores.append({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [float(location['longitude']), float(location['latitude'])], # yes, [lon, lat] since it's [x, y]
},
"properties": {
'address': location['address1'].title(),
'city': location['city'].title(),
'state': location['state'],
'zip': location['zipCode'],
'website': location['pagesUrl'],
},
})
geojson = {
"type": "FeatureCollection",
"features": stores,
}
with open("krispy-kreme-data.geojson", "w") as f:
f.write(json.dumps(geojson))
print(f"{len(locations)} 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 waffleHouseURL from '/data/krispy-kreme-data.geojson?url'; // TODO: remove `?url`?
import pinURL from '/layers/krispy-kreme/pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: waffleHouseURL,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pinURL,
}),
}),
});
export default vectorLayer;

View 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:#046a38;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 851 B