sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1732337 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/ main/java/org/apache/sis/referencing/cs/ test/java/org/apache/sis/internal/referencing/ test/java/org/apache/sis/test/suite/
Date Thu, 25 Feb 2016 18:30:33 GMT
Author: desruisseaux
Date: Thu Feb 25 18:30:33 2016
New Revision: 1732337

URL: http://svn.apache.org/viewvc?rev=1732337&view=rev
Log:
Move ReferencingUtilities.toWKTType(...) to WKTUtilities.toType(...).
This is an internal method - no impact on public API.

Added:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WKTUtilitiesTest.java
      - copied, changed from r1732307, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1732337&r1=1732336&r2=1732337&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
[UTF-8] Thu Feb 25 18:30:33 2016
@@ -296,6 +296,8 @@ public final class ReferencingUtilities
      * @param  type The interface or classes for which to get the XML property name.
      * @return The XML property name for the given class or interface, or {@code null} if
none.
      *
+     * @see WKTUtilities#toType(Class, Class)
+     *
      * @since 0.6
      */
     public static StringBuilder toPropertyName(final Class<?> base, final Class<?>
type) {
@@ -317,37 +319,6 @@ public final class ReferencingUtilities
                 }
             }
         }
-        return null;
-    }
-
-    /**
-     * Returns the WKT type of the given interface.
-     *
-     * For {@link CoordinateSystem} base type, the returned value shall be one of
-     * {@code affine}, {@code Cartesian}, {@code cylindrical}, {@code ellipsoidal}, {@code
linear},
-     * {@code parametric}, {@code polar}, {@code spherical}, {@code temporal} or {@code vertical}.
-     *
-     * @param  base The abstract base interface.
-     * @param  type The interface or classes for which to get the WKT type.
-     * @return The WKT type for the given class or interface, or {@code null} if none.
-     */
-    public static String toWKTType(final Class<?> base, final Class<?> type)
{
-        if (type != base) {
-            final StringBuilder name = toPropertyName(base, type);
-            if (name != null) {
-                int end = name.length() - 2;
-                if (CharSequences.regionMatches(name, end, "CS")) {
-                    name.setLength(end);
-                    if ("time".contentEquals(name)) {
-                        return "temporal";
-                    }
-                    if (CharSequences.regionMatches(name, 0, "cartesian")) {
-                        name.setCharAt(0, 'C');     // "Cartesian"
-                    }
-                    return name.toString();
-                }
-            }
-        }
         return null;
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java?rev=1732337&r1=1732336&r2=1732337&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/WKTUtilities.java
[UTF-8] Thu Feb 25 18:30:33 2016
@@ -40,6 +40,7 @@ import org.apache.sis.io.wkt.ElementKind
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.Static;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Vocabulary;
 
 
@@ -53,7 +54,7 @@ import org.apache.sis.util.resources.Voc
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class WKTUtilities extends Static {
@@ -219,4 +220,37 @@ public final class WKTUtilities extends
             formatter.newLine();
         }
     }
