sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1649761 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
Date Tue, 06 Jan 2015 09:32:34 GMT
Author: desruisseaux
Date: Tue Jan  6 09:32:34 2015
New Revision: 1649761

URL: http://svn.apache.org/r1649761
Log:
Trivial change of method declaration order (no significant code change).
The intend is only to keep related methods together.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
    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
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1649761&r1=1649760&r2=1649761&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] Tue Jan  6 09:32:34 2015
@@ -64,44 +64,43 @@ public final class ReferencingUtilities
     }
 
     /**
-     * Returns the WKT type of the given interface.
+     * Returns {@code true} if the Greenwich longitude of the {@code actual} prime meridian
is equals to the
+     * Greenwich longitude of the {@code expected} prime meridian. The comparison is performed
in unit of the
+     * expected prime meridian.
      *
-     * 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 expected The expected prime meridian, or {@code null}.
+     * @param actual The actual prime meridian, or {@code null}.
+     * @return {@code true} if both prime meridian have the same Greenwich longitude,
+     *         in unit of the expected prime meridian.
+     */
+    public static boolean isGreenwichLongitudeEquals(final PrimeMeridian expected, final
PrimeMeridian actual) {
+        if (expected == actual) {
+            return true;
+        }
+        if (expected == null || actual == null) {
+            return false;
+        }
+        return epsilonEqual(expected.getGreenwichLongitude(),
+                getGreenwichLongitude(actual, expected.getAngularUnit()));
+    }
+
+    /**
+     * Returns the longitude value relative to the Greenwich Meridian, expressed in the specified
units.
+     * This method provides the same functionality than {@link DefaultPrimeMeridian#getGreenwichLongitude(Unit)},
+     * but on arbitrary implementation.
      *
-     * @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.
+     * @param  primeMeridian The prime meridian from which to get the Greenwich longitude.
+     * @param  unit The unit for the prime meridian to return.
+     * @return The prime meridian in the given units.
+     *
+     * @see DefaultPrimeMeridian#getGreenwichLongitude(Unit)
      */
