Compare commits

...

2 commits

Author SHA1 Message Date
Chandler Swift 308ec72569
Add tjx stores
Requested-By: Käthe Swift
2024-04-28 00:17:07 -05:00
Chandler Swift a038e5a0fa
Update dependencies, including OpenLayers 9 2024-04-27 23:25:23 -05:00
6 changed files with 176 additions and 36 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ dist
*.shp *.shp
layers/dot-cams/*/data/states.js layers/dot-cams/*/data/states.js
layers/survey-markers/states.js layers/survey-markers/states.js
layers/tjx/data/chains.js

View file

@ -18,6 +18,7 @@ import state_land from './state-land/index.js';
import trips from './trips/index.js'; import trips from './trips/index.js';
import dot_cams from './dot-cams/index.js'; import dot_cams from './dot-cams/index.js';
import survey_markers from './survey-markers/index.js'; import survey_markers from './survey-markers/index.js';
import tjx from './tjx/index.js';
const layerCategories = [ const layerCategories = [
{ // Base maps { // Base maps
@ -99,6 +100,7 @@ const layerCategories = [
state_land, state_land,
cellular, cellular,
light_pollution, light_pollution,
tjx,
]; ];
export default layerCategories; export default layerCategories;

82
layers/tjx/get_data.py Executable file
View file

@ -0,0 +1,82 @@
#!/usr/bin/python
# Turns out alltheplaces has done all the hard work here; we can use their
# (CC0-licensed) data rather than trying to replicate the scraper ourselves.
#
# Unfortunately, many of the stores' individual location searches, including the
# parent TJX's list at https://www.tjx.com/stores, don't provide a list of
# stores, and only a search result. Some do, e.g. Sierra, with a chunk of
# javascript containing a list of JS objects, but this isn't consistent across
# stores, and I'm too lazy to reimplement something for every store. So, instead
# we take advantage of the hard work of those who have gone before us!
import requests
import json
data = requests.get('https://alltheplaces-data.openaddresses.io/runs/2024-04-20-13-31-46/output/tjx.geojson')
chains = {}
for store in data.json()['features']:
# store = {
# "type": "Feature",
# "id": "iaLJnlhrRR8daHXO0SGtTHQ2aYM=",
# "properties": {
# "ref": "93743",
# "@spider": "tjx",
# "shop": "department_store",
# "addr:full": "655 Sydney Ave",
# "addr:city": "Windsor",
# "addr:state": "ON",
# "addr:postcode": "N8X 5C4",
# "addr:country": "CA",
# "name": "Windsor",
# "phone": "+1 519-250-0494",
# "opening_hours": "Mo-Fr 09:30-21:00; Sa 09:00-21:00; Su 10:00-18:00",
# "brand": "Marshalls",
# "brand:wikidata": "Q15903261",
# "nsi_id": "marshalls-53f9e5"
# },
# "geometry": {
# "type": "Point",
# "coordinates": [
# -82.9981994628906,
# 42.2717170715332
# ]
# }
# },
if not store['properties']['brand'] in chains:
chains[store['properties']['brand']] = []
chains[store['properties']['brand']].append({
"type": "Feature",
"geometry": store['geometry'],
"properties": {
"name": store['properties']['name'],
"addr": store['properties']['addr:full'],
"city": store['properties']['addr:city'],
"state": store['properties']['addr:state'],
"postcode": store['properties']['addr:postcode'],
"country": store['properties']['addr:country'],
},
})
safe_name = lambda s: ''.join([c.lower() for c in s if c.isalpha()])
for chain, features in chains.items():
geojson = {
"type": "FeatureCollection",
"features": features,
}
with open(f"data/{safe_name(chain)}.geojson", "w") as f:
f.write(json.dumps(geojson))
print(f"{len(features)} {chain} locations found")
with open('data/chains.js', 'w') as f:
for chain in chains:
f.write(f"import {safe_name(chain)} from './{safe_name(chain)}.geojson?url';\n")
f.write('\nexport default {\n')
for chain in chains:
f.write(f" \"{chain}\": {safe_name(chain)},\n")
f.write("};\n")

39
layers/tjx/index.js Normal file
View file

@ -0,0 +1,39 @@
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 pin from './pin.svg?url';
import data from './data/chains.js';
const chains = {
name: "TJX brands",
details: `<a href="https://en.wikipedia.org/wiki/TJX_Companies">https://en.wikipedia.org/wiki/TJX_Companies</a>`,
layers: [],
};
for (let [chain, url] of Object.entries(data)) {
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: url,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pin,
}),
}),
});
chains.layers.push({
name: chain,
layer: vectorLayer,
});
}
chains.layers.sort((a, b) => a.name > b.name ? 1 : -1); // Names are always unique
export default chains;

