Object
DomainLinearizer
Method for replacing a non-linear "grid to CRS" conversion by a linear conversion (affine transform).
The
GridGeometry
class allows non-linear "grid to CRS"
conversions, but some GridGeometry
usages are restricted to linear (affine) conversions.
The DomainLinearizer
class encapsulates the method used for replacing non-linear conversions
by a linear approximation.
The same instance can be reused by invoking apply(…)
methods for many GridCoverage
or GridGeometry
instances.
Limitations
Current implementation is designed for two-dimensional grid geometries. Support for higher dimensions is not guaranteed.- Since:
- 1.1
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(GridCoverage coverage) Returns a grid coverage with a linear approximation of the grid to CRS conversion.apply
(GridGeometry gg) Creates a grid geometry with a linear approximation of the grid to CRS conversion.boolean
Returns whetherGridExtent
should have their lower grid coordinates set to zero.double
Returns the scale factor applied on coordinates in all dimensions.void
setGridStartsAtZero
(boolean force) Sets whetherGridExtent
should have their lower grid coordinates set to zero.void
setScaleFactor
(double factor) Sets the scale factor to apply on coordinates in all dimensions.
-
Constructor Details
-
DomainLinearizer
public DomainLinearizer()Creates a new linearizer.
-
-
Method Details
-
getGridStartsAtZero
public boolean getGridStartsAtZero()Returns whetherGridExtent
should have their lower grid coordinates set to zero. Iftrue
, thenDomainLinearizer
will opportunistically apply translation on the "grid to CRS" conversion in such a way thatGridExtent.getLow()
is 0 for all dimensions.- Returns:
- whether to force lower grid coordinates to (0,0,…).
- See Also:
-
setGridStartsAtZero
public void setGridStartsAtZero(boolean force) Sets whetherGridExtent
should have their lower grid coordinates set to zero. The default value isfalse
.- Parameters:
force
- whether to force lower grid coordinates to (0,0,…).
-
getScaleFactor
public double getScaleFactor()Returns the scale factor applied on coordinates in all dimensions.- Returns:
- scale factor applied on coordinates in all dimensions, or 1 if none.
-
setScaleFactor
public void setScaleFactor(double factor) Sets the scale factor to apply on coordinates in all dimensions. Must be a value greater than zero. The default value is 1.- Parameters:
factor
- scale factor applied on coordinates in all dimensions, or 1 if none.
-
apply
Returns a grid coverage with a linear approximation of the grid to CRS conversion. The linear approximation is computed byapply(GridGeometry)
. If the grid to CRS conversion of the given coverage is already linear, then this method returnscoverage
.- Parameters:
coverage
- the grid coverage in which to make the grid to CRS conversion linear.- Returns:
- a grid coverage with a linear approximation of the grid to CRS conversion.
- Throws:
TransformException
- if some cell coordinates cannot be computed.
-
apply
Creates a grid geometry with a linear approximation of the grid to CRS conversion. The approximation is computed by Least Mean Squares method: the affine transform coefficients are chosen in way making the average value of (position − linear approximation of position)² as small as possible for all cells in given grid geometry. If the grid to CRS conversion of the given grid geometry is already linear, then this method returnsgg
.- Parameters:
gg
- the grid geometry in which to make the grid to CRS conversion linear.- Returns:
- a grid geometry with a linear approximation of the grid to CRS conversion.
- Throws:
TransformException
- if some cell coordinates cannot be computed.
-