Class DatumShiftGridGroup<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
java.lang.Object
org.apache.sis.referencing.datum.DatumShiftGrid<C,T>
org.apache.sis.internal.referencing.provider.DatumShiftGridFile<C,T>
org.apache.sis.internal.referencing.provider.DatumShiftGridGroup<C,T>
- All Implemented Interfaces:
Serializable
final class DatumShiftGridGroup<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
extends DatumShiftGridFile<C,T>
A group of datum shift grids. This is used when a NTv2 file contains more than one grid with no common parent.
This class creates a synthetic parent which always delegates its work to a child (as opposed to more classical
transform trees where the parent can do some work if no child can). Coordinate transformations will be applied
as below:
SpecializableTransform
will try to locate the most appropriate grid for given coordinates. This is the class where to put our optimization efforts, for example by checking the last used grid before to check all other grids.- Only if
SpecializableTransform
did not found a better transform, it will fallback on a transform backed by thisDatumShiftGridGroup
. In such case,InterpolatedTransform
will perform its calculation by invokinginterpolateInCell(double, double, double[])
. That method tries again to locate the best grid, but performance is less important there since that method is only a fallback. - The default
DatumShiftGrid.interpolateInCell(double, double, double[])
implementation invokesgetCellValue(int, int, int)
. We provide that method for consistency, but it should not be invoked since we overrodeinterpolateInCell(double, double, double[])
.
- Since:
- 1.1
- Version:
- 1.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
The bounds of a sub-grid, together with the subsampling level compared to the grid having the finest resolution.Nested classes/interfaces inherited from class org.apache.sis.internal.referencing.provider.DatumShiftGridFile
DatumShiftGridFile.Double<C extends javax.measure.Quantity<C>,
T extends javax.measure.Quantity<T>>, DatumShiftGridFile.Float<C extends javax.measure.Quantity<C>, T extends javax.measure.Quantity<T>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DatumShiftGridGroup.Region[]
For eachsubgrids[i]
,regions[i]
is the range of indices valid for that grid.private static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.internal.referencing.provider.DatumShiftGridFile
accuracy, CACHE, scanlineStride, subgrids
Fields inherited from class org.apache.sis.referencing.datum.DatumShiftGrid
INTERPOLATED_DIMENSIONS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
DatumShiftGridGroup
(Tile[] tiles, Map<Tile, DatumShiftGridFile<C, T>> grids, AffineTransform2D gridToCRS, Dimension gridSize) Creates a new group for the given list of sub-grids.private
DatumShiftGridGroup
(DatumShiftGridGroup<C, T> other, DatumShiftGridFile<C, T>[] data) Creates a new grid sharing the same data than an existing grid. -
Method Summary
Modifier and TypeMethodDescription(package private) static <C extends javax.measure.Quantity<C>,
T extends javax.measure.Quantity<T>>
DatumShiftGridGroup<C, T> create
(Path file, List<DatumShiftGridFile<C, T>> subgrids) Puts the given sub-grid in a group.double
getCellValue
(int dim, int gridX, int gridY) Returns the translation stored at the given two-dimensional grid indices for the given dimension.protected Object[]
getData()
Returns direct references (not cloned) to the data arrays.int
Returns the number of dimensions of the translation vectors interpolated by this datum shift grid.void
interpolateInCell
(double gridX, double gridY, double[] vector) Interpolates the translation to apply for the given two-dimensional grid indices.protected final DatumShiftGridFile
<C, T> Returns a new grid with the same geometry than this grid but different data arrays.Methods inherited from class org.apache.sis.internal.referencing.provider.DatumShiftGridFile
castTo, createGeodeticTransformation, equals, getCellPrecision, getParameterDescriptors, getParameterValues, hashCode, replaceOutsideGridCoordinates, setSubGrids, toString, useSharedData
Methods inherited from class org.apache.sis.referencing.datum.DatumShiftGrid
derivativeInCell, getCellMean, getCoordinateToGrid, getCoordinateUnit, getDomainOfValidity, getDomainOfValidity, getGridSize, getGridSize, getTranslationUnit, interpolateAt, isCellInGrid, isCellValueRatio
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
regions
For eachsubgrids[i]
,regions[i]
is the range of indices valid for that grid. This array will be used only as a fallback ifSpecializableTransform
has not been able to find the sub-grid itself. Since it should be rarely used, we do not bother using a R-Tree.
-
-
Constructor Details
-
DatumShiftGridGroup
private DatumShiftGridGroup(Tile[] tiles, Map<Tile, DatumShiftGridFile<C, throws IOException, org.opengis.referencing.operation.NoninvertibleTransformExceptionT>> grids, AffineTransform2D gridToCRS, Dimension gridSize) Creates a new group for the given list of sub-grids. That list shall contain at least 2 elements. The first sub-grid is taken as a template for setting parameter values such as filename (all list elements should declare the same filename parameters, so the selected element should not matter).- Parameters:
tiles
- the tiles computed byTileOrganizer
.grids
- sub-grids associated to tiles computed byTileOrganizer
.gridToCRS
- conversion from grid indices to "real world" coordinates.gridSize
- number of cells along the x and y axes in the grid.- Throws:
IOException
- declared becauseTile.getRegion()
declares it, but should not happen.org.opengis.referencing.operation.NoninvertibleTransformException
-
DatumShiftGridGroup
Creates a new grid sharing the same data than an existing grid. This constructor is forsetData(Object[])
usage only.
-
-
Method Details
-
create
static <C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> DatumShiftGridGroup<C,T> create(Path file, List<DatumShiftGridFile<C, T>> subgrids) throws IOException, org.opengis.util.FactoryException, org.opengis.referencing.operation.NoninvertibleTransformExceptionPuts the given sub-grid in a group. This method infers itself what would be the size of a grid containing all given sub-grids.- Parameters:
file
- filename to report in case of error.subgrids
- the sub-grids to put under a common root.- Throws:
org.opengis.util.FactoryException
- if the sub-grid cannot be combined in a single mosaic or pyramid.IOException
- declared becauseTile.getRegion()
declares it, but should not happen.org.opengis.referencing.operation.NoninvertibleTransformException
-
setData
Returns a new grid with the same geometry than this grid but different data arrays. This method is invoked byDatumShiftGridFile.useSharedData()
when it detects that a newly created grid uses the same data than an existing grid. Theother
object is the old grid, so we can share existing data. -
getData
Returns direct references (not cloned) to the data arrays. This method is for cache management,DatumShiftGridFile.equals(Object)
andDatumShiftGridFile.hashCode()
implementations only and should not be invoked in other context. -
getTranslationDimensions
public int getTranslationDimensions()Returns the number of dimensions of the translation vectors interpolated by this datum shift grid. This implementation takes the first sub-grid as a template. The choice of the grid does not matter since all grids have the same number of target dimensions.- Specified by:
getTranslationDimensions
in classDatumShiftGrid<C extends javax.measure.Quantity<C>,
T extends javax.measure.Quantity<T>> - Returns:
- number of dimensions of translation vectors.
-
getCellValue
public double getCellValue(int dim, int gridX, int gridY) Returns the translation stored at the given two-dimensional grid indices for the given dimension. This method is defined for consistency withinterpolateInCell(double, double, double[])
but should never be invoked. TheInterpolatedTransform
class will rather invoke theinterpolateInCell(…)
method for efficiency.Caller must ensure that all arguments given to this method are in their expected ranges. The behavior of this method is undefined if any argument value is out-of-range.
- Specified by:
getCellValue
in classDatumShiftGrid<C extends javax.measure.Quantity<C>,
T extends javax.measure.Quantity<T>> - Parameters:
dim
- the dimension of the translation vector component to get.gridX
- the grid index on the x axis, from 0 inclusive togridSize[0]
exclusive.gridY
- the grid index on the y axis, from 0 inclusive togridSize[1]
exclusive.- Returns:
- the translation for the given dimension in the grid cell at the given index.
-
interpolateInCell
public void interpolateInCell(double gridX, double gridY, double[] vector) Interpolates the translation to apply for the given two-dimensional grid indices. During forward coordinate transformations, this method is invoked only ifSpecializableTransform
has been unable to use directly one of the child transforms — so performance is not the priority in that situation. During inverse transformations, this method is invoked for estimating an initial position before iterative refinements. The given point may be outside all sub-grids (otherwiseSpecializableTransform
would have done the work itself at least in the forward transformation case). Consequently, searching a sub-grid containing the given point is not sufficient; we need to search for the nearest grid even if the point is outside.- Overrides:
interpolateInCell
in classDatumShiftGrid<C extends javax.measure.Quantity<C>,
T extends javax.measure.Quantity<T>> - Parameters:
gridX
- first grid coordinate of the point for which to get the translation.gridY
- second grid coordinate of the point for which to get the translation.vector
- a pre-allocated array where to write the translation vector.- See Also:
-