Issue 4 wigle wifi - #11
Open
Tom-Neverwinter wants to merge 3 commits into
Open
Conversation
New optional, BYOK layer showing crowdsourced Wi-Fi network observations from the WiGLE API, viewport-bounded and clearly labeled as observations rather than live RF detections. Server: wigleProxy (vite.config.js) BYOK-gates on WIGLE_API_NAME/ WIGLE_API_TOKEN — without both, /api/wigle/search reports `available:false` and the layer shows UNAVAILABLE, never simulated data. With credentials, requests are viewport-bounded (max 0.4° per side, since WiGLE's own daily query allowance is small and account-dependent — verified via research: sliding-scale limits, resets at US/Pacific midnight, new accounts especially restricted) and cached aggressively (24h, memory + disk) with an in-memory daily soft-cap counter (WIGLE_DAILY_QUERY_BUDGET) as a courtesy governor lighter than TomTom's persisted budget.json. Client: src/data/wigleNetworks.js follows the same viewport-bounded, moveEnd-debounced, backoff-retry shape as alprCameras.js/ militaryInstallations.js. Points colored by observation age (recent/aged/ old); click shows SSID, BSSID, encryption, channel, QoS, first/last seen. The "Wi-Fi network observations: WiGLE.net" credit registers only once a keyed search actually returns data (dataCredits.js, mirroring TomTom's dynamic-credit pattern). src/data/wigleApi.js holds the pure helpers (viewport validation, result normalization against WiGLE's real v2/network/search response shape, freshness bucketing, Pacific-midnight day-key) shared by server and client, unit-tested with node:test. Smoke-tested against a live dev server: /api/wigle/status and the no-key /api/wigle/search 503 path both confirmed. Registered in main.js + layerState.js (token 'k'), voice/text aliases, attribution in DATA_SOURCES.md. Age-range filtering (recent/last year/ all) from the issue is left for a follow-up — it needs an options UI this pass doesn't add; getParams()/setParams() aren't wired since nothing would drive them yet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZFzxaNKiGGkq9V64Y9omb
- wigleApi.js normalizeWigleNetwork(): `Number('')` is 0, not NaN, so a
present-but-blank channel/qos field decoded as a fabricated 0 instead of
missing. Added a regression test.
- wigleNetworks.js: registerDynamicCredit(WIGLE_CREDIT) was firing on
every successful response, including an empty-viewport result —
contradicting DATA_SOURCES.md's documented "registered only once a
keyed search actually returns data" contract. Now gated on
records.length.
- wigleNetworks.js: the unavailable-retry backoff (30s->240s doubling) now
lives as its own exported, tested wigleRetryDelayMs() in wigleApi.js
instead of a fourth untested inline copy of the same formula — kept
self-contained here rather than importing alprCameras.js's equivalent,
since this branch is meant to be mergeable independently of ALPR's.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZFzxaNKiGGkq9V64Y9omb
- wigleNetworks.js loadNetworks(): the abort/staleness guard ran AFTER the "not configured" branch already mutated shared state and called renderRecords() — a superseded request whose response body had already fully arrived before abort() took effect resolves without ever throwing AbortError, and could clobber a newer request's already-rendered result. Moved the check to run immediately after both awaits, before any write, matching alprCameras.js's ordering. - The daily query budget (429) and a generic transient failure were both routed through the same escalating 30s->240s retry — but the budget only resets at the next US/Pacific midnight, so retrying on that timer for the rest of the day can't succeed and just cycles the UI through loading/ unavailable states. Now recognized specifically (error.status === 429): a clear message, no retry timer — the next user-driven pan/zoom tries again naturally. - vite.config.js wigleProxy: replaced its hand-rolled, untested day-key- rollover budget counter with the same generic, tested normalizeBudget/ isOverBudget helpers already imported for tomtomProxy (imported again under WiGLE-appropriate names so the code doesn't call something visibly named "TomTom"); WiGLE's Pacific-midnight day key plugs into the same generic "roll on day change, compare to limit" shape TomTom's UTC one does. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZFzxaNKiGGkq9V64Y9omb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.