public class TLcdRasterReferencingUtil extends Object
int imageWidth = 500;
int imageHeight = 500;
ILcdModelReference modelReference =
new TLcdGeodeticReference(new TLcdGeodeticDatum());
ILcdPoint[] imageTiePoints = new ILcdPoint[] {
new TLcdXYPoint(0, 0),
new TLcdXYPoint(imageWidth, 0),
new TLcdXYPoint(0, imageHeight),
};
ILcdPoint[] modelTiePoints = new ILcdPoint[] {
new TLcdLonLatPoint(20.0, 0.0),
new TLcdLonLatPoint(20.0, 20.0),
new TLcdLonLatPoint( 0.0, 0.0),
};
TLcdRasterReferencingUtil util =
new TLcdRasterReferencingUtil(imageWidth, imageHeight);
ILcdBounds bounds =
util.createAxisAlignedBounds(modelReference, imageTiePoints, modelTiePoints, 100);
In this example, the 3 tie points provide a perfect reference. If
necessary, especially with more tie points, a least squares approximation is
computed. With only 2 tie points, the scaling is assumed to be uniform.
With only a single tie point, the scale is assumed to be 1.
If required, we can also allow the model reference to be rotated first,
or have it replaced by a better suited grid reference with an orthographic
projection. For instance, with a geodetic reference that may be updated:
.....
modelReference =
util.createRotatedModelReference(modelReference, imageTiePoints, modelTiePoints, true);
ILcdBounds bounds =
util.createAxisAlignedBounds(modelReference, imageTiePoints, modelTiePoints, 100);
For the tie points from the first example, this doesn't make a difference,
since the rotation is 0. For other tie points, the resulting model
reference may be different from the original one. Note that the model
tie points are updated accordingly, resulting in different axis-aligned
bounds.Constructor and Description |
---|
TLcdRasterReferencingUtil(int aImageWidth,
int aImageHeight)
Creates a new TLcdRasterReferencingUtil for the given image size.
|
Modifier and Type | Method and Description |
---|---|
ILcdBounds |
createAxisAlignedBounds(ILcdModelReference aModelReference,
double[][] aRotationMatrix,
double[] aTranslationMatrix)
Returns the model bounds for a raster with the given transformation
matrices, in the given model reference.
|
ILcdBounds |
createAxisAlignedBounds(ILcdModelReference aModelReference,
ILcdPoint[] aImageTiePoints,
ILcdPoint[] aModelTiePoints,
double aMaximumResidualTiePointError)
Computes the model bounds for a raster with the given size, and given tie
points, in a given model reference.
|
ILcdBounds |
createAxisAlignedBounds(ILcdModelReference aModelReference,
ILcdPoint[] aImageTiePoints,
ILcdPoint[] aModelTiePoints,
double aScaleX,
double aScaleY,
double aMaximumResidualTiePointError)
Returns the model bounds for a raster with the tie points and (optional)
scale, in the given model reference.
|
ILcdModelReference |
createRotatedModelReference(ILcdModelReference aModelReference,
double[][] aRotationMatrixSFCT,
double[] aTranslationMatrixSFCT)
Computes a suitably rotated model reference for the given transformation
matrices.
|
ILcdModelReference |
createRotatedModelReference(ILcdModelReference aModelReference,
ILcdPoint[] aImageTiePoints,
ILcdPoint[] aModelTiePointsSFCT,
boolean aAllowOrthographicReferencing)
Computes a suitably rotated model reference for the given tie points.
|
public TLcdRasterReferencingUtil(int aImageWidth, int aImageHeight)
aImageWidth
- the width of the raster, expressed in pixels.aImageHeight
- the height of the raster, expressed in pixels.public ILcdModelReference createRotatedModelReference(ILcdModelReference aModelReference, ILcdPoint[] aImageTiePoints, ILcdPoint[] aModelTiePointsSFCT, boolean aAllowOrthographicReferencing) throws IOException
aModelReference
- the reference of the raster, defining
the model coordinates in which the
raster will be positioned.aImageTiePoints
- the image tie points, expressed in
pixel coordinates.aModelTiePointsSFCT
- the corresponding model tie points,
expressed in model coordinates.
These points are updated on return,
reflecting the modified model
reference.aAllowOrthographicReferencing
- specifies whether a geodetic model
reference may be replaced by a grid
reference with better suited
orthographic projection, if necessary.IOException
- if the model reference can't be computed.public ILcdModelReference createRotatedModelReference(ILcdModelReference aModelReference, double[][] aRotationMatrixSFCT, double[] aTranslationMatrixSFCT) throws IOException
aModelReference
- the reference of the raster, defining the
model coordinates in which the raster will
be positioned.aRotationMatrixSFCT
- the 2x2 rotation and scaling matrix for
going from pixel coordinates to model
coordinates.aTranslationMatrixSFCT
- the given translation matrix for going from
pixel coordinates to model coordinates.IOException
- if the model reference can't be computed.public ILcdBounds createAxisAlignedBounds(ILcdModelReference aModelReference, ILcdPoint[] aImageTiePoints, ILcdPoint[] aModelTiePoints, double aMaximumResidualTiePointError) throws IOException
aModelReference
- the reference of the raster, defining
the model coordinates in which the
raster will be positioned.aImageTiePoints
- the image tie points, expressed in
pixel coordinates.aModelTiePoints
- the corresponding model tie points,
expressed in model coordinates.aMaximumResidualTiePointError
- the maximum average residual tie point
error, expressed in pixels.IOException
- if the given maximum residual tie point error is
exceeded or if the bounds can't be computed.public ILcdBounds createAxisAlignedBounds(ILcdModelReference aModelReference, ILcdPoint[] aImageTiePoints, ILcdPoint[] aModelTiePoints, double aScaleX, double aScaleY, double aMaximumResidualTiePointError) throws IOException
aModelReference
- the reference of the raster, defining
the model coordinates in which the
raster will be positioned.aImageTiePoints
- the image tie points, expressed in
pixel coordinates.aModelTiePoints
- the corresponding model tie points,
expressed in model coordinates.aScaleX
- the scaling factor on the image x axis,
expressed in model coordinates per
pixel. If 0.0, the scaling factor is
derived from the tie points.aScaleY
- the scaling factor on the image y axis,
expressed in model coordinates per
pixel. If 0.0, the scaling factor is
derived from the tie points.aMaximumResidualTiePointError
- the maximum average residual tie point
error, expressed in pixels.IOException
- if the given maximum residual tie point error is
exceeded or if the bounds can't be computed.public ILcdBounds createAxisAlignedBounds(ILcdModelReference aModelReference, double[][] aRotationMatrix, double[] aTranslationMatrix) throws IOException
aModelReference
- the reference of the raster, defining the model
coordinates in which the raster will be
positioned.aRotationMatrix
- the 2x2 rotation and scaling matrix for
going from pixel coordinates to model
coordinates.aTranslationMatrix
- the given translation matrix for going from
pixel coordinates to model coordinates.IOException
- if the bounds can't be computed.