sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlaid...@apache.org
Subject svn commit: r1358474 - in /incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core: ./ TestLatLon.java TestLatLonPointRadius.java TestLatLonRect.java
Date Sat, 07 Jul 2012 00:01:58 GMT
Author: rlaidlaw
Date: Sat Jul  7 00:01:57 2012
New Revision: 1358474

URL: http://svn.apache.org/viewvc?rev=1358474&view=rev
Log:
SIS-48: added some basic junit tests for the core geometry classes in sis-core

Added:
    incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/
    incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLon.java   (with
props)
    incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java
  (with props)
    incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonRect.java   (with
props)

Added: incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLon.java
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLon.java?rev=1358474&view=auto
==============================================================================
--- incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLon.java (added)
+++ incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLon.java Sat Jul
 7 00:01:57 2012
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sis.core;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests methods from the {@link LatLon} class.
+ * 
+ * @author rlaidlaw
+ */
+public class TestLatLon extends TestCase
+{
+  private static final double EPSILON = 0.000001;
+  private LatLon point;
+  
+  /**
+   * Set up objects prior to tests.
+   */
+  public void setUp()
+  {
+    point = new LatLon(-75.0, -145.0);
+  }
+  
+  /**
+   * Clear up objects after testing.
+   */
+  public void tearDown()
+  {
+    point = null;
+  }
+
+  /**
+   * Tests the LatLon constructor.
+   */
+  public void testCreateLatLon()
+  {
+    assertNotNull(point);
+  }
+  
+  /**
+   * Tests the getLat() method.
+   */
+  public void testGetLat()
+  {
+    assertEquals(-75.0, point.getLat(), EPSILON);
+  }
+  
+  /**
+   * Tests the getLon() method.
+   */
+  public void testGetLon()
+  {
+    assertEquals(-145.0, point.getLon(), EPSILON);
+  }
+  
+  /**
+   * Tests the getShiftedLat() method.
+   */
+  public void testGetShiftedLat()
+  {
+    assertEquals(15.0, point.getShiftedLat(), EPSILON);
+  }
+
+  /**
+   * Tests the getShiftedLon() method.
+   */
+  public void testGetShiftedLon()
+  {
+    assertEquals(35.0, point.getShiftedLon(), EPSILON);
+  }
+
+  /**
+   * Tests the getNormLon() method.
+   */
+  public void testGetNormLon()
+  {
+    LatLon pointHighLon = new LatLon(0.0, 545.0);    
+    assertEquals(-175.0, pointHighLon.getNormLon(), EPSILON);
+    
+    LatLon pointLowLon = new LatLon(0.0, -545.0);
+    assertEquals(175.0, pointLowLon.getNormLon(), EPSILON);    
+  }
+
+  /**
+   * Tests the toString() method.
+   */
+  public void testToString()
+  {
+    assertEquals("-75.0,-145.0", point.toString());
+  }
+}

