Commit graph

95 commits

Author SHA1 Message Date
9aa836e462
refactor(map): share isValidCoordinate and unwrapLongitudes helpers
The coord-validation and antimeridian-unwrap logic added in the last
pass had been duplicated across map.ts, trail_manager.ts, and
info_map.ts. Move both into map_helpers.ts and import from there so
there is one authoritative implementation.
2026-04-21 09:17:52 -05:00
e90226dc21
fix(map): tighten edge cases in heatmap, info map, and trail color
- Heatmap: filter points with invalid coords or out-of-range intensity
  so malformed rows can't distort the layer.
- InfoMap: validate coords for range (not just NaN) and use an epsilon
  when comparing positions, so float noise doesn't cause needless
  re-renders or accept bogus data.
- TrailManager: getTrailCenter returns null for empty input instead of
  the ambiguous (0, 0) null-island; callers guard accordingly.
2026-04-20 18:05:31 -05:00
f777dcbb35
fix(map): stop trail spidering across antimeridian and close gaps
- Normalize longitude delta in trail_manager Haversine so wraps across
  180/-180 no longer compute a near-global distance and spuriously
  split the trail into short-segment-filtered pieces.
- Unwrap longitudes before building segments and drawing polylines in
  both the per-station TrailManager and the show_trail_line handler so
  a date-line crossing renders as a short hop instead of a line that
  wraps around the world.
- Raise maxHopDistance (10 -> 100 km) and drop minSegmentPoints (3 -> 2)
  so legitimate fast movers (aircraft, balloons) and short valid hops
  are drawn instead of being dropped.
- Unbind mousemove/mouseout handlers on a trail before removing it so
  queued events can't fire against discarded state.
- Fix self.isValidCoordinate TypeError in updateMarker (function is
  module-level, not on the hook) and add coord validation to
  show_trail_line.
- Null boundsTimer after clearTimeout for cleanup consistency.
2026-04-20 18:03:25 -05:00
Claude
a8051ce247
fix: code review refinements
- RegexCache: change ETS table from :public to :protected for consistency
  with other tables, preventing uncontrolled writes bypassing GenServer
- MobileChannel: ensure_float now returns nil instead of the original
  unparsed string on parse failure, so validate_bounds properly rejects it
- map.ts: remove dead commented-out localStorage code
- map.ts: use instanceof HTMLAnchorElement instead of unsafe type cast
  in popup navigation handler
- TrailManager: add destroyed flag to prevent stale RAF and debounce
  callbacks from firing after destroy, and clean up hover timer on destroy

https://claude.ai/code/session_01Ps7Zq3wiBur1RtRKN7JM6X
2026-03-27 16:18:27 -05:00
464496222f
fix: harden frontend reconnect callbacks 2026-03-23 14:31:08 -05:00
512b7c4fe9
fix: clean up map resize hook listeners 2026-03-23 14:08:30 -05:00
d2fd0d181f
fix: harden frontend browser compatibility 2026-03-23 13:41:16 -05:00
ac42896271
fix: performance improvements and bug fixes across backend and frontend
Backend:
- Use indexed has_weather boolean for weather queries instead of 6 OR conditions
- Enable gzip compression for static assets
- Re-enable security headers (CSP, X-Frame-Options, X-Content-Type-Options)
- Supervise cleanup task via BroadcastTaskSupervisor instead of Task.start
- Relax IsSupervisor restart limits (5/60s) to survive transient network issues
- Remove dead code: empty cache invalidation block, commented-out logging

Frontend:
- Use callsignIndex for O(1) marker dedup instead of O(n) forEach scan
- Consolidate triple packet loop into single pass in new_packets handler
- Batch trail visualization updates via requestAnimationFrame
- Replace DOM querySelectorAll z-index scan with simple counter
- Only rebuild OMS markers when crossing clustering zoom threshold
- Clean up trail manager on hook destroy
- Remove dead commented-out localStorage code
2026-03-19 12:41:36 -05:00
bcbb39f21c
feat: add trail line display to map frontend
- Add trailLine state to MapHook
- Implement show_trail_line event handler with Leaflet polyline
- Implement clear_trail_line event handler
- Clear trail line when switching to heat map or markers
- Style trail line with blue color, 3px weight, 0.8 opacity
2026-02-27 13:25:00 -06:00
f5049a6e2d
updates 2026-02-22 15:33:35 -06:00
b8d2095346
Fix UI issues: popup positioning, trail/cluster sync, CSS cleanup
- Remove CSS `bottom: 50px !important` on popups that pushed them too
  high above markers
