@Test public void testMidPointAccuracyAndSpeed() { final Location location1 = new Location(Latitude.degrees(51.127), Longitude.degrees(1.338)); final Location location2 = new Location(Latitude.degrees(50.964), Longitude.degrees(1.853)); final Time beginning = Time.now(); final Location derivedMidPoint = location1.shiftAlongGreatCircle( location1.headingTo(location2), location1.distanceTo(location2).scaleBy(Ratio.HALF)); System.out.println("Derived Duration: " + beginning.elapsedSince()); System.out.println(derivedMidPoint.toString() + "\n"); final Time beginning2 = Time.now(); final Location calculatedMidPoint = location1.midPoint(location2); System.out.println("Calculated Duration: " + beginning2.elapsedSince()); System.out.println(calculatedMidPoint.toString() + "\n"); final Time beginning3 = Time.now(); final Location calculatedLoxodromicMidPoint = location1.loxodromicMidPoint(location2); System.out.println("Calculated Loxodromic Duration: " + beginning3.elapsedSince()); System.out.println(calculatedLoxodromicMidPoint.toString() + "\n"); }
@Test public void testLoxodromicMidPoint() { final Location location1 = new Location(Latitude.degrees(51.127), Longitude.degrees(1.338)); final Location location2 = new Location(Latitude.degrees(50.964), Longitude.degrees(1.853)); final Location midpoint = location1.loxodromicMidPoint(location2); Assert.assertEquals(51.0455, midpoint.getLatitude().asDegrees(), DELTA); Assert.assertEquals(1.5957265, midpoint.getLongitude().asDegrees(), DELTA); }