- globalmapper.CalcDistance(float aFromX, float aFromY, float aToX, float aToY, bool aLatLon) GM_Error_t32, float
Calculates the great-circle distance in meters between two points. The points can either be specified as lat/lon values or in the current projection.
- Parameters:
aFromX (float) – start X/longitude coordinate
aFromY (float) – start Y/latitude coordinate
aToX (float) – stop X/longitude coordinate
aToY (float) – stop Y/latitude coordinate
aLatLon (bool) – TRUE - coordinates are lat/lon, FALSE - coordinates are in the current projection
- Returns:
Error Code
- Return type:
GM_Error_t32
- Returns:
Distance in meters between the points
- Return type:
float
Example
The following is an example of CalcDistance.
import globalmapper as gm
# Calculate the distance in meters between two points using Latitude/Longitude
### START SAMPLE
err_CalcDistance, dist = gm.CalcDistance(
44.308776, -69.785005, 44.305236, -69.77998, True
)
### END SAMPLE
assert (
gm.GM_Error_None == err_CalcDistance
), f"CalcDistance: Expected {gm.GM_Error_None}, got {err_CalcDistance}"
# This is the value held when this sample was created
assert dist == 576.9854474873664, "Calculations for distance are incorrect"