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 2021/03/24 09:03:48 UTC
[sis] branch geoapi-4.0 updated: Rename `setUniformScale(…)` as `setScaleFactor(…)` for avoiding the impression that it forces `scaleX` and `scaleY` to same value. Creates the `GridCoverageProcessor` only once and cache the instance.
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 65cd3ad Rename `setUniformScale(…)` as `setScaleFactor(…)` for avoiding the impression that it forces `scaleX` and `scaleY` to same value. Creates the `GridCoverageProcessor` only once and cache the instance.
65cd3ad is described below
commit 65cd3adba3d7d250cada5b62e72ebae3fe2b9198
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue Mar 23 21:49:13 2021 +0100
Rename `setUniformScale(…)` as `setScaleFactor(…)` for avoiding the impression that it forces `scaleX` and `scaleY` to same value.
Creates the `GridCoverageProcessor` only once and cache the instance.
---
.../apache/sis/coverage/grid/DomainLinearizer.java | 28 ++++++++++++++++++----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/DomainLinearizer.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/DomainLinearizer.java
index ce90603..73aa001 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/DomainLinearizer.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/DomainLinearizer.java
@@ -61,10 +61,19 @@ public class DomainLinearizer {
/**
* Scale factor applied on grid coordinates, or 1 if none.
+ *
+ * @see #getScaleFactor()
*/
private double scale = 1;
/**
+ * The processor to use for coverage ressampling, created when first needed.
+ *
+ * @see #processor()
+ */
+ private GridCoverageProcessor processor;
+
+ /**
* Creates a new linearizer.
*/
public DomainLinearizer() {
@@ -99,22 +108,32 @@ public class DomainLinearizer {
*
* @return scale factor applied on coordinates in all dimensions, or 1 if none.
*/
- public double getUniformScale() {
+ public double getScaleFactor() {
return scale;
}
/**
* Sets the scale factor to apply on coordinates in all dimensions.
- * The default value is 1.
+ * Must be a value greater than zero. The default value is 1.
*
* @param factor scale factor applied on coordinates in all dimensions, or 1 if none.
*/
- public void setUniformScale(final double factor) {
+ public void setScaleFactor(final double factor) {
ArgumentChecks.ensureStrictlyPositive("factor", factor);
scale = factor;
}
/**
+ * Returns the grid coverage processor associated to this linearizer.
+ */
+ private GridCoverageProcessor processor() {
+ if (processor == null) {
+ processor = new GridCoverageProcessor();
+ }
+ return processor;
+ }
+
+ /**
* Returns a grid coverage with a linear approximation of the <cite>grid to CRS</cite> conversion.
* The linear approximation is computed by {@link #apply(GridGeometry)}. If the <cite>grid to CRS</cite>
* conversion of the given coverage is already linear, then this method returns {@code coverage}.
@@ -130,8 +149,7 @@ public class DomainLinearizer {
if (gg.equals(linearized)) {
return coverage;
}
- final GridCoverageProcessor processor = new GridCoverageProcessor();
- return processor.resample(coverage, linearized);
+ return processor().resample(coverage, linearized);
}
/**