chore: initial Observable workspace with technical README
This commit is contained in:
41
docs/data/in-n-out-ca-csv.json.js
Normal file
41
docs/data/in-n-out-ca-csv.json.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const csvUrl =
|
||||
"https://raw.githubusercontent.com/madmao/castle-compass/master/csv/In%20N%20Out.csv";
|
||||
const response = await fetch(csvUrl);
|
||||
if (!response.ok) {
|
||||
throw new Error(`In-N-Out CSV request failed: ${response.status}`);
|
||||
}
|
||||
|
||||
const rows = (await response.text()).split(/\r?\n/).filter(Boolean);
|
||||
|
||||
const stores = rows
|
||||
.map((line, index) => {
|
||||
const [latRaw, lonRaw] = line.split(",");
|
||||
const latitude = Number(latRaw);
|
||||
const longitude = Number(lonRaw);
|
||||
|
||||
if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;
|
||||
|
||||
const inCaliforniaBounds =
|
||||
latitude >= 32 &&
|
||||
latitude <= 42.5 &&
|
||||
longitude >= -125 &&
|
||||
longitude <= -114;
|
||||
|
||||
if (!inCaliforniaBounds) return null;
|
||||
|
||||
return {
|
||||
id: `ino/${index}`,
|
||||
name: "In-N-Out Burger",
|
||||
latitude,
|
||||
longitude,
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
const dedup = new Map();
|
||||
for (const store of stores) {
|
||||
const key = `${store.latitude.toFixed(5)},${store.longitude.toFixed(5)}`;
|
||||
if (!dedup.has(key)) dedup.set(key, store);
|
||||
}
|
||||
|
||||
process.stdout.write(JSON.stringify(Array.from(dedup.values())));
|
||||
Reference in New Issue
Block a user