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 6619c1f Less misleading error messages when a datum shift grid such
as NTv2 can not be found. The previous message was saying that it can not be
read, which gave the impression that the file has been found but there were
some problem with it.
6619c1f is described below
commit 6619c1f1e8c733c8604abe497a252c34f8e58542
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sun Dec 8 21:57:47 2019 +0100
Less misleading error messages when a datum shift grid such as NTv2 can not
be found.
The previous message was saying that it can not be read, which gave the
impression that the file has been found but there were some problem with it.
---
.../apache/sis/internal/referencing/Resources.java | 17 ++++++++++++++-
.../sis/internal/referencing/Resources.properties | 3 +++
.../internal/referencing/Resources_fr.properties | 3 +++
.../sis/internal/referencing/package-info.java | 2 +-
.../referencing/provider/DatumShiftGridLoader.java | 25 +++++++++++++++++++---
.../provider/FranceGeocentricInterpolation.java | 5 +++--
.../java/org/apache/sis/util/resources/Errors.java | 9 ++------
.../apache/sis/util/resources/Errors.properties | 1 -
.../apache/sis/util/resources/Errors_fr.properties | 1 -
.../apache/sis/util/resources/package-info.java | 2 +-
10 files changed, 51 insertions(+), 17 deletions(-)
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
index c456c97..555b9cb 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
@@ -33,7 +33,7 @@ import
org.apache.sis.util.resources.ResourceInternationalString;
* by all modules in the Apache SIS project, see {@link
org.apache.sis.util.resources} package.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.1
* @since 0.8
* @module
*/
@@ -180,6 +180,11 @@ public final class Resources extends IndexedResourceBundle
{
public static final short CoordinateOperationNotFound_2 = 13;
/**
+ * Datum shift files are searched in the “{0}” directory.
+ */
+ public static final short DatumChangesDirectory_1 = 92;
+
+ /**
* Origin of temporal datum shall be a date.
*/
public static final short DatumOriginShallBeDate = 14;
@@ -213,6 +218,16 @@ public final class Resources extends IndexedResourceBundle
{
public static final short FallbackDefaultFactoryVersion_2 = 17;
/**
+ * Can not find {0} file named “{1}”.
+ */
+ public static final short FileNotFound_2 = 90;
+
+ /**
+ * Can not parse “{1}” as a file in the {0} format.
+ */
+ public static final short FileNotReadable_2 = 91;
+
+ /**
* {0} geodetic dataset version {1} on “{2}” version {3}.
*/
public static final short GeodeticDataBase_4 = 18;
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
index 854340c..422e471 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
+++
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
@@ -62,10 +62,13 @@ CanNotTransformGeometry = Can not transform the
given geometry.
CanNotUseGeodeticParameters_2 = Can not use the {0} geodetic parameters:
{1}
ColinearAxisDirections_2 = Axis directions {0} and {1} are colinear.
CoordinateOperationNotFound_2 = Coordinate conversion of transformation
from system \u201c{0}\u201d to \u201c{1}\u201d has not been found.
+DatumChangesDirectory_1 = Datum shift files are searched in the
\u201c{0}\u201d directory.
DatumOriginShallBeDate = Origin of temporal datum shall be a date.
DuplicatedParameterName_4 = Name or alias for parameter
\u201c{0}\u201d at index {1} conflict with name \u201c{2}\u201d at index {3}.
DuplicatedSpatialComponents_1 = Compound coordinate reference systems can
not contain two {0,choice,1#horizontal|2#vertical} components.
EllipsoidalHeightNotAllowed_1 = Compound coordinate reference systems
should not contain ellipsoidal height. Use a three-dimensional
{0,choice,0#geographic|1#projected} system instead.
+FileNotFound_2 = Can not find {0} file named
\u201c{1}\u201d.
+FileNotReadable_2 = Can not parse \u201c{1}\u201d as a file in
the {0} format.
IllegalAxisDirection_2 = Coordinate system of class \u2018{0}\u2019
can not have axis in the {1} direction.
IllegalOperationDimension_3 = Dimensions of \u201c{0}\u201d operation
can not be ({1} \u2192 {2}).
IllegalOperationForValueClass_1 = This operation can not be applied to
values of class \u2018{0}\u2019.
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
index 7a32d59..3c1977e 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
+++
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
@@ -67,10 +67,13 @@ CanNotTransformGeometry = Ne peut pas transformer
la g\u00e9om\u00e9tr
CanNotUseGeodeticParameters_2 = Ne peut pas utiliser les param\u00e8tres
g\u00e9od\u00e9siques {0}\u202f: {1}
ColinearAxisDirections_2 = Les directions d\u2019axes {0} et {1} sont
colin\u00e9aires.
CoordinateOperationNotFound_2 = La conversion ou transformation des
coordonn\u00e9es du syst\u00e8me \u00ab\u202f{0}\u202f\u00bb vers
\u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e.
+DatumChangesDirectory_1 = Les fichiers de changements de
r\u00e9f\u00e9rentiel sont cherch\u00e9s dans le dossier
\u00ab\u202f{0}\u202f\u00bb.
DatumOriginShallBeDate = L\u2019origine d\u2019un
r\u00e9f\u00e9rentiel temporel doit \u00eatre une date.
DuplicatedParameterName_4 = Le nom ou un alias pour le param\u00e8tre
\u00ab\u202f{0}\u202f\u00bb \u00e0 l\u2019index {1} duplique le nom
\u00ab\u202f{2}\u202f\u00bb \u00e0 l\u2019index {3}.
DuplicatedSpatialComponents_1 = Un syst\u00e8me de r\u00e9f\u00e9rence des
coordonn\u00e9es ne peut pas contenir deux composantes
{0,choice,1#horizontales|2#verticales}.
EllipsoidalHeightNotAllowed_1 = Un syst\u00e8me de r\u00e9f\u00e9rence des
coordonn\u00e9es ne devrait pas contenir une hauteur ellipso\u00efdale.
Utilisez plut\u00f4t un syst\u00e8me
{0,choice,0#g\u00e9ographique|1#projet\u00e9} \u00e0 trois dimensions.
+FileNotFound_2 = Ne peut pas trouver le fichier {0}
nomm\u00e9 \u00ab\u202f{1}\u202f\u00bb.
+FileNotReadable_2 = Ne peut pas lire
\u00ab\u202f{1}\u202f\u00bb comme un fichier au format {0}.
IllegalAxisDirection_2 = Les syst\u00e8mes de coordonn\u00e9es de
classe \u2018{0}\u2019 ne peuvent pas avoir d\u2019axe dans la direction
\u00ab\u202f{1}\u202f\u00bb.
IllegalOperationDimension_3 = Les dimensions de l\u2019op\u00e9ration
\u00ab\u202f{0}\u202f\u00bb ne peuvent pas \u00eatre ({1} \u2192 {2}).
IllegalOperationForValueClass_1 = Cette op\u00e9ration ne peut pas
s\u2019appliquer aux valeurs de classe \u2018{0}\u2019.
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java
index 7ac0596..f279037 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java
@@ -24,7 +24,7 @@
* may change in incompatible ways in any future version without notice.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
* @since 0.3
* @module
*/
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
index f701d51..35d65a0 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
@@ -18,6 +18,7 @@ package org.apache.sis.internal.referencing.provider;
import java.util.logging.Level;
import java.util.logging.LogRecord;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -28,6 +29,7 @@ import org.opengis.util.FactoryException;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.internal.system.DataDirectory;
import org.apache.sis.internal.referencing.Resources;
import org.apache.sis.referencing.factory.FactoryDataException;
import org.apache.sis.referencing.factory.MissingFactoryResourceException;
@@ -37,7 +39,7 @@ import
org.apache.sis.referencing.factory.MissingFactoryResourceException;
* Base class of datum shift grid loaders.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.1
* @since 0.7
* @module
*/
@@ -80,6 +82,12 @@ class DatumShiftGridLoader {
final ByteBuffer buffer;
/**
+ * Whether the tip about the location of datum shift files has been logged.
+ * We log this tip only once, and only if we failed to load at least one
grid.
+ */
+ private static final AtomicBoolean datumDirectoryLogged = new
AtomicBoolean();
+
+ /**
* Creates a new loader for the given channel and an existing buffer.
*
* @param channel where to read data from.
@@ -157,8 +165,19 @@ class DatumShiftGridLoader {
* @param cause the cause of the failure to load the grid file.
*/
static FactoryException canNotLoad(final String format, final Path file,
final Exception cause) {
- final String message = Errors.format(Errors.Keys.CanNotParseFile_2,
format, file);
- if (cause instanceof NoSuchFileException) {
+ 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);
+ record.setLoggerName(Loggers.COORDINATE_OPERATION);
+ Logging.log(DatumShiftGridLoader.class, "readGrid", record);
// "readGrid" is actually defined by subclasses.
+ }
+ }
+ final boolean notFound = (cause instanceof NoSuchFileException);
+ final String message = Resources.format(notFound ?
Resources.Keys.FileNotFound_2
+ :
Resources.Keys.FileNotReadable_2, format, file);
+ if (notFound) {
return new MissingFactoryResourceException(message, cause);
} else {
return new FactoryDataException(message, cause);
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
index 453fa3c..5e9c8cb 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
@@ -44,6 +44,7 @@ import org.opengis.util.FactoryException;
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.internal.system.DataDirectory;
import org.apache.sis.internal.referencing.NilReferencingObject;
+import org.apache.sis.internal.referencing.Resources;
import org.apache.sis.parameter.ParameterBuilder;
import org.apache.sis.parameter.Parameters;
import org.apache.sis.measure.Units;
@@ -81,7 +82,7 @@ import static java.lang.Float.parseFloat;
*
* @author Simon Reynard (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.1
* @since 0.7
* @module
*/
@@ -444,7 +445,7 @@ public class FranceGeocentricInterpolation extends
GeodeticOperation {
}
}
if (grid == null) {
- throw new
FactoryException(Errors.format(Errors.Keys.CanNotParseFile_2, HEADER, file));
+ throw new
FactoryException(Resources.format(Resources.Keys.FileNotFound_2, HEADER, file));
}
/*
* Loads the data with the sign of all offsets reversed. Data columns
are
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
index 520093d..660817e 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
@@ -36,7 +36,7 @@ import org.opengis.util.InternationalString;
* as they want.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.1
* @since 0.3
* @module
*/
@@ -126,11 +126,6 @@ public final class Errors extends IndexedResourceBundle {
public static final short CanNotOpen_1 = 9;
/**
- * Can not parse “{1}” as a file in the {0} format.
- */
- public static final short CanNotParseFile_2 = 10;
-
- /**
* Can not parse “{0}”.
*/
public static final short CanNotParse_1 = 180;
@@ -491,7 +486,7 @@ public final class Errors extends IndexedResourceBundle {
/**
* Integer overflow during {0} bits arithmetic operation.
*/
- public static final short IntegerOverflow_1 = 188;
+ public static final short IntegerOverflow_1 = 10;
/**
* “{0}” is an invalid version identifier.
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
index b69913a..eceebee 100644
---
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
+++
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
@@ -37,7 +37,6 @@ CanNotCompute_1 = Can not compute
\u201c{0}\u201d.
CanNotCopy_1 = Can not copy \u201c{0}\u201d.
CanNotOpen_1 = Can not open \u201c{0}\u201d.
CanNotParse_1 = Can not parse \u201c{0}\u201d.
-CanNotParseFile_2 = Can not parse \u201c{1}\u201d as a file in
the {0} format.
CanNotProcessProperty_2 = Can not process property \u201c{0}\u201d.
The reason is: {1}
CanNotProcessPropertyAtPath_3 = Can not process property \u201c{1}\u201d
located at path \u201c{0}\u201d. The reason is: {2}
CanNotRead_1 = Can not read \u201c{0}\u201d.
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
index 8bc217f..f117a20 100644
---
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
+++
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
@@ -34,7 +34,6 @@ CanNotCompute_1 = Ne peut pas calculer
\u00ab\u202f{0}\u202f\u
CanNotCopy_1 = Ne peut pas copier
\u00ab\u202f{0}\u202f\u00bb.
CanNotOpen_1 = Ne peut pas ouvrir
\u00ab\u202f{0}\u202f\u00bb.
CanNotParse_1 = Ne peut pas interpr\u00e9ter
\u00ab\u202f{0}\u202f\u00bb.
-CanNotParseFile_2 = Ne peut pas lire
\u00ab\u202f{1}\u202f\u00bb comme un fichier au format {0}.
CanNotProcessProperty_2 = Ne peut pas traiter la propri\u00e9t\u00e9
\u00ab\u202f{0}\u202f\u00bb pour la raison suivante\u2008: {1}
CanNotProcessPropertyAtPath_3 = Ne peut pas traiter la propri\u00e9t\u00e9
\u00ab\u202f{1}\u202f\u00bb d\u00e9sign\u00e9e par le chemin
\u00ab\u202f{0}\u202f\u00bb pour la raison suivante\u2008: {2}
CanNotRead_1 = Ne peut pas lire
\u00ab\u202f{0}\u202f\u00bb.
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
index a147b2c..d5fd5da 100644
---
a/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
+++
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
@@ -83,7 +83,7 @@
* </ul>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
*
* @see java.util.ResourceBundle
* @see java.text.MessageFormat