-    public static String toWKTType(final Class<?> base, final Class<?> type)
{
-        if (type != base) {
-            final UML uml = type.getAnnotation(UML.class);
-            if (uml != null && uml.specification() == Specification.ISO_19111) {
-                String name = uml.identifier();
-                final int length = name.length() - 5; // Length without "CS_" and "CS".
-                if (length >= 1 && name.startsWith("CS_") && name.endsWith("CS"))
{
-                    final StringBuilder buffer = new StringBuilder(length).append(name, 3,
3 + length);
-                    if (!name.regionMatches(3, "Cartesian", 0, 9)) {
-                        buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0)));
-                    }
-                    name = buffer.toString();
-                    if (name.equals("time")) {
-                        name = "temporal";
-                    }
-                    return name;
-                }
-            }
-            for (final Class<?> c : type.getInterfaces()) {
-                if (base.isAssignableFrom(c)) {
-                    final String name = toWKTType(base, c);
-                    if (name != null) {
-                        return name;
-                    }
-                }
-            }
+    public static double getGreenwichLongitude(final PrimeMeridian primeMeridian, final Unit<Angle>
unit) {
+        if (primeMeridian instanceof DefaultPrimeMeridian) { // Maybe the user overrode some
methods.
+            return ((DefaultPrimeMeridian) primeMeridian).getGreenwichLongitude(unit);
+        } else {
+            return primeMeridian.getAngularUnit().getConverterTo(unit).convert(primeMeridian.getGreenwichLongitude());
         }
-        return null;
     }
 
     /**
@@ -211,43 +210,44 @@ public final class ReferencingUtilities
     }
 
     /**
-     * Returns the longitude value relative to the Greenwich Meridian, expressed in the specified
units.
-     * This method provides the same functionality than {@link DefaultPrimeMeridian#getGreenwichLongitude(Unit)},
-     * but on arbitrary implementation.
-     *
-     * @param  primeMeridian The prime meridian from which to get the Greenwich longitude.
-     * @param  unit The unit for the prime meridian to return.
-     * @return The prime meridian in the given units.
+     * Returns the WKT type of the given interface.
      *
-     * @see DefaultPrimeMeridian#getGreenwichLongitude(Unit)
-     */
-    public static double getGreenwichLongitude(final PrimeMeridian primeMeridian, final Unit<Angle>
unit) {
-        if (primeMeridian instanceof DefaultPrimeMeridian) { // Maybe the user overrode some
methods.
-            return ((DefaultPrimeMeridian) primeMeridian).getGreenwichLongitude(unit);
-        } else {
-            return primeMeridian.getAngularUnit().getConverterTo(unit).convert(primeMeridian.getGreenwichLongitude());
-        }
-    }
-
-    /**
-     * Returns {@code true} if the Greenwich longitude of the {@code actual} prime meridian
is equals to the
-     * Greenwich longitude of the {@code expected} prime meridian. The comparison is performed
in unit of the
-     * expected prime meridian.
+     * 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 expected The expected prime meridian, or {@code null}.
-     * @param actual The actual prime meridian, or {@code null}.
-     * @return {@code true} if both prime meridian have the same Greenwich longitude,
-     *         in unit of the expected prime meridian.
+     * @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 boolean isGreenwichLongitudeEquals(final PrimeMeridian expected, final
PrimeMeridian actual) {
-        if (expected == actual) {
-            return true;
-        }
-        if (expected == null || actual == null) {
-            return false;
+    public static String toWKTType(final Class<?> base, final Class<?> type)
{
+        if (type != base) {
+            final UML uml = type.getAnnotation(UML.class);
+            if (uml != null && uml.specification() == Specification.ISO_19111) {
+                String name = uml.identifier();
+                final int length = name.length() - 5; // Length without "CS_" and "CS".
+                if (length >= 1 && name.startsWith("CS_") && name.endsWith("CS"))
{
+                    final StringBuilder buffer = new StringBuilder(length).append(name, 3,
3 + length);
+                    if (!name.regionMatches(3, "Cartesian", 0, 9)) {
+                        buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0)));
+                    }
+                    name = buffer.toString();
+                    if (name.equals("time")) {
+                        name = "temporal";
+                    }
+                    return name;
+                }
+            }
+            for (final Class<?> c : type.getInterfaces()) {
+                if (base.isAssignableFrom(c)) {
+                    final String name = toWKTType(base, c);
+                    if (name != null) {
+                        return name;
+                    }
+                }
+            }
         }
-        return epsilonEqual(expected.getGreenwichLongitude(),
-                getGreenwichLongitude(actual, expected.getAngularUnit()));
+        return 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=1649761&r1=1649760&r2=1649761&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] Tue Jan  6 09:32:34 2015
@@ -46,21 +46,19 @@ public final strictfp class ReferencingU
     private static final double STRICT = 0;
 
     /**
-     * Tests {@link ReferencingUtilities#toWKTType(Class, Class)}.
+     * Tests {@link ReferencingUtilities#isGreenwichLongitudeEquals(PrimeMeridian, PrimeMeridian)}.
      */
     @Test
