sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1570682 - in /sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs: DefaultGeocentricCRS.java DefaultGeodeticCRS.java DefaultGeographicCRS.java
Date Fri, 21 Feb 2014 19:43:20 GMT
Author: desruisseaux
Date: Fri Feb 21 19:43:19 2014
New Revision: 1570682

URL: http://svn.apache.org/r1570682
Log:
Choice of WKT 1 keyword needs to be performed by GeodeticCRS, not by subclasses.

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java?rev=1570682&r1=1570681&r2=1570682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
[UTF-8] Fri Feb 21 19:43:19 2014
@@ -255,10 +255,6 @@ public class DefaultGeocentricCRS extend
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        String keyword = super.formatTo(formatter);
-        if (keyword == null) {
-            keyword = "GeocCS"; // WKT 1
-        }
-        return keyword;
+        return super.formatTo(formatter);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java?rev=1570682&r1=1570681&r2=1570682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
[UTF-8] Fri Feb 21 19:43:19 2014
@@ -165,9 +165,8 @@ class DefaultGeodeticCRS extends Abstrac
 
     /**
      * Formats this CRS as a <cite>Well Known Text</cite> {@code GeodeticCRS[…]}
element.
-     * It is subclasses responsibility to overwrite this method for returning the proper
keyword in WKT 1 case.
      *
-     * @return {@code "GeodeticCRS"} (WKT 2) or {@code null} (WKT 1).
+     * @return {@code "GeodeticCRS"} (WKT 2) or {@code "GeogCS"}/{@code "GeocCS"} (WKT 1).
      */
     @Override
     protected String formatTo(final Formatter formatter) {
@@ -218,6 +217,16 @@ class DefaultGeodeticCRS extends Abstrac
         formatter.removeContextualUnit(unit);
         formatter.addContextualUnit(oldUnit);
         formatter.newLine(); // For writing the ID[…] element on its own line.
-        return isWKT1 ? null : "GeodeticCRS";
+        if (!isWKT1) {
+            return "GeodeticCRS";
+        }
+        /*
+         * For WKT1, the keyword depends on the subclass: "GeogCS" for GeographicCRS,
+         * or 'GeocCS" for GeocentricCRS. However we can not rely on the subclass for
+         * choosing the keyword, because in some situations (after XML unmarhaling)
+         * we only have a GeodeticCRS. We need to make the choice here. The CS type
+         * is a sufficient criterion.
+         */
+        return (cs instanceof EllipsoidalCS) ? "GeogCS" : "GeocCS";
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1570682&r1=1570681&r2=1570682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
[UTF-8] Fri Feb 21 19:43:19 2014
@@ -239,10 +239,6 @@ public class DefaultGeographicCRS extend
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        String keyword = super.formatTo(formatter);
-        if (keyword == null) {
-            keyword = "GeogCS"; // WKT 1
-        }
-        return keyword;
+        return super.formatTo(formatter);
     }
 }



Mime
View raw message