/** * Takes two {@link Point}s and returns a point midway between them. The midpoint is calculated * geodesically, meaning the curvature of the earth is taken into account. * * @param from first point used for calculating the midpoint * @param to second point used for calculating the midpoint * @return a {@link Point} midway between point1 and point2 * @see <a href="http://turfjs.org/docs/#midpoint">Turf Midpoint documentation</a> * @since 1.3.0 */ public static Point midpoint(@NonNull Point from, @NonNull Point to) { double dist = distance(from, to, TurfConstants.UNIT_MILES); double heading = bearing(from, to); return destination(from, dist / 2, heading, TurfConstants.UNIT_MILES); }
return coords.get(i); } else { double direction = bearing(coords.get(i), coords.get(i - 1)) - 180; return destination(coords.get(i), overshot, direction, units);
return LineString.fromLngLats(slice); double direction = TurfMeasurement.bearing(coords.get(i), coords.get(i - 1)) - 180; Point interpolated = TurfMeasurement.destination(coords.get(i), overshot, direction, units); slice.add(interpolated); return LineString.fromLngLats(slice); double direction = TurfMeasurement.bearing(coords.get(i), coords.get(i - 1)) - 180; Point interpolated = TurfMeasurement.destination(coords.get(i), overshot, direction, units); slice.add(interpolated);
@Test public void testBearing() { Point pt1 = Point.fromLngLat(-75.4, 39.4); Point pt2 = Point.fromLngLat(-75.534, 39.123); assertNotEquals(TurfMeasurement.bearing(pt1, pt2), 0, DELTA); }
stop.properties().get("dist").getAsDouble() ); double direction = TurfMeasurement.bearing((Point) start.geometry(), (Point) stop.geometry()); Feature perpendicularPt1 = Feature.fromGeometry(