Topic: distance & altitude
Hi
I want to measure the exact distance between to points.
Those two points are defined by a latitude, longitude, and altitude.
OnlineMapsUtils provide two functions : one that doesn't take the altitude into account, and one that does.
However when i try to compare the result of the two method, i get roughly the same result. See the example below :
//GpsCoordinates is lat, lng, and altitude in meters
GpsCoordinates A = new GpsCoordinates(48.332300, -70.992836, 0);
GpsCoordinates B = new GpsCoordinates(48.332200, -70.992836, 0.2); //small difference in latitude, 200 meters difference in altitude
double dx, dy;
OnlineMapsUtils.DistanceBetweenPoints(A.Longitude, A.Latitude, B.Longitude, B.Latitude, out dx, out dy);
Debug.Log("distance between A and B (no altitude taken into account) : " + Math.Sqrt(dx * dx + dy * dy) * 1000 + " m");
OnlineMapsUtils.DistanceBetweenPoints(A.Longitude, A.Latitude,(float)A.Altitude, B.Longitude, B.Latitude,(float)B.Altitude, out dx, out dy);
Debug.Log("distance between A and B (altitude should matter in the result): " + Math.Sqrt(dx * dx + dy * dy) * 1000 + " m");
//representation of the two points on the map :
string label = "PointA";
OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.instance.Create(A.Longitude, A.Latitude, prefab);
marker.prefab.name = label;
marker.tags.Add(label);
marker.altitudeType = OnlineMapsAltitudeType.relative;
marker.altitude = (float)A.Altitude*1000;
label = "PointB";
OnlineMapsMarker3D marker2 = OnlineMapsMarker3DManager.instance.Create(B.Longitude,B.Latitude, prefab);
marker2.prefab.name = label;
marker2.tags.Add(label);
marker2.altitudeType = OnlineMapsAltitudeType.relative;
marker2.altitude = (float)B.Altitude*1000;
This is what i get :
I was expecting the distance to be 200 meters and more. How can i get the exact distance between my two points ?