asdfasfd
This commit is contained in:
26
distance_test.js
Normal file
26
distance_test.js
Normal file
@@ -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);
|
||||||
@@ -296,6 +296,8 @@ const ApplicationExecutionModal = ({ application, propertyDetails, onClose, onCo
|
|||||||
|
|
||||||
// Debug: log the exact data being sent
|
// Debug: log the exact data being sent
|
||||||
console.log('Sending log data:', JSON.stringify(logData, null, 2));
|
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 {
|
try {
|
||||||
// Save the application log to the backend
|
// Save the application log to the backend
|
||||||
|
|||||||
Reference in New Issue
Block a user