public class LocalizationGridBuilder extends TransformBuilder
width
× height
and input coordinates are (i,j) index in the grid,
where i must be in the [0…width
-1] range and j in the [0…height
-1] range inclusive.
Output coordinates are the values stored in the grid of localization at the specified index.
After a LocalizationGridBuilder
instance has been fully populated (i.e. real world coordinates have been
specified for all grid cells), a transformation from grid coordinates to "real world" coordinates can be obtained
with the create(MathTransformFactory)
method. If this transform is close enough to an affine transform,
then an instance of LinearTransform
is returned.
Otherwise, a transform backed by the localization grid is returned.
This builder performs two steps:
LinearTransformBuilder
.DatumShiftGrid
with the residuals.InterpolatedTransform
with the above shift grid.InterpolatedTransform
,
LinearTransform
,
DatumShiftGrid
Defined in the sis-referencing
module
Constructor and Description |
---|
LocalizationGridBuilder(int width,
int height)
Creates a new, initially empty, builder for a localization grid of the given size.
|
LocalizationGridBuilder(Vector sourceX,
Vector sourceY)
Creates a new, initially empty, builder for a localization grid of a size inferred from the given points.
|
Modifier and Type | Method and Description |
---|---|
MathTransform |
create(MathTransformFactory factory)
Creates a transform from the source points to the target points.
|
double[] |
getControlPoint(int gridX,
int gridY)
Returns a single target coordinate for the given source coordinate, or
null if none. |
double |
getDesiredPrecision()
Returns the desired precision of inverse transformations, in units of source coordinates.
|
LinearTransform |
getSourceToGrid()
Returns the current relationship between "real-world" source coordinates and grid coordinates.
|
void |
setControlPoint(int gridX,
int gridY,
double... target)
Sets a single matching control point pair.
|
void |
setDesiredPrecision(double precision)
Sets the desired precision of inverse transformations, in units of source coordinates.
|
void |
setSourceToGrid(LinearTransform sourceToGrid)
Defines relationship between "real-world" source coordinates and grid coordinates.
|
public LocalizationGridBuilder(int width, int height)
width
- the number of columns in the grid of target positions.height
- the number of rows in the grid of target positions.public LocalizationGridBuilder(Vector sourceX, Vector sourceY)
(Above conversion can be obtained bysourceX
,sourceY
) → (gridX
,gridY
)
getSourceToGrid()
.
Values in the given vectors should be integers, but this constructor is tolerant to non-integer values
if they have a constant offset (typically 0.5) relative to integer values. The two vectors do not need to
have the same length (i.e. sourceX[i]
are not necessarily related to sourceY[i]
).
sourceX
- all possible x inputs before conversion to grid coordinates.sourceY
- all possible y inputs before conversion to grid coordinates.ArithmeticException
- if this constructor can not infer a reasonable grid size from the given vectors.public void setDesiredPrecision(double precision)
precision
- desired precision of the results of inverse transformations.DatumShiftGrid.getCellPrecision()
public double getDesiredPrecision()
setDesiredPrecision(double)
.public void setSourceToGrid(LinearTransform sourceToGrid)
gridX
, gridY
) indices can be done with the following formulas:
setDesiredPrecision(double)
method.coordinateToGrid
transform for the above formulas can be represented by the following matrix:
┌ ┐ │ 1/Δx 0 -x₀/Δx │ │ 0 1/Δy -y₀/Δy │ │ 0 0 1 │ └ ┘If this method is never invoked, then the default conversion is identity. If a desired precision has been specified before this method call, it is caller's responsibility to convert that value to new source units if needed.
sourceToGrid
- conversion from the "real world" source coordinates to grid indices including fractional parts.DatumShiftGrid.getCoordinateToGrid()
public LinearTransform getSourceToGrid()
setSourceToGrid(LinearTransform)
.
If that setter method has never been invoked, then this is an automatically computed transform
if the grid coordinates have been specified
to the constructor, or the identity transform otherwise.public void setControlPoint(int gridX, int gridY, double... target)
If a source to grid conversion exists, it shall have been applied
by the caller for computing the (gridX
, gridY
) coordinates given to this method.
gridX
- the column index in the grid where to store the given target position.gridY
- the row index in the grid where to store the given target position.target
- the target coordinates, assumed uncertain.IllegalArgumentException
- if the x
or y
ordinate value is out of grid range.MismatchedDimensionException
- if the target position does not have the expected number of dimensions.public double[] getControlPoint(int gridX, int gridY)
null
if none.gridX
- the column index in the grid where to read the target position.gridY
- the row index in the grid where to read the target position.null
if none.IllegalArgumentException
- if the x
or y
ordinate value is out of grid range.public MathTransform create(MathTransformFactory factory) throws FactoryException
LinearTransform
is returned.create
in class TransformBuilder
factory
- the factory to use for creating the transform, or null
for the default factory.
The MathTransformFactory.createAffineTransform(Matrix)
method of that factory
shall return LinearTransform
instances.FactoryException
- if the transform can not be created,
for example because the target points have not be specified.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.