Skip to content

Add 25m distance filtering and 150km Ottawa geofence to wardriver pings#38

Merged
MrAlders0n merged 3 commits into
devfrom
copilot/implement-distance-based-ping-filtering
Dec 18, 2025
Merged

Add 25m distance filtering and 150km Ottawa geofence to wardriver pings#38
MrAlders0n merged 3 commits into
devfrom
copilot/implement-distance-based-ping-filtering

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 18, 2025

Reduces unnecessary API calls by skipping pings when user hasn't moved ≥25m, and restricts wardriving to Ottawa region (150km radius from Parliament Hill) for data quality.

Changes

Distance Filtering

  • Haversine formula calculates distance from last successful ping
  • Skip ping if < 25m moved: "Ping skipped, too close to last ping (22.2m away). Need 2.8m more to ping"
  • lastPingLocation state tracks last ping coordinates and timestamp
  • Auto mode reschedules to continuously recheck as user moves

Geofence Validation

  • Center: 45.4215°N, 75.6972°W (Parliament Hill)
  • Radius: 150km (covers greater Ottawa region)
  • Block pings outside boundary: "Location outside service area (166.3km from Ottawa)"
  • GPS tracking continues, only transmission blocked

Implementation Details

// Execute checks before transmission in sendPing()
const geofenceCheck = checkGeofence(lat, lon);
if (!geofenceCheck.inBounds) {
  setStatus(`Location outside service area (${geofenceCheck.distanceKm.toFixed(1)}km from Ottawa)`, "text-red-300");
  return;
}

if (state.lastPingLocation) {
  const distanceFromLastPing = calculateDistance(lat, lon, 
    state.lastPingLocation.lat, state.lastPingLocation.lon);
  if (distanceFromLastPing < MIN_PING_DISTANCE_M) {
    const remaining = MIN_PING_DISTANCE_M - distanceFromLastPing;
    setStatus(`Ping skipped, too close to last ping (${distanceFromLastPing.toFixed(1)}m away). Need ${remaining.toFixed(1)}m more to ping`, "text-amber-300");
    return;
  }
}

Constants added: MIN_PING_DISTANCE_M, OTTAWA_CENTER_LAT/LON, OTTAWA_GEOFENCE_RADIUS_KM, EARTH_RADIUS_METERS, DEG_TO_RAD

Modified: sendPing() adds validation before payload transmission. All existing functionality preserved.

Test Results

  • Distance calculations: 0m, 22.2m (skip), 33.4m (send), 1000.8m validated
  • Geofence: Ottawa/Gatineau in-bounds, Montreal/Toronto blocked
  • CodeQL: 0 vulnerabilities

Application UI

Original prompt

MeshCore Wardrive GPS Enhancement Task

Project Context

  • Repository: MrAlders0n/MeshCore-GOME-WarDriver
  • Language: JavaScript (Web Bluetooth + Geolocation API)
  • Current GPS Features: Real-time location tracking, accuracy display, continuous GPS watch
  • Location: Ottawa Mesh Network wardriving application
  • Purpose: Send pings to mesh network and map coverage zones

Requirements

1. Distance-Based Ping Filtering (25m Radius)

Implement movement detection to reduce unnecessary API calls and network traffic:

Objectives:

  • Track the GPS coordinates of the last successful ping sent to the MeshMapper API
  • Before sending a new ping, calculate the distance between:
    • Current GPS position
    • Last ping location
  • Skip the ping if distance < 25 meters
  • Display status message: "Ping skipped, too close to last ping (X. Xm away)"
  • Maintain a counter showing distance since last valid ping

Technical Details:

  • Use the Haversine formula to calculate great-circle distance between coordinates
  • Apply this logic in the sendPing() function before calling postToMeshMapperApi()
  • Store lastPingLocation = { lat, lon, tsMs } after successful API post
  • Display remaining distance needed to trigger next ping (e.g., "Need 8. 5m more to ping")
  • Log all distance calculations for debugging

2. Ottawa Regional Geofence (100km radius)

Restrict the application to the Ottawa region to ensure data quality:

Objectives:

  • Define Ottawa city center coordinates as the geofence origin
  • Set a 150km radius boundary
  • Prevent pings from being sent outside this boundary
  • Display clear warnings when user moves outside the geofence
  • Allow GPS tracking but block API calls when out of bounds

Geofence Details:

  • Ottawa Center Coordinates: 45.4215° N, 75.6972° W (Parliament Hill)
  • Radius: 150km
  • Status Messages:
    • When in bounds: Show normal GPS/status (no change to current behavior)
    • When out of bounds show this status: "Location outside service area (X.Xkm from Ottawa)"

Technical Details:

  • Calculate distance from current GPS to Ottawa center using Haversine formula
  • Check geofence before sending any ping (both manual and auto)
  • Add a visual indicator showing distance from center (optional)
  • Still allow the app to function (connect, UI updates) but prevent ping transmission
  • Log geofence violations for debugging

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 18, 2025 11:48
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Copilot AI changed the title [WIP] Add distance-based ping filtering for GPS enhancement Add 25m distance filtering and 150km Ottawa geofence to wardriver pings Dec 18, 2025
Copilot AI requested a review from MrAlders0n December 18, 2025 11:56
@MrAlders0n MrAlders0n marked this pull request as ready for review December 18, 2025 11:56
@MrAlders0n MrAlders0n merged commit ae869b4 into dev Dec 18, 2025
@MrAlders0n MrAlders0n deleted the copilot/implement-distance-based-ping-filtering branch December 18, 2025 13:16
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.

2 participants