Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content/wardrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ function checkAndRefreshMap(trigger) {

// For GPS trigger, check distance
if (trigger === 'gps' && mapRefreshService.lastRefreshLocation) {
const distance = haversineDistance(
const distance = calculateHaversineDistance(
mapRefreshService.lastRefreshLocation.lat,
mapRefreshService.lastRefreshLocation.lon,
lat,
Expand Down Expand Up @@ -1086,7 +1086,7 @@ async function releaseWakeLock() {
* @returns {number} Distance in meters
*/
function calculateHaversineDistance(lat1, lon1, lat2, lon2) {
debugLog(`[GEOFENCE] Calculating Haversine distance: (${lat1.toFixed(5)}, ${lon1.toFixed(5)}) to (${lat2.toFixed(5)}, ${lon2.toFixed(5)})`);
debugLog(`[HAVERSINE] Calculating distance: (${lat1.toFixed(5)}, ${lon1.toFixed(5)}) to (${lat2.toFixed(5)}, ${lon2.toFixed(5)})`);

const R = 6371000; // Earth's radius in meters
const toRad = (deg) => (deg * Math.PI) / 180;
Expand All @@ -1102,7 +1102,7 @@ function calculateHaversineDistance(lat1, lon1, lat2, lon2) {
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
const distance = R * c;

debugLog(`[GEOFENCE] Haversine distance calculated: ${distance.toFixed(2)}m`);
debugLog(`[HAVERSINE] Distance calculated: ${distance.toFixed(2)}m`);
return distance;
}

Expand Down