+
+    /**
+     * Returns the WKT type of the given interface.
+     *
+     * For {@link CoordinateSystem} base type, the returned value shall be one of
+     * {@code affine}, {@code Cartesian}, {@code cylindrical}, {@code ellipsoidal}, {@code
linear},
+     * {@code parametric}, {@code polar}, {@code spherical}, {@code temporal} or {@code vertical}.
+     *
+     * @param  base The abstract base interface.
+     * @param  type The interface or classes for which to get the WKT type.
+     * @return The WKT type for the given class or interface, or {@code null} if none.
+     *
+     * @see ReferencingUtilities#toPropertyName(Class, Class)
+     */
+    public static String toType(final Class<?> base, final Class<?> type) {
+        if (type != base) {
+            final StringBuilder name = ReferencingUtilities.toPropertyName(base, type);
+            if (name != null) {
+                int end = name.length() - 2;
+                if (CharSequences.regionMatches(name, end, "CS")) {
+                    name.setLength(end);
+                    if ("time".contentEquals(name)) {
+                        return "temporal";
+                    }
+                    if (CharSequences.regionMatches(name, 0, "cartesian")) {
+                        name.setCharAt(0, 'C');     // "Cartesian"
+                    }
+                    return name.toString();
+                }
+            }
+        }
+        return null;
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1732337&r1=1732336&r2=1732337&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
[UTF-8] Thu Feb 25 18:30:33 2016
@@ -33,7 +33,7 @@ import org.opengis.referencing.cs.AxisDi
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.io.wkt.ElementKind;
@@ -457,7 +457,7 @@ public class AbstractCS extends Abstract
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        final String type = ReferencingUtilities.toWKTType(CoordinateSystem.class, getInterface());
+        final String type = WKTUtilities.toType(CoordinateSystem.class, getInterface());
         if (type == null) {
             formatter.setInvalidWKT(this, null);
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java?rev=1732337&r1=1732336&r2=1732337&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
[UTF-8] Thu Feb 25 18:30:33 2016
@@ -25,7 +25,6 @@ import org.opengis.referencing.datum.Pri
 import org.opengis.referencing.IdentifiedObject;
 import org.apache.sis.referencing.datum.HardCodedDatum;
 import org.apache.sis.referencing.crs.HardCodedCRS;
-import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -98,6 +97,8 @@ public final strictfp class ReferencingU
     /**
      * Tests {@link ReferencingUtilities#toPropertyName(Class, Class)}.
      *
+     * @see WKTUtilitiesTest#testToType()
+     *
      * @since 0.6
      */
     @Test
@@ -114,22 +115,4 @@ public final strictfp class ReferencingU
         assertEquals("timeCS",           toPropertyName(CoordinateSystem.class, TimeCS  
       .class).toString());
         assertEquals("verticalCS",       toPropertyName(CoordinateSystem.class, VerticalCS
     .class).toString());
     }
-
-    /**
-     * Tests {@link ReferencingUtilities#toWKTType(Class, Class)}.
-     */
-    @Test
-    public void testType() {
-        assertNull  (                         toWKTType(CoordinateSystem.class, CoordinateSystem.class));
-        assertEquals(WKTKeywords.affine,      toWKTType(CoordinateSystem.class, AffineCS
       .class));
-        assertEquals(WKTKeywords.Cartesian,   toWKTType(CoordinateSystem.class, CartesianCS
    .class));
-        assertEquals(WKTKeywords.cylindrical, toWKTType(CoordinateSystem.class, CylindricalCS
  .class));
-        assertEquals(WKTKeywords.ellipsoidal, toWKTType(CoordinateSystem.class, EllipsoidalCS
  .class));
-        assertEquals(WKTKeywords.linear,      toWKTType(CoordinateSystem.class, LinearCS
       .class));
-//      assertEquals(WKTKeywords.parametric,  toWKTType(CoordinateSystem.class, ParametricCS
   .class));
-        assertEquals(WKTKeywords.polar,       toWKTType(CoordinateSystem.class, PolarCS 
       .class));
-        assertEquals(WKTKeywords.spherical,   toWKTType(CoordinateSystem.class, SphericalCS
    .class));
-        assertEquals(WKTKeywords.temporal,    toWKTType(CoordinateSystem.class, TimeCS  
       .class));
-        assertEquals(WKTKeywords.vertical,    toWKTType(CoordinateSystem.class, VerticalCS
     .class));
