From e75be978fafc4df2f86f0f237b3e42acf2e8f7a5 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Fri, 29 Aug 2025 14:46:32 -0400 Subject: [PATCH] asdfasfd --- distance_test.js | 26 +++++++++++++++++++ .../Applications/ApplicationExecutionModal.js | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 distance_test.js diff --git a/distance_test.js b/distance_test.js new file mode 100644 index 0000000..2f51ed9 --- /dev/null +++ b/distance_test.js @@ -0,0 +1,26 @@ +// Test distance calculation with the actual GPS coordinates from logs +const calculateDistance = (lat1, lng1, lat2, lng2) => { + const R = 6371e3; // Earth's radius in meters + const φ1 = lat1 * Math.PI/180; + const φ2 = lat2 * Math.PI/180; + const Δφ = (lat2-lat1) * Math.PI/180; + const Δλ = (lng2-lng1) * Math.PI/180; + + const a = Math.sin(Δφ/2) * Math.sin(Δφ/2) + + Math.cos(φ1) * Math.cos(φ2) * + Math.sin(Δλ/2) * Math.sin(Δλ/2); + const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); + + return R * c; +}; + +// Coordinates from backend log +const lat1 = 40.147240223806946; +const lng1 = -87.38764855098722; +const lat2 = 40.14725114957544; +const lng2 = -87.38763106622388; + +const distance = calculateDistance(lat1, lng1, lat2, lng2); +console.log('Distance in meters:', distance); +console.log('Distance rounded to 2 decimals:', Math.round(distance * 100) / 100); +console.log('Distance in feet:', distance * 3.28084); \ No newline at end of file diff --git a/frontend/src/components/Applications/ApplicationExecutionModal.js b/frontend/src/components/Applications/ApplicationExecutionModal.js index fddeda4..4c27bf8 100644 --- a/frontend/src/components/Applications/ApplicationExecutionModal.js +++ b/frontend/src/components/Applications/ApplicationExecutionModal.js @@ -296,6 +296,8 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo // Debug: log the exact data being sent console.log('Sending log data:', JSON.stringify(logData, null, 2)); + console.log('Total distance being stored:', totalDistance); + console.log('GPS track data being stored:', gpsTrackData); try { // Save the application log to the backend