added destination tests
This commit is contained in:
parent
9bcf8714e5
commit
08e825c52a
@ -1,6 +1,7 @@
|
||||
package btools.router;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -110,4 +111,22 @@ public class OsmNodeNamedTest {
|
||||
0.1 * 5
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDestination() {
|
||||
// Segment ends
|
||||
int lon1, lat1, lon2, lat2;
|
||||
// Circle definition
|
||||
OsmNodeNamed node = new OsmNodeNamed();
|
||||
// Center
|
||||
node.ilon = toOsmLon(0);
|
||||
node.ilat = toOsmLat(0);
|
||||
double startDist = 1000;
|
||||
|
||||
for (int i = 0; i <= 360; i += 45) {
|
||||
int[] pos = CheapRuler.destination(node.ilon, node.ilat, startDist, i);
|
||||
double dist = CheapRuler.distance(node.ilon, node.ilat, pos[0], pos[1]);
|
||||
assertTrue("pos " + pos[0] + " " + pos[1] + " distance (" + dist + ") should be around (" + startDist + ")", dist -1 < startDist && dist +1 > startDist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user