@Test public void testTwoPoints() { p1.setDivergence(0.5f); p2.setDivergence(0.3f); distanceSet.add(p1); distanceSet.add(p2); NicGeoPoint dstPoint = interpolator.interpolatePosition(distanceSet); assertEquals(9f/3f, dstPoint.getX(), delta); assertEquals(7f/3f, dstPoint.getY(), delta); }
@Override public T interpolatePosition(final SortedSet<T> points) { final T result = pointFactory.newPoint(); if (points.size() > 0) { int weight = points.size(); final int normalizationFactor = (weight * (weight + 1)) / 2; float x = 0; float y = 0; for (NicGeoPoint point : points) { x += weight * point.getX(); y += weight * point.getY(); weight--; } x = x / normalizationFactor; y = y / normalizationFactor; result.setXY(x, y); } return result; }
LinearInterpolation implements PositionInterpolator<T> { @Override public T interpolatePosition(final SortedSet<T> points) { final T result = pointFactory.newPoint(); if (points.size() > 0) { int weight = points.size(); final int normalizationFactor = (weight * (weight + 1)) / 2; float x = 0; float y = 0; for (NicGeoPoint point : points) { x += weight * point.getX(); y += weight * point.getY(); weight--; } x = x / normalizationFactor; y = y / normalizationFactor; result.setXY(x, y); } return result; } }
LinearInterpolation implements PositionInterpolator<T> { @Override public T interpolatePosition(final SortedSet<T> points) { final T result = pointFactory.newPoint(); if (points.size() > 0) { int weight = points.size(); final int normalizationFactor = (weight * (weight + 1)) / 2; float x = 0; float y = 0; for (NicGeoPoint point : points) { x += weight * point.getX(); y += weight * point.getY(); weight--; } x = x / normalizationFactor; y = y / normalizationFactor; result.setXY(x, y); } return result; } LinearInterpolation(final PointFactory<T> factory); }
LinearInterpolation implements PositionInterpolator<T> { @Override public T interpolatePosition(final SortedSet<T> points) { final T result = pointFactory.newPoint(); if (points.size() > 0) { int weight = points.size(); final int normalizationFactor = (weight * (weight + 1)) / 2; float x = 0; float y = 0; for (NicGeoPoint point : points) { x += weight * point.getX(); y += weight * point.getY(); weight--; } x = x / normalizationFactor; y = y / normalizationFactor; result.setXY(x, y); } return result; } LinearInterpolation(final PointFactory<T> factory); @Override T interpolatePosition(final SortedSet<T> points); }
LinearInterpolation implements PositionInterpolator<T> { @Override public T interpolatePosition(final SortedSet<T> points) { final T result = pointFactory.newPoint(); if (points.size() > 0) { int weight = points.size(); final int normalizationFactor = (weight * (weight + 1)) / 2; float x = 0; float y = 0; for (NicGeoPoint point : points) { x += weight * point.getX(); y += weight * point.getY(); weight--; } x = x / normalizationFactor; y = y / normalizationFactor; result.setXY(x, y); } return result; } LinearInterpolation(final PointFactory<T> factory); @Override T interpolatePosition(final SortedSet<T> points);  }