Skip to content

web: fix topology device markers placed in the water#655

Open
armcconnell wants to merge 1 commit into
mainfrom
fix/topology-device-coordinates
Open

web: fix topology device markers placed in the water#655
armcconnell wants to merge 1 commit into
mainfrom
fix/topology-device-coordinates

Conversation

@armcconnell

Copy link
Copy Markdown
Contributor

Resolves: #652

Summary of Changes

  • Fix device markers on the topology map and globe that were rendered in the ocean. They were positioned as a metro centroid plus a fixed 0.3° (~25 mi) radial fanout, ignoring real device locations; for coastal metros like NYC that arc placed markers offshore in the Atlantic and the harbor.
  • Default to a much tighter metro-centroid fanout (radius 0.3°0.04°, ~3 mi) so co-located devices stay visually separated without landing in the water.
  • Add a "Precise locations" toggle (available on both map and globe) that anchors each device at its real facility coordinates, with a small jitter (~0.5 mi) so devices sharing a facility remain individually clickable. Devices with no facility coordinates fall back to the fanout.
  • Extract the duplicated calculateDevicePosition from the map and globe into one shared, unit-tested helper (computeDevicePositions).
  • Expose per-device facility latitude/longitude from the topology API (LEFT JOIN dz_facilities_current via location_pk).

The graph view is non-geo (force-directed), so it is unaffected.

Diff Breakdown

Category Files Notes
Core logic 5 shared helper (new), map, globe, topology API handler, context toggle
Scaffolding 2 control-bar toggle, api.ts type
Tests 1 devicePositions.test.ts (new)

Most of the change is the shared positioning helper plus wiring; the rest is the toggle and the API field.

Key files (click to expand)
  • web/src/components/topology/devicePositions.ts — new pure helper: fanout (default, tight radius) + facility-anchored (with co-located jitter) + fallback
  • web/src/components/topology-map.tsx / topology-globe.tsx — use the shared helper, keyed off the toggle; removed the duplicated local functions
  • web/src/components/topology/TopologyContext.tsx — new preciseLocations overlay toggle (URL-synced like other overlays)
  • web/src/components/topology/TopologyControlBar.tsx — "Precise locations" control on map and globe
  • api/handlers/topology.go — facility lat/lng on the topology Device

Testing Verification

  • New unit tests for the positioning helper: lone device sits on the metro center; co-metro devices stay within the (small) fanout radius and remain distinct; facility mode anchors a lone device exactly on its facility coords; co-located devices jitter within the facility radius and stay distinct; a device with no facility coords falls back to the metro fanout rather than [0,0].
  • Full web unit suite passes (185 tests).
  • Verified against production data that all 97 activated devices have facility coordinates (so facility mode resolves real locations rather than falling back), and that up to 4 devices share a facility (hence the co-located jitter).

Device markers on the topology map and globe were positioned as a metro
centroid plus a 0.3 degree (~25 mi) radial fanout, ignoring real device
locations. For coastal metros like NYC that arc placed markers offshore in
the Atlantic and the harbor (#652).

- Extract the duplicated calculateDevicePosition from the map and globe into
  one shared, unit-tested helper (computeDevicePositions).
- Default to a much tighter metro-centroid fanout (radius 0.3 -> 0.04 degrees)
  so co-located devices stay separated without landing in the water.
- Add a "Precise locations" toggle (map and globe) that anchors each device at
  its real facility coordinates, with a small jitter so devices sharing a
  facility remain individually clickable; devices without facility coordinates
  fall back to the fanout.
- Expose per-device facility latitude/longitude from the topology API
  (LEFT JOIN dz_facilities_current via location_pk).
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.

web: NYC-area DZDs render in the water on the multicast map

1 participant