mapbox-java icon indicating copy to clipboard operation
mapbox-java copied to clipboard

TurfMeasurements should have a function for determining bearing deltas

Open kmadsen opened this issue 4 years ago • 1 comments

TurfMeasurement.bearing(Point point1, Point point2

This function can return -180.0, 180.0.

In order to calculate the difference between two bearings. Downstream needs to create a normalizing function which can determine that the difference between -179.0 and 179.0, is 2 degrees.

double TurfMeasurements.shortestBearingDiff(double bearing1, double bearing2) {
  ...
}

This function should be proven with unit tests.

kmadsen avatar Jun 07 '21 19:06 kmadsen

other name ideas for the function. i like extending the bearing function with bearingShortest*. am not preferring "rotationDiff" because rotation is a difference.

bearingDifference bearingShortestDiff bearingShortestDelta shortestRotationDiff

kmadsen avatar Jun 07 '21 19:06 kmadsen