sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1569282 - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-referencing/src/main/java/org/apache/sis/referencing/crs/ sis-referencing/src/main/java/org/apache/sis/referencing/datum/
Date Tue, 18 Feb 2014 11:33:27 GMT
Author: desruisseaux
Date: Tue Feb 18 11:33:26 2014
New Revision: 1569282

URL: http://svn.apache.org/r1569282
Log:
Implemented WKT 2 for ImageCRS and TemporalCRS.

Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -151,6 +151,12 @@ public enum Convention {
      *   <li>{@code Remarks} element is formatted for all
      *       {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject identified objects},
      *       not only CRS or coordinate operations.</li>
+     *   <li>Additional attributes not defined by ISO 19162 may be formatted:
+     *     <ul>
+     *       <li>{@code ImageDatum} includes the {@link org.apache.sis.referencing.datum.DefaultImageDatum#getPixelInCell()
Pixel in Cell} code.</li>
+     *       <li>{@code TemporalDatum} includes the {@link org.apache.sis.referencing.datum.DefaultTemporalDatum#getOrigin()
Origin} date.</li>
+     *     </ul>
+     *   </li>
      * </ul>
      *
      * This convention is used only for debugging purpose.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -27,6 +27,7 @@ import org.opengis.referencing.cs.Cartes
 import org.opengis.referencing.datum.ImageDatum;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
@@ -250,4 +251,22 @@ public class DefaultImageCRS extends Abs
     final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem
cs) {
         return new DefaultImageCRS(properties, datum, (AffineCS) cs);
     }
+
+    /**
+     * Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a>
element.
+     * {@code ImageCRS} are defined in the WKT 2 specification only.
+     *
+     * @param  formatter The formatter to use.
+     * @return The name of the WKT element type, which is {@code "ImageCRS"}.
+     */
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        /*
+         * Note: super.formatTo(formatter) will usually format a DefaultImageDatum instance,
+         * which will declare this WKT has invalid if the formatter convention is a WKT 1
one.
+         * So we do not redo this check here.
+         */
+        super.formatTo(formatter);
+        return "ImageCRS";
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -29,6 +29,7 @@ import org.opengis.referencing.crs.Tempo
 import org.opengis.referencing.datum.TemporalDatum;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.measure.Units;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -293,4 +294,22 @@ public class DefaultTemporalCRS extends 
         }
         return toMillis.inverse().convert(time.getTime() - origin);
     }
+
+    /**
+     * Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a>
element.
+     * {@code TimeCRS} are defined in the WKT 2 specification only.
+     *
+     * @param  formatter The formatter to use.
+     * @return The name of the WKT element type, which is {@code "TimeCRS"}.
+     */
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        /*
+         * Note: super.formatTo(formatter) will usually format a DefaultTemporalDatum instance,
+         * which will declare this WKT has invalid if the formatter convention is a WKT 1
one.
+         * So we do not redo this check here.
+         */
+        super.formatTo(formatter);
+        return "TimeCRS";
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -29,7 +29,6 @@ import org.opengis.referencing.datum.Dat
 import org.opengis.referencing.ReferenceIdentifier;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.internal.metadata.MetadataUtilities;
