Question
I'm trying to find the distance between two locations in meters using the Tizen.Location class. I found the GetDistanceTo and GetDistanceBetween methods, but there's no documentation about the unit of measurement for the returned distance.
Can someone confirm:
- What unit does GetDistanceTo/GetDistanceBetween return (is it meters)?
- Is this the correct method to use for calculating distance between two GPS coordinates?
- I'm seeing unexpected distance values (greater than 5 meters) even when testing with very close points - is this normal behavior?
Answer
Problem Understanding
The user wants to:
- Understand the measurement unit of Tizen's location distance methods
- Verify if these methods are suitable for GPS coordinate distance calculation
- Investigate why they're getting unexpectedly large distance values for nearby points
Solution Methods
-
Measurement Unit Confirmation:
- Both GetDistanceTo() and GetDistanceBetween() return distance in meters
- This is confirmed in the native API documentation (though missing in C# API docs)
-
Method Suitability:
- These methods are indeed the correct way to calculate distance between GPS coordinates
- They use the Haversine formula for great-circle distance calculation
-
GPS Accuracy Considerations:
- GPS hardware has inherent limitations in accuracy
- Even when stationary, GPS readings can "jump" by several meters
- This is normal behavior due to:
- Atmospheric conditions
- Signal reflection
- Hardware limitations
- Satellite geometry
Code Examples
// Example usage of GetDistanceBetween
double distance = Location.GetDistanceBetween(
previousLatitude,
previousLongitude,
currentLatitude,
currentLongitude);
// Example with distance threshold check
if (distance > 5) // 5 meters
{
// Save new location
SaveLocationInformation();
previouslySavedLocation = currentLocation;
}
Additional Tips
- For better accuracy, consider:
- Using a larger distance threshold (e.g., 10-15 meters)
- Implementing location averaging over multiple readings
- Combining with other sensors (like accelerometer) to detect actual movement
- This behavior doesn't need to be reported as a bug as it's a hardware limitation
- The API team will improve the C# documentation to clarify the measurement unit