1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.kuali.mobility.math.geometry;
16
17 import org.apache.log4j.Logger;
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertTrue;
21
22
23
24
25 public class SphericalTest {
26 private static final Logger LOG = Logger.getLogger(SphericalTest.class);
27
28 @Test
29 public void testComputeHeading() {
30 double expectedHeading = -142.8573142931038;
31 Point p1 = new Point(42.276674,-83.738029);
32 Point p2 = new Point(39.788,-86.165);
33
34 double heading = Spherical.computeHeading(p1, p2);
35
36 LOG.debug("Must travel "+heading+" from Ann Arbor to Bloomington");
37
38 assertTrue("Heading doesn't match. Found "+heading+". Expected "+expectedHeading, heading == expectedHeading);
39 }
40
41 @Test
42 public void testComputeDistanceBetween() {
43 double expectedDistance = 343887.6338228662;
44 Point p1 = new Point(42.276674,-83.738029);
45 Point p2 = new Point(39.788,-86.165);
46
47 double distance = Spherical.computeDistanceBetween(p1, p2);
48
49 LOG.debug("Bloomington is "+distance+" meters from Ann Arbor.");
50
51 assertTrue("Distance doesn't match. Found "+distance+". Expected "+expectedDistance,distance == expectedDistance);
52 }
53 }