- Hide trails when markers are clustered (zoom < 11) so trails don't
  point to invisible markers inside cluster bubbles
- Fix locate button overlap with zoom controls and keep it always
  light mode
- Remove duplicate slideover/toggle CSS from layout files (single
  source of truth in component)
- Remove dead CSS classes and standardize breakpoints to 1024px
- Add isDestroyed guards on async callbacks to prevent race conditions
- Escape callsigns in marker HTML to prevent XSS
- Replace Leaflet _container private API with getContainer()
- Clean up about page placeholder text
2026-02-20 09:46:45 -06:00
84e65232e5
Batch RF path queries, batch marker removals, and JS callsign index
- Replace N+1 get_latest_packet_for_callsign calls in RF path loading
  with single get_latest_packets_for_callsigns batch query (DISTINCT ON)
- Change batch packet processing to collect marker removal IDs and push
  one remove_markers_batch event instead of individual remove_marker calls
- Add callsignIndex reverse map (callsign_group → Set<markerID>) for O(1)
  lookup in new_packet/new_packets handlers instead of scanning all markers
2026-02-20 09:04:22 -06:00
b4bbfda620
Move client-side logic to server-side LiveView
- Server tracks callsign replacements in prepare_packet_state, sends
  convert_to_historical list so JS skips full markerStates scan
- Historical packets get red dot HTML server-side in build_minimal_packet_data
  instead of JS createMarkerIcon generating it
- Add callsign_group field to all packet data output; server pre-sorts
  by group with chronological order so JS iterates directly
- Normalize heat map intensity in Clustering.cluster_packets (min/50, cap 1.0)
  instead of JS doing it per-point
- Remove buildPopupContent JS fallback and unused escapeHtml import;
  server already provides popup in all data paths
2026-02-20 08:54:34 -06:00
dcabb744df
Batch push_events, RF path queries, and ETS tuning for hot paths
- Batch real-time packet push_events: collect marker data across the
  packet batch and send a single "new_packets" WebSocket message instead
  of one per packet. JS handler processes all live→historical conversions
  before adding new markers to avoid intra-batch conflicts.
- Batch RF path station queries: replace N+1 get_latest_packet_for_callsign
  calls with a single DISTINCT ON query selecting only callsign + lat/lng.
- Add read_concurrency: true to streaming_packets_subscribers and :aprsme
  ETS tables (read-heavy, rarely written).
- Remove dead GC code in PacketConsumer (threshold > 1000 unreachable with
  max batch_size of 100).
2026-02-20 08:30:54 -06:00
d9c04f7e0c
Fix code review findings: security, correctness, performance, dead code
Security:
- Add SQL identifier validation to DbOptimizer.analyze_table/vacuum_table
- Move health/readiness routes to non-rate-limited pipeline

Correctness:
- Fix monitor reference leak in StreamingPacketsPubSub (track refs, demonitor on unsubscribe)
- Persist circuit breaker half-open state transitions
- Simplify ShutdownHandler.terminate to avoid pointless Process.send_after

Performance:
- Batch marker removal into single WebSocket event (remove_markers_batch)
- Use Task.Supervisor.start_child for fire-and-forget broadcasts

Dead code removal:
- Remove copy_insert/regular_batch_insert/rows_to_csv from DbOptimizer
- Remove dead packet_pipeline_integration tests
- Remove unused telemetry event detach

Other:
- Fix Callsign.valid? docstring to match permissive behavior
- Fix DatabaseMetrics to delegate instead of hardcoding pool stats
- Add circuit breaker and encoding test coverage
2026-02-19 18:49:27 -06:00
27f9b32dff
Fix duplicate station icons when live packet replaces historical
Historical loading overrides all markers to historical:true, including
the most-recent marker. When a new live packet arrives, the conversion
check only looked for non-historical markers, missing the existing
"current" marker. Broaden the check to also convert markers with
is_most_recent_for_callsign set.
2026-02-19 18:27:26 -06:00
976b6f153f
Fix slideover toggle: always-light button, map resize via LiveView JS
The slideover toggle button now uses a fixed light theme (white bg,
dark arrow) so it's always visible on the map regardless of OS dark
mode. Removed prefers-color-scheme overrides since the button overlays
the always-light map tiles.