13
layers/tjx/pin.svg Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 384 512"
width="40px"
height="30px"
version="1.1"
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:#000;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 667 B

75
package-lock.json generated
View file

@ -370,21 +370,24 @@
} }
}, },
"node_modules/@petamoriken/float16": { "node_modules/@petamoriken/float16": {
"version": "3.8.4", "version": "3.8.6",
"resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.4.tgz", "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.6.tgz",
"integrity": "sha512-kB+NJ5Br56ZhElKsf0pM7/PQfrDdDVMRz8f0JM6eVOGE+L89z9hwcst9QvWBBnazzuqGTGtPsJNZoQ1JdNiGSQ==" "integrity": "sha512-GNJhABTtcmt9al/nqdJPycwFD46ww2+q2zwZzTjY0dFFwUAFRw9zszvEr9osyJRd9krRGy6hUDopWUg9fX7VVw=="
}, },
"node_modules/color-name": { "node_modules/color-name": {
"version": "1.1.4", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "resolved": "https://registry.npmjs.org/color-name/-/color-name-2.0.0.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" "integrity": "sha512-SbtvAMWvASO5TE2QP07jHBMXKafgdZz8Vrsrn96fiL+O92/FN/PLARzUW5sKt013fjAprK2d2iCn2hk2Xb5oow==",
"engines": {
"node": ">=12.20"
}
}, },
"node_modules/color-parse": { "node_modules/color-parse": {
"version": "2.0.0", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.0.tgz", "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.2.tgz",
"integrity": "sha512-g2Z+QnWsdHLppAbrpcFWo629kLOnOPtpxYV69GCqm92gqSgyXbzlfyN3MXs0412fPBkFmiuS+rXposgBgBa6Kg==", "integrity": "sha512-eCtOz5w5ttWIUcaKLiktF+DxZO1R9KLNY/xhbV6CkhM7sR3GhVghmt6X6yOnzeaM24po+Z9/S1apbXMwA3Iepw==",
"dependencies": { "dependencies": {
"color-name": "^1.0.0" "color-name": "^2.0.0"
} }
}, },
"node_modules/color-rgba": { "node_modules/color-rgba": {
@ -458,9 +461,9 @@
} }
}, },
"node_modules/geotiff": { "node_modules/geotiff": {
"version": "2.1.2", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.1.2.tgz", "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.1.3.tgz",
"integrity": "sha512-xw7Cd6HXukUdfFSe5QCSjdhebTCGkk87x7fKURqQPFKT+TijCCwKvoksL7T3+B6mJWZSB7muTJlwVIQsLtbkMA==", "integrity": "sha512-PT6uoF5a1+kbC3tHmZSUsLHBp2QJlHasxxxxPW47QIY1VBKpFB+FcDvX+MxER6UzgLQZ0xDzJ9s48B9JbOCTqA==",
"dependencies": { "dependencies": {
"@petamoriken/float16": "^3.4.7", "@petamoriken/float16": "^3.4.7",
"lerc": "^3.0.0", "lerc": "^3.0.0",
@ -476,9 +479,9 @@
} }
}, },
"node_modules/hls.js": { "node_modules/hls.js": {
"version": "1.5.3", "version": "1.5.8",
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.5.3.tgz", "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.5.8.tgz",
"integrity": "sha512-gonnYpZ5bxuVdwpcbzfylUlNZ8917LjACUjpWXiaeo8zPAIDfPcMZjEQPy6CeeRSJbcg1P+aVqwxrXr2J+SeUg==" "integrity": "sha512-hJYMPfLhWO7/7+n4f9pn6bOheCGx0WgvVz7k3ouq3Pp1bja48NN+HeCQu3XCGYzqWQF/wo7Sk6dJAyWVJD8ECA=="
}, },
"node_modules/ieee754": { "node_modules/ieee754": {
"version": "1.2.1", "version": "1.2.1",
@ -528,9 +531,9 @@
} }
}, },
"node_modules/ol": { "node_modules/ol": {
"version": "8.2.0", "version": "9.1.0",
"resolved": "https://registry.npmjs.org/ol/-/ol-8.2.0.tgz", "resolved": "https://registry.npmjs.org/ol/-/ol-9.1.0.tgz",
"integrity": "sha512-/m1ddd7Jsp4Kbg+l7+ozR5aKHAZNQOBAoNZ5pM9Jvh4Etkf0WGkXr9qXd7PnhmwiC1Hnc2Toz9XjCzBBvexfXw==", "integrity": "sha512-nDrkJ2tzZNpo/wzN/PpHV5zdxbnXZaFktoMaD2cFLEc6gCwlgLY21Yd8wnt/4FjaVYwLBnbN9USXSwIBGcyksQ==",
"dependencies": { "dependencies": {
"color-rgba": "^3.0.0", "color-rgba": "^3.0.0",
"color-space": "^2.0.1", "color-space": "^2.0.1",
@ -545,9 +548,9 @@
} }
}, },
"node_modules/ol-contextmenu": { "node_modules/ol-contextmenu": {
"version": "5.3.0", "version": "5.4.0",
"resolved": "https://registry.npmjs.org/ol-contextmenu/-/ol-contextmenu-5.3.0.tgz", "resolved": "https://registry.npmjs.org/ol-contextmenu/-/ol-contextmenu-5.4.0.tgz",
"integrity": "sha512-AO9rGKaQpLAzqpEva7mukhkWrGkL/o1s8tXPsYuYBGMoiTBbXffgTikXjTmq1m7l3gDwXWWWi6R2ROda5lgXNw==", "integrity": "sha512-F2cIwCToMAYsddnrcRvCnWAH4bp9n9LNHrDTqU3mDJMiNUw1RB4Ovz5b2FwxasLpymtkzV8ME39u+mP3IvpT6g==",
"dependencies": { "dependencies": {
"tiny-emitter": "^2.1.0" "tiny-emitter": "^2.1.0"
}, },
@ -556,7 +559,7 @@
"npm": ">=8" "npm": ">=8"
}, },
"peerDependencies": { "peerDependencies": {
"ol": "> 7.x <= 8.x" "ol": "> 7.x <= 9.x"
} }
}, },
"node_modules/pako": { "node_modules/pako": {
@ -588,9 +591,9 @@
"dev": true "dev": true
}, },
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.4.33", "version": "8.4.38",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
"integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@ -609,7 +612,7 @@
"dependencies": { "dependencies": {
"nanoid": "^3.3.7", "nanoid": "^3.3.7",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"source-map-js": "^1.0.2" "source-map-js": "^1.2.0"
}, },
"engines": { "engines": {
"node": "^10 || ^12 || >=14" "node": "^10 || ^12 || >=14"
@ -678,9 +681,9 @@
} }
}, },
"node_modules/source-map-js": { "node_modules/source-map-js": {
"version": "1.0.2", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
@ -692,9 +695,9 @@
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
}, },
"node_modules/vite": { "node_modules/vite": {
"version": "4.5.2", "version": "4.5.3",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.5.2.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.3.tgz",
"integrity": "sha512-tBCZBNSBbHQkaGyhGCDUGqeo2ph8Fstyp6FMSvTtsXeZSPpSMGlviAOav2hxVTqFcx8Hj/twtWKsMJXNY0xI8w==", "integrity": "sha512-kQL23kMeX92v3ph7IauVkXkikdDRsYMGTVl5KY2E9OY4ONLvkHf04MDTbnfo6NKxZiDLWzVpP5oTa8hQD8U3dg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"esbuild": "^0.18.10", "esbuild": "^0.18.10",
@ -757,9 +760,9 @@
"integrity": "sha512-ZnV3yH8/k58ZPACOXeiHaMuXIiaTk1t0hSUVisbO0t4RjA5wPpUytcxeyiN2h+LZRrmuHIh/1UlrR9e7DHDvTw==" "integrity": "sha512-ZnV3yH8/k58ZPACOXeiHaMuXIiaTk1t0hSUVisbO0t4RjA5wPpUytcxeyiN2h+LZRrmuHIh/1UlrR9e7DHDvTw=="
}, },
"node_modules/xml-utils": { "node_modules/xml-utils": {
"version": "1.7.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/xml-utils/-/xml-utils-1.7.0.tgz", "resolved": "https://registry.npmjs.org/xml-utils/-/xml-utils-1.8.0.tgz",
"integrity": "sha512-bWB489+RQQclC7A9OW8e5BzbT8Tu//jtAOvkYwewFr+Q9T9KDGvfzC1lp0pYPEQPEoPQLDkmxkepSC/2gIAZGw==" "integrity": "sha512-1TY5yLw8DApowZAUsWCniNr8HH6Ebt6O7UQvmIwziGKwUNsQx6e+4NkfOvCfnqmYIcPjCeoI6dh1JenPJ9a1hQ=="
}, },
"node_modules/zstddec": { "node_modules/zstddec": {
"version": "0.1.0", "version": "0.1.0",