-    }
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WKTUtilitiesTest.java
(from r1732307, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WKTUtilitiesTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WKTUtilitiesTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java&r1=1732307&r2=1732337&rev=1732337&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/WKTUtilitiesTest.java
[UTF-8] Thu Feb 25 18:30:33 2016
@@ -16,120 +16,43 @@
  */
 package org.apache.sis.internal.referencing;
 
-import javax.measure.unit.Unit;
-import javax.measure.unit.NonSI;
 import org.opengis.referencing.cs.*;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.datum.PrimeMeridian;
-import org.opengis.referencing.IdentifiedObject;
-import org.apache.sis.referencing.datum.HardCodedDatum;
-import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.apache.sis.internal.metadata.WKTKeywords;
-import org.apache.sis.util.Utilities;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.*;
+import static org.apache.sis.internal.referencing.WKTUtilities.*;
 
 
 /**
- * Tests {@link ReferencingUtilities}.
+ * Tests {@link WKTUtilities}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @since   0.5 (derived from 0.4)
+ * @since   0.7
  * @version 0.7
  * @module
  */
-public final strictfp class ReferencingUtilitiesTest extends TestCase {
+@DependsOn(ReferencingUtilitiesTest.class)
+public final strictfp class WKTUtilitiesTest extends TestCase {
     /**
-     * Tests {@link ReferencingUtilities#getGreenwichLongitude(PrimeMeridian, Unit)}.
-     */
-    @Test
-    public void testGetGreenwichLongitude() {
-        assertEquals(0,          getGreenwichLongitude(HardCodedDatum.GREENWICH, NonSI.DEGREE_ANGLE),
STRICT);
-        assertEquals(0,          getGreenwichLongitude(HardCodedDatum.GREENWICH, NonSI.GRADE),
       STRICT);
-        assertEquals(2.5969213,  getGreenwichLongitude(HardCodedDatum.PARIS,     NonSI.GRADE),
       STRICT);
-        assertEquals(2.33722917, getGreenwichLongitude(HardCodedDatum.PARIS,     NonSI.DEGREE_ANGLE),
1E-12);
-        assertEquals(2.33720833, getGreenwichLongitude(HardCodedDatum.PARIS_RGS, NonSI.DEGREE_ANGLE),
1E-8);
-        assertEquals(2.596898,   getGreenwichLongitude(HardCodedDatum.PARIS_RGS, NonSI.GRADE),
       1E-6);
-    }
-
-    /**
-     * Asserts that normalization of the given CRS produces {@link HardCodedCRS#WGS84} (ignoring
metadata).
-     *
-     * @param message The message to show in case of failure.
-     * @param createExpected {@code true} if we expect normalization to create a new CRS
object.
-     * @param crs The CRS for which to test normalization.
-     */
-    private static void assertNormalizedEqualsWGS84(final String message, final boolean createExpected,
-            final CoordinateReferenceSystem crs)
-    {
-        final GeographicCRS normalizedCRS = toNormalizedGeographicCRS(crs);
-        assertTrue(message, Utilities.equalsIgnoreMetadata(HardCodedCRS.WGS84, normalizedCRS));
-        assertEquals("New CRS instance expected:", createExpected, normalizedCRS != HardCodedCRS.WGS84);
-    }
-
-    /**
-     * Tests {@link ReferencingUtilities#toNormalizedGeographicCRS(CoordinateReferenceSystem)}.
-     */
-    @Test
-    public void testToNormalizedGeographicCRS() {
-        assertNormalizedEqualsWGS84("Expected identity operation.",    false, HardCodedCRS.WGS84);
-        assertNormalizedEqualsWGS84("Shall extract the 2D component.", false, HardCodedCRS.GEOID_3D);
-        assertNormalizedEqualsWGS84("Shall extract the 2D component.", false, HardCodedCRS.GEOID_4D);
-        assertNormalizedEqualsWGS84("Shall build a the 2D component.", true,  HardCodedCRS.WGS84_3D);
-        assertNormalizedEqualsWGS84("Shall normalize axis order.",     true,  HardCodedCRS.WGS84_φλ);
-        assertNull(toNormalizedGeographicCRS(null));
-    }
-
-    /**
-     * Tests {@link ReferencingUtilities#getPropertiesForModifiedCRS(IdentifiedObject, String...)}.
+     * Tests {@link ReferencingUtilities#toType(Class, Class)}.
      *
-     * @since 0.7
-     */
-    @Test
-    public void testGetPropertiesForModifiedCRS() {
-        assertEquals("WGS 84", getPropertiesForModifiedCRS(HardCodedCRS.WGS84_3D).get(IdentifiedObject.NAME_KEY));
-        assertEquals("WGS 84", getPropertiesForModifiedCRS(HardCodedCRS.GEOID_4D).get(IdentifiedObject.NAME_KEY));
-    }
-
-    /**
-     * Tests {@link ReferencingUtilities#toPropertyName(Class, Class)}.
-     *
-     * @since 0.6
-     */
-    @Test
-    public void testToPropertyName() {
-        assertEquals("coordinateSystem", toPropertyName(CoordinateSystem.class, CoordinateSystem.class).toString());
-        assertEquals("affineCS",         toPropertyName(CoordinateSystem.class, AffineCS
       .class).toString());
-        assertEquals("cartesianCS",      toPropertyName(CoordinateSystem.class, CartesianCS
    .class).toString());
-        assertEquals("cylindricalCS",    toPropertyName(CoordinateSystem.class, CylindricalCS
  .class).toString());
-        assertEquals("ellipsoidalCS",    toPropertyName(CoordinateSystem.class, EllipsoidalCS
  .class).toString());
-        assertEquals("linearCS",         toPropertyName(CoordinateSystem.class, LinearCS
       .class).toString());
-//      assertEquals("parametricCS",     toPropertyName(CoordinateSystem.class, ParametricCS
   .class).toString());
-        assertEquals("polarCS",          toPropertyName(CoordinateSystem.class, PolarCS 
       .class).toString());
-        assertEquals("sphericalCS",      toPropertyName(CoordinateSystem.class, SphericalCS
    .class).toString());
-        assertEquals("timeCS",           toPropertyName(CoordinateSystem.class, TimeCS  
       .class).toString());
-        assertEquals("verticalCS",       toPropertyName(CoordinateSystem.class, VerticalCS
     .class).toString());
-    }
-
-    /**
-     * Tests {@link ReferencingUtilities#toWKTType(Class, Class)}.
+     * @see ReferencingUtilitiesTest#testToPropertyName()
      */
     @Test
-    public void testType() {
-        assertNull  (                         toWKTType(CoordinateSystem.class, CoordinateSystem.class));
-        assertEquals(WKTKeywords.affine,      toWKTType(CoordinateSystem.class, AffineCS
       .class));
-        assertEquals(WKTKeywords.Cartesian,   toWKTType(CoordinateSystem.class, CartesianCS
    .class));
-        assertEquals(WKTKeywords.cylindrical, toWKTType(CoordinateSystem.class, CylindricalCS
  .class));
-        assertEquals(WKTKeywords.ellipsoidal, toWKTType(CoordinateSystem.class, EllipsoidalCS
  .class));
-        assertEquals(WKTKeywords.linear,      toWKTType(CoordinateSystem.class, LinearCS
       .class));
-//      assertEquals(WKTKeywords.parametric,  toWKTType(CoordinateSystem.class, ParametricCS
   .class));