Propchange: incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLon.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java?rev=1358474&view=auto
==============================================================================
--- incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java
(added)
+++ incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java
Sat Jul  7 00:01:57 2012
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sis.core;
+
+import junit.framework.TestCase;
+
+//JDK imports
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Tests methods from the {@link LatLonPointRadius} class.
+ * 
+ * @author rlaidlaw
+ */
+public class TestLatLonPointRadius extends TestCase
+{
+  private static final double EPSILON = 0.000001;
+
+  /**
+   * Tests the LatLonPoint constructor.
+   */
+  public void testCreateLatLonPointRadius()
+  {
+    LatLonPointRadius region = new LatLonPointRadius(new LatLon(0.0, 0.0), 100.0);
+    assertNotNull(region);
+  }
+
+  /**
+   * Tests the getCircularRegionApproximation() method.
+   */
+  public void testGetCircularRegionApproximation()
+  {
+    LatLonPointRadius pr1 = new LatLonPointRadius(new LatLon(0.0, 0.0), 25000.0);
+    LatLon pts1[] = pr1.getCircularRegionApproximation(10);
+    assertEquals(5, pts1.length);
+    assertEquals(-90.0, pts1[0].getLat(), EPSILON);
+    assertEquals(-180.0, pts1[0].getLon(), EPSILON);
+    assertEquals(90.0, pts1[1].getLat(), EPSILON);
+    assertEquals(-180.0, pts1[1].getLon(), EPSILON);
+    assertEquals(90.0, pts1[2].getLat(), EPSILON);
+    assertEquals(180.0, pts1[2].getLon(), EPSILON);
+    assertEquals(-90.0, pts1[3].getLat(), EPSILON);
+    assertEquals(180.0, pts1[3].getLon(), EPSILON);
+    assertEquals(-90.0, pts1[4].getLat(), EPSILON);
+    assertEquals(-180.0, pts1[4].getLon(), EPSILON);
+    
+    LatLonPointRadius pr2 = new LatLonPointRadius(new LatLon(0.0, 0.0), 1000.0);
+    LatLon pts2[] = pr2.getCircularRegionApproximation(6);
+    assertEquals(7, pts2.length);
+  }
+
+  /**
+   * Tests the getRectangularRegionApproximation() method.
+   */
+  public void testGetRectangularRegionApproximation() 
+  {
+    LatLonPointRadius pr1 = new LatLonPointRadius(new LatLon(0.0, 0.0), 25000.0);
+    Rectangle2D r1 = pr1.getRectangularRegionApproximation(10);
+    assertEquals(0.0, r1.getX(), EPSILON);
+    assertEquals(0.0, r1.getY(), EPSILON);
+    assertEquals(360.0, r1.getWidth(), EPSILON);
+    assertEquals(180.0, r1.getHeight(), EPSILON);
+  }
+}

Propchange: incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonRect.java
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonRect.java?rev=1358474&view=auto
==============================================================================
--- incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonRect.java (added)
+++ incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonRect.java Sat
Jul  7 00:01:57 2012
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sis.core;
+
+import junit.framework.TestCase;
+
+//JDK imports
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Tests methods from the {@link LatLonRect} class.
+ * 
+ * @author rlaidlaw
+ */
+public class TestLatLonRect extends TestCase
+{
+  private static final double EPSILON = 0.000001;
+  
+  /**
+   * Tests the LatLonRect constructor.
+   */
+  public void testCreateLatLonRect()
+  {
+    LatLonRect rect = new LatLonRect(new LatLon(-50.0, -150.0), 
+                                     new LatLon(50.0, 150.0));
+    assertNotNull(rect);    
+  }
+  
+  /**
+   * Tests the getJavaRectangles() method.
+   */
+  public void testGetJavaRectangles()
+  {
+    LatLonRect r1 = new LatLonRect(new LatLon(0.0, 0.0), 
+        new LatLon(50.0, 50.0));
+    
+    Rectangle2D[] rects1 = r1.getJavaRectangles();
+    assertEquals(1, rects1.length);
+    assertEquals(180.0, rects1[0].getX(), EPSILON);
+    assertEquals(90.0, rects1[0].getY(), EPSILON);
+    assertEquals(50.0, rects1[0].getWidth(), EPSILON);
+    assertEquals(50.0, rects1[0].getHeight(), EPSILON);
+
+    
+    LatLonRect r2 = new LatLonRect(new LatLon(0.0, 155.0), 
+        new LatLon(50.0, -155.0));
+
+    Rectangle2D[] rects2 = r2.getJavaRectangles();
+    assertEquals(2, rects2.length);
+
+    assertEquals(0.0, rects2[0].getX(), EPSILON);
+    assertEquals(90.0, rects2[0].getY(), EPSILON);
+    assertEquals(25.0, rects2[0].getWidth(), EPSILON);
+    assertEquals(50.0, rects2[0].getHeight(), EPSILON);
+
+    assertEquals(335.0, rects2[1].getX(), EPSILON);
+    assertEquals(90.0, rects2[1].getY(), EPSILON);
+    assertEquals(25.0, rects2[1].getWidth(), EPSILON);
+    assertEquals(50.0, rects2[1].getHeight(), EPSILON);
+  }
+}

Propchange: incubator/sis/trunk/sis-core/src/test/java/org/apache/sis/core/TestLatLonRect.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message