Issue #665 fixed TransformFactory when getting worldToGrid to return crsToGrid
Amend: Updated comment for new return Change-Id: I95151c5233898d156398760d3360de8c80b28001 Former-commit-id:d7b326cfa6
[formerly 42fc0cbd10401a6099e571467ff112f544e525e7] Former-commit-id:930d4569a5
This commit is contained in:
parent
86e285c8e7
commit
f3caa3f442
1 changed files with 14 additions and 12 deletions
|
@ -168,9 +168,8 @@ public class TransformFactory {
|
|||
|
||||
/**
|
||||
* Constructs a transform from the "world" CRS of the target geometry to the
|
||||
* grid of the targetGeometry. Null is a valid return and indicates there is
|
||||
* no "world" CRS to convert from and all conversions should be from
|
||||
* targetGeometry CRS to grid
|
||||
* grid of the targetGeometry. Will return crsToGrid if no "world" CRS
|
||||
* exists.
|
||||
*
|
||||
* @param targetGeometry
|
||||
* @param cellType
|
||||
|
@ -181,20 +180,23 @@ public class TransformFactory {
|
|||
PixelInCell cellType) throws FactoryException {
|
||||
CoordinateReferenceSystem crs = targetGeometry.getEnvelope()
|
||||
.getCoordinateReferenceSystem();
|
||||
if (crs instanceof GeneralDerivedCRS) {
|
||||
GeneralDerivedCRS projCRS = (GeneralDerivedCRS) crs;
|
||||
CoordinateReferenceSystem worldCRS = projCRS.getBaseCRS();
|
||||
MathTransform worldToCRS = CRSCache.getInstance()
|
||||
.findMathTransform(worldCRS, crs);
|
||||
try {
|
||||
try {
|
||||
if (crs instanceof GeneralDerivedCRS) {
|
||||
GeneralDerivedCRS projCRS = (GeneralDerivedCRS) crs;
|
||||
CoordinateReferenceSystem worldCRS = projCRS.getBaseCRS();
|
||||
MathTransform worldToCRS = CRSCache.getInstance()
|
||||
.findMathTransform(worldCRS, crs);
|
||||
|
||||
MathTransform crsToPixel = targetGeometry
|
||||
.getGridToCRS(cellType).inverse();
|
||||
return factory.createConcatenatedTransform(worldToCRS,
|
||||
crsToPixel);
|
||||
} catch (Exception e) {
|
||||
throw new FactoryException(e);
|
||||
} else {
|
||||
// No associated "world" CRS, go straight crs to grid
|
||||
return targetGeometry.getGridToCRS(cellType).inverse();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new FactoryException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue