You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2022/04/03 16:09:36 UTC
[sis] branch geoapi-4.0 updated (3bb589a -> 1b0c4e2)
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git.
from 3bb589a Complete the ASCII Grid reader implementation.
new 7d3a1bcb Store ASCII Grid data as single (instead of double) precision floating point values.
new c351e03 Move `DEFAULT_CRS` from `OptionKey` to `DataOptionKey`. Conceptually, CRS is more about the data than the carrier format.
new 1b0c4e2 Make a better effort for saying in which object a property was missing. Minor formatting in comments.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/sis/internal/metadata/Identifiers.java | 20 +++++++++++++++--
.../sis/internal/metadata/MetadataUtilities.java | 4 ++--
.../apache/sis/internal/metadata/package-info.java | 2 +-
.../iso/extent/DefaultGeographicBoundingBox.java | 12 +++++-----
.../referencing/CC_GeneralOperationParameter.java | 18 +++++++--------
.../jaxb/referencing/CC_OperationMethod.java | 8 +++----
.../sis/referencing/AbstractIdentifiedObject.java | 2 +-
.../sis/referencing/ImmutableIdentifier.java | 2 +-
.../sis/referencing/crs/AbstractDerivedCRS.java | 15 +++++++------
.../operation/AbstractSingleOperation.java | 6 ++---
.../main/java/org/apache/sis/setup/OptionKey.java | 14 +-----------
.../apache/sis/internal/storage/PRJDataStore.java | 26 +++++++++++-----------
.../apache/sis/internal/storage/ascii/Store.java | 8 +++----
.../java/org/apache/sis/storage/DataOptionKey.java | 14 +++++++++++-
14 files changed, 84 insertions(+), 67 deletions(-)
[sis] 03/03: Make a better effort for saying in which object a property was missing. Minor formatting in comments.
Posted by de...@apache.org.
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 1b0c4e2c6e43efde7afdaae320e4d88ace015b2d
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Apr 3 17:05:42 2022 +0200
Make a better effort for saying in which object a property was missing.
Minor formatting in comments.
---
.../apache/sis/internal/metadata/Identifiers.java | 20 ++++++++++++++++++--
.../sis/internal/metadata/MetadataUtilities.java | 4 ++--
.../apache/sis/internal/metadata/package-info.java | 2 +-
.../iso/extent/DefaultGeographicBoundingBox.java | 12 ++++++------
.../referencing/CC_GeneralOperationParameter.java | 18 +++++++++---------
.../jaxb/referencing/CC_OperationMethod.java | 8 ++++----
.../sis/referencing/AbstractIdentifiedObject.java | 2 +-
.../apache/sis/referencing/ImmutableIdentifier.java | 2 +-
.../sis/referencing/crs/AbstractDerivedCRS.java | 15 ++++++++-------
.../operation/AbstractSingleOperation.java | 6 +++---
10 files changed, 53 insertions(+), 36 deletions(-)
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
index 925c378..c764dee 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Identifiers.java
@@ -27,13 +27,14 @@ import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Characters;
import org.apache.sis.util.Deprecable;
import org.apache.sis.util.Static;
+import org.apache.sis.util.resources.Errors;
/**
* Methods working on {@link Identifier} instances.
*
* @author Martin Desruisseaux (Geomatys)
- * @since 1.1
+ * @since 1.2
* @version 1.0
* @module
*/
@@ -110,7 +111,7 @@ public final class Identifiers extends Static {
*/
public static String getIdentifier(final Citation citation, final boolean strict) {
if (citation != null) {
- boolean isUnicode = false; // Whether 'identifier' is a Unicode identifier.
+ boolean isUnicode = false; // Whether `identifier` is a Unicode identifier.
String identifier = null; // The best identifier found so far.
String codeSpace = null; // Code space of the identifier, or null if none.
for (final Identifier id : CollectionsExt.nonNull(citation.getIdentifiers())) {
@@ -263,4 +264,19 @@ public final class Identifiers extends Static {
}
return null;
}
+
+ /**
+ * Returns a message saying that a property is missing for an object having the given identifier.
+ *
+ * @param owner identifier of the object for which a property is missing.
+ * @param property name of the missing property.
+ * @return a message saying that a value is missing for the given property in the specified identified object.
+ *
+ * @since 1.2
+ */
+ public static String missingValueForProperty(final Identifier owner, final String property) {
+ return (owner == null)
+ ? Errors.format(Errors.Keys.MissingValueForProperty_1, property)
+ : Errors.format(Errors.Keys.MissingValueForProperty_2, owner, property);
+ }
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
index f8fab9c..087cf45 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
@@ -100,7 +100,7 @@ public final class MetadataUtilities extends Static {
{
if (newValue != null) {
final double value = newValue.doubleValue();
- if (!(strict ? value > 0 : value >= 0)) { // Use '!' for catching NaN.
+ if (!(strict ? value > 0 : value >= 0)) { // Use `!` for catching NaN.
if (NilReason.forObject(newValue) == null) {
final String msg = logOrFormat(classe, property, strict
? Errors.Keys.ValueNotGreaterThanZero_2
@@ -134,7 +134,7 @@ public final class MetadataUtilities extends Static {
{
if (newValue != null) {
final double value = newValue.doubleValue();
- if (!(value >= minimum.doubleValue() && value <= maximum.doubleValue())) { // Use '!' for catching NaN.
+ if (!(value >= minimum.doubleValue() && value <= maximum.doubleValue())) { // Use `!` for catching NaN.
if (NilReason.forObject(newValue) == null) {
final String msg = logOrFormat(classe, property,
Errors.Keys.ValueOutOfRange_4, property, minimum, maximum, newValue);
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/package-info.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/package-info.java
index e77da0c..3aa3f67 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/package-info.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/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.2
* @since 0.3
* @module
*/
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
index db059d0..7bfdfa7 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
@@ -264,7 +264,7 @@ public class DefaultGeographicBoundingBox extends AbstractGeographicExtent imple
final boolean p = value;
/*
* (value == Boolean.FALSE) is an optimization for a common case avoiding PrimitiveTypeProperties check.
- * DO NOT REPLACE BY 'equals' OR 'booleanValue()' - the exact reference value matter.
+ * DO NOT REPLACE BY `equals` OR `booleanValue()` — the exact reference value matter.
*/
if (p || (value == Boolean.FALSE) || !(PrimitiveTypeProperties.property(value) instanceof NilReason)) {
return p;
@@ -442,7 +442,7 @@ public class DefaultGeographicBoundingBox extends AbstractGeographicExtent imple
southBoundLatitude = Latitude.clamp(southBoundLatitude);
northBoundLatitude = Latitude.clamp(northBoundLatitude);
final double span = eastBoundLongitude - westBoundLongitude;
- if (!(span >= (Longitude.MAX_VALUE - Longitude.MIN_VALUE))) { // 'span' may be NaN.
+ if (!(span >= (Longitude.MAX_VALUE - Longitude.MIN_VALUE))) { // `span` may be NaN.
westBoundLongitude = Longitude.normalize(westBoundLongitude);
eastBoundLongitude = Longitude.normalize(eastBoundLongitude);
if (span != 0) {
@@ -596,14 +596,14 @@ public class DefaultGeographicBoundingBox extends AbstractGeographicExtent imple
* the result would be much wort (for each lower rectangle, imagine translating
* the longuest part in the opposite direction instead of the shortest one).
*
- * Note that only one of 'left' and 'right' can be positive, otherwise we would
+ * Note that only one of `left` and `right` can be positive, otherwise we would
* not be in the case where one box is crossing the anti-meridian while the other
* box does not.
*/
if (left >= 0) return +1;
if (right >= 0) return -1;
/*
- * Both 'left' and 'right' are negative. For each alternatives (translating λmin
+ * Both `left` and `right` are negative. For each alternatives (translating λmin
* or translating λmax), we will choose the one which give the closest result to
* a bound of this box:
*
@@ -618,7 +618,7 @@ public class DefaultGeographicBoundingBox extends AbstractGeographicExtent imple
return (left < right) ? -1 : +1;
}
/*
- * Same algorithm than above, but with the sign of 'left' an 'right' inversed.
+ * Same algorithm than above, but with the sign of `left` an `right` inversed.
* The "if" statements have been combined for avoiding to repeat the +/- operations.
*/
if (!(left <= 0) && right <= 0 || left > right) {
@@ -665,7 +665,7 @@ public class DefaultGeographicBoundingBox extends AbstractGeographicExtent imple
double φmin = box.getSouthBoundLatitude();
double φmax = box.getNorthBoundLatitude();
/*
- * Reminder: 'inclusion' is a mandatory attribute, so it should never be null for a
+ * Reminder: `inclusion` is a mandatory attribute, so it should never be null for a
* valid metadata object. If the metadata object is invalid, it is better to get a
* an exception than having a code doing silently some inappropriate work.
*/
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
index a51e119..f3ecbd4 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
@@ -186,7 +186,7 @@ public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralO
if (min instanceof Number) {
final Comparable<?> max = descriptor.getMaximumValue();
if (max instanceof Number) {
- // Compare as 'double' because we want (-0 == +0) to be true.
+ // Compare as `double` because we want (-0 == +0) to be true.
return ((Number) min).doubleValue() == ((Number) max).doubleValue();
}
}
@@ -247,7 +247,7 @@ public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralO
* assuming that the additional properties are acceptable.
*
* We make an exception to the above rule if the existing instance put a possibly too strong
- * restriction on the parameter values. See 'isRestricted(…)' for more information.
+ * restriction on the parameter values. See `isRestricted(…)` for more information.
*/
if (!isRestricted((ParameterDescriptor<?>) complete)) {
return complete;
@@ -255,7 +255,7 @@ public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralO
}
/*
* Collect the properties specified in the GML document and complete with the properties provided
- * by the 'complete' descriptor. If the descriptor is a group, then this 'replacement' method will
+ * by the `complete` descriptor. If the descriptor is a group, then this `replacement` method will
* be invoked recursively for each parameter in the group.
*/
final Map<String,Object> merged = new HashMap<>(expected);
@@ -303,11 +303,11 @@ public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralO
final GeneralParameterDescriptor p = provided[i];
try {
/*
- * Replace the descriptors provided in the GML document by descriptors from the 'complete' instance,
+ * Replace the descriptors provided in the GML document by descriptors from the `complete` instance,
* if possible. Keep trace of the complete descriptors that we found in this process.
*/
GeneralParameterDescriptor predefined = complete.descriptor(p.getName().getCode());
- if (predefined != null) { // Safety in case 'complete' is a user's implementation.
+ if (predefined != null) { // Safety in case `complete` is a user's implementation.
canSubstitute &= (provided[i] = merge(p, predefined)) == predefined;
if (!included.add(predefined)) {
throw new CorruptedObjectException(predefined); // Broken hashCode/equals, or object mutated.
@@ -325,7 +325,7 @@ public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralO
(caller == DefaultParameterValueGroup.class) ? "setValues" : "setDescriptors", e, canSubstitute);
}
/*
- * If a parameter was not found in the 'complete' descriptor, we will not be able to use that descriptor.
+ * If a parameter was not found in the `complete` descriptor, we will not be able to use that descriptor.
* But we may still be able to use its properties (name, alias, identifier) provided that the parameter
* not found was optional.
*/
@@ -334,7 +334,7 @@ public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralO
}
if (isCompatible) {
/*
- * At this point, we determined that all mandatory parameters in the GML document exist in the 'complete'
+ * At this point, we determined that all mandatory parameters in the GML document exist in the `complete`
* descriptor. However the converse is not necessarily true. Verify that all parameters missing in the GML
* document were optional.
*/
@@ -427,9 +427,9 @@ public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralO
T[] complete = (T[]) merged.get(key);
if (complete != null) {
/*
- * Add the 'provided' values before 'complete' for two reasons:
+ * Add the `provided` values before `complete` for two reasons:
* 1) Use the same insertion order than the declaration order in the GML file.
- * 2) Replace 'provided' instances by 'complete' instances, since the latter
+ * 2) Replace `provided` instances by `complete` instances, since the latter
* are sometime pre-defined instances defined as static final constants.
*/
final Map<NamedIdentifier,T> c = new LinkedHashMap<>();
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
index 83e3f64..5ec514f 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
@@ -32,6 +32,7 @@ import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.referencing.operation.OperationMethod;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.internal.jaxb.gco.PropertyType;
+import org.apache.sis.internal.metadata.Identifiers;
import org.apache.sis.internal.referencing.CoordinateOperations;
import org.apache.sis.internal.referencing.provider.MapProjection;
import org.apache.sis.parameter.DefaultParameterValue;
@@ -39,7 +40,6 @@ import org.apache.sis.parameter.DefaultParameterValueGroup;
import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
import org.apache.sis.referencing.operation.DefaultOperationMethod;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.ArraysExt;
@@ -48,7 +48,7 @@ import org.apache.sis.util.ArraysExt;
* package documentation for more information about JAXB and interface.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.2
* @since 0.6
* @module
*/
@@ -113,7 +113,7 @@ public final class CC_OperationMethod extends PropertyType<CC_OperationMethod, O
* Parameters are mandatory and SIS classes need them. Provide an error message
* here instead of waiting for a NullPointerException in some arbitrary place.
*/
- throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingValueForProperty_1, "parameters"));
+ throw new IllegalArgumentException(Identifiers.missingValueForProperty(method.getName(), "parameters"));
}
metadata = method;
}
@@ -191,7 +191,7 @@ public final class CC_OperationMethod extends PropertyType<CC_OperationMethod, O
if (method != null) {
/*
* Verify that the pre-defined operation method contains at least all the parameters specified by
- * the 'descriptors' array. If this is the case, then the pre-defined parameters will be used in
+ * the `descriptors` array. If this is the case, then the pre-defined parameters will be used in
* replacement of the given ones.
*/
final ParameterDescriptorGroup parameters = method.getParameters();
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
index 3420131..650f1cc 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
@@ -1084,7 +1084,7 @@ public class AbstractIdentifiedObject extends FormattableObject implements Ident
} else {
/*
* Our Code and RS_Identifier implementations should always create NamedIdentifier instance,
- * so the 'instanceof' check should not be necessary. But we do a paranoiac check anyway.
+ * so the `instanceof` check should not be necessary. But we do a paranoiac check anyway.
*/
final GenericName n = id instanceof GenericName ? (GenericName) id : new NamedIdentifier(id);
if (alias == null) {
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/ImmutableIdentifier.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/ImmutableIdentifier.java
index 97de5bb..2cb778b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/ImmutableIdentifier.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/ImmutableIdentifier.java
@@ -465,7 +465,7 @@ public class ImmutableIdentifier extends FormattableObject implements Identifier
* The code, codeSpace, authority and version local variables in this method usually have the exact same
* value than the fields of the same name in this class. But we get those values by invoking the public
* methods in order to give to users a chance to override those properties. The intent is also to use a
- * consistent approach for all 'formatTo' implementations, since some other classes have no choice other
+ * consistent approach for all `formatTo` implementations, since some other classes have no choice other
* than using the public methods.
*/
final String code = getCode();
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
index 6824cfc..5c8fdb5 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
@@ -38,6 +38,7 @@ import org.apache.sis.referencing.operation.DefaultConversion;
import org.apache.sis.internal.jaxb.referencing.CC_Conversion;
import org.apache.sis.internal.referencing.ReferencingFactoryContainer;
import org.apache.sis.internal.metadata.MetadataUtilities;
+import org.apache.sis.internal.metadata.Identifiers;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.system.Semaphores;
import org.apache.sis.util.resources.Errors;
@@ -53,7 +54,7 @@ import static org.apache.sis.util.Utilities.deepEquals;
* (not by a {@linkplain org.apache.sis.referencing.datum.AbstractDatum datum}).
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 1.1
+ * @version 1.2
*
* @param <C> the conversion type, either {@code Conversion} or {@code Projection}.
*
@@ -223,7 +224,7 @@ abstract class AbstractDerivedCRS<C extends Conversion> extends AbstractCRS impl
if (super.equals(object, mode)) {
final boolean strict = (mode == ComparisonMode.STRICT);
/*
- * Avoid never-ending recursivity: Conversion has a 'targetCRS' field (inherited from
+ * Avoid never-ending recursivity: Conversion has a `targetCRS` field (inherited from
* the AbstractCoordinateOperation super-class) that is set to this AbstractDerivedCRS.
*
* Do NOT compare the baseCRS explicitly. This is done implicitely in the comparison of the Conversion
@@ -254,8 +255,8 @@ abstract class AbstractDerivedCRS<C extends Conversion> extends AbstractCRS impl
@Override
protected long computeHashCode() {
/*
- * Do not invoke 'conversionFromBase.hashCode()' in order to avoid a never-ending loop.
- * This is because Conversion inherits a 'sourceCRS' field from the CoordinateOperation
+ * Do not invoke `conversionFromBase.hashCode()` in order to avoid a never-ending loop.
+ * This is because Conversion inherits a `sourceCRS` field from the CoordinateOperation
* parent type, which is set to this DerivedCRS. Checking the OperationMethod does not
* work neither for the reason documented inside the AbstractSingleOperation.equals(…)
* method body. The MathTransform is our best discriminant.
@@ -345,10 +346,10 @@ abstract class AbstractDerivedCRS<C extends Conversion> extends AbstractCRS impl
}
}
/*
- * If we reach this point, we failed to update the conversion. The 'baseCRS' information will be lost
- * and call to 'getConversionFromBase()' will throw a ClassCastException if this instance is actually
+ * If we reach this point, we failed to update the conversion. The `baseCRS` information will be lost
+ * and call to `getConversionFromBase()` will throw a ClassCastException if this instance is actually
* a ProjectedCRS (because of the method overriding with return type covariance).
*/
- throw new ValidationException(Errors.format(Errors.Keys.MissingValueForProperty_1, property));
+ throw new ValidationException(Identifiers.missingValueForProperty(getName(), property));
}
}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
index 969b1b2..cd6eacb 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
@@ -45,8 +45,8 @@ import org.apache.sis.internal.referencing.CoordinateOperations;
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.metadata.MetadataUtilities;
import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.metadata.Identifiers;
import org.apache.sis.util.collection.Containers;
-import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ComparisonMode;
@@ -64,7 +64,7 @@ import static org.apache.sis.util.Utilities.deepEquals;
* {@link DefaultPassThroughOperation}.</p>
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.2
* @since 0.6
* @module
*/
@@ -346,7 +346,7 @@ class AbstractSingleOperation extends AbstractCoordinateOperation implements Sin
private void setParameters(final GeneralParameterValue[] values) {
if (parameters == null) {
if (!(method instanceof DefaultOperationMethod)) { // May be a non-null proxy if defined only by xlink:href.
- throw new IllegalStateException(Errors.format(Errors.Keys.MissingValueForProperty_1, "method"));
+ throw new IllegalStateException(Identifiers.missingValueForProperty(getName(), "method"));
}
/*
* The descriptors in the <gml:method> element do not know the class of parameter value
[sis] 02/03: Move `DEFAULT_CRS` from `OptionKey` to `DataOptionKey`. Conceptually, CRS is more about the data than the carrier format.
Posted by de...@apache.org.
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 c351e038b5d6c83a41b6f6b559d17238b5cfd7b4
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Apr 3 16:04:43 2022 +0200
Move `DEFAULT_CRS` from `OptionKey` to `DataOptionKey`.
Conceptually, CRS is more about the data than the carrier format.
---
.../main/java/org/apache/sis/setup/OptionKey.java | 14 +-----------
.../apache/sis/internal/storage/PRJDataStore.java | 26 +++++++++++-----------
.../java/org/apache/sis/storage/DataOptionKey.java | 14 +++++++++++-
3 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
index 54911c6..8aebfad 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
@@ -29,7 +29,6 @@ import java.util.TimeZone;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Modules;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
/**
@@ -62,7 +61,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
* }
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 0.8
*
* @param <T> the type of option values.
*
@@ -193,17 +192,6 @@ public class OptionKey<T> implements Serializable {
public static final OptionKey<GeometryLibrary> GEOMETRY_LIBRARY = new OptionKey<>("GEOMETRY_LIBRARY", GeometryLibrary.class);
/**
- * The coordinate reference system (CRS) of data to use if not explicitly defined.
- * This option can be used when the file to read does not describe itself the data CRS.
- * For example this option can be used when reading ASCII Grid without CRS information,
- * but is ignored if the ASCII Grid file is accompanied by a {@code *.prj} file giving the CRS.
- *
- * @since 1.2
- */
- public static final OptionKey<CoordinateReferenceSystem> DEFAULT_CRS =
- new OptionKey<>("DEFAULT_CRS", CoordinateReferenceSystem.class);
-
- /**
* The number of spaces to use for indentation when formatting text files in WKT or XML formats.
* A value of {@value org.apache.sis.io.wkt.WKTFormat#SINGLE_LINE} means to format the whole WKT
* or XML document on a single line without line feeds or indentation.
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java
index f339599..0a5a548 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java
@@ -34,6 +34,7 @@ import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.storage.DataOptionKey;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.DataStoreProvider;
@@ -43,7 +44,6 @@ import org.apache.sis.internal.storage.wkt.StoreFormat;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.parameter.ParameterBuilder;
import org.apache.sis.parameter.Parameters;
-import org.apache.sis.setup.OptionKey;
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ArraysExt;
@@ -51,13 +51,13 @@ import org.apache.sis.util.ArraysExt;
/**
* A data store for a file or URI accompanied by an auxiliary file of the same name with {@code .prj} extension.
- * If the auxiliary file is absent, {@link OptionKey#DEFAULT_CRS} is used as a fallback.
+ * If the auxiliary file is absent, {@link DataOptionKey#DEFAULT_CRS} is used as a fallback.
* The WKT 1 variant used for parsing the {@code "*.prj"} file is the variant used by "World Files" and GDAL;
* this is not the standard specified by OGC 01-009 (they differ in there interpretation of units of measurement).
*
* <p>It is still possible to create a data store with a {@link java.nio.channels.ReadableByteChannel},
* {@link java.io.InputStream} or {@link java.io.Reader}, in which case the {@linkplain #location} will
- * be null and the CRS defined by the {@code OptionKey} will be used.</p>
+ * be null and the CRS defined by the {@code DataOptionKey} will be used.</p>
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.2
@@ -92,7 +92,7 @@ public abstract class PRJDataStore extends URIDataStore {
private final TimeZone timezone;
/**
- * The coordinate reference system. This is initialized on the value provided by {@link OptionKey#DEFAULT_CRS}
+ * The coordinate reference system. This is initialized on the value provided by {@link DataOptionKey#DEFAULT_CRS}
* at construction time, and is modified later if a {@code "*.prj"} file is found.
*/
protected CoordinateReferenceSystem crs;
@@ -101,10 +101,10 @@ public abstract class PRJDataStore extends URIDataStore {
* Creates a new data store. The following options are recognized:
*
* <ul>
- * <li>{@link OptionKey#DEFAULT_CRS}: default CRS if no auxiliary {@code "*.prj"} file is found.</li>
- * <li>{@link OptionKey#ENCODING}: encoding of the {@code "*.prj"} file. Default is the JVM default.</li>
- * <li>{@link OptionKey#TIMEZONE}: timezone of dates in the {@code "*.prj"} file. Default is UTC.</li>
- * <li>{@link OptionKey#LOCALE}: locale for texts in the {@code "*.prj"} file. Default is English.</li>
+ * <li>{@link DataOptionKey#DEFAULT_CRS}: default CRS if no auxiliary {@code "*.prj"} file is found.</li>
+ * <li>{@link DataOptionKey#ENCODING}: encoding of the {@code "*.prj"} file. Default is the JVM default.</li>
+ * <li>{@link DataOptionKey#TIMEZONE}: timezone of dates in the {@code "*.prj"} file. Default is UTC.</li>
+ * <li>{@link DataOptionKey#LOCALE}: locale for texts in the {@code "*.prj"} file. Default is English.</li>
* </ul>
*
* @param provider the factory that created this {@code PRJDataStore} instance, or {@code null} if unspecified.
@@ -113,10 +113,10 @@ public abstract class PRJDataStore extends URIDataStore {
*/
protected PRJDataStore(final DataStoreProvider provider, final StorageConnector connector) throws DataStoreException {
super(provider, connector);
- crs = connector.getOption(OptionKey.DEFAULT_CRS);
- encoding = connector.getOption(OptionKey.ENCODING);
- locale = connector.getOption(OptionKey.LOCALE); // For `InternationalString`, not for numbers.
- timezone = connector.getOption(OptionKey.TIMEZONE);
+ crs = connector.getOption(DataOptionKey.DEFAULT_CRS);
+ encoding = connector.getOption(DataOptionKey.ENCODING);
+ locale = connector.getOption(DataOptionKey.LOCALE); // For `InternationalString`, not for numbers.
+ timezone = connector.getOption(DataOptionKey.TIMEZONE);
}
/**
@@ -298,7 +298,7 @@ public abstract class PRJDataStore extends URIDataStore {
ArgumentChecks.ensureNonNull("parameter", parameters);
final StorageConnector connector = connector(this, parameters);
final Parameters pg = Parameters.castOrWrap(parameters);
- connector.setOption(OptionKey.DEFAULT_CRS, pg.getValue(DEFAULT_CRS));
+ connector.setOption(DataOptionKey.DEFAULT_CRS, pg.getValue(DEFAULT_CRS));
return open(connector);
}
}
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
index 699dcf5..208f62c 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
@@ -18,6 +18,7 @@ package org.apache.sis.storage;
import org.apache.sis.setup.OptionKey;
import org.apache.sis.feature.FoliationRepresentation;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
/**
@@ -26,7 +27,7 @@ import org.apache.sis.feature.FoliationRepresentation;
* or other kinds of structure that are specific to some data formats.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.2
*
* @param <T> the type of option values.
*
@@ -40,6 +41,17 @@ public final class DataOptionKey<T> extends OptionKey<T> {
private static final long serialVersionUID = 8927757348322016043L;
/**
+ * The coordinate reference system (CRS) of data to use if not explicitly defined.
+ * This option can be used when the file to read does not describe itself the data CRS.
+ * For example this option can be used when reading ASCII Grid without CRS information,
+ * but is ignored if the ASCII Grid file is accompanied by a {@code *.prj} file giving the CRS.
+ *
+ * @since 1.2
+ */
+ public static final OptionKey<CoordinateReferenceSystem> DEFAULT_CRS =
+ new DataOptionKey<>("DEFAULT_CRS", CoordinateReferenceSystem.class);
+
+ /**
* Whether to assemble trajectory fragments (distinct CSV lines) into a single {@code Feature} instance
* forming a foliation. This is ignored if the file does not seem to contain moving features.
*
[sis] 01/03: Store ASCII Grid data as single (instead of double) precision floating point values.
Posted by de...@apache.org.
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 7d3a1bcb9f3316bd45c52183334b0a748bc7e7c4
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Apr 3 15:51:33 2022 +0200
Store ASCII Grid data as single (instead of double) precision floating point values.
---
.../main/java/org/apache/sis/internal/storage/ascii/Store.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/Store.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/Store.java
index 4b119fe..d67738f 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/Store.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ascii/Store.java
@@ -22,7 +22,7 @@ import java.util.Optional;
import java.util.StringJoiner;
import java.io.IOException;
import java.nio.file.StandardOpenOption;
-import java.awt.image.DataBufferDouble;
+import java.awt.image.DataBufferFloat;
import org.opengis.geometry.Envelope;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.maintenance.ScopeCode;
@@ -378,7 +378,7 @@ cellsize: if (value != null) {
final CharactersView view = input();
final String filename = view.input.filename;
final Statistics stats = new Statistics(filename);
- final double[] data = new double[width * height];
+ final float[] data = new float[width * height];
for (int i=0; i < data.length; i++) {
final String token = view.readToken();
double value;
@@ -395,7 +395,7 @@ cellsize: if (value != null) {
Resources.Keys.CanNotReadPixel_3, i % width, i / width, filename), e);
}
}
- data[i] = value;
+ data[i] = (float) value;
stats.accept(value); // Need to invoke even for NaN values (because we count them).
}
/*
@@ -422,7 +422,7 @@ cellsize: if (value != null) {
coverage = new GridCoverageBuilder()
.addRange(band)
.setDomain(gridGeometry)
- .setValues(new DataBufferDouble(data, data.length), null)
+ .setValues(new DataBufferFloat(data, data.length), null)
.addImageProperty(PlanarImage.STATISTICS_KEY, new Statistics[] {stats})
.build();
} catch (DataStoreException e) {