Example #1
0
  @Test
  public void canCalculateTheDistanceBetweenTwoLocationsOnTheSameContinent() {
    Coordinates centerBellInMontreal = Coordinates.locatedAt(45.4959755, -73.5693904);
    Coordinates yankeeStadiumInNewYork = Coordinates.locatedAt(40.8295818, -73.9261455);

    Length distance = centerBellInMontreal.getDistanceTo(yankeeStadiumInNewYork);

    assertThat(distance.toKilometers()).isWithin(0.5).of(519.23);
  }
Example #2
0
  @Test
  public void canCalculateTheDistanceBetweenTwoLocationsOnDifferentContinents() {
    // Example found on http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates
    Coordinates statueOfLiberty = Coordinates.locatedAt(40.6892, -74.0444);
    Coordinates eiffelTower = Coordinates.locatedAt(48.8583, 2.2945);

    Length distance = statueOfLiberty.getDistanceTo(eiffelTower);

    assertThat(distance.toKilometers()).isWithin(0.5).of(5_837);
  }