Select to view content in your preferred language

geodesicUtils.geodesicDistance azimuth and reverse azimuth almost equally

166
3
Jump to solution
12-07-2024 02:58 PM
SebastianKrings
Frequent Contributor
Hi,
I am using geodesicUtils.geodesicDistance but always getting pretty similar values for azimuth and reverse azimuth.
 
This is how I call the distance calculation of the geodesicUtils:
 
const bearing = geodesicUtils.geodesicDistance(
                point1Wgs84,
                point2Wgs84,
                "kilometers"
            );
This is how a result looks like:
 
z {distance: 61.525187404214556, azimuth: 90.42038020754926, reverseAzimuth: 91.18218544411303}
While the azimuth looks good (that was a line from west to east), the reverse azimuth is almost the same value.
From what I understood I expected the reverse azimuth to be about 270° instead.
When drawing a line from south to north, the azimuth is abut 0-1° and reverse azimuth too, which I would expect to be about 180° instead.
 
Can anyone help me with these struggles?
0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

This may be a bug in the SDK.  One might expect the algorithm to calculate the azimuth first, and then calculate the reverse azimuth off of that value by simply adding or subtracting 180 (depending on whether the calculated azimuth is less than 180 or not, respectively), but that's definitely not the case here, because the SDK is calculating them independently of each other (for the most part).

Since it appears the azimuth value is correct, you can just fix the reverseAzimuth value manually after the fact:

const bearing = geodesicUtils.geodesicDistance(point1Wgs84, point2Wgs84, "kilometers");

//fix the reverseAzimuth value
bearing.reverseAzimuth = ((bearing.azimuth >= 180) ? bearing.azimuth - 180 : bearing.azimuth + 180);

 

View solution in original post

3 Replies
JoelBennett
MVP Regular Contributor

This may be a bug in the SDK.  One might expect the algorithm to calculate the azimuth first, and then calculate the reverse azimuth off of that value by simply adding or subtracting 180 (depending on whether the calculated azimuth is less than 180 or not, respectively), but that's definitely not the case here, because the SDK is calculating them independently of each other (for the most part).

Since it appears the azimuth value is correct, you can just fix the reverseAzimuth value manually after the fact:

const bearing = geodesicUtils.geodesicDistance(point1Wgs84, point2Wgs84, "kilometers");

//fix the reverseAzimuth value
bearing.reverseAzimuth = ((bearing.azimuth >= 180) ? bearing.azimuth - 180 : bearing.azimuth + 180);

 

SebastianKrings
Frequent Contributor

Yeah exactly, the difference should be 180°.

Not great that it is a bug, but knowing it is a bug is great.
Thanks. 

0 Kudos
JesseCloutier
Esri Community Manager

Hi @SebastianKrings, we appreciate you sharing a potential bug with the broader Esri Community; however, Esri does not actively track software defects posted here. The official channel for investigating and validating bugs is Esri Technical Support. All customers experiencing a potential software bug should leverage technical support to report and investigate the issue.

By reporting bugs through technical support, Esri can better track the scope and impact of the issue across all our customers and better prioritize it with our product teams. Our teams can also investigate the issue more thoroughly to see if there is a solution, workaround, or patch to get you back up and running as soon as possible.

As a reminder, Esri Community is primarily a self-service support platform where Esri users can ask or answer each other’s questions, share feature requests, and collaborate to solve problems with GIS.

*Note that this is a scripted message prompted when posts allude to a potential product bug.

Jesse Cloutier
Community Manager, Engagement & Content
0 Kudos