This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 458bb5e893 Remove dependency to `org.opengis.temporal.Instant`,
replaced by `java.time.Instant`.
https://github.com/opengeospatial/geoapi/issues/79
458bb5e893 is described below
commit 458bb5e893f1aef0cd86ef37d7770f1dc1fe715b
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Wed May 8 13:54:32 2024 +0200
Remove dependency to `org.opengis.temporal.Instant`, replaced by
`java.time.Instant`.
https://github.com/opengeospatial/geoapi/issues/79
---
.../main/org/apache/sis/filter/TemporalFilter.java | 94 +++++-----------------
.../test/org/apache/sis/filter/PeriodLiteral.java | 21 +----
.../metadata/iso/extent/DefaultTemporalExtent.java | 27 +++----
.../metadata/iso/lineage/DefaultProcessStep.java | 3 +-
.../sis/metadata/privy/TemporalUtilities.java | 74 ++++++++---------
.../org/apache/sis/xml/bind/gml/TM_Primitive.java | 7 +-
.../org/apache/sis/xml/bind/gml/TimeInstant.java | 21 +++--
.../apache/sis/xml/bind/gml/TimePeriodBound.java | 2 +-
.../apache/sis/xml/bind/gml/TimePeriodTest.java | 26 +++---
.../sis/storage/geotiff/reader/XMLMetadata.java | 3 +-
.../apache/sis/storage/netcdf/base/CRSBuilder.java | 4 +-
.../apache/sis/storage/base/MetadataBuilder.java | 16 ++++
.../sis/pending/temporal/DefaultInstant.java | 65 ---------------
.../apache/sis/pending/temporal/DefaultPeriod.java | 2 +-
.../pending/temporal/DefaultTemporalFactory.java | 7 +-
geoapi/snapshot | 2 +-
16 files changed, 117 insertions(+), 257 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
index a9d6d8c8a1..f6e567be64 100644
---
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
+++
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
@@ -16,7 +16,6 @@
*/
package org.apache.sis.filter;
-import java.util.Date;
import java.time.Instant;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
@@ -63,81 +62,28 @@ abstract class TemporalFilter<T> extends
BinaryFunction<T,Object,Object>
super(expression1, expression2);
}
- /**
- * Converts a GeoAPI instant to a Java instant. This is a temporary method
- * to be removed after we revisited {@link org.opengis.temporal} package.
- *
- * @param instant the GeoAPI instant, or {@code null}.
- * @return the Java instant, or {@code null}.
- */
- private static Instant toInstant(final org.opengis.temporal.Instant
instant) {
- if (instant != null) {
- final Date t = instant.getDate();
- if (t != null) {
- return t.toInstant();
- }
- }
- return null;
- }
-
/**
* Returns {@code true} if {@code self} is non null and before {@code
other}.
* This is an helper function for {@code evaluate(…)} methods
implementations.
*/
- private static boolean isBefore(final org.opengis.temporal.Instant self,
final Instant other) {
- final Instant t = toInstant(self);
- return (t != null) && t.isBefore(other);
+ private static boolean isBefore(final Instant self, final Instant other) {
+ return (self != null) && (other != null) && self.isBefore(other);
}
/**
* Returns {@code true} if {@code self} is non null and after {@code
other}.
* This is an helper function for {@code evaluate(…)} methods
implementations.
*/
- private static boolean isAfter(final org.opengis.temporal.Instant self,
final Instant other) {
- final Instant t = toInstant(self);
- return (t != null) && t.isAfter(other);
+ private static boolean isAfter(final Instant self, final Instant other) {
+ return (self != null) && (other != null) && self.isAfter(other);
}
/**
* Returns {@code true} if {@code self} is non null and equal to {@code
other}.
* This is an helper function for {@code evaluate(…)} methods
implementations.
*/
- private static boolean isEqual(final org.opengis.temporal.Instant self,
final Instant other) {
- final Instant t = toInstant(self);
- return (t != null) && t.equals(other);
- }
-
- /**
- * Returns {@code true} if {@code self} is non null and before {@code
other}.
- * This is an helper function for {@code evaluate(…)} methods
implementations.
- */
- private static boolean isBefore(final org.opengis.temporal.Instant self,
- final org.opengis.temporal.Instant other)
- {
- final Instant t, o;
- return ((t = toInstant(self)) != null) && ((o = toInstant(other)) !=
null) && t.isBefore(o);
- }
-
- /**
- * Returns {@code true} if {@code self} is non null and after {@code
other}.
- * This is an helper function for {@code evaluate(…)} methods
implementations.
- */
- private static boolean isAfter(final org.opengis.temporal.Instant self,
- final org.opengis.temporal.Instant other)
- {
- final Instant t, o;
- return ((t = toInstant(self)) != null) && ((o = toInstant(other)) !=
null) && t.isAfter(o);
- }
-
- /**
- * Returns {@code true} if {@code self} is non null and equal to {@code
other}.
- * This is an helper function for {@code evaluate(…)} methods
implementations.
- */
- private static boolean isEqual(final org.opengis.temporal.Instant self,
- final org.opengis.temporal.Instant other)
- {
- final Instant t = toInstant(self);
- return (t != null) && t.equals(toInstant(other));
+ private static boolean isEqual(final Instant self, final Instant other) {
+ return (self != null) && self.equals(other);
}
/**
@@ -735,11 +681,11 @@ abstract class TemporalFilter<T> extends
BinaryFunction<T,Object,Object>
/** Condition defined by ISO 19108:2006 (corrigendum) §5.2.3.5. */
@Override public boolean evaluate(final Period self, final Period
other) {
- final Instant selfEnd, otherBegin;
- return ((selfEnd = toInstant(self .getEnding())) != null) &&
- ((otherBegin = toInstant(other.getBeginning())) != null) &&
selfEnd.isAfter(otherBegin) &&
- isBefore(self.getBeginning(), otherBegin) &&
- isAfter(other.getEnding(), selfEnd);
+ final Instant selfBegin, selfEnd, otherBegin, otherEnd;
+ return ((otherBegin = other.getBeginning()) != null) &&
+ ((selfBegin = self .getBeginning()) != null) &&
selfBegin.isBefore(otherBegin) &&
+ ((selfEnd = self .getEnding()) != null) && selfEnd
.isAfter (otherBegin) &&
+ ((otherEnd = other.getEnding()) != null) && otherEnd
.isAfter (selfEnd);
}
}
@@ -775,11 +721,11 @@ abstract class TemporalFilter<T> extends
BinaryFunction<T,Object,Object>
/** Condition defined by ISO 19108:2006 (corrigendum) §5.2.3.5. */
@Override public boolean evaluate(final Period self, final Period
other) {
- final Instant selfBegin, otherEnd;
- return ((selfBegin = toInstant(self .getBeginning())) != null) &&
- ((otherEnd = toInstant(other.getEnding())) != null) &&
selfBegin.isBefore(otherEnd) &&
- isBefore(other.getBeginning(), selfBegin) &&
- isAfter (self .getEnding(), otherEnd);
+ final Instant selfBegin, selfEnd, otherBegin, otherEnd;
+ return ((selfBegin = self .getBeginning()) != null) &&
+ ((otherBegin = other.getBeginning()) != null) &&
otherBegin.isBefore(selfBegin) &&
+ ((otherEnd = other.getEnding()) != null) && selfBegin
.isBefore(otherEnd) &&
+ ((selfEnd = self .getEnding()) != null) && selfEnd
.isAfter (otherEnd);
}
}
@@ -814,10 +760,10 @@ abstract class TemporalFilter<T> extends
BinaryFunction<T,Object,Object>
/** Condition defined by OGC filter specification. */
@Override public boolean evaluate(final Period self, final Period
other) {
final Instant selfBegin, selfEnd, otherBegin, otherEnd;
- return ((selfBegin = toInstant(self .getBeginning())) != null) &&
- ((otherEnd = toInstant(other.getEnding())) != null) &&
selfBegin.isBefore(otherEnd) &&
- ((selfEnd = toInstant(self .getEnding())) != null) &&
- ((otherBegin = toInstant(other.getBeginning())) != null) &&
selfEnd.isAfter(otherBegin);
+ return ((selfBegin = self .getBeginning()) != null) &&
+ ((otherEnd = other.getEnding()) != null) &&
selfBegin.isBefore(otherEnd) &&
+ ((selfEnd = self .getEnding()) != null) &&
+ ((otherBegin = other.getBeginning()) != null) &&
selfEnd.isAfter(otherBegin);
}
}
}
diff --git
a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java
b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java
index 3afd405583..e9738893d7 100644
---
a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java
+++
b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java
@@ -28,11 +28,11 @@ import org.opengis.filter.Expression;
import org.opengis.filter.Literal;
import org.opengis.temporal.Period;
import org.opengis.temporal.RelativePosition;
-import org.opengis.temporal.TemporalPosition;
import org.opengis.temporal.TemporalPrimitive;
import org.opengis.temporal.TemporalGeometricPrimitive;
// Specific to the geoapi-4.0 branch:
+import java.time.Instant;
import java.time.temporal.TemporalAmount;
import org.opengis.metadata.Identifier;
@@ -62,23 +62,8 @@ final class PeriodLiteral implements Period,
Literal<Feature,Period>, Serializab
@Override public Period getValue() {return this;}
/** Returns a bound of this period. */
- @Override public org.opengis.temporal.Instant getBeginning() {return
instant(begin);}
- @Override public org.opengis.temporal.Instant getEnding() {return
instant(end);}
-
- /** Wraps the value that defines a period. */
- private static org.opengis.temporal.Instant instant(final long t) {
- return new org.opengis.temporal.Instant() {
- @Override public Date getDate() {return new Date(t);}
- @Override public String toString() {return "Instant[" +
TestUtilities.format(getDate()) + '[';}
-
- /** Not needed for the tests. */
- @Override public Identifier getName()
{throw new UnsupportedOperationException();}
- @Override public TemporalPosition getTemporalPosition()
{throw new UnsupportedOperationException();}
- @Override public RelativePosition
relativePosition(TemporalPrimitive o) {throw new
UnsupportedOperationException();}
- @Override public TemporalAmount
distance(TemporalGeometricPrimitive o) {throw new
UnsupportedOperationException();}
- @Override public TemporalAmount length()
{throw new UnsupportedOperationException();}
- };
- }
+ @Override public Instant getBeginning() {return
Instant.ofEpochMilli(begin);}
+ @Override public Instant getEnding() {return Instant.ofEpochMilli(end);}
/** Not needed for the tests. */
@Override public Identifier getName()
{throw new UnsupportedOperationException();}
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
index f9b20ae538..cd5dd14d9a 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
@@ -33,8 +33,8 @@ import org.apache.sis.xml.NilObject;
import org.apache.sis.xml.NilReason;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
+import java.time.Instant;
import org.opengis.temporal.Period;
-import org.opengis.temporal.Instant;
/**
@@ -64,7 +64,7 @@ import org.opengis.temporal.Instant;
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
- * @version 1.4
+ * @version 1.5
* @since 0.3
*/
@XmlType(name = "EX_TemporalExtent_Type")
@@ -168,15 +168,14 @@ public class DefaultTemporalExtent extends ISOMetadata
implements TemporalExtent
* @return the requested time as a Java date, or {@code null} if none.
*/
static Date getTime(final TemporalPrimitive extent, final boolean begin) {
- final Instant instant;
- if (extent instanceof Instant) {
- instant = (Instant) extent;
- } else if (extent instanceof Period) {
- instant = begin ? ((Period) extent).getBeginning() : ((Period)
extent).getEnding();
- } else {
- return null;
+ if (extent instanceof Period) {
+ var p = (Period) extent;
+ Instant time = begin ? p.getBeginning() : p.getEnding();
+ if (time != null) {
+ return Date.from(time);
+ }
}
- return instant.getDate();
+ return null;
}
/**
@@ -209,13 +208,7 @@ public class DefaultTemporalExtent extends ISOMetadata
implements TemporalExtent
public void setBounds(final Date startTime, final Date endTime) throws
UnsupportedOperationException {
TemporalPrimitive value = null;
if (startTime != null || endTime != null) {
- if (endTime == null || endTime.equals(startTime)) {
- value = TemporalUtilities.createInstant(startTime);
- } else if (startTime == null) {
- value = TemporalUtilities.createInstant(endTime);
- } else {
- value = TemporalUtilities.createPeriod(startTime, endTime);
- }
+ value = TemporalUtilities.createPeriod(startTime, endTime);
}
setExtent(value);
}
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
index 523a18c87a..7762e52c8c 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
@@ -180,6 +180,7 @@ public class DefaultProcessStep extends ISOMetadata
implements ProcessStep {
*
* @see #castOrCopy(ProcessStep)
*/
+ @SuppressWarnings("this-escape")
public DefaultProcessStep(final ProcessStep object) {
super(object);
if (object != null) {
@@ -299,7 +300,7 @@ public class DefaultProcessStep extends ISOMetadata
implements ProcessStep {
@Deprecated(since="1.0")
@XmlElement(name = "dateTime", namespace = LegacyNamespaces.GMD)
public Date getDate() {
- return FilterByVersion.LEGACY_METADATA.accept() ?
TemporalUtilities.getDate(getStepDateTime()) : null;
+ return FilterByVersion.LEGACY_METADATA.accept() ?
TemporalUtilities.getAnyDate(getStepDateTime()) : null;
}
/**
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/TemporalUtilities.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/TemporalUtilities.java
index 8274143c87..ee30445316 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/TemporalUtilities.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/TemporalUtilities.java
@@ -25,7 +25,7 @@ import org.apache.sis.system.SystemListener;
import org.apache.sis.pending.temporal.DefaultTemporalFactory;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
+import java.time.Instant;
import org.opengis.temporal.Period;
import org.opengis.temporal.TemporalFactory;
@@ -67,7 +67,7 @@ public final class TemporalUtilities extends SystemListener {
*
* @return the temporal factory.
*/
- public static TemporalFactory getTemporalFactory() {
+ private static TemporalFactory getTemporalFactory() {
TemporalFactory factory = implementation;
if (factory == null) {
factory = ServiceLoader.load(TemporalFactory.class,
Reflect.getContextClassLoader())
@@ -77,13 +77,6 @@ public final class TemporalUtilities extends SystemListener {
return factory;
}
- /**
- * Creates an instant for the given date using the given factory.
- */
- private static Instant createInstant(final TemporalFactory factory, final
Date date) {
- return factory.createInstant(date);
- }
-
/**
* Creates an instant for the given date.
*
@@ -91,54 +84,61 @@ public final class TemporalUtilities extends SystemListener
{
* @return the instant, or {@code null} if the given time was null.
* @throws UnsupportedOperationException if the temporal factory is not
available on the module path.
*/
- public static Instant createInstant(final Date time) throws
UnsupportedOperationException {
- return (time != null) ? createInstant(getTemporalFactory(), time) :
null;
+ public static TemporalPrimitive createInstant(final Date time) throws
UnsupportedOperationException {
+ if (time == null) return null;
+ final Instant t = time.toInstant();
+ return getTemporalFactory().createPeriod(t, t);
}
/**
* Creates a period for the given begin and end dates. The given arguments
can be null if the
- * {@link TemporalFactory#createInstant(Date)} method accepts null dates,
which stand for
- * undetermined position.
+ * {@link TemporalFactory} methods accept null instants, which stand for
undetermined position.
*
* @param begin the begin date, inclusive.
* @param end the end date, inclusive.
- * @return the period.
+ * @return the period, or {@code null} if both arguments are null.
* @throws UnsupportedOperationException if the temporal factory is not
available on the module path.
*/
- public static Period createPeriod(final Date begin, final Date end) throws
UnsupportedOperationException {
- final TemporalFactory factory = getTemporalFactory();
- return factory.createPeriod(createInstant(factory, begin),
createInstant(factory, end));
+ public static TemporalPrimitive createPeriod(final Date begin, final Date
end) throws UnsupportedOperationException {
+ if (begin == null && end == null) return null;
+ return getTemporalFactory().createPeriod(
+ (begin != null) ? begin.toInstant() : null,
+ (end != null) ? end.toInstant() : null);
}
/**
- * Infers a value from the extent as a {@link Date} object.
- * This method is used for compatibility with legacy API and may disappear
in future SIS version.
+ * Returns the given value as an instant if the period is a single point
in time, or {@code null} otherwis.
*
* @param time the instant or period for which to get a date, or {@code
null}.
- * @return the requested time as a Java date, or {@code null} if none.
+ * @return the instant, or {@code null} if none.
*/
- public static Date getDate(final TemporalPrimitive time) {
- Instant instant;
- if (time instanceof Instant) {
- instant = (Instant) time;
- } else if (time instanceof Period) {
- instant = ((Period) time).getEnding();
- if (instant == null) {
- instant = ((Period) time).getBeginning();
- }
- } else {
- return null;
+ public static Instant getInstant(final TemporalPrimitive time) {
+ if (time instanceof Period) {
+ var p = (Period) time;
+ final Instant begin = p.getBeginning();
+ final Instant end = p.getEnding();
+ if (begin == null) return end;
+ if (end == null) return begin;
+ if (begin.equals(end)) return end;
}
- return instant.getDate();
+ return null;
}
/**
- * Temporary method, to be removed after we upgraded metadata to {@link
java.time}.
+ * Infers a value from the extent as a {@link Date} object.
+ * This method is used for compatibility with legacy API and may disappear
in future SIS version.
*
- * @param instant the Java instant, or {@code null}.
- * @return the legacy Java date, or {@code null}.
+ * @param time the instant or period for which to get a date, or {@code
null}.
+ * @return the requested time as a Java date, or {@code null} if none.
*/
- public static Date toDate(final java.time.Instant instant) {
- return (instant != null) ? Date.from(instant) : null;
+ public static Date getAnyDate(final TemporalPrimitive time) {
+ if (time instanceof Period) {
+ var p = (Period) time;
+ Instant instant;
+ if ((instant = p.getEnding()) != null || (instant =
p.getBeginning()) != null) {
+ return Date.from(instant);
+ }
+ }
+ return null;
}
}
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
index 51233a96ab..edea96f9cb 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
@@ -26,8 +26,8 @@ import org.apache.sis.metadata.privy.TemporalUtilities;
import org.apache.sis.util.resources.Errors;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
+import java.time.Instant;
import org.opengis.temporal.Period;
-import org.opengis.temporal.Instant;
/**
@@ -82,6 +82,7 @@ public class TM_Primitive extends PropertyType<TM_Primitive,
TemporalPrimitive>
*/
@XmlElement(name = "TimePeriod")
public final TimePeriod getTimePeriod() {
+ @SuppressWarnings("LocalVariableHidesMemberVariable")
final TemporalPrimitive metadata = this.metadata;
return (metadata instanceof Period) ? new TimePeriod((Period)
metadata) : null;
}
@@ -94,8 +95,8 @@ public class TM_Primitive extends PropertyType<TM_Primitive,
TemporalPrimitive>
*/
@XmlElement(name = "TimeInstant")
public final TimeInstant getTimeInstant() {
- final TemporalPrimitive metadata = this.metadata;
- return (metadata instanceof Instant) ? new TimeInstant((Instant)
metadata) : null;
+ Instant time = TemporalUtilities.getInstant(metadata);
+ return (time != null) ? new TimeInstant(time) : null;
}
/**
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimeInstant.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimeInstant.java
index d643f739aa..3f3cbebe49 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimeInstant.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimeInstant.java
@@ -27,7 +27,7 @@ import org.apache.sis.util.privy.Strings;
import org.apache.sis.xml.privy.XmlUtilities;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
+import java.time.Instant;
/**
@@ -78,18 +78,15 @@ public final class TimeInstant extends GMLAdapter {
*/
static XMLGregorianCalendar toXML(final Instant instant) {
if (instant != null) {
- final Date date = instant.getDate();
- if (date != null) {
- final Context context = Context.current();
- try {
- final XMLGregorianCalendar gc =
XmlUtilities.toXML(context, date);
- if (gc != null) {
- XmlUtilities.trimTime(gc, false);
- return gc;
- }
- } catch (DatatypeConfigurationException e) {
- Context.warningOccured(context, TimeInstant.class,
"toXML", e, true);
+ final Context context = Context.current();
+ try {
+ final XMLGregorianCalendar gc = XmlUtilities.toXML(context,
Date.from(instant));
+ if (gc != null) {
+ XmlUtilities.trimTime(gc, false);
+ return gc;
}
+ } catch (DatatypeConfigurationException | IllegalArgumentException
e) {
+ Context.warningOccured(context, TimeInstant.class, "toXML", e,
true);
}
}
return null;
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java
index c50166bd32..01fe46259c 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java
@@ -23,7 +23,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlTransient;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
+import java.time.Instant;
/**
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/gml/TimePeriodTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/gml/TimePeriodTest.java
index e7f45e320f..3036090230 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/gml/TimePeriodTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/gml/TimePeriodTest.java
@@ -27,7 +27,6 @@ import org.apache.sis.xml.XML;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.MarshallerPool;
import org.apache.sis.xml.privy.XmlUtilities;
-import org.apache.sis.pending.temporal.DefaultTemporalFactory;
// Test dependencies
import org.junit.jupiter.api.Test;
@@ -39,7 +38,7 @@ import static org.apache.sis.test.TestUtilities.date;
import static org.apache.sis.test.TestUtilities.format;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
+import java.time.Instant;
/**
@@ -76,13 +75,6 @@ public final class TimePeriodTest extends TestCase {
createContext(true, Locale.FRANCE, "CET");
}
- /**
- * Creates a GeoAPI instant object for the given date.
- */
- private static Instant instant(final String date) {
- return DefaultTemporalFactory.provider().createInstant(date(date));
- }
-
/**
* Tests time instant. The test is executed using an arbitrary locale and
timezone.
*
@@ -118,8 +110,8 @@ public final class TimePeriodTest extends TestCase {
@Test
public void testPeriodGML2() throws JAXBException {
createContext();
- final TimePeriodBound begin = new
TimePeriodBound.GML2(instant("1992-01-01 00:00:00"));
- final TimePeriodBound end = new
TimePeriodBound.GML2(instant("2007-12-31 00:00:00"));
+ final TimePeriodBound begin = new
TimePeriodBound.GML2(Instant.parse("1992-01-01T00:00:00Z"));
+ final TimePeriodBound end = new
TimePeriodBound.GML2(Instant.parse("2007-12-31T00:00:00Z"));
testPeriod(begin, end,
"<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:begin>\n" +
@@ -170,8 +162,8 @@ public final class TimePeriodTest extends TestCase {
@Test
public void testPeriodGML3() throws JAXBException {
createContext();
- final TimePeriodBound begin = new
TimePeriodBound.GML3(instant("1992-01-01 00:00:00"), "before");
- final TimePeriodBound end = new
TimePeriodBound.GML3(instant("2007-12-31 00:00:00"), "after");
+ final TimePeriodBound begin = new
TimePeriodBound.GML3(Instant.parse("1992-01-01T00:00:00Z"), "before");
+ final TimePeriodBound end = new
TimePeriodBound.GML3(Instant.parse("2007-12-31T00:00:00Z"), "after");
testPeriod(begin, end,
"<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
"
<gml:beginPosition>1992-01-01T01:00:00+01:00</gml:beginPosition>\n" +
@@ -188,8 +180,8 @@ public final class TimePeriodTest extends TestCase {
@Test
public void testSimplifiedPeriodGML3() throws JAXBException {
createContext();
- final TimePeriodBound begin = new
TimePeriodBound.GML3(instant("1992-01-01 23:00:00"), "before");
- final TimePeriodBound end = new
TimePeriodBound.GML3(instant("2007-12-30 23:00:00"), "after");
+ final TimePeriodBound begin = new
TimePeriodBound.GML3(Instant.parse("1992-01-01T23:00:00Z"), "before");
+ final TimePeriodBound end = new
TimePeriodBound.GML3(Instant.parse("2007-12-30T23:00:00Z"), "after");
testPeriod(begin, end,
"<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
@@ -207,7 +199,7 @@ public final class TimePeriodTest extends TestCase {
public void testBeforePeriodGML3() throws JAXBException {
createContext();
final TimePeriodBound begin = new TimePeriodBound.GML3(null, "before");
- final TimePeriodBound end = new
TimePeriodBound.GML3(instant("2007-12-30 23:00:00"), "after");
+ final TimePeriodBound end = new
TimePeriodBound.GML3(Instant.parse("2007-12-30T23:00:00Z"), "after");
testPeriod(begin, end,
"<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:beginPosition indeterminatePosition=\"before\"/>\n" +
@@ -224,7 +216,7 @@ public final class TimePeriodTest extends TestCase {
@Test
public void testAfterPeriodGML3() throws JAXBException {
createContext();
- final TimePeriodBound begin = new
TimePeriodBound.GML3(instant("1992-01-01 23:00:00"), "before");
+ final TimePeriodBound begin = new
TimePeriodBound.GML3(Instant.parse("1992-01-01T23:00:00Z"), "before");
final TimePeriodBound end = new TimePeriodBound.GML3(null, "after");
testPeriod(begin, end,
"<gml:TimePeriod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java
index d62da4e6d5..87fa31eaba 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/reader/XMLMetadata.java
@@ -49,7 +49,6 @@ import org.apache.sis.util.collection.DefaultTreeTable;
import org.apache.sis.util.collection.TableColumn;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.xml.XML;
-import static org.apache.sis.metadata.privy.TemporalUtilities.toDate;
/**
@@ -503,7 +502,7 @@ public final class XMLMetadata implements Filter {
* Writes to {@link MetadataBuilder} all information that were pending
parsing completion.
*/
void flush() {
- metadata.addTemporalExtent(toDate(startTime), toDate(endTime));
+ metadata.addTemporalExtent(startTime, endTime);
}
}
diff --git
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java
index fbd2f01bb3..a437ffd0f2 100644
---
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java
+++
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/CRSBuilder.java
@@ -18,6 +18,7 @@ package org.apache.sis.storage.netcdf.base;
import java.util.Map;
import java.util.List;
+import java.util.Date;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringJoiner;
@@ -51,7 +52,6 @@ import org.apache.sis.referencing.crs.DefaultGeocentricCRS;
import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory;
import org.apache.sis.referencing.operation.provider.Equirectangular;
-import org.apache.sis.metadata.privy.TemporalUtilities;
import org.apache.sis.storage.DataStoreContentException;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.netcdf.internal.Resources;
@@ -967,7 +967,7 @@ previous: for (int i=components.size(); --i >= 0;) {
datum = c.datum();
} else {
properties = properties("Time since " + epoch);
- datum = factory.createTemporalDatum(properties,
TemporalUtilities.toDate(epoch));
+ datum = factory.createTemporalDatum(properties,
Date.from(epoch));
}
}
}
diff --git
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
index 7ab125d63c..33dba9aa1b 100644
---
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
+++
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java
@@ -18,6 +18,7 @@ package org.apache.sis.storage.base;
import java.time.Instant;
import java.time.Duration;
+import java.time.temporal.Temporal;
import java.time.temporal.TemporalAmount;
import java.util.Date;
import java.util.Locale;
@@ -1782,6 +1783,21 @@ public class MetadataBuilder {
}
}
+ /**
+ * Adds a temporal extent covered by the data.
+ * Storage location is:
+ *
+ * <ul>
+ * <li>{@code metadata/identificationInfo/extent/temporalElement}</li>
+ * </ul>
+ *
+ * @param startTime when the data begins, or {@code null} if unbounded.
+ * @param endTime when the data ends, or {@code null} if unbounded.
+ */
+ public final void addTemporalExtent(final Temporal startTime, final
Temporal endTime) {
+ addTemporalExtent(StandardDateFormat.toDate(startTime),
StandardDateFormat.toDate(endTime));
+ }
+
/**
* Adds a temporal extent covered by the data.
* Storage location is:
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultInstant.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultInstant.java
deleted file mode 100644
index 9c56da0adf..0000000000
---
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultInstant.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sis.pending.temporal;
-
-import java.util.Date;
-
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
-import org.opengis.temporal.TemporalPosition;
-
-
-/**
- * Default implementation of GeoAPI instant. This is a temporary class;
- * GeoAPI temporal interfaces are expected to change a lot in a future
revision.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-final class DefaultInstant extends Primitive implements Instant {
- /** The date in milliseconds since epoch. */
- private final long millis;
-
- /** Creates a new instant for the given date. */
- DefaultInstant(final Date time) {
- millis = time.getTime();
- }
-
- /** Returns the date used for describing temporal position. */
- @Override public Date getDate() {
- return new Date(millis);
- }
-
- /** Association to a temporal reference system. */
- @Override public TemporalPosition getTemporalPosition() {
- throw DefaultTemporalFactory.unsupported();
- }
-
- /** String representation in ISO format. */
- @Override public String toString() {
- return java.time.Instant.ofEpochMilli(millis).toString();
- }
-
- /** Hash code value of the time position. */
- @Override public int hashCode() {
- return Long.hashCode(millis) ^ 57;
- }
-
- /** Compares with given object for equality. */
- @Override public boolean equals(final Object obj) {
- return (obj instanceof DefaultInstant) && ((DefaultInstant)
obj).millis == millis;
- }
-}
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultPeriod.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultPeriod.java
index 1d046f5855..1973da502c 100644
---
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultPeriod.java
+++
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultPeriod.java
@@ -19,7 +19,7 @@ package org.apache.sis.pending.temporal;
import java.util.Objects;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.Instant;
+import java.time.Instant;
import org.opengis.temporal.Period;
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultTemporalFactory.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultTemporalFactory.java
index eb05607337..b52df00f46 100644
---
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultTemporalFactory.java
+++
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultTemporalFactory.java
@@ -16,7 +16,7 @@
*/
package org.apache.sis.pending.temporal;
-import java.util.Date;
+import java.time.Instant;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
import org.opengis.temporal.*;
@@ -43,11 +43,6 @@ public final class DefaultTemporalFactory implements
TemporalFactory {
private DefaultTemporalFactory() {
}
- /** Creates an {@link Instant} for the given date. */
- @Override public Instant createInstant(Date date) {
- return new DefaultInstant(date);
- }
-
/** Creates a period for the two given instants. */
@Override public Period createPeriod(Instant begin, Instant end) {
return new DefaultPeriod(begin, end);
diff --git a/geoapi/snapshot b/geoapi/snapshot
index b523de038f..268b27c27d 160000
--- a/geoapi/snapshot
+++ b/geoapi/snapshot
@@ -1 +1 @@
-Subproject commit b523de038f29cc88bc7ae8d6820848cec0410004
+Subproject commit 268b27c27dcc3b034dd7621a682bc4d432511f11