- globalmapper.CalcBearing(float aFromX, float aFromY, float aToX, float aToY, GM_CalcBearingFlags_t8 aFlags) GM_Error_t32, float
Calculates the bearing in radians between two points. The points can either be specified as lat/lon values or in the current projection. The bearing retrieved is a cartographic bearing, with 0 being north, PI / 2 being east, PI being south, and 3 * PI / 2 being west.
- 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
aFlags (GM_CalcBearingFlags_t8) – flags controlling coordinate projection and returned bearing sense
- Returns:
Error Code
- Return type:
GM_Error_t32
- Returns:
Bearing in radians between the points
- Return type:
float
Example
The following is an example of CalcBearing.
import globalmapper as gm
# Calculates the bearing in radians between two points using Latitude/Longitude
### START SAMPLE
err_CalcBearing, bearing = gm.CalcBearing(
44.308776, -69.785005, 44.305236, -69.77998, gm.GM_CalcBearing_LatLon
)
### END SAMPLE
assert (
gm.GM_Error_None == err_CalcBearing
), f"CalcBearing: Expected {gm.GM_Error_None}, got {err_CalcBearing}"
# This is the value held when this sample was created
assert bearing == 6.044160336858966, "Calculations for bearing are incorrect"