From 7917d1a1e70c9918ad2f027d45986c1cc6b55b8d Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 9 Mar 2024 19:54:18 -0600 Subject: [PATCH] Add Raising Cane's layer --- layers/chains/index.js | 5 + layers/chains/raising-canes/get_data.py | 46 ++++ layers/chains/raising-canes/layer.js | 24 ++ layers/chains/raising-canes/pin.svg | 278 ++++++++++++++++++++++++ 4 files changed, 353 insertions(+) create mode 100755 layers/chains/raising-canes/get_data.py create mode 100644 layers/chains/raising-canes/layer.js create mode 100644 layers/chains/raising-canes/pin.svg diff --git a/layers/chains/index.js b/layers/chains/index.js index 6ad85f2..bd89355 100644 --- a/layers/chains/index.js +++ b/layers/chains/index.js @@ -5,6 +5,7 @@ import kwikTripLayer from './kwik-trip/layer.js'; import menardsLayer from './menards/layer.js'; import milwaukeeBurgerCompanyLayer from './milwaukee-burger-company/layer.js'; 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'; @@ -39,6 +40,10 @@ const chains = { name: "Punch Pizza", layer: punchPizzaLayer, }, + { + name: "Raising Cane's", + layer: raisingCanesLayer, + }, { name: "Waffle House", layer: waffleHouseLayer, diff --git a/layers/chains/raising-canes/get_data.py b/layers/chains/raising-canes/get_data.py new file mode 100755 index 0000000..dc6e4f6 --- /dev/null +++ b/layers/chains/raising-canes/get_data.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 + +import requests +import json + +print("Searching for Raising Cane's locations") +response = requests.get('https://raisingcanes.com/page-data/sq/d/3976656178.json').json() + +stores = [] + +for s in response['data']['allPrismicStoreLocation']['nodes']: + if s['uid'] == 'ara2': # Not sure what's up with this one: https://raisingcanes.com/locations/ara2/ + continue + elif s['uid'] == 'c524': # Null island? https://raisingcanes.com/locations/c524/ + s['data']['coordinates'] = { + "longitude": -111.9811399, + "latitude": 40.5447361, + } + stores.append({ + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [float(s['data']['coordinates']['longitude']), float(s['data']['coordinates']['latitude'])], # yes, [lon, lat] since it's [x, y] + }, + "properties": { + 'name': s['data']['external_location_data']['displayName'], + 'nickname': s['data']['external_location_data']['nickname'], + 'address': s['data']['external_location_data']['address1'], + 'city': s['data']['external_location_data']['city'], + 'state': s['data']['external_location_data']['state'], + 'zip': s['data']['external_location_data']['postal_code'], + 'website': f"https://raisingcanes.com/locations/{s['uid']}", + 'opened': s['data']['external_location_data']['birthdate'], + 'hours': s['data']['external_location_data']['hours'], + }, + }) + +print(f"""{len(stores)} locations found""") + +geojson = { + "type": "FeatureCollection", + "features": stores, +} + +with open("data.geojson", "w") as f: + f.write(json.dumps(geojson)) diff --git a/layers/chains/raising-canes/layer.js b/layers/chains/raising-canes/layer.js new file mode 100644 index 0000000..af140b4 --- /dev/null +++ b/layers/chains/raising-canes/layer.js @@ -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; diff --git a/layers/chains/raising-canes/pin.svg b/layers/chains/raising-canes/pin.svg new file mode 100644 index 0000000..344a169 --- /dev/null +++ b/layers/chains/raising-canes/pin.svg @@ -0,0 +1,278 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +