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 0ec29ad1eb Fix an exception when metadata in a TIFF file declare a resolution of 0. 0ec29ad1eb is described below commit 0ec29ad1ebd1f1b53941eb3c0c6afd273bda73d7 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Wed Feb 5 11:38:59 2025 +0100 Fix an exception when metadata in a TIFF file declare a resolution of 0. --- .../org/apache/sis/storage/base/MetadataBuilder.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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 b7ea27fe0a..6d4cefd9cb 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 @@ -20,7 +20,6 @@ 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; import java.util.Optional; import java.util.Iterator; @@ -90,6 +89,7 @@ import org.apache.sis.metadata.iso.spatial.*; import org.apache.sis.metadata.sql.MetadataStoreException; import org.apache.sis.metadata.sql.MetadataSource; import org.apache.sis.metadata.privy.Merger; +import org.apache.sis.temporal.TimeMethods; import org.apache.sis.referencing.NamedIdentifier; import org.apache.sis.referencing.ImmutableIdentifier; import org.apache.sis.referencing.privy.AxisDirections; @@ -1142,20 +1142,19 @@ public class MetadataBuilder { * If two dates are of the same type, retains the latest one if the type name starts with {@code "LATE_"} * or retains the earliest date otherwise. */ - private static void addEarliest(final Collection<CitationDate> dates, final CitationDate cd, final DateType type) { + private static void addEarliest(final Collection<CitationDate> dates, final CitationDate date, final DateType type) { for (final Iterator<CitationDate> it = dates.iterator(); it.hasNext();) { - final CitationDate co = it.next(); - if (type.equals(co.getDateType())) { - final Date oldDate = co.getDate(); - final Date newDate = cd.getDate(); - if (type.name().startsWith("LATE_") ? oldDate.before(newDate) : oldDate.after(newDate)) { + final CitationDate existing = it.next(); + if (type.equals(existing.getDateType())) { + final int method = type.name().startsWith("LATE_") ? TimeMethods.BEFORE : TimeMethods.AFTER; + if (TimeMethods.compareAny(method, existing.getReferenceDate(), date.getReferenceDate())) { it.remove(); break; } return; } } - dates.add(cd); + dates.add(date); } /** @@ -2043,7 +2042,7 @@ public class MetadataBuilder { * @param distance the resolution in metres, or {@code NaN} for no-operation. */ public final void addLinearResolution(final double distance) { - if (Double.isFinite(distance)) { + if (distance > 0 && distance != Double.POSITIVE_INFINITY) { final var r = new DefaultResolution(); r.setDistance(shared(distance)); addIfNotPresent(identification().getSpatialResolutions(), r);