rhumbBearing function

num rhumbBearing(
  1. Point start,
  2. Point end, {
  3. bool kFinal = false,
})

Takes two Point and finds the bearing angle between them along a Rhumb line i.e. the angle measured in degrees start the north line (0 degrees) kFinal calculates the final bearing if true. Returns bearing from north in decimal degrees, between -180 and 180 degrees (positive clockwise) example:

var point1 = Feature(geometry: Point(coordinates: Position.of([-75.343, 39.984])), properties: {"marker-color": "#F00"});
var point2 = Feature(geometry: Point(coordinates: Position.of([-75.534, 39.123])), properties: {"marker-color": "#00F"});
var bearing = rhumbBearing(point1.geometry, point2.geometry);
//addToMap
var addToMap = [point1, point2];
point1.properties['bearing'] = bearing;
point2.properties['bearing'] = bearing;

Implementation

num rhumbBearing(Point start, Point end, {bool kFinal = false}) {
  num bear360;
  if (kFinal) {
    bear360 = calculateRhumbBearing(getCoord(end), getCoord(start));
  } else {
    bear360 = calculateRhumbBearing(getCoord(start), getCoord(end));
  }

  var bear180 = bear360 > 180 ? -(360 - bear360) : bear360;

  return bear180;
}