mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 22:37:15 +00:00
fixed node distance calculation to point outside node; fixes failing tests; added specific test case for Node.getDistance
This commit is contained in:
1 parent
897d1d9a9a
commit
8bd932c9c2
2 files changed
+38
-4
No files matched your search
@@ -15,10 +15,12 @@ import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.Bounds;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.BoundsImpl;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.quadtree.QuadTree;
|
||||
import com.sap.sailing.domain.common.quadtree.impl.Node;
|
||||
import com.sap.sailing.domain.test.measurements.Measurement;
|
||||
import com.sap.sailing.domain.test.measurements.MeasurementCase;
|
||||
import com.sap.sailing.domain.test.measurements.MeasurementXMLFile;
|
||||
@@ -1336,6 +1338,31 @@ public class QuadTreeTest {
|
||||
assertTrue(dNearReverse < dFarReverse);
|
||||
}
|
||||
|
||||
private static class NodeWithPublicGetDistance<T> extends Node<T> {
|
||||
public NodeWithPublicGetDistance(Bounds bounds, int maxItems) {
|
||||
super(bounds, maxItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDistance(Position point) {
|
||||
return super.getDistance(point);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeDistance() {
|
||||
/*
|
||||
{SW: (50.625,-5.625), NE: (53.4375,0.0)}: 15 items in node, 0 child nodes
|
||||
(51.0,-6.0)
|
||||
*/
|
||||
NodeWithPublicGetDistance<String> node = new NodeWithPublicGetDistance<>(new BoundsImpl(new DegreePosition(50.625,-5.625), new DegreePosition(53.4375,0.0)),
|
||||
/* maxItems */ 20);
|
||||
Position p = new DegreePosition(51.0, -6.0);
|
||||
// lat is in bounds; lon is nearby, -5.625+6.0 should be the distance
|
||||
final double expectedDistance = -5.625 + 6.0;
|
||||
assertEquals(expectedDistance, node.getDistance(p), 0.0001);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void writeMeasurements() throws IOException {
|
||||
performanceReport.write();
|
||||
|
||||
Reference in new issue
Block a user