sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1677707 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing: crs/AbstractCRS.java cs/DefaultCoordinateSystemAxis.java
Date Mon, 04 May 2015 22:52:20 GMT
Author: desruisseaux
Date: Mon May  4 22:52:19 2015
New Revision: 1677707

URL: http://svn.apache.org/r1677707
Log:
Referencing: clarified usage of Formatter.getEnclosingElement(int).

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1677707&r1=1677706&r2=1677707&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
[UTF-8] Mon May  4 22:52:19 2015
@@ -474,6 +474,11 @@ public class AbstractCRS extends Abstrac
      * Returns {@code true} if the given formatter is in the process of formatting the base
CRS of a
      * {@link AbstractDerivedCRS}. In such case, the coordinate system axes shall not be
formatted.
      *
+     * <p>This method should return {@code true} when {@code this} CRS is the value
returned by
+     * {@link GeneralDerivedCRS#getBaseCRS()} (typically {@link AbstractDerivedCRS#getBaseCRS()}).
+     * Since the base CRS is the only CRS enclosed in derived CRS, we should have no ambiguity
+     * (assuming that the user did not created some weird subclass).</p>
+     *
      * <p>This method should be invoked for WKT 2 formatting only.</p>
      */
     static boolean isBaseCRS(final Formatter formatter) {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1677707&r1=1677706&r2=1677707&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Mon May  4 22:52:19 2015
@@ -742,18 +742,15 @@ public class DefaultCoordinateSystemAxis
      * Returns the enclosing coordinate system, or {@code null} if none. In ISO 19162 compliant
WKT the coordinate
      * <strong>reference</strong> system should be the first parent ({@code formatter.getEnclosingElement(1)})
and
      * the coordinate system shall be obtained from that CRS (yes, this is convolved. This
is because of historical
-     * reasons, since compatibility with WKT 1 was a requirement of WKT 2). But we nevertheless
walk over all parents
-     * in case someone format unusual things.
+     * reasons, since compatibility with WKT 1 was a requirement of WKT 2).
      */
     private static CoordinateSystem getEnclosingCS(final Formatter formatter) {
-        int depth = 1;
-        for (Object e; (e = formatter.getEnclosingElement(depth)) != null; depth++) {
-            if (e instanceof CoordinateReferenceSystem) {   // This is what we expect in
standard WKT.
-                return ((CoordinateReferenceSystem) e).getCoordinateSystem();
-            }
-            if (e instanceof CoordinateSystem) {    // In case someone formats something
unusual.
-                return (CoordinateSystem) e;
-            }
+        final FormattableObject e = formatter.getEnclosingElement(1);
+        if (e instanceof CoordinateReferenceSystem) {   // This is what we expect in standard
WKT.
+            return ((CoordinateReferenceSystem) e).getCoordinateSystem();
+        }
+        if (e instanceof CoordinateSystem) {    // Not standard WKT, but conceptually the
right thing.
+            return (CoordinateSystem) e;
         }
         return null;
     }



Mime
View raw message