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
commit 1c5de085a49e1f419e287a1038c1820fa80b8678 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Dec 25 21:33:16 2023 +0100 Declare the provider as the source of warning in `DatumShiftGridLoader.canNotLoad(…)`. --- .../sis/referencing/operation/provider/DatumShiftGridFile.java | 2 +- .../referencing/operation/provider/DatumShiftGridLoader.java | 10 ++++------ .../operation/provider/FranceGeocentricInterpolation.java | 4 ++-- .../org/apache/sis/referencing/operation/provider/NADCON.java | 2 +- .../org/apache/sis/referencing/operation/provider/NTv2.java | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridFile.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridFile.java index 173bf4a8f9..2b8c69c9bd 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridFile.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridFile.java @@ -257,7 +257,7 @@ abstract class DatumShiftGridFile<C extends Quantity<C>, T extends Quantity<T>> * @throws Exception if an error occurred while loading the grid. * Caller should handle the exception with {@code canNotLoad(…)}. * - * @see DatumShiftGridLoader#canNotLoad(String, URI, Exception) + * @see DatumShiftGridLoader#canNotLoad(Class, String, URI, Exception) */ static DatumShiftGridFile<?,?> getOrLoad(final URI f1, final URI f2, final Callable<DatumShiftGridFile<?,?>> loader) throws Exception diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridLoader.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridLoader.java index 516e7b804e..eb4b6c6530 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridLoader.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/DatumShiftGridLoader.java @@ -226,19 +226,17 @@ abstract class DatumShiftGridLoader { /** * Creates the exception to throw when the provider failed to load the grid file. * + * @param caller the provider to logs as the source class if a warning occurs. * @param format the format name (e.g. "NTv2" or "NADCON"). * @param file the grid file that the subclass tried to load. * @param cause the cause of the failure to load the grid file. */ - public static FactoryException canNotLoad(final String format, final URI file, final Exception cause) { + public static FactoryException canNotLoad(final Class<?> caller, final String format, final URI file, final Exception cause) { if (!datumDirectoryLogged.get()) { final Path directory = DataDirectory.DATUM_CHANGES.getDirectory(); if (directory != null && !datumDirectoryLogged.getAndSet(true)) { - final LogRecord record = Resources.forLocale(null).getLogRecord( - Level.INFO, Resources.Keys.DatumChangesDirectory_1, directory); - - // "readGrid" is actually defined by subclasses. - Logging.completeAndLog(AbstractProvider.LOGGER, DatumShiftGridLoader.class, "readGrid", record); + log(caller, Resources.forLocale(null).getLogRecord(Level.INFO, + Resources.Keys.DatumChangesDirectory_1, directory)); } } final boolean notFound = (cause instanceof NoSuchFileException) || (cause instanceof FileNotFoundException); diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java index f96ee96f8c..e45e3bf626 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java @@ -346,7 +346,7 @@ public final class FranceGeocentricInterpolation extends GeodeticOperation { grid = getOrLoad(file, isRecognized(file) ? new double[] {TX, TY, TZ} : null, PRECISION); } catch (Exception e) { // NumberFormatException, ArithmeticException, NoSuchElementException, and more. - throw DatumShiftGridLoader.canNotLoad(HEADER, file, e); + throw DatumShiftGridLoader.canNotLoad(FranceGeocentricInterpolation.class, HEADER, file, e); } MathTransform tr = InterpolatedGeocentricTransform.createGeodeticTransformation(factory, createEllipsoid(pg, Molodensky.TGT_SEMI_MAJOR, @@ -371,7 +371,7 @@ public final class FranceGeocentricInterpolation extends GeodeticOperation { * @throws Exception if an error occurred while loading the grid. * Caller should handle the exception with {@code canNotLoad(…)}. * - * @see DatumShiftGridLoader#canNotLoad(String, URI, Exception) + * @see DatumShiftGridLoader#canNotLoad(Class, String, URI, Exception) */ static DatumShiftGridFile<Angle,Length> getOrLoad(final URI file, final double[] averages, final double scale) throws Exception diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java index 242c09f927..1039770b15 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java @@ -185,7 +185,7 @@ public final class NADCON extends AbstractProvider { * Handle the exception here instead of by the caller * because we know which of the 2 files is problematic. */ - throw DatumShiftGridLoader.canNotLoad("NADCON", file, e); + throw DatumShiftGridLoader.canNotLoad(NADCON.class, "NADCON", file, e); } grid = DatumShiftGridCompressed.compress(loader.grid, null, loader.grid.accuracy); return grid.useSharedData(); diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java index aa3d3412a1..1c4911634b 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java @@ -146,7 +146,7 @@ public final class NTv2 extends AbstractProvider { try { grid = getOrLoad(provider, file, version); } catch (Exception e) { - throw DatumShiftGridLoader.canNotLoad(provider.getSimpleName(), file, e); + throw DatumShiftGridLoader.canNotLoad(provider, provider.getSimpleName(), file, e); } return DatumShiftGridFile.createGeodeticTransformation(provider, factory, grid); }