use of org.opengis.referencing.operation.PassThroughOperation in project sis by apache.
the class TransformCommand method printOperations.
/**
* Prints a summary of the given coordinate operation as a sequence of steps.
* If the operations is specified by EPSG, prints the EPSG name and code.
* Otherwise prints only the operation method names, since the coordinate operation names
* generated by SIS are not very meaningful.
*
* @param step the coordinate operation to print as a sequence of steps.
*/
private void printOperations(final CoordinateOperation step, boolean isNext) {
if (isNext) {
isNext = false;
if (colors) {
outHeader.append(X364.FOREGROUND_GREEN.sequence());
}
outHeader.append(" → ");
if (colors) {
outHeader.append(X364.FOREGROUND_DEFAULT.sequence());
}
}
if (!printNameAndIdentifier(step, true)) {
if (step instanceof ConcatenatedOperation) {
for (final CoordinateOperation op : ((ConcatenatedOperation) step).getOperations()) {
printOperations(op, isNext);
isNext = true;
}
} else if (step instanceof PassThroughOperation) {
printOperations(((PassThroughOperation) step).getOperation(), false);
} else if (step instanceof SingleOperation) {
outHeader.append(((SingleOperation) step).getMethod().getName().getCode());
}
}
}
use of org.opengis.referencing.operation.PassThroughOperation in project sis by apache.
the class AbstractCoordinateOperation method formatTo.
/**
* Formats this coordinate operation in Well Known Text (WKT) version 2 format.
*
* @param formatter the formatter to use.
* @return {@code "CoordinateOperation"}.
*
* @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#113">WKT 2 specification §17</a>
*/
@Override
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
formatter.newLine();
/*
* If the WKT is a component of a ConcatenatedOperation, do not format the source CRS since it is identical
* to the target CRS of the previous step, or to the source CRS of the enclosing "ConcatenatedOperation" if
* this step is the first step.
*
* This decision is SIS-specific since the WKT 2 specification does not define concatenated operations.
* This choice may change in any future SIS version.
*/
final FormattableObject enclosing = formatter.getEnclosingElement(1);
final boolean isSubOperation = (enclosing instanceof PassThroughOperation);
final boolean isComponent = (enclosing instanceof ConcatenatedOperation);
if (!isSubOperation && !isComponent) {
append(formatter, getSourceCRS(), WKTKeywords.SourceCRS);
append(formatter, getTargetCRS(), WKTKeywords.TargetCRS);
}
final OperationMethod method = getMethod();
if (method != null) {
formatter.append(DefaultOperationMethod.castOrCopy(method));
ParameterValueGroup parameters;
try {
parameters = getParameterValues();
} catch (UnsupportedOperationException e) {
final IdentifiedObject c = getParameterDescriptors();
formatter.setInvalidWKT(c != null ? c : this, e);
parameters = null;
}
if (parameters != null) {
/*
* Format the parameter values. Apache SIS uses the EPSG geodetic dataset as the main source of
* parameter definitions. When a parameter is defined by both OGC and EPSG with different names,
* the Formatter class is responsible for choosing an appropriate name. But when the difference
* is more fundamental, we may have duplication. For example in the "Molodensky" operation, OGC
* uses source and target axis lengths while EPSG uses only difference between those lengths.
* In this case, OGC and EPSG parameters are defined separately and are redundant. To simplify
* the CoordinateOperation WKT, we omit non-EPSG parameters when we have determined that we are
* about to describe an EPSG operation. We could generalize this filtering to any authority, but
* we don't because few authorities are as complete as EPSG, so other authorities are more likely
* to mix EPSG or someone else components with their own. Note also that we don't apply filtering
* on MathTransform WKT neither for more reliable debugging.
*/
final boolean filter = // NOT method.getName()
WKTUtilities.isEPSG(parameters.getDescriptor(), false) && Constants.EPSG.equalsIgnoreCase(Citations.getCodeSpace(formatter.getNameAuthority()));
formatter.newLine();
formatter.indent(+1);
for (final GeneralParameterValue param : parameters.values()) {
if (!filter || WKTUtilities.isEPSG(param.getDescriptor(), true)) {
WKTUtilities.append(param, formatter);
}
}
formatter.indent(-1);
}
}
if (!isSubOperation && !(this instanceof ConcatenatedOperation)) {
append(formatter, getInterpolationCRS(), WKTKeywords.InterpolationCRS);
final double accuracy = getLinearAccuracy();
if (accuracy > 0) {
formatter.append(new FormattableObject() {
@Override
protected String formatTo(final Formatter formatter) {
formatter.append(accuracy);
return WKTKeywords.OperationAccuracy;
}
});
}
}
if (formatter.getConvention().majorVersion() == 1) {
formatter.setInvalidWKT(this, null);
}
if (isComponent) {
formatter.setInvalidWKT(this, null);
return "CoordinateOperationStep";
}
return WKTKeywords.CoordinateOperation;
}
Aggregations