sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1626637 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-referencing/src/main/java/org/apache/sis/referencing/datum/ sis-referencing/src/test/java/o...
Date Sun, 21 Sep 2014 21:31:13 GMT
Author: desruisseaux
Date: Sun Sep 21 21:31:12 2014
New Revision: 1626637

URL: http://svn.apache.org/r1626637
Log:
Add 'TimeOrigin' element in temporal datum WKT.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1626637&r1=1626636&r2=1626637&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
[UTF-8] Sun Sep 21 21:31:12 2014
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Locale;
+import java.util.TimeZone;
 import java.util.Date;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
@@ -318,6 +319,7 @@ public class Formatter implements Locali
         this.dateFormat    = new SimpleDateFormat(WKTFormat.DATE_PATTERN, symbols.getLocale());
         this.unitFormat    = UnitFormat.getInstance(symbols.getLocale());
         this.buffer        = new StringBuffer();
+        dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1626637&r1=1626636&r2=1626637&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] Sun Sep 21 21:31:12 2014
@@ -103,7 +103,7 @@ public class WKTFormat extends CompoundF
      *
      * @see #createFormat(Class)
      */
-    static final String DATE_PATTERN = "yyyy-MM-dd";
+    static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SX";
 
     /**
      * The symbols to use for this formatter.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1626637&r1=1626636&r2=1626637&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Sun Sep 21 21:31:12 2014
@@ -619,10 +619,10 @@ public class ImmutableIdentifier extends
      * The {@code CITATION[…]} element inside an {@code ID[…]}.
      */
     private static final class Cite extends FormattableObject {
-        /** The component of the citation to format. */
+        /** The value of the citation to format. */
         private final String identifier;
 
-        /** Creates a new citation with the given component. */
+        /** Creates a new citation with the given value. */
         Cite(final String identifier) {
             this.identifier = identifier;
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1626637&r1=1626636&r2=1626637&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
(original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
Sun Sep 21 21:31:12 2014
@@ -31,6 +31,7 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.FormattableObject;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
@@ -72,7 +73,7 @@ import java.util.Objects;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-1.2)
- * @version 0.4
+ * @version 0.5
  * @module
  *
  * @see org.apache.sis.referencing.CommonCRS.Temporal#datum()
@@ -288,11 +289,30 @@ public class DefaultTemporalDatum extend
     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.majorVersion() == 1) {
+        formatter.append(new Origin(MetadataUtilities.toDate(origin)));
+        if (convention.majorVersion() == 1) {
             formatter.setInvalidWKT(this, null);
         }
         return "TimeDatum";
     }
+
+    /**
+     * The {@code TIMEORIGIN[…]} element inside an {@code TDATUM[…]}.
+     */
+    private static final class Origin extends FormattableObject {
+        /** The value of the origin to format. */
+        private final Date origin;
+
+        /** Creates a new time origin with the given value. */
+        Origin(final Date origin) {
+            this.origin = origin;
+        }
+
+        /** Formats the time origin. */
+        @Override
+        protected String formatTo(final Formatter formatter) {
+            formatter.append(origin);
+            return "TimeOrigin";
+        }
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java?rev=1626637&r1=1626636&r2=1626637&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
[UTF-8] Sun Sep 21 21:31:12 2014
@@ -162,7 +162,7 @@ public final strictfp class DefaultCompo
                 "    UNIT[“metre”, 1],\n" +
                 "    AXIS[“Gravity-related height”, UP]],\n" +
                 "  TIMECRS[“Time”,\n" +
-                "    TIMEDATUM[“UNIX”],\n" +
+                "    TIMEDATUM[“UNIX”, TIMEORIGIN[1970-01-01T00:00:00.0Z]],\n" +
                 "    UNIT[“day”, 86400],\n" +
                 "    AXIS[“Time”, FUTURE]]]",
                 HardCodedCRS.GEOID_4D);
@@ -190,7 +190,7 @@ public final strictfp class DefaultCompo
                 "      Axis[“Gravity-related height (H)”, up],\n" +
                 "      LengthUnit[“metre”, 1]],\n" +
                 "  TimeCRS[“Time”,\n" +
-                "    TimeDatum[“UNIX”],\n" +
+                "    TimeDatum[“UNIX”, TimeOrigin[1970-01-01T00:00:00.0Z]],\n" +
                 "    CS[“temporal”, 1],\n" +
                 "      Axis[“Time (t)”, future],\n" +
                 "      TimeUnit[“day”, 86400]],\n" +

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java?rev=1626637&r1=1626636&r2=1626637&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java
[UTF-8] Sun Sep 21 21:31:12 2014
@@ -20,6 +20,7 @@ import java.util.Date;
 import java.util.Map;
 import java.util.HashMap;
 import javax.xml.bind.JAXBException;
+import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.metadata.iso.citation.HardCodedCitations;
 import org.apache.sis.test.XMLTestCase;
@@ -34,7 +35,7 @@ import static org.apache.sis.test.TestUt
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final strictfp class DefaultTemporalDatumTest extends XMLTestCase {
@@ -49,12 +50,9 @@ public final strictfp class DefaultTempo
     private static final long ORIGIN = -40587 * (24*60*60*1000L);
 
     /**
-     * Tests XML marshalling.
-     *
-     * @throws JAXBException If an error occurred during marshalling.
+     * Creates the temporal datum to use for testing purpose.
      */
-    @Test
-    public void testMarshalling() throws JAXBException {
+    private static DefaultTemporalDatum create() {
         final Map<String,Object> properties = new HashMap<>(4);
         assertNull(properties.put(DefaultTemporalDatum.IDENTIFIERS_KEY,
                 new ImmutableIdentifier(HardCodedCitations.SIS, "SIS", "MJ")));
@@ -62,8 +60,28 @@ public final strictfp class DefaultTempo
         assertNull(properties.put(DefaultTemporalDatum.SCOPE_KEY, "History."));
         assertNull(properties.put(DefaultTemporalDatum.REMARKS_KEY,
                 "Time measured as days since November 17, 1858 at 00:00 UTC."));
+        return new DefaultTemporalDatum(properties, new Date(ORIGIN));
+    }
 
-        final DefaultTemporalDatum datum = new DefaultTemporalDatum(properties, new Date(ORIGIN));
+    /**
+     * Tests {@link DefaultTemporalDatum#toWKT()}.
+     *
+     * @since 0.5
+     */
+    @Test
+    public void testToWKT() {
+        final DefaultTemporalDatum datum = create();
+        assertWktEquals(Convention.WKT2, "TimeDatum[“Modified Julian”, TimeOrigin[1858-11-17T00:00:00.0Z],
Id[“SIS”, “MJ”]]", datum);
+    }
+
+    /**
+     * Tests XML marshalling.
+     *
+     * @throws JAXBException If an error occurred during marshalling.
+     */
+    @Test
+    public void testMarshalling() throws JAXBException {
+        final DefaultTemporalDatum datum = create();
         assertMarshalEqualsFile(XML_FILE, datum, "xlmns:*", "xsi:schemaLocation");
     }
 



Mime
View raw message