@@ -334,16 +333,6 @@ public class AbstractDatum extends Abstr
     }
 
     /**
-     * Gets the type of the datum as an enumerated code. Datum type was provided for all
kind of datum
-     * in the legacy OGC 01-009 specification. Datum types became provided only for vertical
datum in
-     * the ISO 19111:2003 specification, then removed completely in the ISO 19111:2007 revision.
-     * We keep this method around only for WKT 1 formatting.
-     */
-    int getLegacyDatumType() {
-        return 0;
-    }
-
-    /**
      * Returns {@code true} if either the {@linkplain #getName() primary name} or at least
      * one {@linkplain #getAlias() alias} matches the given string according heuristic rules.
      * This method performs the comparison documented in the
@@ -435,19 +424,4 @@ public class AbstractDatum extends Abstr
     protected long computeHashCode() {
         return super.computeHashCode() + Objects.hash(anchorDefinition, realizationEpoch,
domainOfValidity, scope);
     }
-
-    /**
-     * Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a>
element.
-     *
-     * @param  formatter The formatter to use.
-     * @return The WKT element name.
-     */
-    @Override
-    protected String formatTo(final Formatter formatter) {
-        final String keyword = super.formatTo(formatter);
-        if (formatter.getConvention().versionOfWKT() == 1) {
-            formatter.append(getLegacyDatumType());
-        }
-        return keyword;
-    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -172,6 +172,16 @@ public class DefaultEngineeringDatum ext
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
-        return (formatter.getConvention().versionOfWKT() == 1) ? "Local_Datum" : "EngineeringDatum";
+        if (formatter.getConvention().versionOfWKT() == 1) {
+            /*
+             * Datum type was provided for all kind of datum in the legacy OGC 01-009 specification.
+             * Datum types became provided only for vertical datum in the ISO 19111:2003
specification,
+             * then removed completely in the ISO 19111:2007 revision. We are supposed to
format them
+             * in WKT 1, but do not have any indication about what the values should be.
+             */
+            formatter.append(0);
+            return "Local_Datum";
+        }
+        return "EngineeringDatum";
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -34,13 +34,11 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException;
 import org.apache.sis.metadata.iso.extent.Extents;
 import org.apache.sis.internal.referencing.ExtentSelector;
-import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.FormattableObject;
-import org.apache.sis.io.wkt.ElementKind;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -506,13 +504,15 @@ public class DefaultGeodeticDatum extend
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        // Do NOT invokes the super-class method, because
-        // horizontal datum do not write the datum type.
-        WKTUtilities.appendName(this, formatter, ElementKind.DATUM);
+        super.formatTo(formatter);
         formatter.newLine();
         formatter.append(ellipsoid instanceof FormattableObject ? (FormattableObject) ellipsoid
:
                          DefaultEllipsoid.castOrCopy(ellipsoid));
         if (formatter.getConvention().versionOfWKT() == 1) {
+            /*
+             * Note that at the different of other datum (in particular vertical datum),
+             * WKT of geodetic datum do not have a numerical code for the datum type.
+             */
             if (bursaWolf != null) {
                 for (final BursaWolfParameters candidate : bursaWolf) {
                     if (candidate.isToWGS84()) {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -26,6 +26,7 @@ import org.opengis.referencing.Reference
 import org.opengis.referencing.datum.ImageDatum;
 import org.opengis.referencing.datum.PixelInCell;
 import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.util.ComparisonMode;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -234,13 +235,17 @@ public class DefaultImageDatum extends A
      * {@code ImageDatum} are defined in the WKT 2 specification only.
      *
      * @param  formatter The formatter to use.
-     * @return The WKT element name.
+     * @return The WKT element name, which is {@code "ImageDatum"}.
      */
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
-        formatter.append(pixelInCell);
-        formatter.setInvalidWKT(this, null);
-        return "GenDatum"; // Generic datum (WKT 2)
+        final Convention convention = formatter.getConvention();
+        if (convention == Convention.INTERNAL) {
+            formatter.append(pixelInCell); // This is an extension compared to ISO 19162.
+        } else if (convention.versionOfWKT() == 1) {
+            formatter.setInvalidWKT(this, null);
+        }
+        return "ImageDatum";
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
(original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
Tue Feb 18 11:33:26 2014
@@ -29,6 +29,8 @@ import org.opengis.referencing.datum.Tem
 import org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter;
 import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
@@ -271,4 +273,23 @@ public class DefaultTemporalDatum extend
     protected long computeHashCode() {
         return super.computeHashCode() + origin;
     }
+
+    /**
+     * Format the inner part of a <cite>Well Known Text</cite> (WKT) element.
+     * {@code TimeDatum} are defined in the WKT 2 specification only.
+     *
+     * @param  formatter The formatter to use.
+     * @return The WKT element name, which is {@code "TimeDatum"}.
+     */
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        super.formatTo(formatter);
+        final Convention convention = formatter.getConvention();
+        if (convention == Convention.INTERNAL) {
+            formatter.append(MetadataUtilities.toDate(origin)); // This is an extension compared
to ISO 19162.
+        } else if (convention.versionOfWKT() == 1) {
+            formatter.setInvalidWKT(this, null);
+        }
+        return "TimeDatum";
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1569282&r1=1569281&r2=1569282&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
[UTF-8] Tue Feb 18 11:33:26 2014
@@ -247,18 +247,6 @@ public class DefaultVerticalDatum extend
     }
 
     /**
-     * Gets the type of the datum as an enumerated code. Datum type was provided for all
kind of datum
-     * in the legacy OGC 01-009 specification. Datum type became provided only for vertical
datum in
-     * the ISO 19111:2003 specification, then removed completely in ISO 19111:2007.
-     *
-     * @see #getVerticalDatumType()
-     */
-    @Override
-    final int getLegacyDatumType() {
-        return VerticalDatumTypes.toLegacy(getVerticalDatumType().ordinal());
-    }
-
-    /**
      * Returns the type to be marshalled to XML.
      * This element was present in GML 3.0 and 3.1, but has been removed from GML 3.2.
      *
@@ -320,12 +308,21 @@ public class DefaultVerticalDatum extend
     /**
      * Formats the inner part of a <cite>Well Known Text</cite> (WKT) element.
      *
+     * {@note OGC 01-009 defined numerical codes for various vertical datum types, for example
2005 for geoidal height
+     *        and 2002 for ellipsoidal height. Such codes were formatted for all <code>Datum</code>
subtypes in WKT 1.
+     *        Datum types became provided only for vertical datum in the ISO 19111:2003 specification,
then removed
+     *        completely in ISO 19111:2007.}
+     *
      * @param  formatter The formatter to use.
      * @return The WKT element name, which is {@code "VerticalDatum"} (WKT 2) or {@code "Vert_Datum"}
(WKT 1).
      */
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
-        return (formatter.getConvention().versionOfWKT() == 1) ? "Vert_Datum" : "VerticalDatum";
+        if (formatter.getConvention().versionOfWKT() == 1) {
+            formatter.append(VerticalDatumTypes.toLegacy(type().ordinal()));
+            return "Vert_Datum";
+        }
+        return "VerticalDatum";
     }
 }



Mime
View raw message