use of org.apache.sis.util.UnsupportedImplementationException in project sis by apache.
the class UnitDimension method combine.
/**
* Returns the product or the quotient of this dimension with the specified one.
*
* @param other the dimension by which to multiply or divide this dimension.
* @param divide {@code false} for a multiplication, {@code true} for a division.
* @return the product or division of this dimension by the given dimension.
*/
private UnitDimension combine(final Dimension other, final boolean divide) {
final Map<UnitDimension, Fraction> product = new LinkedHashMap<>(components);
for (final Map.Entry<? extends Dimension, Fraction> entry : getBaseDimensions(other).entrySet()) {
final Dimension dim = entry.getKey();
Fraction p = entry.getValue();
if (divide) {
p = p.negate();
}
if (dim instanceof UnitDimension) {
product.merge((UnitDimension) dim, p, (sum, toAdd) -> {
sum = sum.add(toAdd);
return (sum.numerator != 0) ? sum : null;
});
} else if (p.numerator != 0) {
throw new UnsupportedImplementationException(Errors.format(Errors.Keys.UnsupportedImplementation_1, dim.getClass()));
}
}
return create(product);
}
use of org.apache.sis.util.UnsupportedImplementationException in project sis by apache.
the class DefaultPassThroughOperation method getModifiedCoordinates.
/**
* Returns the ordered sequence of indices in a source coordinate tuple of the coordinates
* affected by this pass-through operation.
*
* @return zero-based indices of the modified source coordinates.
*
* @see PassThroughTransform#getModifiedCoordinates()
*/
@Override
public int[] getModifiedCoordinates() {
final MathTransform transform = super.getMathTransform();
if (transform instanceof PassThroughTransform) {
return ((PassThroughTransform) transform).getModifiedCoordinates();
} else {
/*
* Should not happen with objects created by public methods since the constructor created the transform
* itself. However may happen with operations parsed from GML. As a fallback, search in the components
* of CompoundCRS. This is not a universal fallback, but work for the most straightforward cases.
*/
final CoordinateReferenceSystem sourceCRS = super.getSourceCRS();
if (sourceCRS instanceof CompoundCRS) {
int firstAffectedOrdinate = 0;
final CoordinateReferenceSystem search = operation.getSourceCRS();
for (final CoordinateReferenceSystem c : ((CompoundCRS) sourceCRS).getComponents()) {
final int dim = ReferencingUtilities.getDimension(c);
if (c == search) {
final int[] indices = new int[dim];
for (int i = 0; i < dim; i++) {
indices[i] = firstAffectedOrdinate + i;
}
return indices;
}
firstAffectedOrdinate += dim;
}
}
throw new UnsupportedImplementationException(transform.getClass());
}
}
Aggregations