* affine transform. This transform also drop source dimensions not used
* for any target coordinates.
*/
assert count == targets.size() : count;
while (count!=0 && steps[--count].getMathTransform().isIdentity());
final ReferencingFactoryContainer factories = getFactoryContainer();
CoordinateOperation operation = null;
CoordinateReferenceSystem sourceStepCRS = sourceCRS;
final XMatrix select = MatrixFactory.create(dimensions+1, indices.length+1);
select.setZero();
select.setElement(dimensions, indices.length, 1);
for (int j=0; j<dimensions; j++) {
select.setElement(j, indices[j], 1);
}
if (!select.isIdentity()) {
if (ordered.length == 1) {
sourceStepCRS = ordered[0];
} else {
sourceStepCRS = factories.getCRSFactory().createCompoundCRS(
getTemporaryName(sourceCRS), ordered);
}
operation = createFromAffineTransform(AXIS_CHANGES, sourceCRS, sourceStepCRS, select);
}
/*
* Now creates the pass through transforms for each transformation steps found above.
* We get (or construct temporary) source and target CRS for this step. They will be
* given to the constructor of the pass through operation, after the construction of
* pass through transform.
*/
int lower, upper=0;
for (int i=0; i<targets.size(); i++) {
CoordinateOperation step = steps[i];
final Map<String,?> properties = AbstractIdentifiedObject.getProperties(step);
final CoordinateReferenceSystem source = ordered[i];
final CoordinateReferenceSystem target = targets.get(i);
final CoordinateReferenceSystem targetStepCRS;
ordered[i] = target; // Used for the construction of targetStepCRS.
MathTransform mt = step.getMathTransform();
if (i >= count) {
targetStepCRS = targetCRS;
} else if (mt.isIdentity()) {
targetStepCRS = sourceStepCRS;
} else if (ordered.length == 1) {
targetStepCRS = ordered[0];
} else {
targetStepCRS = factories.getCRSFactory().createCompoundCRS(
getTemporaryName(target), ordered);
}
lower = upper;
upper += getDimension(source);
if (lower!=0 || upper!=dimensions) {