This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 03de33124954e090b27097efd2fb66201d8da51f Author: Martin Desruisseaux <[email protected]> AuthorDate: Fri Sep 25 16:38:33 2026 +0900 Cleanup related to relative files in WKT parameters. --- .../main/org/apache/sis/parameter/Parameters.java | 5 ++--- .../sis/referencing/operation/AbstractSingleOperation.java | 2 +- .../main/org/apache/sis/storage/netcdf/MetadataReader.java | 14 +++++--------- .../main/org/apache/sis/storage/base/PRJDataStore.java | 4 ++-- .../main/org/apache/sis/storage/wkt/Store.java | 3 ++- .../main/org/apache/sis/storage/wkt/StoreFormat.java | 5 +---- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java index 9c6a0cbec1..ab4266f8f0 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/Parameters.java @@ -16,7 +16,6 @@ */ package org.apache.sis.parameter; -import java.util.Map; import java.util.HashMap; import java.util.List; import java.util.Optional; @@ -297,7 +296,7 @@ public abstract class Parameters implements ParameterValueGroup, Cloneable, Prin if (parameters == null) { return null; } - final GeneralParameterDescriptor[] descriptors = new GeneralParameterDescriptor[parameters.length]; + final var descriptors = new GeneralParameterDescriptor[parameters.length]; for (int i=0; i<parameters.length; i++) { final GeneralParameterValue p = parameters[i]; if (p != null) { @@ -913,7 +912,7 @@ public abstract class Parameters implements ParameterValueGroup, Cloneable, Prin throws InvalidParameterNameException, InvalidParameterValueException { final Integer ZERO = 0; - final Map<String,Integer> occurrences = new HashMap<>(); + final var occurrences = new HashMap<String, Integer>(); for (final GeneralParameterValue value : values.values()) { final String name = value.getDescriptor().getName().getCode(); final int occurrence = occurrences.getOrDefault(name, ZERO); diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractSingleOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractSingleOperation.java index c97b956b88..3294d97433 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractSingleOperation.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractSingleOperation.java @@ -412,7 +412,7 @@ class AbstractSingleOperation extends AbstractCoordinateOperation implements Sin * because Apache SIS infers the type from the actual parameter value. The `merge` method * below puts those information together. */ - final Map<GeneralParameterDescriptor,GeneralParameterDescriptor> replacements = new IdentityHashMap<>(4); + final var replacements = new IdentityHashMap<GeneralParameterDescriptor, GeneralParameterDescriptor>(4); final GeneralParameterDescriptor[] merged = CC_OperationParameterGroup.merge( method.getParameters().descriptors(), Parameters.getDescriptors(values), diff --git a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java index 43ae7b17ff..e9ec40cf82 100644 --- a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java +++ b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/MetadataReader.java @@ -190,14 +190,6 @@ final class MetadataReader extends MetadataBuilder { searchPath = decoder.getSearchPath(); } - /** - * Returns the netCDF file as an <abbr>URI</abbr>, or {@code null} if none. - */ - private URI location() { - final Path location = decoder.location; - return (location != null) ? location.toUri() : null; - } - /** * Invoked when a non-fatal exception occurred while reading metadata. * This method sends a record to the registered listeners if any, @@ -661,7 +653,11 @@ split: while ((start = CharSequences.skipLeadingWhitespaces(value, start, lengt */ final String wkt = stringValue(GEOSPATIAL_BOUNDS); if (wkt != null) { - var parser = new StoreFormat(location(), null, null, decoder.geomlib, decoder.listeners); + var parser = new StoreFormat(null, null, decoder.geomlib, decoder.listeners); + final Path location = decoder.location; + if (location != null) { + parser.setSourceFile(location.toUri()); + } addBoundingPolygon(parser.parseGeometry(wkt, stringValue(GEOSPATIAL_BOUNDS + "_crs"), stringValue(GEOSPATIAL_BOUNDS + "_vertical_crs"))); diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java index 772ab836b9..7ae3a2d2a0 100644 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/PRJDataStore.java @@ -165,7 +165,7 @@ public abstract class PRJDataStore extends URIDataStore { throw new DataStoreException(s.getMessage(getLocale()), s.exception); } final String wkt = content.toString(); - final var format = new StoreFormat(content.getURI(), dataLocale, timezone, null, listeners); + final var format = new StoreFormat(dataLocale, timezone, null, listeners); format.setConvention(getConvention()); // Ignored if the format is WKT 2. try { format.setSourceFile(content.getURI()); @@ -213,7 +213,7 @@ public abstract class PRJDataStore extends URIDataStore { if (crs == null) { deleteAuxiliaryFile(PRJ); } else try (BufferedWriter out = writeAuxiliaryFile(PRJ)) { - final var format = new StoreFormat(null, dataLocale, timezone, null, listeners); + final var format = new StoreFormat(dataLocale, timezone, null, listeners); format.setConvention(Convention.WKT2_2015); // TODO: upgrade to newer version. format.format(crs, out); out.newLine(); diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/Store.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/Store.java index 544da67e8f..5bf89570cc 100644 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/Store.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/Store.java @@ -125,7 +125,8 @@ final class Store extends URIDataStore { * definitions. */ final var pos = new ParsePosition(0); - final var parser = new StoreFormat(location, dataLocale, timezone, library, listeners); + final var parser = new StoreFormat(dataLocale, timezone, library, listeners); + parser.setSourceFile(location); do { final Object obj = parser.parse(wkt, pos); objects.add(obj); diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java index fe4b4cf2a4..df464ea39f 100644 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java @@ -16,7 +16,6 @@ */ package org.apache.sis.storage.wkt; -import java.net.URI; import java.text.ParseException; import java.time.ZoneId; import java.util.Locale; @@ -63,19 +62,17 @@ public final class StoreFormat extends WKTFormat { * The given locale will be used for {@link InternationalString} localization; * this is <strong>not</strong> the locale for number format. * - * @param source the file being parsed, or {@code null} if unknown. * @param locale the locale for the new {@code Format}, or {@code null} for {@code Locale.ROOT}. * @param timezone the timezone, or {@code null} for UTC. * @param library the geometry library, or {@code null} for the default. * @param listeners where to send warnings. */ - public StoreFormat(final URI source, final Locale locale, final ZoneId timezone, + public StoreFormat(final Locale locale, final ZoneId timezone, final GeometryLibrary library, final StoreListeners listeners) { super(locale, timezone); this.library = library; this.listeners = listeners; - setSourceFile(source); } /**