-    public void testType() {
-        assertNull  (               toWKTType(CoordinateSystem.class, CoordinateSystem.class));
-        assertEquals("affine",      toWKTType(CoordinateSystem.class, AffineCS        .class));
-        assertEquals("Cartesian",   toWKTType(CoordinateSystem.class, CartesianCS     .class));
-        assertEquals("cylindrical", toWKTType(CoordinateSystem.class, CylindricalCS   .class));
-        assertEquals("ellipsoidal", toWKTType(CoordinateSystem.class, EllipsoidalCS   .class));
-        assertEquals("linear",      toWKTType(CoordinateSystem.class, LinearCS        .class));
-//      assertEquals("parametric",  toWKTType(CoordinateSystem.class, ParametricCS    .class));
-        assertEquals("polar",       toWKTType(CoordinateSystem.class, PolarCS         .class));
-        assertEquals("spherical",   toWKTType(CoordinateSystem.class, SphericalCS     .class));
-        assertEquals("temporal",    toWKTType(CoordinateSystem.class, TimeCS          .class));
-        assertEquals("vertical",    toWKTType(CoordinateSystem.class, VerticalCS      .class));
+    public void testIsGreenwichLongitudeEquals() {
+        assertFalse(isGreenwichLongitudeEquals(HardCodedDatum.GREENWICH, HardCodedDatum.PARIS));
+        assertFalse(isGreenwichLongitudeEquals(HardCodedDatum.PARIS, HardCodedDatum.PARIS_RGS));
+        assertFalse(isGreenwichLongitudeEquals(HardCodedDatum.PARIS_RGS, HardCodedDatum.PARIS));
+        /*
+         * Test two prime meridians using different units (Paris in grade and Paris in degrees).
+         */
+        final PrimeMeridian pd = new DefaultPrimeMeridian(singletonMap(NAME_KEY, "Paris"),
2.33722917, NonSI.DEGREE_ANGLE);
+        assertTrue(isGreenwichLongitudeEquals(HardCodedDatum.PARIS, pd));
+        assertTrue(isGreenwichLongitudeEquals(pd, HardCodedDatum.PARIS));
     }
 
     /**
@@ -77,18 +75,20 @@ public final strictfp class ReferencingU
     }
 
     /**
-     * Tests {@link ReferencingUtilities#isGreenwichLongitudeEquals(PrimeMeridian, PrimeMeridian)}.
+     * Tests {@link ReferencingUtilities#toWKTType(Class, Class)}.
      */
     @Test
-    public void testIsGreenwichLongitudeEquals() {
-        assertFalse(isGreenwichLongitudeEquals(HardCodedDatum.GREENWICH, HardCodedDatum.PARIS));
-        assertFalse(isGreenwichLongitudeEquals(HardCodedDatum.PARIS, HardCodedDatum.PARIS_RGS));
-        assertFalse(isGreenwichLongitudeEquals(HardCodedDatum.PARIS_RGS, HardCodedDatum.PARIS));
-        /*
-         * Test two prime meridians using different units (Paris in grade and Paris in degrees).
-         */
-        final PrimeMeridian pd = new DefaultPrimeMeridian(singletonMap(NAME_KEY, "Paris"),
2.33722917, NonSI.DEGREE_ANGLE);
-        assertTrue(isGreenwichLongitudeEquals(HardCodedDatum.PARIS, pd));
-        assertTrue(isGreenwichLongitudeEquals(pd, HardCodedDatum.PARIS));
+    public void testType() {
+        assertNull  (               toWKTType(CoordinateSystem.class, CoordinateSystem.class));
+        assertEquals("affine",      toWKTType(CoordinateSystem.class, AffineCS        .class));
+        assertEquals("Cartesian",   toWKTType(CoordinateSystem.class, CartesianCS     .class));
+        assertEquals("cylindrical", toWKTType(CoordinateSystem.class, CylindricalCS   .class));
+        assertEquals("ellipsoidal", toWKTType(CoordinateSystem.class, EllipsoidalCS   .class));
+        assertEquals("linear",      toWKTType(CoordinateSystem.class, LinearCS        .class));
+//      assertEquals("parametric",  toWKTType(CoordinateSystem.class, ParametricCS    .class));
+        assertEquals("polar",       toWKTType(CoordinateSystem.class, PolarCS         .class));
+        assertEquals("spherical",   toWKTType(CoordinateSystem.class, SphericalCS     .class));
+        assertEquals("temporal",    toWKTType(CoordinateSystem.class, TimeCS          .class));
+        assertEquals("vertical",    toWKTType(CoordinateSystem.class, VerticalCS      .class));
     }
 }



Mime
View raw message