Fixed map not resizing when closing the sidebar — the #aprs-map div
has phx-update="ignore" so server-rendered classes never updated.
Now uses LiveView JS commands (JS.toggle_class + JS.dispatch) to
toggle classes client-side and trigger map.invalidateSize(), replacing
the custom push_event/handleEvent JS handler.
2026-02-19 16:02:08 -06:00
14fa16df6d
Fix RF path visualization for hovering over track points
parse_rf_path was filtering out all paths containing qA* constructs,
which is virtually every APRS-IS packet. The qA* element delimits the
RF path from the APRS-IS metadata — it should be split on, not
discarded. Now properly extracts digipeaters (before qA*) and the
igate (after qA*), while filtering APRS aliases like WIDE/RELAY/TRACE.

Also adds hover handlers to trail polylines so hovering anywhere on a
call's track shows the RF path, not just on the dot markers.
2026-02-19 15:41:32 -06:00
509f271eac
Improve packet pipeline reliability, security, and cleanup efficiency
- Fix XSS vulnerability in buildPopupContent fallback (escape callsign/comment)
- Add batch insert retry with individual fallback in PacketConsumer
- Add APRS-IS login response validation (logresp dispatch handler)
- Fix stale generation check bypass in HistoricalLoader
- Replace two-step SELECT+DELETE cleanup with single CTE-based batch DELETE
- Change default packet retention from 365 to 7 days
- Delete MapHelpers (100% duplicate of CoordinateUtils + BoundsUtils)
- Delete AprsIsConnection (dead code, second unused APRS-IS connection)
- Fix InfoMap hook memory leak (store/cancel setTimeout ref)
- Extract singleton loadMapBundle with callback queue in app.js
- Extract @heat_map_max_zoom constant in DisplayManager
- Add telemetry to cleanup worker and PacketProducer buffer overflow
- Track PacketProducer buffer_size as integer for O(1) length checks
- Remove duplicate bounds functions from index.ex
2026-02-19 14:11:48 -06:00
d2910b5475
Increase marker spidering spread to prevent icon overlap
Widen nearbyDistance, spiderfyDistanceMultiplier, and foot separation
to accommodate 120x32px marker labels that were overlapping when
spidered at close zoom levels.
2026-02-18 13:34:30 -06:00
ff06c13224
Fix JavaScript/TypeScript bugs in plotting and validation
- Fix rain chart: remove incorrect /10 division on rain_24h values
- Fix RF path: change dashArray null to undefined for type safety
- Clarify trail proximity threshold: use kilometers directly instead of degrees
- Improve coordinate validation: add isFinite() checks to prevent infinity values
- Add Sobelow skip annotations for existing security warnings
2026-02-09 11:16:04 -06:00
d68bbe28f0
Fix coordinate extraction to handle nested arrays
- Add extractCoordinate helper to recursively extract coordinates
- Handle coordinates that come as nested arrays like [[lat]]
- Log raw coordinate values when validation fails for debugging
- Prevents Invalid coordinates errors in console

This handles edge cases where coordinates are wrapped in arrays
before being passed to the marker creation code.
2025-10-25 11:39:00 -05:00
4bc076906f
Add stricter coordinate validation in addMarker
- Check if data object exists before accessing properties
- Validate lat/lng are numbers, not just truthy values
- Prevents TypeError when clustering tries to access undefined coordinates
- Fixes: Error adding historical packet: TypeError: can't access property x of undefined
2025-10-25 11:20:29 -05:00
5e3f0bc5cf
fix coord bug 2025-10-19 09:06:58 -05:00
95fd9aa443
fix: fix Leaflet polyline error and add coordinate validation
- Fix typo: bindTooltip -> bindTooltip in RF path visualization
- Add coordinate validation before creating polylines
  - Check initial station coordinates are finite numbers
  - Validate each path station's coordinates
  - Skip invalid coordinates with console warning
- Prevents "can't access property 'x', h is undefined" error
2025-10-12 14:58:39 -05:00
62ada761cd
refactor: improve code quality and fix potential issues
- Remove duplicate time formatting function in components.ex
  - Use existing time_ago_in_words from TimeHelpers instead of custom format_time_ago
