Why a Tokyo Camera Landed on Our Saitama Map — The Real Cost of a Map Service Is the Coordinates
Stripping brackets as noise pulled titles into same-name towns, and the bounding box let the next prefecture in
I saw tomarigi.me, a map of YouTube live cameras across Japan, and built a Saitama version myself. The cost of cloning a map service turned out to be the coordinates, not the code. The Leaflet map and YouTube embeds came together fast. Everything after that was a fight over "where is this video?" I hit three traps and kept one last line of defense.
What the service actually accumulates
On 2026-08-22 I looked at tomarigi with the browser dev tools. Next.js with Leaflet (Canvas renderer); the data arrives in one /api/spots call, about 330KB and 1,312 records. Thumbnails come straight from img.youtube.com. A record is basically this:
{"id":"...","name":"【LIVE】京都 随心院ライブ中継カメラ",
"lat":34.955,"lng":135.82,"category":"landmark",
"video_id":"5Ica9fIP_Ng","is_live":true}
Videos play through the original publisher's YouTube embed. What the service builds up is a single mapping: video_id ↔ lat/lng. I couldn't find anything public about how those 1,312 were collected.
36 out of 182
My first collection run, targeting Saitama:
YouTube search candidates 182
passed geocoding 36 ← 80% dropped here
Geocoding turns a place name or address into latitude and longitude. Most drops were either "couldn't pull a place name from the title" or "pulled one, but it's outside the target area." And the ones that passed weren't all right. Scrolling the map, I found a Tokyo river camera pinned in Saitama.
Trap 1: the brackets I removed as noise held the only address
Japanese river monitoring cameras have titles like this:
【呑川】池上映像監視局[大田区池上1]
While stripping prefixes like 【LIVE】, I stripped the [] brackets too. What was left got pulled into same-name places elsewhere:
【呑川】池上映像監視局[大田区池上1] → Ikegami, Fujimino, Saitama (actually Ota, Tokyo)
【新河岸川】笹目橋映像監視局[板橋区…] → Sasame, Toda, Saitama (actually Itabashi, Tokyo)
【綾瀬川】内匠橋映像監視局[足立区…] → Takumi, Tomioka, Gunma (actually Adachi, Tokyo)
Trap 2: a bounding box can't keep out the next prefecture
The third line is in Gunma, and it passed my Saitama bounding box (a lat/lng rectangle). Tomioka (lng 138.90, lat 36.24) sits inside that rectangle, because Saitama's western mountains and eastern Gunma overlap in longitude.
Approximate a prefecture with a rectangle and it leaks at the borders.
Trap 3: the fix made the fallback wrong
I promoted the bracketed address to the first candidate. Then this happened:
1st [調布市東つつじヶ丘2] → Tokyo address → out of area → rejected
2nd channel name 入間川 → Irumagawa, Sayama, Saitama → passed (wrong)
The design stacked candidates by confidence and tried them in order. I thought that was robust. But when a bracketed address exists, it's the only truth. If it's outside the area, the video should be dropped with no fallback. Don't let weaker evidence overturn a "no" from the strongest evidence.
The last line of defense: a string, not coordinates
def in_target?(geocoded)
geocoded[:address].start_with?('埼玉県')
end
Check whether the normalized address the geocoder returns starts with 埼玉県 (Saitama Prefecture). The bounding box stays as a secondary check. After recollecting: zero cameras from other prefectures, 58 in the final set, 24 of which allow embedding and play right on the map.
I went through the 67 rejections too. Almost all were correct. The three that looked like Saitama were "大宮" (Omiya), a name that also exists in Nara City and in Suginami, Tokyo. The failure log became the evidence that the filter works.
Bounding box, string, or boundary polygon
| Method | Catches | Misses |
|---|---|---|
| bounding box | wildly wrong regions | neighboring prefectures (borders aren't rectangles) |
| address prefix string | neighbors, same-name places | a geocoder that returns the wrong address itself |
| administrative boundary polygon | points near the border | you have to ship boundary data |
For filtering at prefecture level, the address string was enough. Add polygons when you need exact city or ward borders.
If coordinates keep drifting while you collect map or location data, the problem is usually data cleaning more than code. If you'd like someone to look with you, reach us at https://www.negabaro.com/contact.
How It Works
Pull place or address candidates from the video title (keep the bracketed address)
If a bracketed address exists, use only it. Out of area means drop, no fallback
Decide the target area by the prefix (埼玉県) of the geocoder's normalized address
Keep the bounding box as a secondary check; reread the rejection log to verify the filter