View Javadoc

1   /**
2    * Copyright 2011-2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
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   * @author Kuali Mobility Team (mobility.collab@kuali.org)
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); // Ann Arbor
32          Point p2 = new Point(39.788,-86.165);       // Bloomington
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); // Ann Arbor
45          Point p2 = new Point(39.788,-86.165);       // Bloomington
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  }