MetricInterpolation implements PositionInterpolator<T> { @Override public T interpolatePosition(final SortedSet<T> points) { T result = pointFactory.newPoint(); final int size = points.size(); switch (size) { case 0: break; case 1: final NicGeoPoint singlePoint = points.first(); result.setXY(singlePoint.getX(), singlePoint.getY()); break; default: result = doInterpolatePosition(points); } return result; } MetricInterpolation(final PointFactory<T> factory); @Override T interpolatePosition(final SortedSet<T> points);  }
@Test public void testEmptySet() { NicGeoPoint dstPoint = interpolator.interpolatePosition(distanceSet); assertEquals(0.0, dstPoint.getX()); assertEquals(0.0, dstPoint.getY()); }
@Test public void testSinglePoint() { p1.setDivergence(4.0f); distanceSet.add(p1); NicGeoPoint dstPoint = interpolator.interpolatePosition(distanceSet); assertEquals(p1.getX(), dstPoint.getX(), delta); assertEquals(p1.getY(), dstPoint.getY(), delta); }
@Test public void testTwoPoints() { p1.setDivergence(0.5f); p2.setDivergence(0.3f); distanceSet.add(p1); distanceSet.add(p2); NicGeoPoint dstPoint = interpolator.interpolatePosition(distanceSet); assertEquals(2.875f, dstPoint.getX(), delta); assertEquals(2.375f, dstPoint.getY(), delta); }
@Test public void testThreePoints() { p1.setDivergence(0.4f); p2.setDivergence(1.1f); p3.setDivergence(0.6f); distanceSet.add(p1); distanceSet.add(p2); distanceSet.add(p3); NicGeoPoint dstPoint = interpolator.interpolatePosition(distanceSet); assertEquals(1.8657f, dstPoint.getX(), delta); assertEquals(2.4925f, dstPoint.getY(), delta); }