- Remove unnecessary Float multiplication in format_coordinates
  - Changed Float.round(lat * 1.0, 4) to Float.round(lat, 4)
- Fix TypeScript type safety issues
  - Add pendingMarkers to LiveViewHookContext interface
  - Add initializationTimeout property for proper cleanup
- Add cleanup for map initialization retry timeout
  - Prevent memory leak by clearing timeout in destroyed() method
- Format code with mix format

All changes maintain backward compatibility while improving code quality.
2025-10-12 14:02:27 -05:00
8a70011679
fix: add safety checks for marker cluster removal
- Check if markerClusterGroup is ready before removing markers
- Verify _map and _topClusterLevel exist in cluster group
- Add try-catch blocks to handle removal errors gracefully
- Clean up tracking maps even if layer removal fails
- Prevents 'can't access property "_childClusters"' errors
2025-10-12 12:50:06 -05:00
81d8605dc8
fix: prevent map initialization race condition
- Add marker queuing system for markers that arrive before map is ready
- Check map._container and getZoom to ensure internal structures exist
- Process pending markers after map.whenReady() callback
- Fix typo: bindTooltip -> bindTooltip
2025-10-12 12:44:16 -05:00
0528a99f36
fix: remove problematic errorTileUrl to resolve tile loading errors
The errorTileUrl was set to a base64 data URL of a transparent 1x1 PNG,
which caused browsers to fail when trying to use it as a tile replacement.
Removing this option allows Leaflet to handle tile errors with its
default behavior, which is more robust and prevents console errors.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 16:52:41 -05:00
8bc5d35e2e
fix: move sendMapReadyEvents definition before whenReady callback
The function was being called before it was defined, causing a runtime error.
Moving the function definition before the whenReady callback ensures it's
available when the callback executes.
2025-08-05 13:59:24 -05:00
44bc802f9d
refactor: simplify map.ts code with helper functions
- Add isValidCoordinate() helper to reduce duplicate coordinate validation
- Add createDivIcon() helper to standardize marker icon creation
- Simplify map ready event handling with sendMapReadyEvents() helper
- Fix typo: bindTooltip -> bindTooltip
- Reduce code duplication throughout the file
2025-08-05 13:51:33 -05:00
537ddec4d6
fix: improve RF path line cleanup to prevent persistent lines
- Add clearRfPathLines() method for centralized cleanup logic
- Clear RF paths when clearing all markers
- Clear RF paths in destroyed() lifecycle hook
- Add error handling to prevent failures during cleanup
- Fix issue where path lines could persist after hover ends
2025-08-05 13:43:46 -05:00
9b207e0d67
updates with parser updates 2025-08-03 09:19:31 -05:00
0375448019
fix: Send bounds to server after map initialization to trigger historical loading
- Added sendBoundsToServer() call after map_ready event
- Previously only saveMapState was called which doesn't send bounds
- This ensures historical packets are loaded on initial page load
- Also added to retry logic for reliability

The issue was that bounds_changed event was never triggered on initial load, preventing historical packets from being fetched.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 09:41:43 -05:00
d00a3945c9
feat: Increase spider distance multiplier for better marker separation
- Increased spiderfyDistanceMultiplier from 2 to 3.5
- Provides much better separation when overlapping markers are clicked
- Markers now spread out 3.5x the default distance for easier clicking

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 09:14:04 -05:00
b718d6bb3d
fix: Reduce spidering nearbyDistance to prevent grouping distant markers
- Reduced nearbyDistance from 100 to 20 pixels to only spider truly overlapping markers
- Added spiderfyDistanceMultiplier: 2 to increase separation when markers do spider
- Added leg color configuration for better visibility
- Fixes issue where distant markers like K5FDT-R were incorrectly grouped with AE5PL stations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 09:06:49 -05:00
6bd183dd6f
feat: Further increase spidering distance to 100 pixels
- Increased nearbyDistance from 60 to 100 pixels for maximum clickability
- Increased circleSpiralSwitchover from 12 to 15 markers
- Provides even better separation when clicking on densely packed APRS packets

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 18:03:27 -05:00
d99879dd56
feat: Increase spidering distance for overlapping markers
- Increased nearbyDistance from 40 to 60 pixels for better clickability
- Increased circleSpiralSwitchover from 9 to 12 markers before switching to spiral layout
- Improves user experience when clicking on overlapping APRS packets

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 17:46:37 -05:00
850498c50b
Add defensive checks for is_most_recent_for_callsign property
Improves robustness by adding fallback logic when is_most_recent_for_callsign
is undefined or null. In edge cases where this server-side property might not
be reliably set, falls back to the previous behavior of excluding historical
markers using the _isHistorical flag.