-        assertEquals(WKTKeywords.polar,       toWKTType(CoordinateSystem.class, PolarCS 
       .class));
-        assertEquals(WKTKeywords.spherical,   toWKTType(CoordinateSystem.class, SphericalCS
    .class));
-        assertEquals(WKTKeywords.temporal,    toWKTType(CoordinateSystem.class, TimeCS  
       .class));
-        assertEquals(WKTKeywords.vertical,    toWKTType(CoordinateSystem.class, VerticalCS
     .class));
+    public void testToType() {
+        assertNull  (                         toType(CoordinateSystem.class, CoordinateSystem.class));
+        assertEquals(WKTKeywords.affine,      toType(CoordinateSystem.class, AffineCS   
    .class));
+        assertEquals(WKTKeywords.Cartesian,   toType(CoordinateSystem.class, CartesianCS
    .class));
+        assertEquals(WKTKeywords.cylindrical, toType(CoordinateSystem.class, CylindricalCS
  .class));
+        assertEquals(WKTKeywords.ellipsoidal, toType(CoordinateSystem.class, EllipsoidalCS
  .class));
+        assertEquals(WKTKeywords.linear,      toType(CoordinateSystem.class, LinearCS   
    .class));
+//      assertEquals(WKTKeywords.parametric,  toType(CoordinateSystem.class, ParametricCS
   .class));
+        assertEquals(WKTKeywords.polar,       toType(CoordinateSystem.class, PolarCS    
    .class));
+        assertEquals(WKTKeywords.spherical,   toType(CoordinateSystem.class, SphericalCS
    .class));
+        assertEquals(WKTKeywords.temporal,    toType(CoordinateSystem.class, TimeCS     
    .class));
+        assertEquals(WKTKeywords.vertical,    toType(CoordinateSystem.class, VerticalCS 
    .class));
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1732337&r1=1732336&r2=1732337&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Thu Feb 25 18:30:33 2016
@@ -35,6 +35,7 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.referencing.j2d.ShapeUtilitiesTest.class,
     org.apache.sis.internal.referencing.PositionalAccuracyConstantTest.class,
     org.apache.sis.internal.referencing.ReferencingUtilitiesTest.class,
+    org.apache.sis.internal.referencing.WKTUtilitiesTest.class,
     org.apache.sis.internal.jaxb.referencing.CodeTest.class,
     org.apache.sis.internal.jaxb.referencing.SecondDefiningParameterTest.class,
 



Mime
View raw message