Skip to content

fix(cctv): stop the Dutch cameras landing on the map twice - #329

Open
meijbaard wants to merge 1 commit into
simplifaisoul:masterfrom
meijbaard:fix/cctv-netherlands-double-count
Open

fix(cctv): stop the Dutch cameras landing on the map twice#329
meijbaard wants to merge 1 commit into
simplifaisoul:masterfrom
meijbaard:fix/cctv-netherlands-double-count

Conversation

@meijbaard

Copy link
Copy Markdown

netherlands.ts is reached two ways: as its own key in RAW_REGION_FETCHERS, and through fetchEuropeCameras, which calls fetchNetherlandsCameras() directly. GET concatenates whatever the regions return without deduplicating, so every Rijkswaterstaat camera is pushed twice — two pins on one spot, and sources reporting 52 cameras where there are 26.

Measured

before after
?region=netherlands,europeRijkswaterstaat 52 26
...ids appearing twice 26 0
?region=all → cameras / unique ids 35,004 / 35,004
viewport at Harlingen → Rijkswaterstaat 26 26
viewport at Vienna → Rijkswaterstaat none none

Three parts, and the second is the one that is easy to miss

The call comes out of fetchEuropeCameras. The country has its own region key; fetching it inside Europe as well was the duplication.

netherlands gains a branch in getRegionsForBounds, explicit the way Utah and Oregon already are. It was never in there — the broad europe box was carrying the Dutch feed for viewport queries. Removing the call alone would have left a viewport over the Netherlands answering with no Dutch cameras at all, trading a visible bug for a silent one. The box is the one netherlands.ts already filters the feed on.

GET deduplicates on id. Regions overlap by design — a bounding box can name both europe and a country inside it — so this is a property of the merge rather than of any one source, and it keeps the next source that gets registered twice from doing the same thing. Cameras without an id are passed through untouched; several of the inline fetchers are typed any[].

Verifying

npm test        # 548 passed
npx tsc --noEmit
curl 'localhost:3000/api/cctv?region=netherlands,europe' | jq '.sources.Rijkswaterstaat'
curl 'localhost:3000/api/cctv?region=all' | jq '[.total, ([.cameras[].id] | unique | length)]'

npm run lint runs out of heap on this repo on master too, so it is not usable as a gate here. eslint src/app/api/cctv/route.ts reports the same 29 pre-existing findings before and after.

🤖 Generated with Claude Code

netherlands.ts was reached two ways: as its own key in RAW_REGION_FETCHERS,
and through fetchEuropeCameras, which called it directly. GET concatenates
whatever the regions return without deduplicating, so every Rijkswaterstaat
camera was pushed twice — two pins on one spot, and `sources` reporting 52
cameras where there are 26.

Measured on ?region=netherlands,europe before this change: Rijkswaterstaat
52, with all 26 ids appearing twice. After: 26, none twice. On ?region=all,
which is what the frontend asks for, 35,004 cameras and 35,004 unique ids.

Three parts, and the second is the one that is easy to miss:

  The call comes out of fetchEuropeCameras. The country has its own region
  key; fetching it inside Europe as well was the duplication.

  'netherlands' gains a branch in getRegionsForBounds, explicit the way Utah
  and Oregon are. The broad europe box covers these latitudes but no longer
  carries the Dutch feed, so removing the call alone would have left a
  viewport over the Netherlands answering with no Dutch cameras at all —
  trading a visible bug for a silent one.

  GET deduplicates on id. Regions overlap by design, a bounding box can name
  both 'europe' and a country inside it, so this is a property of the merge
  rather than of any one source. Cameras without an id are passed through
  untouched; several of the inline fetchers are typed any[].

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

@meijbaard is attempting to deploy a commit to the Developing Osiris' projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant