Skip to content

Commit

Permalink
added test for sorting array based on great circle distances
Browse files Browse the repository at this point in the history
  • Loading branch information
wwerner committed Mar 6, 2010
1 parent c54954b commit 386cc5e
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.util.Arrays;
import java.util.Comparator;

import net.wolfgangwerner.geo.GeoConstants;
import net.wolfgangwerner.geo.distance.DistanceCalculationAlgorithm;
import net.wolfgangwerner.geo.distance.DistanceCalculator;
import net.wolfgangwerner.geo.distance.GeoPointDistanceComparator;
import net.wolfgangwerner.geo.model.GeoPoint;

Expand Down Expand Up @@ -48,4 +51,16 @@ public void testSortArray() {
assertArrayEquals(shuffelled, increasingDistanceToZurich);
}

@Test
public void testSortArrayWithGreatCircleAlg() {
GeoPoint[] increasingDistanceToZurich = new GeoPoint[] { stuttgart,
munich, berlin };
GeoPoint[] shuffelled = new GeoPoint[] { munich, stuttgart, berlin };

Arrays.sort(shuffelled, new GeoPointDistanceComparator(zurich,
new DistanceCalculator(GeoConstants.GREAT_CIRCLE_ALGORITHM)));

assertArrayEquals(shuffelled, increasingDistanceToZurich);
}

}

0 comments on commit 386cc5e

Please sign in to comment.