Changes:
- Added explicit boolean checks for is_most_recent_for_callsign === true
- Added fallback logic: if property is null/undefined, use \!_isHistorical
- Applied to both addMarker() and zoom handler functions
- Ensures spidering works even if server-side property is inconsistent

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 12:00:49 -05:00
8848c5b391
Fix packet spidering to only include most recent markers with icons
The OverlappingMarkerSpiderfier (OMS) was incorrectly configured to exclude
historical markers but wasn't properly filtering for only the most recent
packets with icons. This caused spidering functionality to break.

Changes:
- Updated addMarker() to check data.is_most_recent_for_callsign instead of \!_isHistorical
- Updated zoom handler to check markerState.is_most_recent_for_callsign when re-adding markers to OMS
- Ensures only current position markers (with APRS icons) participate in spidering
- Historical markers (red dots) are excluded from spidering as intended

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 11:57:41 -05:00
afaf5730a3
Exclude historical markers from spider clustering
Only include actual current position icons in the OverlappingMarkerSpiderfier,
not historical trail points. This prevents historical positions from spidering
out when clicked.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 08:06:30 -05:00
330e69bf90
Fix syntax error in map.ts - remove extra closing brace
Removed extra closing brace that was prematurely ending the try block
and causing build failure.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 07:52:06 -05:00
dab0c8737b
Remove all VectorGrid references and code
- Removed VectorGrid from map.ts, now using only raster tiles
- Removed VectorGrid from vendor bundle build scripts
- Removed VectorGrid TypeScript definitions
- Removed VectorGrid JavaScript file
- Rebuilt all vendor bundles without VectorGrid
- Simplified tile layer creation to use only OpenStreetMap raster tiles

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 07:43:44 -05:00
8ddcb8000f
Fix Leaflet library loading race condition and enable Redis-free development
- Fix race condition in map bundle loading by waiting for script to load before initializing map
- Ensure Leaflet is properly exposed as window.L in map bundle
- Add Leaflet availability check in map initialization function
- Disable Exq background jobs in development environment to remove Redis dependency
- Remove invalid TelemetryMetricsPrometheus plug from endpoint
- Application now starts successfully without Redis in development mode

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-27 12:20:23 -05:00
0b1e0b85f0
Fix map loading error with dynamic vendor bundles
- Fixed "Leaflet library failed to load" error by deferring window.L access
- Changed map.ts to access window.L dynamically instead of at module load time
- Added const L = window.L; inside functions that use Leaflet
- This allows the vendor bundle to load asynchronously before map initialization

The issue was that the TypeScript module was trying to access window.L
immediately when imported, before the vendor bundle had loaded Leaflet.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 14:25:05 -05:00
31bd5f5749
Switch back to raster map tiles
Disabled vector tiles by setting useVectorTiles to false.
The application will now use OpenStreetMap raster tiles instead.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 20:19:01 -05:00
9e45ffbf9a
ts tweak 2025-07-24 15:05:41 -05:00
206adb6b7d
back to raster 2025-07-24 12:02:28 -05:00
ae8c74afbe
try vector tiles 2025-07-24 10:54:31 -05:00
688fc6ba95
Implement mobile web optimization and fix sidebar clipping
- Add comprehensive mobile viewport meta tags for better mobile experience
- Implement touch gesture support with long-press to show station info
- Create mobile-specific CSS with touch target optimization (44px minimum)
- Add safe area insets support for notched devices
- Position zoom controls at bottom-right on mobile for thumb accessibility
- Optimize map performance on mobile with canvas renderer
- Fix desktop sidebar toggle button clipping when slideover is open
- Improve responsive design for slideover panels and popups
- Add landscape mode and high DPI screen optimizations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-21 14:31:49 -05:00