Skip to content

Commit 6738e72

Browse files
fix(data): replace 13 literal "lat,lng" gmaps_links with real coordinates
The 13 UK SAT centres in `sat_centre.json` still had `gmaps_link: "https://maps.google.com/?q=lat,lng"` from the record-shape template, while their `lat`/`lng` fields were correct. Fill each link with that record's own coordinates. Also harden `validate-places.mjs` so the same bug can't ship again: a `gmaps_link` that still contains the literal `lat,lng` placeholder now fails validation (it previously passed the URL-pattern check). Fixes #229 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 05c2272 commit 6738e72

3 files changed

Lines changed: 48 additions & 20 deletions

File tree

data/places/sat_centre.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,15 +3652,15 @@
36523652
"exam": "SAT",
36533653
"valid_till": "2026-11-07"
36543654
},
3655-
{
3655+
{
36563656
"id": "57137",
36573657
"name": "WELLINGTON COLLEGE",
36583658
"type": "sat_centre",
36593659
"city": "crowthorne",
36603660
"lat": 51.3624135,
36613661
"lng": -0.8080941,
36623662
"address": "DUKE'S RIDE",
3663-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3663+
"gmaps_link": "https://maps.google.com/?q=51.3624135,-0.8080941",
36643664
"added_by": "Shauryagangrade",
36653665
"exam": "SAT",
36663666
"valid_till": "2026-11-07"
@@ -3673,7 +3673,7 @@
36733673
"lat": 52.9133979,
36743674
"lng": 1.105435,
36753675
"address": "GRESHAM'S SCHOOL",
3676-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3676+
"gmaps_link": "https://maps.google.com/?q=52.9133979,1.105435",
36773677
"added_by": "Shauryagangrade",
36783678
"exam": "SAT",
36793679
"valid_till": "2026-11-07"
@@ -3686,7 +3686,7 @@
36863686
"lat": 50.845905,
36873687
"lng": -0.3026392,
36883688
"address": "LANCING COLLEGE",
3689-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3689+
"gmaps_link": "https://maps.google.com/?q=50.845905,-0.3026392",
36903690
"added_by": "Shauryagangrade",
36913691
"exam": "SAT",
36923692
"valid_till": "2026-11-07"
@@ -3699,7 +3699,7 @@
36993699
"lat": 51.529308,
37003700
"lng": -0.4505667,
37013701
"address": "108 VINE LANE",
3702-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3702+
"gmaps_link": "https://maps.google.com/?q=51.529308,-0.4505667",
37033703
"added_by": "Shauryagangrade",
37043704
"exam": "SAT",
37053705
"valid_till": "2026-11-07"
@@ -3712,7 +3712,7 @@
37123712
"lat": 51.7809367,
37133713
"lng": -0.0307223,
37143714
"address": "COLLEGE ROAD",
3715-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3715+
"gmaps_link": "https://maps.google.com/?q=51.7809367,-0.0307223",
37163716
"added_by": "Shauryagangrade",
37173717
"exam": "SAT",
37183718
"valid_till": "2026-11-07"
@@ -3725,7 +3725,7 @@
37253725
"lat": 52.7343597,
37263726
"lng": -2.739891,
37273727
"address": "SHREWSBURY SCHOOL",
3728-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3728+
"gmaps_link": "https://maps.google.com/?q=52.7343597,-2.739891",
37293729
"added_by": "Shauryagangrade",
37303730
"exam": "SAT",
37313731
"valid_till": "2026-11-07"
@@ -3738,7 +3738,7 @@
37383738
"lat": 51.4545374,
37393739
"lng": -2.6525262,
37403740
"address": "32 COLLEGE ROAD CLIFTON",
3741-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3741+
"gmaps_link": "https://maps.google.com/?q=51.4545374,-2.6525262",
37423742
"added_by": "Shauryagangrade",
37433743
"exam": "SAT",
37443744
"valid_till": "2026-11-07"
@@ -3751,7 +3751,7 @@
37513751
"lat": 53.6055858,
37523752
"lng": -2.9208933,
37533753
"address": "SOUTHPORT ROAD",
3754-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3754+
"gmaps_link": "https://maps.google.com/?q=53.6055858,-2.9208933",
37553755
"added_by": "Shauryagangrade",
37563756
"exam": "SAT",
37573757
"valid_till": "2026-11-07"
@@ -3764,7 +3764,7 @@
37643764
"lat": 51.5567447,
37653765
"lng": -0.2023618,
37663766
"address": "FROGNAL",
3767-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3767+
"gmaps_link": "https://maps.google.com/?q=51.5567447,-0.2023618",
37683768
"added_by": "Shauryagangrade",
37693769
"exam": "SAT",
37703770
"valid_till": "2026-11-07"
@@ -3777,7 +3777,7 @@
37773777
"lat": 54.5126023,
37783778
"lng": -6.0422466,
37793779
"address": "25 CASTLE STREET",
3780-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3780+
"gmaps_link": "https://maps.google.com/?q=54.5126023,-6.0422466",
37813781
"added_by": "Shauryagangrade",
37823782
"exam": "SAT",
37833783
"valid_till": "2026-11-07"
@@ -3790,7 +3790,7 @@
37903790
"lat": 51.4087711,
37913791
"lng": -3.488243,
37923792
"address": "ST DONATS CASTLE",
3793-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3793+
"gmaps_link": "https://maps.google.com/?q=51.4087711,-3.488243",
37943794
"added_by": "Shauryagangrade",
37953795
"exam": "SAT",
37963796
"valid_till": "2026-11-07"
@@ -3803,7 +3803,7 @@
38033803
"lat": 57.1937119,
38043804
"lng": -2.2042166,
38053805
"address": "PITFODELS HOUSE",
3806-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3806+
"gmaps_link": "https://maps.google.com/?q=57.1937119,-2.2042166",
38073807
"added_by": "Shauryagangrade",
38083808
"exam": "SAT",
38093809
"valid_till": "2026-11-07"
@@ -3816,7 +3816,7 @@
38163816
"lat": 51.7431151,
38173817
"lng": -2.2807025,
38183818
"address": "BRISTOL ROAD",
3819-
"gmaps_link": "https://maps.google.com/?q=lat,lng",
3819+
"gmaps_link": "https://maps.google.com/?q=51.7431151,-2.2807025",
38203820
"added_by": "Shauryagangrade",
38213821
"exam": "SAT",
38223822
"valid_till": "2026-11-07"

scripts/lib/data-validation.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66

77
const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
88

9+
/**
10+
* True when `value` is a Google Maps link whose `q=` parameter is still the raw
11+
* `<lat>,<lng>` placeholder from the record-shape template (see #229).
12+
*/
13+
export function isLatLngPlaceholderGmapsLink(value) {
14+
if (typeof value !== "string") return false;
15+
try {
16+
const { searchParams } = new URL(value);
17+
const q = searchParams.get("q");
18+
return typeof q === "string" && q.trim() === "lat,lng";
19+
} catch {
20+
return false;
21+
}
22+
}
23+
924
/** True when `value` is a "YYYY-MM-DD" string naming a real calendar date. */
1025
export function isRealIsoDate(value) {
1126
if (typeof value !== "string" || !ISO_DATE_RE.test(value)) return false;

scripts/validate-places.mjs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@
2626
import { readFileSync, readdirSync } from "fs";
2727
import { join, dirname } from "path";
2828
import { fileURLToPath } from "url";
29-
import { Reporter, hasEmDash, isRealIsoDate } from "./lib/data-validation.mjs";
29+
import {
30+
Reporter,
31+
hasEmDash,
32+
isLatLngPlaceholderGmapsLink,
33+
isRealIsoDate,
34+
} from "./lib/data-validation.mjs";
35+
3036

3137
const __dirname = dirname(fileURLToPath(import.meta.url));
3238
const DATA_DIR = join(__dirname, "../data/places");
@@ -198,11 +204,18 @@ for (const file of files) {
198204
}
199205

200206
// gmaps_link format
201-
if (r.gmaps_link !== undefined && !GMAPS_RE.test(r.gmaps_link)) {
202-
err(
203-
loc,
204-
`gmaps_link must be https://maps.google.com/?q=<lat>,<lng>, got "${r.gmaps_link}"`,
205-
);
207+
if (r.gmaps_link !== undefined) {
208+
if (!GMAPS_RE.test(r.gmaps_link)) {
209+
err(
210+
loc,
211+
`gmaps_link must be https://maps.google.com/?q=<lat>,<lng>, got "${r.gmaps_link}"`,
212+
);
213+
} else if (isLatLngPlaceholderGmapsLink(r.gmaps_link)) {
214+
err(
215+
loc,
216+
`gmaps_link is still the literal "lat,lng" placeholder (see #229) — fill it with the record's coordinates`,
217+
);
218+
}
206219
}
207220

208221
// No em dashes in any string field

0 commit comments

Comments
 (0)