BearingPointCalculator { public GeoCoordinates calculateBearingDestinationAgainstDirection(Line lrpLine, int bearingDistance, int projectionAlongLine) { return getBearingDestination(lrpLine, projectionAlongLine, false, bearingDistance); }  GeoCoordinates calculateBearingDestinationInDirection(Line lrpLine, int bearingDistance, int projectionAlongLine); GeoCoordinates calculateBearingDestinationAgainstDirection(Line lrpLine, int bearingDistance, int projectionAlongLine);  }
@Test public void testBearingDestinationAgainstLocationDirection() { Line lrpLine = mapDatabase.getLine(4L); int projectionAlongLine = 14; GeoCoordinates bearingDestinationAgainstDirection = bearingPointCalculator.calculateBearingDestinationAgainstDirection(lrpLine, bearingDistance, projectionAlongLine); Line parentLine = mapDatabase.getLine(3L); int distanceAlongPredecessorLine = parentLine.getLineLength() - (bearingDistance - projectionAlongLine); assertEquals(bearingDestinationAgainstDirection, parentLine.getGeoCoordinateAlongLine(distanceAlongPredecessorLine)); }
@Test public void testBearingDestinationAtIntersectionAgainstDirection() { Line lrpLine = mapDatabase.getLine(6L); int projectionAlongLine = 5; assertEquals(bearingPointCalculator.calculateBearingDestinationAgainstDirection(lrpLine, bearingDistance, projectionAlongLine), lrpLine.getStartNode().getGeoCoordinates()); }
@Test public void testBearingDestinationAtLrpLineAgainstDirection() { Line lrpLine = mapDatabase.getLine(6L); assertEquals(bearingPointCalculator.calculateBearingDestinationAgainstDirection(lrpLine, bearingDistance, lrpLine.getLineLength()), lrpLine.getGeoCoordinateAlongLine(lrpLine.getLineLength() - bearingDistance)); }
@Test public void testBearingRouteAlongMultipleRoadSegmentsInReverseDirection() { Line lrpLine = multiWalkMapDatabase.getLine(6L); Line bearingDestination = multiWalkMapDatabase.getLine(1L); assertEquals(bearingPointCalculator.calculateBearingDestinationAgainstDirection(lrpLine, 500, lrpLine.getLineLength()), bearingDestination.getStartNode().getGeoCoordinates()); }