sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1684115 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-referencing/src/main/java/org/apache/sis/internal/referencing/ sis-referencing/src/test/java/org/apache/sis/internal/referencing/ sis-ut...
Date Mon, 08 Jun 2015 07:58:10 GMT
Author: desruisseaux
Date: Mon Jun  8 07:58:09 2015
New Revision: 1684115

URL: http://svn.apache.org/r1684115
Log:
WKT parsing: fix a bug in the handling of abbreviation of "South-South-East" and similar axis
directions.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1684115&r1=1684114&r2=1684115&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Mon Jun  8 07:58:09 2015
@@ -382,7 +382,7 @@ public class ReferencingServices extends
     /**
      * Suggests an abbreviation for the given axis direction. The unit of measurement may
be used
      * for resolving some ambiguities like whether {@link AxisDirection#EAST} is for "x"
(Easting)
-     * or "λ" (Longitude). The axis name is used only in last resort.
+     * or "λ" (Longitude).
      *
      * @param name      The axis name for which to suggest an abbreviation.
      * @param direction The axis direction for which to suggest an abbreviation.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java?rev=1684115&r1=1684114&r2=1684115&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
[UTF-8] Mon Jun  8 07:58:09 2015
@@ -527,7 +527,7 @@ public final class AxisDirections extend
     /**
      * Suggests an abbreviation for the given axis direction. The unit of measurement may
be used
      * for resolving some ambiguities like whether {@link AxisDirection#EAST} is for "x"
(Easting)
-     * or "λ" (Longitude). The axis name is used only in last resort.
+     * or "λ" (Longitude).
      *
      * @param name      The axis name for which to suggest an abbreviation.
      * @param direction The axis direction for which to suggest an abbreviation.
@@ -537,6 +537,9 @@ public final class AxisDirections extend
      * @since 0.6
      */
     public static String suggestAbbreviation(final String name, final AxisDirection direction,
final Unit<?> unit) {
+        if (name.length() == 1) {
+            return name;  // Most common cases are "x", "y", "z", "t", "i" and "j".
+        }
         if (isCompass(direction)) {
             /*
              * NORTH, EAST, SOUTH, WEST and all intercardinal directions (SOUTH_SOUTH_WEST,
etc.):

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java?rev=1684115&r1=1684114&r2=1684115&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] Mon Jun  8 07:58:09 2015
@@ -539,7 +539,7 @@ public final class ServicesForMetadata e
     /**
      * Suggests an abbreviation for the given axis direction. The unit of measurement may
be used
      * for resolving some ambiguities like whether {@link AxisDirection#EAST} is for "x"
(Easting)
-     * or "λ" (Longitude). The axis name is used only in last resort.
+     * or "λ" (Longitude).
      *
      * @param name      The axis name for which to suggest an abbreviation.
      * @param direction The axis direction for which to suggest an abbreviation.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java?rev=1684115&r1=1684114&r2=1684115&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
[UTF-8] Mon Jun  8 07:58:09 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.referencing;
 
+import java.lang.reflect.Field;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import javax.measure.unit.Unit;
@@ -370,6 +371,7 @@ public final strictfp class AxisDirectio
      */
     @Test
     public void testSuggestAbbreviation() {
+        assertEquals("x",   AxisDirections.suggestAbbreviation("x",                     
EAST,             SI.METRE));
         assertEquals("λ",   AxisDirections.suggestAbbreviation("Geodetic longitude",   
 EAST,          NonSI.DEGREE_ANGLE));
         assertEquals("φ",   AxisDirections.suggestAbbreviation("Geodetic latitude",    
 NORTH,         NonSI.DEGREE_ANGLE));
         assertEquals("θ",   AxisDirections.suggestAbbreviation("Spherical longitude",  
 EAST,          NonSI.DEGREE_ANGLE));
@@ -394,7 +396,31 @@ public final strictfp class AxisDirectio
         assertEquals("NW",  AxisDirections.suggestAbbreviation("not needed",            
NORTH_WEST,       SI.METRE));
         assertEquals("SE",  AxisDirections.suggestAbbreviation("not needed",            
SOUTH_EAST,       SI.METRE));
         assertEquals("SW",  AxisDirections.suggestAbbreviation("not needed",            
SOUTH_WEST,       SI.METRE));
-//      assertEquals("SSE", AxisDirections.suggestAbbreviation("not needed",            
SOUTH_SOUTH_EAST, SI.METRE));
+        assertEquals("SSE", AxisDirections.suggestAbbreviation("not needed",            
SOUTH_SOUTH_EAST, SI.METRE));
+        assertEquals("NNW", AxisDirections.suggestAbbreviation("not needed",            
NORTH_NORTH_WEST, SI.METRE));
+        assertEquals("ENE", AxisDirections.suggestAbbreviation("not needed",            
EAST_NORTH_EAST,  SI.METRE));
+    }
+
+    /**
+     * Verifies that the abbreviations used in {@link HardCodedAxes} constants are consistent
with the abbreviations
+     * suggested by {@link AxisDirections#suggestAbbreviation(String, AxisDirection, Unit)}.
 Note that a failure in
+     * this verification does not necessarily means that the {@code suggestAbbreviation(…)}.
It could also be the
+     * hard-coded constant which need a revision, or we may decide that the different abbreviations
are intended and
+     * should not be compared.
+     *
+     * @throws IllegalAccessException should never happen since we inspect only for public
fields.
+     *
+     * @since 0.6
+     */
+    @Test
+    public void verifyAbbreviationConsistency() throws IllegalAccessException {
+        for (final Field field : HardCodedAxes.class.getFields()) {
+            if (CoordinateSystemAxis.class.isAssignableFrom(field.getType())) {
+                final CoordinateSystemAxis axis = (CoordinateSystemAxis) field.get(null);
+                assertEquals(field.getName(), axis.getAbbreviation(), AxisDirections.suggestAbbreviation(
+                        axis.getName().getCode(), axis.getDirection(), axis.getUnit()));
+            }
+        }
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1684115&r1=1684114&r2=1684115&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
[UTF-8] Mon Jun  8 07:58:09 2015
@@ -1351,8 +1351,8 @@ searchWordBreak:    while (true) {
                     wantChar = true;
                 } else if (Character.isUpperCase(c)) {
                     // Test for mixed-case (e.g. "northEast").
-                    // Note that the buffer is guaranteed to contain at least 1 character.
-                    if (isLowerCase(buffer.codePointBefore(buffer.length()))) {
+                    // Note that i is guaranteed to be greater than 0 here.
+                    if (!Character.isUpperCase(Character.codePointBefore(text, i))) {
                         buffer.appendCodePoint(c);
                     }
                 }

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1684115&r1=1684114&r2=1684115&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
[UTF-8] Mon Jun  8 07:58:09 2015
@@ -318,6 +318,7 @@ public final strictfp class CharSequence
         assertEquals("NE",  camelCaseToAcronym("North-East").toString());
         assertEquals("NE",  camelCaseToAcronym("NORTH_EAST").toString());
         assertEquals("NE",  camelCaseToAcronym("northEast").toString());
+        assertEquals("SSE", camelCaseToAcronym("southSouthEast").toString());
         assertNull(camelCaseToAcronym(null));
     }
 



Mime
View raw message