This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-3.1 in repository https://gitbox.apache.org/repos/asf/sis.git
commit f3588042526973292d3eafd06ad529c99c969215 Merge: e9dd6d1621 0cae00bc0e Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sun Jun 23 20:32:10 2024 +0200 Merge branch 'geoapi-4.0' into geoapi-3.1 - Completion of the work on temporal objects - Some work on Shapefile and SQL store .../org/apache/sis/coverage/grid/PixelInCell.java | 3 + .../main/org/apache/sis/filter/TemporalFilter.java | 21 +- .../org/apache/sis/filter/TemporalOperation.java | 105 ++++-- .../apache/sis/geometry/wrapper/Geometries.java | 1 + .../apache/sis/geometry/wrapper/esri/Factory.java | 5 +- .../test/org/apache/sis/filter/PeriodLiteral.java | 44 ++- .../org.apache.sis.metadata/main/module-info.java | 9 + .../apache/sis/metadata/iso/DefaultMetadata.java | 2 +- .../sis/metadata/iso/acquisition/DefaultEvent.java | 2 +- .../iso/acquisition/DefaultRequestedDate.java | 2 +- .../iso/acquisition/DefaultRequirement.java | 2 +- .../sis/metadata/iso/citation/DefaultCitation.java | 2 +- .../metadata/iso/citation/DefaultCitationDate.java | 4 +- .../distribution/DefaultStandardOrderProcess.java | 2 +- .../metadata/iso/extent/DefaultTemporalExtent.java | 12 +- .../apache/sis/metadata/iso/extent/Extents.java | 21 +- .../metadata/iso/identification/DefaultUsage.java | 10 +- .../sis/metadata/iso/legacy/TemporalToDate.java | 2 +- .../metadata/iso/lineage/DefaultProcessStep.java | 16 +- .../org/apache/sis/metadata/sql/privy/Dialect.java | 22 +- .../apache/sis/pending/temporal/DefaultPeriod.java | 78 ----- .../org/apache/sis/pending/temporal/Primitive.java | 69 ---- .../sis/pending/temporal/TemporalUtilities.java | 137 -------- .../org/apache/sis/temporal/DefaultInstant.java | 336 +++++++++++++++++++ .../org/apache/sis/temporal/DefaultPeriod.java | 206 ++++++++++++ .../temporal/DefaultPeriodDuration.java | 9 +- .../org/apache/sis/temporal/GeneralDuration.java | 370 +++++++++++++++++++++ .../apache/sis/temporal/LenientDateFormat.java} | 17 +- .../org/apache/sis/temporal}/TemporalDate.java | 38 +-- .../org/apache/sis/temporal/TemporalObject.java | 89 +++++ .../org/apache/sis/temporal/TemporalObjects.java | 154 +++++++++ .../main/org/apache/sis/temporal}/TimeMethods.java | 123 ++++--- .../sis/{pending => }/temporal/package-info.java | 9 +- .../apache/sis/xml/bind/IdentifierMapAdapter.java | 1 + .../org/apache/sis/xml/bind/gml/TM_Primitive.java | 14 +- .../apache/sis/xml/bind/gml/TimePeriodBound.java | 19 +- .../apache/sis/xml/bind/gts/TM_PeriodDuration.java | 2 +- .../org/apache/sis/xml/privy/XmlUtilities.java | 2 +- .../iso/citation/DefaultCitationDateTest.java | 8 +- .../sis/metadata/iso/extent/DefaultExtentTest.java | 3 +- .../apache/sis/temporal/DefaultInstantTest.java | 215 ++++++++++++ .../org/apache/sis/temporal/DefaultPeriodTest.java | 128 +++++++ .../apache/sis/temporal/GeneralDurationTest.java | 52 +++ .../sis/temporal/LenientDateFormatTest.java} | 46 +-- .../apache/sis/xml/bind/gml/TimePeriodTest.java | 17 +- .../org/apache/sis/geometry/CoordinateFormat.java | 2 +- .../main/org/apache/sis/io/wkt/AbstractParser.java | 4 +- .../main/org/apache/sis/io/wkt/Formatter.java | 6 +- .../main/org/apache/sis/io/wkt/WKTFormat.java | 6 +- .../sis/referencing/crs/DefaultTemporalCRS.java | 2 +- .../sis/referencing/datum/AbstractDatum.java | 2 +- .../referencing/datum/DefaultTemporalDatum.java | 2 +- .../referencing/factory/sql/EPSGDataAccess.java | 4 +- .../operation/CoordinateOperationFinder.java | 2 +- .../sis/referencing/privy/AxisDirections.java | 38 +-- .../sis/referencing/privy/ExtentSelector.java | 2 +- .../test/org/apache/sis/io/wkt/ElementTest.java | 2 +- .../sis/io/wkt/GeodeticObjectParserTest.java | 2 +- .../org/apache/sis/referencing/CommonCRSTest.java | 2 +- .../datum/DefaultTemporalDatumTest.java | 2 +- .../sis/referencing/privy/AxisDirectionsTest.java | 2 +- .../sis/test/integration/MetadataVerticalTest.java | 2 +- .../sis/storage/geotiff/reader/XMLMetadata.java | 6 +- .../storage/geotiff/reader/XMLMetadataTest.java | 4 +- .../sis/storage/netcdf/classic/ChannelDecoder.java | 8 +- .../sis/storage/netcdf/classic/VariableInfo.java | 4 +- .../apache/sis/storage/netcdf/base/TestCase.java | 2 +- .../sis/storage/sql/feature/FeatureStream.java | 4 +- .../sis/storage/sql/feature/GeometryGetter.java | 48 ++- .../sis/storage/xml/stream/StaxStreamReader.java | 6 +- .../main/org/apache/sis/storage/csv/Store.java | 6 +- .../org/apache/sis/storage/csv/TimeEncoding.java | 6 +- .../main/org/apache/sis/measure/RangeFormat.java | 44 ++- .../main/org/apache/sis/pending/jdk/JDK18.java | 11 + .../org/apache/sis/util/privy/LazyCandidate.java} | 24 +- .../main/org/apache/sis/util/resources/Errors.java | 7 +- .../apache/sis/util/resources/Errors.properties | 3 +- .../apache/sis/util/resources/Errors_fr.properties | 1 + geoapi/snapshot | 2 +- .../main/org/apache/sis/cql/CQL.java | 6 +- .../org/apache/sis/cql/FilterToCQLVisitor.java | 6 +- .../sis/storage/shapefile/ShapefileStore.java | 8 +- .../sis/storage/shapefile/shp/ShapeWriter.java | 4 +- .../sis/storage/shapefile/shx/IndexWriter.java | 6 +- 84 files changed, 2104 insertions(+), 623 deletions(-) diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java index a735d8369c,355c09c9b7..a97f3bbdb0 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java @@@ -29,10 -29,10 +29,10 @@@ import org.opengis.metadata.acquisition import org.opengis.metadata.acquisition.Requirement; import org.opengis.metadata.citation.Citation; import org.apache.sis.metadata.iso.ISOMetadata; - import org.apache.sis.util.privy.TemporalDate; + import org.apache.sis.temporal.TemporalDate; -// Specific to the geoapi-4.0 branch: -import org.opengis.metadata.citation.Responsibility; +// Specific to the main and geoapi-3.1 branches: +import org.opengis.metadata.citation.ResponsibleParty; /** diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultUsage.java index 02574b2e61,842b4ee063..a47f0e1dea --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultUsage.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/DefaultUsage.java @@@ -34,12 -34,12 +34,12 @@@ import org.apache.sis.xml.privy.LegacyN import org.apache.sis.metadata.TitleProperty; import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.metadata.internal.Dependencies; - import org.apache.sis.pending.temporal.TemporalUtilities; + import org.apache.sis.temporal.TemporalObjects; + import org.apache.sis.temporal.TemporalDate; import org.apache.sis.util.iso.Types; - import org.apache.sis.util.privy.TemporalDate; -// Specific to the geoapi-4.0 branch: -import org.opengis.metadata.citation.Responsibility; +// Specific to the main and geoapi-3.1 branches: +import org.opengis.metadata.citation.ResponsibleParty; /** diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java index a91ec949e4,d1b49d4ca5..feb25054d3 --- 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 @@@ -37,11 -37,8 +37,12 @@@ import org.apache.sis.xml.bind.FilterBy import org.apache.sis.xml.bind.gml.TM_Primitive; import org.apache.sis.xml.bind.metadata.MD_Scope; import org.apache.sis.xml.privy.LegacyNamespaces; - import org.apache.sis.pending.temporal.TemporalUtilities; + import org.apache.sis.temporal.TemporalObjects; +// Specific to the main and geoapi-3.1 branches: +import org.opengis.metadata.citation.ResponsibleParty; ++import org.apache.sis.temporal.TemporalDate; + // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.metadata.maintenance.Scope; @@@ -186,8 -186,8 +187,8 @@@ public class DefaultProcessStep extend if (object != null) { description = object.getDescription(); rationale = object.getRationale(); - stepDateTime = TemporalUtilities.createInstant(object.getDate()); - stepDateTime = object.getStepDateTime(); - processors = copyCollection(object.getProcessors(), Responsibility.class); ++ stepDateTime = toInstant(object.getDate()); + processors = copyCollection(object.getProcessors(), ResponsibleParty.class); references = copyCollection(object.getReferences(), Citation.class); sources = copyCollection(object.getSources(), Source.class); scope = object.getScope(); @@@ -320,7 -320,7 +321,14 @@@ */ @Deprecated(since="1.0") public void setDate(final Date newValue) { - setStepDateTime(TemporalUtilities.createInstant(newValue == null ? null : newValue.toInstant())); - setStepDateTime(TemporalObjects.createInstant(newValue == null ? null : newValue.toInstant())); ++ setStepDateTime(toInstant(newValue)); ++ } ++ ++ /** ++ * Converts the given date to a temporal primitive, which may be null. ++ */ ++ private static TemporalPrimitive toInstant(final Date newValue) { ++ return (newValue == null) ? null : TemporalObjects.createInstant(TemporalDate.toTemporal(newValue)); } /** diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriodDuration.java index 0687530a3e,0000000000..c0372e7397 mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriodDuration.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/temporal/DefaultPeriodDuration.java @@@ -1,71 -1,0 +1,74 @@@ +/* + * 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; ++package org.apache.sis.temporal; + +import java.io.Serializable; +import java.time.temporal.TemporalAmount; +import org.opengis.temporal.PeriodDuration; + +// Specific to the geoapi-3.1 branch: +import java.time.temporal.Temporal; +import java.time.temporal.TemporalUnit; +import java.util.List; + + +/** - * Default implementation of GeoAPI period duration. This is a temporary class; - * GeoAPI temporal interfaces are expected to change a lot in a future revision. ++ * Default implementation of GeoAPI period duration. + * + * @author Martin Desruisseaux (Geomatys) ++ * ++ * @deprecated This is a temporary class for compatibility with GeoAPI 3.x only. ++ * It should disappear with GeoAPI 4.0. + */ ++@Deprecated +@SuppressWarnings("serial") +public final class DefaultPeriodDuration implements PeriodDuration, Serializable { + /** + * The temporal object providing the duration value. + */ + public final TemporalAmount duration; + + /** + * Creates a new duration. + */ + public DefaultPeriodDuration(final TemporalAmount duration) { + this.duration = duration; + } + + @Override public List<TemporalUnit> getUnits() {return duration.getUnits();} + @Override public long get (TemporalUnit unit) {return duration.get(unit);} + @Override public Temporal addTo (Temporal temporal) {return duration.addTo(temporal);} + @Override public Temporal subtractFrom(Temporal temporal) {return duration.subtractFrom(temporal);} + + /** String representation. */ + @Override public String toString() { + return duration.toString(); + } + + /** Hash code value of the time position. */ + @Override public int hashCode() { + return duration.hashCode() ^ 879337943; + } + + /** Compares with given object for equality. */ + @Override public boolean equals(final Object obj) { + if (obj instanceof DefaultPeriodDuration) { + duration.equals(((DefaultPeriodDuration) obj).duration); + } + return false; + } +} diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_PeriodDuration.java index 472c346555,0000000000..f22367030f mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_PeriodDuration.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_PeriodDuration.java @@@ -1,100 -1,0 +1,100 @@@ +/* + * 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.xml.bind.gts; + +import java.time.temporal.TemporalAmount; +import javax.xml.datatype.Duration; +import jakarta.xml.bind.annotation.XmlElement; +import org.opengis.temporal.PeriodDuration; - import org.apache.sis.pending.temporal.DefaultPeriodDuration; ++import org.apache.sis.temporal.DefaultPeriodDuration; +import org.apache.sis.xml.bind.gco.PropertyType; + + +/** + * Wraps a {@code gts:TM_PeriodDuration} element. + * + * @author Guilhem Legal (Geomatys) + * @author Martin Desruisseaux (Geomatys) + */ +public final class TM_PeriodDuration extends PropertyType<TM_PeriodDuration, PeriodDuration> { + /** + * Empty constructor for JAXB. + */ + public TM_PeriodDuration() { + } + + /** + * Wraps a Temporal Period Duration value at marshalling-time. + * + * @param metadata the metadata value to marshal. + */ + private TM_PeriodDuration(final PeriodDuration metadata) { + super(metadata); + } + + /** + * Returns the Period Duration value wrapped by a {@code gts:TM_PeriodDuration} element. + * + * @param value the value to marshal. + * @return the adapter which wraps the metadata value. + */ + @Override + protected TM_PeriodDuration wrap(final PeriodDuration value) { + return new TM_PeriodDuration(value); + } + + /** + * Returns the GeoAPI interface which is bound by this adapter. + * + * @return {@code PeriodDuration.class} + */ + @Override + protected final Class<PeriodDuration> getBoundType() { + return PeriodDuration.class; + } + + /** + * Returns the {@link Duration} generated from the metadata value. + * This method is systematically called at marshalling time by JAXB. + * + * @return the time period, or {@code null}. + */ + @XmlElement(name = "TM_PeriodDuration") + public final Duration getElement() { + if (metadata instanceof TemporalAmount) { + return new TM_Duration((TemporalAmount) metadata).getElement(); + } + return null; + } + + /** + * Sets the value from the {@link Duration}. + * This method is called at unmarshalling time by JAXB. + * + * @param duration the adapter to set. + */ + public final void setElement(final Duration duration) { + var p = new TM_Duration(); + p.setElement(duration); + TemporalAmount t = p.get(); + if (t == null || t instanceof PeriodDuration) { + metadata = (PeriodDuration) t; + } else { + metadata = new DefaultPeriodDuration(t); + } + } +} diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java index 5381ff13e1,0c3a5579d9..e7549ff4fb --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/crs/DefaultTemporalCRS.java @@@ -45,9 -45,6 +45,9 @@@ import org.apache.sis.math.Fraction import static org.apache.sis.util.privy.Constants.NANOS_PER_SECOND; import static org.apache.sis.util.privy.Constants.MILLIS_PER_SECOND; +// Specific to the main and geoapi-3.1 branches: - import org.apache.sis.util.privy.TemporalDate; ++import org.apache.sis.temporal.TemporalDate; + /** * A 1-dimensional coordinate reference system used for the recording of time. diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java index f1e678b567,99648a7ba6..455ce924a3 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/datum/DefaultTemporalDatum.java @@@ -34,9 -34,6 +34,9 @@@ import org.apache.sis.util.ComparisonMo import org.apache.sis.io.wkt.Formatter; import org.apache.sis.io.wkt.FormattableObject; +// Specific to the main and geoapi-3.1 branches: - import org.apache.sis.util.privy.TemporalDate; ++import org.apache.sis.temporal.TemporalDate; + // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.metadata.Identifier; diff --cc endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java index 92beac6368,39a7d78e28..b552643a84 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/CoordinateOperationFinder.java @@@ -70,9 -70,6 +70,9 @@@ import org.apache.sis.util.privy.Double import org.apache.sis.util.resources.Vocabulary; import static org.apache.sis.util.Utilities.equalsIgnoreMetadata; +// Specific to the main and geoapi-3.1 branches: - import org.apache.sis.util.privy.TemporalDate; ++import org.apache.sis.temporal.TemporalDate; + /** * Finds a conversion or transformation path from a source CRS to a target CRS. diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java index 1010d8ac43,4610b54611..b11e8b14cc --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java @@@ -55,9 -55,6 +55,9 @@@ import static org.apache.sis.referencin import static org.apache.sis.referencing.Assertions.assertDiagonalEquals; import static org.apache.sis.test.TestUtilities.getSingleton; +// Specific to the main and geoapi-3.1 branches: - import org.apache.sis.util.privy.TemporalDate; ++import org.apache.sis.temporal.TemporalDate; + /** * Tests {@link GeodeticObjectParser}. diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java index 1bd6f16f54,028a9d1cb7..296cb93297 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java @@@ -51,9 -51,6 +51,9 @@@ import static org.apache.sis.test.Asser import static org.apache.sis.test.Assertions.assertMessageContains; import static org.apache.sis.test.TestUtilities.*; +// Specific to the main and geoapi-3.1 branches: - import org.apache.sis.util.privy.TemporalDate; ++import org.apache.sis.temporal.TemporalDate; + // Specific to the geoapi-3.1 and geoapi-4.0 branches: import org.opengis.referencing.datum.RealizationMethod; import static org.opengis.test.Assertions.assertAxisDirectionsEqual; diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java index 58b4981490,443246a803..dc6845ddef --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/datum/DefaultTemporalDatumTest.java @@@ -34,9 -34,6 +34,9 @@@ import static org.apache.sis.referencin import static org.apache.sis.test.TestUtilities.getSingleton; import static org.apache.sis.test.TestUtilities.getScope; +// Specific to the main and geoapi-3.1 branches: - import org.apache.sis.util.privy.TemporalDate; ++import org.apache.sis.temporal.TemporalDate; + // Specific to the geoapi-3.1 and geoapi-4.0 branches: import static org.opengis.referencing.ObjectDomain.*; import static org.opengis.referencing.IdentifiedObject.*; diff --cc geoapi/snapshot index 7554560355,2c16f9a1d5..db2b62d7c4 --- a/geoapi/snapshot +++ b/geoapi/snapshot @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit 755456035537d00a695b25953b76e47b8cb5db46 -Subproject commit 2c16f9a1d5c2bd2b7c4b1666f877232f162bbc30 ++Subproject commit db2b62d7c4452ba91c90fa98f58721e7f5485174