Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -108,7 +108,7 @@ class ArrayEnvelope extends AbstractEnve public ArrayEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner) throws MismatchedDimensionException, MismatchedReferenceSystemException { - crs = getCommonCRS(lowerCorner, upperCorner); // This performs also an argument check. + crs = getCommonCRS(lowerCorner, upperCorner); // This performs also an argument check. final int dimension = lowerCorner.getDimension(); ensureDimensionMatches("crs", dimension, crs); ensureSameDimension(dimension, upperCorner.getDimension()); @@ -221,10 +221,10 @@ class ArrayEnvelope extends AbstractEnve */ public ArrayEnvelope(final CharSequence wkt) throws IllegalArgumentException { ensureNonNull("wkt", wkt); - int levelParenth = 0; // Number of opening parenthesis: ( - int levelBracket = 0; // Number of opening brackets: [ - int dimLimit = 4; // The length of minimum and maximum arrays. - int maxDimension = 0; // The number of valid entries in the minimum and maximum arrays. + int levelParenth = 0; // Number of opening parenthesis: ( + int levelBracket = 0; // Number of opening brackets: [ + int dimLimit = 4; // The length of minimum and maximum arrays. + int maxDimension = 0; // The number of valid entries in the minimum and maximum arrays. final int length = CharSequences.skipTrailingWhitespaces(wkt, 0, wkt.length()); double[] minimum = new double[dimLimit]; double[] maximum = new double[dimLimit]; @@ -368,7 +368,7 @@ scanNumber: while ((i += Character.charC { Object name = IdentifiedObjects.getName(getAxis(crs, dimension), null); if (name == null) { - name = dimension; // Paranoiac fallback (name should never be null). + name = dimension; // Paranoiac fallback (name should never be null). } return Errors.format(Errors.Keys.IllegalOrdinateRange_3, lower, upper, name); } @@ -413,7 +413,7 @@ scanNumber: while ((i += Character.charC * * @return The dimensionality of this envelope. */ - @Override // Must also be overridden in SubEnvelope + @Override // Must also be overridden in SubEnvelope public int getDimension() { return ordinates.length >>> 1; } @@ -434,7 +434,7 @@ scanNumber: while ((i += Character.charC /** * {@inheritDoc} */ - @Override // Must also be overridden in SubEnvelope + @Override // Must also be overridden in SubEnvelope public double getLower(final int dimension) throws IndexOutOfBoundsException { ensureValidIndex(ordinates.length >>> 1, dimension); return ordinates[dimension]; @@ -443,7 +443,7 @@ scanNumber: while ((i += Character.charC /** * {@inheritDoc} */ - @Override // Must also be overridden in SubEnvelope + @Override // Must also be overridden in SubEnvelope public double getUpper(final int dimension) throws IndexOutOfBoundsException { final int d = ordinates.length >>> 1; ensureValidIndex(d, dimension); @@ -458,7 +458,7 @@ scanNumber: while ((i += Character.charC ensureValidIndex(endIndex(), dimension); final int i = dimension + beginIndex(); double lower = ordinates[i]; - if (isNegative(ordinates[i + (ordinates.length >>> 1)] - lower)) { // Special handling for -0.0 + if (isNegative(ordinates[i + (ordinates.length >>> 1)] - lower)) { // Special handling for -0.0 final CoordinateSystemAxis axis = getAxis(crs, dimension); lower = (axis != null) ? axis.getMinimumValue() : Double.NEGATIVE_INFINITY; } @@ -473,7 +473,7 @@ scanNumber: while ((i += Character.charC ensureValidIndex(endIndex(), dimension); final int i = dimension + beginIndex(); double upper = ordinates[i + (ordinates.length >>> 1)]; - if (isNegative(upper - ordinates[i])) { // Special handling for -0.0 + if (isNegative(upper - ordinates[i])) { // Special handling for -0.0 final CoordinateSystemAxis axis = getAxis(crs, dimension); upper = (axis != null) ? axis.getMaximumValue() : Double.POSITIVE_INFINITY; } @@ -490,7 +490,7 @@ scanNumber: while ((i += Character.charC final double minimum = ordinates[i]; final double maximum = ordinates[i + (ordinates.length >>> 1)]; double median = 0.5 * (minimum + maximum); - if (isNegative(maximum - minimum)) { // Special handling for -0.0 + if (isNegative(maximum - minimum)) { // Special handling for -0.0 median = fixMedian(getAxis(crs, dimension), median); } return median; @@ -504,7 +504,7 @@ scanNumber: while ((i += Character.charC ensureValidIndex(endIndex(), dimension); final int i = dimension + beginIndex(); double span = ordinates[i + (ordinates.length >>> 1)] - ordinates[i]; - if (isNegative(span)) { // Special handling for -0.0 + if (isNegative(span)) { // Special handling for -0.0 span = fixSpan(getAxis(crs, dimension), span); } return span; @@ -523,7 +523,7 @@ scanNumber: while ((i += Character.charC final int d = ordinates.length >>> 1; for (int i=beginIndex; i<endIndex; i++) { final double span = ordinates[i+d] - ordinates[i]; - if (!(span > 0)) { // Use '!' in order to catch NaN + if (!(span > 0)) { // Use '!' in order to catch NaN if (!(isNegative(span) && isWrapAround(crs, i - beginIndex))) { return true; } @@ -536,7 +536,7 @@ scanNumber: while ((i += Character.charC /** * {@inheritDoc} */ - @Override // Must also be overridden in SubEnvelope + @Override // Must also be overridden in SubEnvelope public boolean isAllNaN() { for (int i=0; i<ordinates.length; i++) { if (!Double.isNaN(ordinates[i])) { @@ -550,7 +550,7 @@ scanNumber: while ((i += Character.charC /** * {@inheritDoc} */ - @Override // Must also be overridden in SubEnvelope + @Override // Must also be overridden in SubEnvelope public int hashCode() { int code = Arrays.hashCode(ordinates); if (crs != null) { @@ -571,7 +571,7 @@ scanNumber: while ((i += Character.charC /** * {@inheritDoc} */ - @Override // Must also be overridden in SubEnvelope + @Override // Must also be overridden in SubEnvelope public boolean equals(final Object object) { if (object != null && object.getClass() == getClass()) { final ArrayEnvelope that = (ArrayEnvelope) object;
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -232,7 +232,7 @@ public class Envelope2D extends Rectangl public Envelope2D(final CoordinateReferenceSystem crs, final Rectangle2D rect) throws MismatchedDimensionException { - super(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); // Really 'super', not 'this'. + super(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); // Really 'super', not 'this'. ensureDimensionMatches("crs", DIMENSION, crs); this.crs = crs; } @@ -255,7 +255,7 @@ public class Envelope2D extends Rectangl public Envelope2D(final CoordinateReferenceSystem crs, final double x, final double y, final double width, final double height) throws MismatchedDimensionException { - super(x, y, width, height); // Really 'super', not 'this'. + super(x, y, width, height); // Really 'super', not 'this'. ensureDimensionMatches("crs", DIMENSION, crs); this.crs = crs; } @@ -363,7 +363,7 @@ public class Envelope2D extends Rectangl case 1: value=y; span=height; break; default: throw indexOutOfBounds(dimension); } - if (isNegative(span)) { // Special handling for -0.0 + if (isNegative(span)) { // Special handling for -0.0 final CoordinateSystemAxis axis = getAxis(crs, dimension); return (axis != null) ? axis.getMinimumValue() : NEGATIVE_INFINITY; } @@ -387,7 +387,7 @@ public class Envelope2D extends Rectangl case 1: value=y; span=height; break; default: throw indexOutOfBounds(dimension); } - if (isNegative(span)) { // Special handling for -0.0 + if (isNegative(span)) { // Special handling for -0.0 final CoordinateSystemAxis axis = getAxis(crs, dimension); return (axis != null) ? axis.getMaximumValue() : POSITIVE_INFINITY; } @@ -412,7 +412,7 @@ public class Envelope2D extends Rectangl default: throw indexOutOfBounds(dimension); } value += 0.5*span; - if (isNegative(span)) { // Special handling for -0.0 + if (isNegative(span)) { // Special handling for -0.0 value = fixMedian(getAxis(crs, dimension), value); } return value; @@ -434,7 +434,7 @@ public class Envelope2D extends Rectangl case 1: span=height; break; default: throw indexOutOfBounds(dimension); } - if (isNegative(span)) { // Special handling for -0.0 + if (isNegative(span)) { // Special handling for -0.0 span = fixSpan(getAxis(crs, dimension), span); } return span; @@ -569,11 +569,12 @@ public class Envelope2D extends Rectangl * * @since 0.4 */ + @SuppressWarnings("ReturnOfCollectionOrArrayField") public Rectangle2D.Double[] toRectangles() { - int isWrapAround = 0; // A bitmask of the dimensions having a "wrap around" behavior. + int isWrapAround = 0; // A bitmask of the dimensions having a "wrap around" behavior. for (int i=0; i!=DIMENSION; i++) { final double span = (i == 0) ? width : height; - if (!(span > 0)) { // Use '!' for catching NaN. + if (!(span > 0)) { // Use '!' for catching NaN. if (!isNegative(span) || !isWrapAround(crs, i)) { return EMPTY; } @@ -613,7 +614,7 @@ public class Envelope2D extends Rectangl */ final CoordinateSystemAxis axis = getAxis(crs, 1); final Rectangle2D.Double start = rect[0]; - final Rectangle2D.Double next = rect[isWrapAround - 1]; // == 1 if y is the only wraparound axis, or 2 otherwise. + final Rectangle2D.Double next = rect[isWrapAround - 1]; // == 1 if y is the only wraparound axis, or 2 otherwise. start.height = axis.getMaximumValue() - y; next.y = axis.getMinimumValue(); next.height += y - next.y; @@ -838,14 +839,14 @@ public class Envelope2D extends Rectangl /* * See GeneralEnvelope.intersect(Envelope) for an explanation of the algorithm applied below. */ - if (isSameSign(span0, span1)) { // Always 'false' if any value is NaN. + if (isSameSign(span0, span1)) { // Always 'false' if any value is NaN. if ((min1 > max0 || max1 < min0) && !isNegativeUnsafe(span0)) { - continue; // No intersection: leave ordinate values to NaN + continue; // No intersection: leave ordinate values to NaN } } else if (isNaN(span0) || isNaN(span1)) { - continue; // Leave ordinate values to NaN + continue; // Leave ordinate values to NaN } else { - int intersect = 0; // A bitmask of intersections (two bits). + int intersect = 0; // A bitmask of intersections (two bits). if (isNegativeUnsafe(span0)) { if (min1 <= max0) {min = min1; intersect = 1;} if (max1 >= min0) {max = max1; intersect |= 2;} @@ -862,7 +863,7 @@ public class Envelope2D extends Rectangl min = min1; max = max1; } else { - continue; // Leave ordinate values to NaN + continue; // Leave ordinate values to NaN } } } @@ -930,7 +931,7 @@ public class Envelope2D extends Rectangl final boolean sp1 = isNegative(span1); if (sp0 == sp1) { if (sp0 && !isNegativeUnsafe(max - min)) { - continue; // Leave ordinates to NaN. + continue; // Leave ordinates to NaN. } } else if (sp0) { if (max1 <= max0 || min1 >= min0) { @@ -940,7 +941,7 @@ public class Envelope2D extends Rectangl final double left = min1 - max0; final double right = min0 - max1; if (!(left > 0 || right > 0)) { - continue; // Leave ordinates to NaN. + continue; // Leave ordinates to NaN. } if (left > right) {min = min1; max = max0;} if (right > left) {min = min0; max = max1;} @@ -953,7 +954,7 @@ public class Envelope2D extends Rectangl final double left = min0 - max1; final double right = min1 - max0; if (!(left > 0 || right > 0)) { - continue; // Leave ordinates to NaN. + continue; // Leave ordinates to NaN. } if (left > right) {min = min0; max = max1;} if (right > left) {min = min1; max = max0;} @@ -1000,7 +1001,7 @@ public class Envelope2D extends Rectangl @Override public void add(final double px, final double py) { double off = px - x; - if (!isNegative(width)) { // Standard case, or NaN. + if (!isNegative(width)) { // Standard case, or NaN. if (off < 0) {x=px; width -= off;} if (off > width) {width = off;} } else if (off < 0) { Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -29,7 +29,6 @@ import org.opengis.referencing.cs.Coordi import org.opengis.referencing.cs.CoordinateSystemAxis; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.CoordinateOperation; -import org.opengis.referencing.operation.CoordinateOperationFactory; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.TransformException; @@ -42,9 +41,9 @@ import org.apache.sis.util.logging.Loggi import org.apache.sis.util.resources.Errors; import org.apache.sis.referencing.CRS; import org.apache.sis.referencing.operation.transform.AbstractMathTransform; +import org.apache.sis.internal.referencing.CoordinateOperations; import org.apache.sis.internal.referencing.DirectPositionView; import org.apache.sis.internal.referencing.Formulas; -import org.apache.sis.internal.system.DefaultFactories; import org.apache.sis.internal.system.Loggers; import static org.apache.sis.util.ArgumentChecks.ensureNonNull; @@ -102,17 +101,6 @@ public final class Envelopes extends Sta } /** - * Returns the coordinate operation factory to be used for transforming the envelope. - */ - private static CoordinateOperationFactory getFactory() throws TransformException { - final CoordinateOperationFactory factory = DefaultFactories.forClass(CoordinateOperationFactory.class); - if (factory != null) { - return factory; - } - throw new TransformException(Errors.format(Errors.Keys.MissingRequiredModule_1, "geotk-referencing")); // This is temporary. - } - - /** * Returns {@code true} if the given axis is of kind "Wrap Around". */ private static boolean isWrapAround(final CoordinateSystemAxis axis) { @@ -184,7 +172,7 @@ public final class Envelopes extends Sta } else { final CoordinateOperation operation; try { - operation = getFactory().createOperation(sourceCRS, targetCRS); + operation = CoordinateOperations.factory().createOperation(sourceCRS, targetCRS); } catch (FactoryException exception) { throw new TransformException(Errors.format(Errors.Keys.CanNotTransformEnvelope), exception); } @@ -304,11 +292,11 @@ public final class Envelopes extends Sta sourcePt, ordinates, offset, isDerivativeSupported); } catch (TransformException e) { if (!isDerivativeSupported) { - throw e; // Derivative were already disabled, so something went wrong. + throw e; // Derivative were already disabled, so something went wrong. } isDerivativeSupported = false; transform.transform(sourcePt, 0, ordinates, offset, 1); - recoverableException(e); // Log only if the above call was successful. + recoverableException(e); // Log only if the above call was successful. } /* * The transformed point has been saved for future reuse after the enclosing @@ -336,10 +324,10 @@ public final class Envelopes extends Sta int indexBase3 = ++pointIndex; for (int dim=sourceDim; --dim>=0; indexBase3 /= 3) { switch (indexBase3 % 3) { - case 0: sourcePt[dim] = envelope.getMinimum(dim); break; // Continue the loop. + case 0: sourcePt[dim] = envelope.getMinimum(dim); break; // Continue the loop. case 1: sourcePt[dim] = envelope.getMaximum(dim); continue transformPoint; case 2: sourcePt[dim] = envelope.getMedian (dim); continue transformPoint; - default: throw new AssertionError(indexBase3); // Should never happen + default: throw new AssertionError(indexBase3); // Should never happen } } break; @@ -469,7 +457,7 @@ public final class Envelopes extends Sta */ final MathTransform mt; try { - mt = getFactory().createOperation(crs, sourceCRS).getMathTransform(); + mt = CoordinateOperations.factory().createOperation(crs, sourceCRS).getMathTransform(); } catch (FactoryException e) { throw new TransformException(Errors.format(Errors.Keys.CanNotTransformEnvelope), e); } @@ -703,9 +691,9 @@ public final class Envelopes extends Sta * or skip c={2,3}. */ double value = max; - if ((c & 1) == 0) { // 'true' if we are testing "wrapAroundMin". + if ((c & 1) == 0) { // 'true' if we are testing "wrapAroundMin". if (((c == 0 ? includedMinValue : includedMaxValue) & bm) == 0) { - c++; // Skip also the case for "wrapAroundMax". + c++; // Skip also the case for "wrapAroundMax". continue; } targetPt.setOrdinate(axisIndex, (c == 0) ? axis.getMinimumValue() : axis.getMaximumValue()); Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -127,7 +127,7 @@ public class GeneralDirectPosition exten * @param point The position to copy. */ public GeneralDirectPosition(final DirectPosition point) { - ordinates = point.getCoordinate(); // Should already be cloned. + ordinates = point.getCoordinate(); // Should already be cloned. crs = point.getCoordinateReferenceSystem(); ensureDimensionMatches("crs", ordinates.length, crs); } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -312,7 +312,7 @@ public class GeneralEnvelope extends Arr } } } - this.crs = crs; // Set only on success. + this.crs = crs; // Set only on success. } /** @@ -325,7 +325,7 @@ public class GeneralEnvelope extends Arr * @throws IllegalArgumentException If {@code lower > upper} and the axis range meaning at the given dimension * is not "wraparound". See <cite>Envelope validation</cite> in class javadoc for more details. */ - @Override // Must also be overridden in SubEnvelope + @Override // Must also be overridden in SubEnvelope public void setRange(final int dimension, final double lower, final double upper) throws IndexOutOfBoundsException { @@ -432,8 +432,7 @@ public class GeneralEnvelope extends Arr * * @see #isAllNaN() */ - // Must be overridden in SubEnvelope - public void setToNaN() { + public void setToNaN() { // Must be overridden in SubEnvelope Arrays.fill(ordinates, Double.NaN); assert isAllNaN() : this; } @@ -522,7 +521,7 @@ public class GeneralEnvelope extends Arr final double value = position.getOrdinate(i); final double min = ordinates[iLower]; final double max = ordinates[iUpper]; - if (!isNegative(max - min)) { // Standard case, or NaN. + if (!isNegative(max - min)) { // Standard case, or NaN. if (value < min) ordinates[iLower] = value; if (value > max) ordinates[iUpper] = value; } else { @@ -621,7 +620,7 @@ public class GeneralEnvelope extends Arr if (min1 < min0) ordinates[iLower] = min1; if (max1 > max0) ordinates[iUpper] = max1; if (!sp0 || isNegativeUnsafe(ordinates[iUpper] - ordinates[iLower])) { - continue; // We are done, go to the next dimension. + continue; // We are done, go to the next dimension. } // If we were spanning the anti-meridian before the union but // are not anymore after the union, we actually merged to two @@ -637,8 +636,8 @@ public class GeneralEnvelope extends Arr * └────┘ │ │ * ──────────┘ └───── */ - if (max1 <= max0) continue; // This is the case of above picture. - if (min1 >= min0) continue; // Like above picture, but on the right side. + if (max1 <= max0) continue; // This is the case of above picture. + if (min1 >= min0) continue; // Like above picture, but on the right side. /* * At this point, the given envelope partially overlaps the "exclusion area" * of this envelope or has NaN values. We will move at most one edge of this @@ -654,8 +653,8 @@ public class GeneralEnvelope extends Arr // The < and > checks below are not completly redundant. // The difference is when a value is NaN. if (left > right) ordinates[iLower] = min1; - if (right > left) ordinates[iUpper] = max1; // This is the case illustrated above. - continue; // We are done, go to the next dimension. + if (right > left) ordinates[iUpper] = max1; // This is the case illustrated above. + continue; // We are done, go to the next dimension. } // If we reach this point, the given envelope fills completly the "exclusion area" // of this envelope. As a consequence this envelope is now spanning to infinities. @@ -728,7 +727,7 @@ public class GeneralEnvelope extends Arr final double max1 = upper.getOrdinate(i); final double span0 = max0 - min0; final double span1 = max1 - min1; - if (isSameSign(span0, span1)) { // Always 'false' if any value is NaN. + if (isSameSign(span0, span1)) { // Always 'false' if any value is NaN. /* * First, verify that the two envelopes intersect. * ┌──────────┐ ┌─────────────┐ @@ -756,7 +755,7 @@ public class GeneralEnvelope extends Arr continue; } } else { - int intersect = 0; // A bitmask of intersections (two bits). + int intersect = 0; // A bitmask of intersections (two bits). if (!Double.isNaN(span0) && !Double.isNaN(span1)) { if (isNegativeUnsafe(span0)) { /* Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/SubEnvelope.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/SubEnvelope.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/SubEnvelope.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/SubEnvelope.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -207,6 +207,7 @@ final class SubEnvelope extends GeneralE * If the user wants a clone, copy only the relevant part of the ordinates array. */ @Override + @SuppressWarnings("CloneDoesntCallSuperClone") public GeneralEnvelope clone() { final int d = ordinates.length >>> 1; final int dimension = endIndex - beginIndex; Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -30,10 +30,9 @@ import org.opengis.parameter.ParameterVa import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.referencing.operation.OperationMethod; -import org.opengis.referencing.operation.CoordinateOperationFactory; import org.apache.sis.internal.jaxb.Context; import org.apache.sis.internal.jaxb.gco.PropertyType; -import org.apache.sis.internal.system.DefaultFactories; +import org.apache.sis.internal.referencing.CoordinateOperations; import org.apache.sis.internal.referencing.provider.MapProjection; import org.apache.sis.parameter.DefaultParameterValue; import org.apache.sis.parameter.DefaultParameterValueGroup; @@ -43,9 +42,6 @@ import org.apache.sis.referencing.Identi import org.apache.sis.util.resources.Errors; import org.apache.sis.util.ArraysExt; -// Branch-specific imports -import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory; - /** * JAXB adapter mapping implementing class to the GeoAPI interface. See @@ -53,7 +49,7 @@ import org.apache.sis.referencing.operat * * @author Martin Desruisseaux (Geomatys) * @since 0.6 - * @version 0.6 + * @version 0.7 * @module */ public final class CC_OperationMethod extends PropertyType<CC_OperationMethod, OperationMethod> { @@ -183,14 +179,13 @@ public final class CC_OperationMethod ex * @return A parameter group containing at least the given descriptors, or equivalent descriptors. */ public static ParameterDescriptorGroup group(final Identifier name, final GeneralParameterDescriptor[] descriptors) { - final DefaultCoordinateOperationFactory factory = - DefaultFactories.forBuildin(CoordinateOperationFactory.class, DefaultCoordinateOperationFactory.class); - OperationMethod method = null; - if (factory != null) try { - method = factory.getOperationMethod(name.getCode()); + OperationMethod method; + try { + method = CoordinateOperations.factory().getOperationMethod(name.getCode()); } catch (FactoryException e) { // Use DefaultOperationMethod as the source class because it is the first public class in callers. Context.warningOccured(Context.current(), DefaultOperationMethod.class, "setDescriptors", e, true); + method = null; } final Map<String,?> properties = Collections.singletonMap(ParameterDescriptorGroup.NAME_KEY, name); if (method != null) { Copied: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_ParametricDatum.java (from r1740152, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_ParametricDatum.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_ParametricDatum.java?p2=sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_ParametricDatum.java&p1=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_ParametricDatum.java&r1=1740152&r2=1740177&rev=1740177&view=diff ============================================================================== --- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_ParametricDatum.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_ParametricDatum.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -17,7 +17,6 @@ package org.apache.sis.internal.jaxb.referencing; import javax.xml.bind.annotation.XmlElement; -import org.opengis.referencing.datum.ParametricDatum; import org.apache.sis.internal.jaxb.gco.PropertyType; import org.apache.sis.referencing.datum.DefaultParametricDatum; @@ -32,7 +31,7 @@ import org.apache.sis.referencing.datum. * @version 0.7 * @module */ -public final class CD_ParametricDatum extends PropertyType<CD_ParametricDatum, ParametricDatum> { +public final class CD_ParametricDatum extends PropertyType<CD_ParametricDatum, DefaultParametricDatum> { /** * Empty constructor for JAXB only. */ @@ -47,14 +46,14 @@ public final class CD_ParametricDatum ex * @return {@code ParametricDatum.class} */ @Override - protected Class<ParametricDatum> getBoundType() { - return ParametricDatum.class; + protected Class<DefaultParametricDatum> getBoundType() { + return DefaultParametricDatum.class; } /** * Constructor for the {@link #wrap} method only. */ - private CD_ParametricDatum(final ParametricDatum datum) { + private CD_ParametricDatum(final DefaultParametricDatum datum) { super(datum); } @@ -66,7 +65,7 @@ public final class CD_ParametricDatum ex * @return A {@code PropertyType} wrapping the given the element. */ @Override - protected CD_ParametricDatum wrap(final ParametricDatum datum) { + protected CD_ParametricDatum wrap(final DefaultParametricDatum datum) { return new CD_ParametricDatum(datum); } @@ -79,7 +78,7 @@ public final class CD_ParametricDatum ex */ @XmlElement(name = "ParametricDatum") public DefaultParametricDatum getElement() { - return DefaultParametricDatum.castOrCopy(metadata); + return metadata; } /** Copied: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_ParametricCS.java (from r1740152, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_ParametricCS.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_ParametricCS.java?p2=sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_ParametricCS.java&p1=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_ParametricCS.java&r1=1740152&r2=1740177&rev=1740177&view=diff ============================================================================== --- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_ParametricCS.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_ParametricCS.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -17,7 +17,6 @@ package org.apache.sis.internal.jaxb.referencing; import javax.xml.bind.annotation.XmlElement; -import org.opengis.referencing.cs.ParametricCS; import org.apache.sis.referencing.cs.DefaultParametricCS; import org.apache.sis.internal.jaxb.gco.PropertyType; @@ -31,7 +30,7 @@ import org.apache.sis.internal.jaxb.gco. * @version 0.7 * @module */ -public final class CS_ParametricCS extends PropertyType<CS_ParametricCS, ParametricCS> { +public final class CS_ParametricCS extends PropertyType<CS_ParametricCS, DefaultParametricCS> { /** * Empty constructor for JAXB only. */ @@ -46,14 +45,14 @@ public final class CS_ParametricCS exten * @return {@code ParametricCS.class} */ @Override - protected Class<ParametricCS> getBoundType() { - return ParametricCS.class; + protected Class<DefaultParametricCS> getBoundType() { + return DefaultParametricCS.class; } /** * Constructor for the {@link #wrap} method only. */ - private CS_ParametricCS(final ParametricCS cs) { + private CS_ParametricCS(final DefaultParametricCS cs) { super(cs); } @@ -65,7 +64,7 @@ public final class CS_ParametricCS exten * @return A {@code PropertyType} wrapping the given the element. */ @Override - protected CS_ParametricCS wrap(final ParametricCS cs) { + protected CS_ParametricCS wrap(final DefaultParametricCS cs) { return new CS_ParametricCS(cs); } @@ -78,7 +77,7 @@ public final class CS_ParametricCS exten */ @XmlElement(name = "ParametricCS") public DefaultParametricCS getElement() { - return DefaultParametricCS.castOrCopy(metadata); + return metadata; } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/GeodeticObjectBuilder.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -37,7 +37,6 @@ import org.opengis.referencing.cs.Cartes import org.opengis.referencing.cs.TimeCS; import org.opengis.referencing.datum.DatumFactory; import org.opengis.referencing.datum.TemporalDatum; -import org.opengis.referencing.operation.CoordinateOperationFactory; import org.opengis.referencing.operation.OperationMethod; import org.opengis.referencing.operation.Conversion; import org.apache.sis.internal.metadata.ReferencingServices; @@ -146,8 +145,7 @@ public class GeodeticObjectBuilder exten */ private DefaultCoordinateOperationFactory getCoordinateOperationFactory() { if (copFactory == null) { - copFactory = DefaultFactories.forBuildin(CoordinateOperationFactory.class, - DefaultCoordinateOperationFactory.class); + copFactory = CoordinateOperations.factory(); } return copFactory; } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Legacy.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -18,9 +18,9 @@ package org.apache.sis.internal.referenc import javax.measure.unit.SI; import javax.measure.unit.Unit; +import javax.measure.quantity.Length; import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.cs.CartesianCS; -import org.opengis.referencing.cs.CoordinateSystemAxis; import org.apache.sis.referencing.CommonCRS; import org.apache.sis.referencing.cs.AxisFilter; import org.apache.sis.referencing.cs.CoordinateSystems; @@ -40,10 +40,10 @@ import static org.opengis.referencing.Id * * @author Martin Desruisseaux (Geomatys) * @since 0.4 - * @version 0.6 + * @version 0.7 * @module */ -public final class Legacy implements AxisFilter { +public final class Legacy { /** * A three-dimensional Cartesian CS with the legacy set of geocentric axes. * OGC 01-009 defines the default geocentric axes as: @@ -62,6 +62,12 @@ public final class Legacy implements Axi new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, "Z"), "Z", AxisDirection.NORTH, SI.METRE)); /** + * Do not allow instantiation of this class. + */ + private Legacy() { + } + + /** * The standard three-dimensional Cartesian CS as defined by ISO 19111. * * @param unit The linear unit of the desired coordinate system, or {@code null} for metres. @@ -108,71 +114,8 @@ public final class Legacy implements Axi */ public static CartesianCS replaceUnit(CartesianCS cs, final Unit<?> unit) { if (unit != null && !unit.equals(SI.METRE)) { - cs = (CartesianCS) CoordinateSystems.replaceAxes(cs, new Legacy(unit)); + cs = (CartesianCS) CoordinateSystems.replaceLinearUnit(cs, unit.asType(Length.class)); } return cs; } - - - - - // ----------------------------------------------------------------- - // AxisFilter implementation for internal usage only - // ----------------------------------------------------------------- - - /** - * The value to be returned by {@link #getUnitReplacement(CoordinateSystemAxis, Unit)}, - * or {@code null} if no replacement should be done. - */ - private final Unit<?> replacement; - - /** - * For internal usage by {@link #replaceUnit(CartesianCS, Unit)} only. - */ - private Legacy(final Unit<?> unit) { - replacement = unit; - } - - @Override - @Deprecated - public Unit<?> getUnitReplacement(Unit<?> unit) { - return getUnitReplacement(null, unit); - } - - /** - * For internal usage by {@link #replaceUnit(CartesianCS, Unit)} only. - * - * @param axis ignored. - * @param unit ignored. - * @return The unit of the new coordinate system. - */ - @Override - public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, final Unit<?> unit) { - return replacement; - } - - /** - * Returns the given axis unchanged. - */ - @Override - public boolean accept(final CoordinateSystemAxis axis) { - return true; - } - - /** - * Returns the given direction unchanged. - */ - @Override - @Deprecated - public AxisDirection getDirectionReplacement(final AxisDirection direction) { - return direction; - } - - /** - * Returns the given direction unchanged. - */ - @Override - public AxisDirection getDirectionReplacement(CoordinateSystemAxis axis, final AxisDirection direction) { - return direction; - } } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -67,7 +67,7 @@ public final class PositionalAccuracyCon * * @see org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() */ - private static final double UNKNOWN_ACCURACY = 3000; + public static final double UNKNOWN_ACCURACY = 3000; /** * Default accuracy of datum shift, if not explicitly provided in the EPSG database. @@ -131,8 +131,8 @@ public final class PositionalAccuracyCon * This method tries each of the following procedures and returns the first successful one: * * <ul> - * <li>If a {@link QuantitativeResult} is found with a linear unit, then this accuracy estimate - * is converted to {@linkplain SI#METRE metres} and returned.</li> + * <li>If at least one {@link QuantitativeResult} is found with a linear unit, then the largest + * accuracy estimate is converted to {@linkplain SI#METRE metres} and returned.</li> * <li>Otherwise, if the operation is a {@link Conversion}, then returns 0 since a conversion * is by definition accurate up to rounding errors.</li> * <li>Otherwise, if the operation is a {@link Transformation}, then checks if the datum shift @@ -152,9 +152,10 @@ public final class PositionalAccuracyCon * @see org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() */ public static double getLinearAccuracy(final CoordinateOperation operation) { + double accuracy = Double.NaN; final Collection<PositionalAccuracy> accuracies = operation.getCoordinateOperationAccuracy(); - for (final PositionalAccuracy accuracy : accuracies) { - for (final Result result : accuracy.getResults()) { + for (final PositionalAccuracy metadata : accuracies) { + for (final Result result : metadata.getResults()) { if (result instanceof QuantitativeResult) { final QuantitativeResult quantity = (QuantitativeResult) result; final Collection<? extends Record> records = quantity.getValues(); @@ -167,7 +168,9 @@ public final class PositionalAccuracyCon if (value instanceof Number) { double v = ((Number) value).doubleValue(); v = unitOfLength.getConverterTo(SI.METRE).convert(v); - return v; + if (v >= 0 && !(v <= accuracy)) { // '!' is for replacing the NaN value. + accuracy = v; + } } } } @@ -176,40 +179,41 @@ public final class PositionalAccuracyCon } } } - /* - * No quantitative (linear) accuracy were found. If the coordinate operation is actually - * a conversion, the accuracy is up to rounding error (i.e. conceptually 0) by definition. - */ - if (operation instanceof Conversion) { - return 0; - } - /* - * If the coordinate operation is actually a transformation, checks if Bursa-Wolf parameters - * were available for the datum shift. This is SIS-specific. See field javadoc for a rational - * about the return values chosen. - */ - if (operation instanceof Transformation) { - if (accuracies.contains(DATUM_SHIFT_APPLIED)) { - return DATUM_SHIFT_ACCURACY; + if (Double.isNaN(accuracy)) { + /* + * No quantitative (linear) accuracy were found. If the coordinate operation is actually + * a conversion, the accuracy is up to rounding error (i.e. conceptually 0) by definition. + */ + if (operation instanceof Conversion) { + return 0; } - if (accuracies.contains(DATUM_SHIFT_OMITTED)) { - return UNKNOWN_ACCURACY; + /* + * If the coordinate operation is actually a transformation, checks if Bursa-Wolf parameters + * were available for the datum shift. This is SIS-specific. See field javadoc for a rational + * about the return values chosen. + */ + if (operation instanceof Transformation) { + if (accuracies.contains(DATUM_SHIFT_APPLIED)) { + return DATUM_SHIFT_ACCURACY; + } + if (accuracies.contains(DATUM_SHIFT_OMITTED)) { + return UNKNOWN_ACCURACY; + } } - } - /* - * If the coordinate operation is a compound of other coordinate operations, returns the sum of their accuracy, - * skipping unknown ones. Making the sum is a conservative approach (not exactly the "worst case" scenario, - * since it could be worst if the transforms are highly non-linear). - */ - double accuracy = Double.NaN; - if (operation instanceof ConcatenatedOperation) { - for (final CoordinateOperation op : ((ConcatenatedOperation) operation).getOperations()) { - final double candidate = Math.abs(getLinearAccuracy(op)); - if (!Double.isNaN(candidate)) { - if (Double.isNaN(accuracy)) { - accuracy = candidate; - } else { - accuracy += candidate; + /* + * If the coordinate operation is a compound of other coordinate operations, returns the sum of their accuracy, + * skipping unknown ones. Making the sum is a conservative approach (not exactly the "worst case" scenario, + * since it could be worst if the transforms are highly non-linear). + */ + if (operation instanceof ConcatenatedOperation) { + for (final CoordinateOperation op : ((ConcatenatedOperation) operation).getOperations()) { + final double candidate = Math.abs(getLinearAccuracy(op)); + if (!Double.isNaN(candidate)) { + if (Double.isNaN(accuracy)) { + accuracy = candidate; + } else { + accuracy += candidate; + } } } } Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -247,9 +247,16 @@ public final class ReferencingUtilities /** * Returns the properties of the given object but potentially with a modified name. * Current implement truncates the name at the first non-white character which is not - * a valid Unicode identifier part. + * a valid Unicode identifier part, with the following exception: + * + * <ul> + * <li>If the character is {@code '('} and the content until the closing {@code ')'} is a valid + * Unicode identifier, then that part is included. The intend is to keep the prime meridian + * name in names like <cite>"NTF (Paris)"</cite>.</li> + * </ul> * * <div class="note"><b>Example:</b><ul> + * <li><cite>"NTF (Paris)"</cite> is left unchanged.</li> * <li><cite>"WGS 84 (3D)"</cite> is truncated as <cite>"WGS 84"</cite>.</li> * <li><cite>"Ellipsoidal 2D CS. Axes: latitude, longitude. Orientations: north, east. UoM: degree"</cite> * is truncated as <cite>"Ellipsoidal 2D CS"</cite>.</li> @@ -272,6 +279,15 @@ public final class ReferencingUtilities for (int i=0; i < name.length();) { final int c = name.codePointAt(i); if (!Character.isUnicodeIdentifierPart(c) && !Character.isSpaceChar(c)) { + if (c == '(') { + final int endAt = name.indexOf(')', i); + if (endAt >= 0) { + final String extra = name.substring(i+1, endAt); + if (CharSequences.isUnicodeIdentifier(extra)) { + i += extra.length() + 2; + } + } + } name = CharSequences.trimWhitespaces(name, 0, i).toString(); if (!name.isEmpty()) { final Map<String,Object> copy = new HashMap<String,Object>(properties); Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -17,8 +17,10 @@ package org.apache.sis.internal.referencing; import java.util.Map; +import java.util.HashMap; import java.util.Iterator; import java.util.Collection; +import java.util.Collections; import java.util.Locale; import javax.measure.unit.Unit; import javax.measure.quantity.Length; @@ -34,6 +36,9 @@ import org.opengis.referencing.crs.Tempo import org.opengis.referencing.crs.VerticalCRS; import org.opengis.referencing.crs.GeographicCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.crs.CRSFactory; +import org.opengis.referencing.cs.CSFactory; +import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.cs.CartesianCS; import org.opengis.referencing.cs.CoordinateSystem; import org.opengis.referencing.cs.CoordinateSystemAxis; @@ -54,7 +59,6 @@ import org.opengis.metadata.extent.Geogr import org.opengis.metadata.extent.VerticalExtent; import org.opengis.geometry.Envelope; -import org.opengis.referencing.cs.AxisDirection; import org.apache.sis.geometry.Envelopes; import org.apache.sis.referencing.CRS; import org.apache.sis.referencing.CommonCRS; @@ -89,7 +93,14 @@ import org.apache.sis.util.Exceptions; import org.apache.sis.util.Utilities; // Branch-dependent imports +import org.apache.sis.internal.jdk8.JDK8; import org.apache.sis.metadata.iso.citation.DefaultCitation; +import org.apache.sis.referencing.factory.GeodeticObjectFactory; +import org.apache.sis.referencing.cs.DefaultParametricCS; +import org.apache.sis.referencing.datum.DefaultParametricDatum; +import org.apache.sis.referencing.factory.InvalidGeodeticParameterException; +import org.opengis.referencing.datum.Datum; +import org.opengis.referencing.datum.DatumFactory; /** @@ -154,7 +165,7 @@ public final class ServicesForMetadata e !Utilities.equalsIgnoreMetadata(cs2.getAxis(1), cs1.getAxis(1))) { final CoordinateOperation operation; - final CoordinateOperationFactory factory = DefaultFactories.forBuildin(CoordinateOperationFactory.class); + final CoordinateOperationFactory factory = CoordinateOperations.factory(); try { operation = factory.createOperation(crs, normalizedCRS); } catch (FactoryException e) { @@ -531,6 +542,77 @@ public final class ServicesForMetadata e } /** + * Creates a parametric CS. This method requires the SIS factory + * since parametric CRS were not available in GeoAPI 3.0. + * + * @param properties the coordinate system name, and optionally other properties. + * @param axis the axis of the parametric coordinate system. + * @param factory the factory to use for creating the coordinate system. + * @return a parametric coordinate system using the given axes. + * @throws FactoryException if the parametric object creation failed. + * + * @since 0.7 + */ + @Override + public CoordinateSystem createParametricCS(final Map<String,?> properties, final CoordinateSystemAxis axis, + CSFactory factory) throws FactoryException + { + if (!(factory instanceof GeodeticObjectFactory)) { + factory = DefaultFactories.forBuildin(CSFactory.class, GeodeticObjectFactory.class); + } + return ((GeodeticObjectFactory) factory).createParametricCS(properties, axis); + } + + /** + * Creates a parametric datum. This method requires the SIS factory + * since parametric CRS were not available in GeoAPI 3.0. + * + * @param properties the datum name, and optionally other properties. + * @param factory the factory to use for creating the datum. + * @return a parametric datum using the given name. + * @throws FactoryException if the parametric object creation failed. + * + * @since 0.7 + */ + @Override + public Datum createParametricDatum(final Map<String,?> properties, DatumFactory factory) + throws FactoryException + { + if (!(factory instanceof GeodeticObjectFactory)) { + factory = DefaultFactories.forBuildin(DatumFactory.class, GeodeticObjectFactory.class); + } + return ((GeodeticObjectFactory) factory).createParametricDatum(properties); + } + + /** + * Creates a parametric CRS. This method requires the SIS factory + * since parametric CRS were not available in GeoAPI 3.0. + * + * @param properties the coordinate reference system name, and optionally other properties. + * @param datum the parametric datum. + * @param cs the parametric coordinate system. + * @param factory the factory to use for creating the coordinate reference system. + * @return a parametric coordinate system using the given axes. + * @throws FactoryException if the parametric object creation failed. + * + * @since 0.7 + */ + @Override + public SingleCRS createParametricCRS(final Map<String,?> properties, final Datum datum, + final CoordinateSystem cs, CRSFactory factory) throws FactoryException + { + if (!(factory instanceof GeodeticObjectFactory)) { + factory = DefaultFactories.forBuildin(CRSFactory.class, GeodeticObjectFactory.class); + } + try { + return ((GeodeticObjectFactory) factory).createParametricCRS(properties, + (DefaultParametricDatum) datum, (DefaultParametricCS) cs); + } catch (ClassCastException e) { + throw new InvalidGeodeticParameterException(e.toString(), e); + } + } + + /** * Creates a derived CRS from the information found in a WKT 1 {@code FITTED_CS} element. * This coordinate system can not be easily constructed from the information provided by the WKT 1 format. * Note that this method is needed only for WKT 1 parsing, since WKT provides enough information for using @@ -614,7 +696,7 @@ public final class ServicesForMetadata e if (factory instanceof DefaultCoordinateOperationFactory) { df = (DefaultCoordinateOperationFactory) factory; } else { - df = DefaultFactories.forBuildin(CoordinateOperationFactory.class, DefaultCoordinateOperationFactory.class); + df = CoordinateOperations.factory(); } return df.createSingleOperation(properties, sourceCRS, targetCRS, interpolationCRS, method, null); } @@ -626,17 +708,30 @@ public final class ServicesForMetadata e * * @param properties The default properties. * @param mtFactory The math transform factory to use. + * @param crsFactory The factory to use if the operation factory needs to create CRS for intermediate steps. + * @param csFactory The factory to use if the operation factory needs to create CS for intermediate steps. * @return The coordinate operation factory to use. * - * @since 0.6 + * @since 0.7 */ @Override - public CoordinateOperationFactory getCoordinateOperationFactory(Map<String,?> properties, MathTransformFactory mtFactory) { - if (Containers.isNullOrEmpty(properties) && DefaultFactories.isDefaultInstance(MathTransformFactory.class, mtFactory)) { - return DefaultFactories.forBuildin(CoordinateOperationFactory.class); - } else { - return new DefaultCoordinateOperationFactory(properties, mtFactory); + public CoordinateOperationFactory getCoordinateOperationFactory(Map<String,?> properties, + final MathTransformFactory mtFactory, final CRSFactory crsFactory, final CSFactory csFactory) + { + if (Containers.isNullOrEmpty(properties)) { + if (DefaultFactories.isDefaultInstance(MathTransformFactory.class, mtFactory) && + DefaultFactories.isDefaultInstance(CRSFactory.class, crsFactory) && + DefaultFactories.isDefaultInstance(CSFactory.class, csFactory)) + { + return CoordinateOperations.factory(); + } + properties = Collections.emptyMap(); } + final HashMap<String,Object> p = new HashMap<String,Object>(properties); + JDK8.putIfAbsent(p, CRS_FACTORY, crsFactory); + JDK8.putIfAbsent(p, CS_FACTORY, csFactory); + properties = p; + return new DefaultCoordinateOperationFactory(properties, mtFactory); } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbridgedMolodensky.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -22,10 +22,8 @@ import org.opengis.parameter.ParameterVa import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.MathTransformFactory; -import org.opengis.referencing.operation.OperationMethod; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.parameter.Parameters; -import org.apache.sis.util.ArgumentChecks; /** @@ -70,22 +68,11 @@ public final class AbridgedMolodensky ex } /** - * The providers for all combinations between 2D and 3D cases. - * Array length is 4. Index is build with following rule: - * <ul> - * <li>Bit 1: dimension of source coordinates (0 for 2D, 1 for 3D).</li> - * <li>Bit 0: dimension of target coordinates (0 for 2D, 1 for 3D).</li> - * </ul> - */ - private final AbridgedMolodensky[] redimensioned; - - /** * Constructs a new provider. */ @SuppressWarnings("ThisEscapedInObjectConstruction") public AbridgedMolodensky() { - super(3, 3, PARAMETERS); - redimensioned = new AbridgedMolodensky[4]; + this(3, 3, new AbridgedMolodensky[4]); redimensioned[0] = new AbridgedMolodensky(2, 2, redimensioned); redimensioned[1] = new AbridgedMolodensky(2, 3, redimensioned); redimensioned[2] = new AbridgedMolodensky(3, 2, redimensioned); @@ -95,27 +82,12 @@ public final class AbridgedMolodensky ex /** * Constructs a provider for the given dimensions. * - * @param sourceDimension Number of dimensions in the source CRS of this operation method. - * @param targetDimension Number of dimensions in the target CRS of this operation method. - * @param redimensioned Providers for all combinations between 2D and 3D cases. - */ - private AbridgedMolodensky(final int sourceDimension, final int targetDimension, final AbridgedMolodensky[] redimensioned) { - super(sourceDimension, targetDimension, PARAMETERS); - this.redimensioned = redimensioned; - } - - /** - * Returns the same operation method, but for different number of dimensions. - * - * @param sourceDimensions The desired number of input dimensions. - * @param targetDimensions The desired number of output dimensions. - * @return The redimensioned operation method, or {@code this} if no change is needed. + * @param sourceDimensions number of dimensions in the source CRS of this operation method. + * @param targetDimensions number of dimensions in the target CRS of this operation method. + * @param redimensioned providers for all combinations between 2D and 3D cases, or {@code null}. */ - @Override - public OperationMethod redimension(final int sourceDimensions, final int targetDimensions) { - ArgumentChecks.ensureBetween("sourceDimensions", 2, 3, sourceDimensions); - ArgumentChecks.ensureBetween("targetDimensions", 2, 3, targetDimensions); - return redimensioned[((sourceDimensions & 1) << 1) | (targetDimensions & 1)]; + private AbridgedMolodensky(int sourceDimension, int targetDimension, GeodeticOperation[] redimensioned) { + super(sourceDimension, targetDimension, PARAMETERS, redimensioned); } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -76,15 +76,15 @@ public abstract class AbstractProvider e * Constructs a math transform provider from a set of parameters. The provider name and * {@linkplain #getIdentifiers() identifiers} will be the same than the parameter ones. * - * @param sourceDimension Number of dimensions in the source CRS of this operation method. - * @param targetDimension Number of dimensions in the target CRS of this operation method. - * @param parameters The set of parameters (never {@code null}). + * @param sourceDimensions Number of dimensions in the source CRS of this operation method. + * @param targetDimensions Number of dimensions in the target CRS of this operation method. + * @param parameters Description of parameters expected by this operation. */ - AbstractProvider(final int sourceDimension, - final int targetDimension, + AbstractProvider(final int sourceDimensions, + final int targetDimensions, final ParameterDescriptorGroup parameters) { - super(toMap(parameters), sourceDimension, targetDimension, parameters); + super(toMap(parameters), sourceDimensions, targetDimensions, parameters); } /** @@ -180,7 +180,7 @@ public abstract class AbstractProvider e } /** - * Creates a false easting or northing parameter in metre with a default value of 0. + * Creates a false easting, false northing or height parameter in metre with a default value of 0. */ static ParameterDescriptor<Double> createShift(final ParameterBuilder builder) { return builder.create(0.0, SI.METRE); @@ -219,7 +219,24 @@ public abstract class AbstractProvider e * Returns {@code true} if the inverse of this operation method is the same operation method with some parameter * values changed (typically with sign inverted). The default implementation returns {@code false}. * + * <p>This is a SIS-specific information which may be changed in any future SIS version. + * Current implementation provides this information in a "all or nothing" way: either all parameter values + * can have their sign reversed, or either the operation is considered not revertible at all. + * This is different than the EPSG dataset in two way:</p> + * + * <ul class="verbose"> + * <li>EPSG provides an equivalent information in the {@code PARAM_SIGN_REVERSAL} column of the + * {@code [Coordinate_Operation Parameter Usage]} table, but on a parameter-by-parameter basis + * instead than for the whole operation (which is probably better).</li> + * + * <li>EPSG provides another information in the {@code REVERSE_OP} column of the + * {@code [Coordinate_Operation Method]} table, but this is not equivalent to this method because it + * does not differentiate the map projection methods from <em>inverse</em> map projection methods.</li> + * </ul> + * * @return {@code true} if the inverse of this operation method can be described by the same operation method. + * + * @see org.apache.sis.internal.referencing.SignReversalComment */ public boolean isInvertible() { return false; Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -236,10 +236,10 @@ public final class Affine extends Abstra * Returns the operation method for the specified source and target dimensions. * This method provides different {@code Affine} instances for different dimensions. * - * @param sourceDimensions The number of source dimensions. - * @param targetDimensions The number of target dimensions. - * @param isAffine {@code true} if the transform is affine. - * @return The provider for transforms of the given source and target dimensions. + * @param sourceDimensions the number of source dimensions. + * @param targetDimensions the number of target dimensions. + * @param isAffine {@code true} if the transform is affine. + * @return the provider for transforms of the given source and target dimensions. */ public static Affine getProvider(final int sourceDimensions, final int targetDimensions, final boolean isAffine) { Affine method; Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -57,7 +57,7 @@ public final class CoordinateFrameRotati * Constructs the provider. */ public CoordinateFrameRotation() { - super(3, 3, PARAMETERS); + super(3, 3, PARAMETERS, null); } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation2D.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation2D.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation2D.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation2D.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -57,7 +57,22 @@ public final class CoordinateFrameRotati * Constructs the provider. */ public CoordinateFrameRotation2D() { - super(2, 2, PARAMETERS); + this(null); + } + + /** + * Constructs a provider that can be resized. + */ + CoordinateFrameRotation2D(GeodeticOperation[] redimensioned) { + super(2, 2, PARAMETERS, redimensioned); + } + + /** + * Returns the three-dimensional variant of this operation method. + */ + @Override + Class<CoordinateFrameRotation3D> variant3D() { + return CoordinateFrameRotation3D.class; } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/CoordinateFrameRotation3D.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -56,8 +56,24 @@ public final class CoordinateFrameRotati /** * Constructs the provider. */ + @SuppressWarnings("ThisEscapedInObjectConstruction") public CoordinateFrameRotation3D() { - super(3, 3, PARAMETERS); + this(3, 3, new GeocentricAffineBetweenGeographic[4]); + redimensioned[0] = new CoordinateFrameRotation2D( redimensioned); + redimensioned[1] = new CoordinateFrameRotation3D(2, 3, redimensioned); + redimensioned[2] = new CoordinateFrameRotation3D(3, 2, redimensioned); + redimensioned[3] = this; + } + + /** + * Constructs a provider for the given dimensions. + * + * @param sourceDimensions number of dimensions in the source CRS of this operation method. + * @param targetDimensions number of dimensions in the target CRS of this operation method. + * @param redimensioned providers for all combinations between 2D and 3D cases, or {@code null}. + */ + private CoordinateFrameRotation3D(int sourceDimensions, int targetDimensions, GeodeticOperation[] redimensioned) { + super(sourceDimensions, targetDimensions, PARAMETERS, redimensioned); } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -38,8 +38,6 @@ import org.opengis.parameter.InvalidPara import org.opengis.referencing.datum.Ellipsoid; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.MathTransformFactory; -import org.opengis.referencing.operation.Transformation; -import org.opengis.referencing.operation.OperationMethod; import org.opengis.referencing.operation.NoninvertibleTransformException; import org.opengis.util.FactoryException; import org.apache.sis.internal.system.Loggers; @@ -47,7 +45,6 @@ import org.apache.sis.internal.system.Da import org.apache.sis.internal.referencing.NilReferencingObject; import org.apache.sis.parameter.ParameterBuilder; import org.apache.sis.parameter.Parameters; -import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.CharSequences; import org.apache.sis.util.logging.Logging; import org.apache.sis.util.resources.Errors; @@ -93,7 +90,7 @@ import org.apache.sis.internal.jdk8.JDK8 * @module */ @XmlTransient -public class FranceGeocentricInterpolation extends AbstractProvider { +public class FranceGeocentricInterpolation extends GeodeticOperation { /** * Serial number for inter-operability with different versions. */ @@ -172,18 +169,6 @@ public class FranceGeocentricInterpolati } /** - * The providers for all combinations between 2D and 3D cases. - * Array length is 4. Index is built with following rule: - * <ul> - * <li>Bit 1: dimension of source coordinates (0 for 2D, 1 for 3D).</li> - * <li>Bit 0: dimension of target coordinates (0 for 2D, 1 for 3D).</li> - * </ul> - * - * This array is initialized at construction time and shall not be modified after. - */ - final FranceGeocentricInterpolation[] redimensioned; - - /** * Constructs a provider. */ @SuppressWarnings("ThisEscapedInObjectConstruction") @@ -198,32 +183,17 @@ public class FranceGeocentricInterpolati /** * Constructs a provider for the given number of dimensions. * - * @param sourceDimensions Number of dimensions in the source CRS of this operation method. - * @param targetDimensions Number of dimensions in the target CRS of this operation method. - * @param parameters The set of parameters (never {@code null}). - * @param redimensioned Providers for all combinations between 2D and 3D cases. + * @param sourceDimensions number of dimensions in the source CRS of this operation method. + * @param targetDimensions number of dimensions in the target CRS of this operation method. + * @param parameters description of parameters expected by this operation. + * @param redimensioned providers for all combinations between 2D and 3D cases, or {@code null}. */ FranceGeocentricInterpolation(final int sourceDimensions, final int targetDimensions, final ParameterDescriptorGroup parameters, - final FranceGeocentricInterpolation[] redimensioned) + final GeodeticOperation[] redimensioned) { - super(sourceDimensions, targetDimensions, parameters); - this.redimensioned = redimensioned; - } - - /** - * Returns the same operation method, but for different number of dimensions. - * - * @param sourceDimensions The desired number of input dimensions. - * @param targetDimensions The desired number of output dimensions. - * @return The redimensioned operation method, or {@code this} if no change is needed. - */ - @Override - public OperationMethod redimension(final int sourceDimensions, final int targetDimensions) { - ArgumentChecks.ensureBetween("sourceDimensions", 2, 3, sourceDimensions); - ArgumentChecks.ensureBetween("targetDimensions", 2, 3, targetDimensions); - return redimensioned[((sourceDimensions & 1) << 1) | (targetDimensions & 1)]; + super(sourceDimensions, targetDimensions, parameters, redimensioned); } /** @@ -240,13 +210,13 @@ public class FranceGeocentricInterpolati } /** - * Returns the base interface of the {@code CoordinateOperation} instances that use this method. + * The inverse of {@code FranceGeocentricInterpolation} is a different operation. * - * @return Fixed to {@link Transformation}. + * @return {@code false}. */ @Override - public Class<Transformation> getOperationType() { - return Transformation.class; + public final boolean isInvertible() { + return false; } /** Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java?rev=1740177&r1=1740176&r2=1740177&view=diff ============================================================================== --- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java [UTF-8] (original) +++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java [UTF-8] Wed Apr 20 17:40:11 2016 @@ -30,7 +30,6 @@ import org.opengis.referencing.cs.Coordi import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.MathTransformFactory; -import org.opengis.referencing.operation.Transformation; import org.apache.sis.internal.referencing.Formulas; import org.apache.sis.internal.referencing.WKTUtilities; import org.apache.sis.internal.metadata.WKTKeywords; @@ -64,7 +63,7 @@ import org.apache.sis.util.logging.Loggi * @module */ @XmlTransient -public abstract class GeocentricAffine extends AbstractProvider { +public abstract class GeocentricAffine extends GeodeticOperation { /** * Serial number for inter-operability with different versions. */ @@ -153,21 +152,13 @@ public abstract class GeocentricAffine e /** * Constructs a provider with the specified parameters. * - * @param sourceDimensions Number of dimensions in the source CRS of this operation method. - * @param targetDimensions Number of dimensions in the target CRS of this operation method. + * @param sourceDimensions number of dimensions in the source CRS of this operation method. + * @param targetDimensions number of dimensions in the target CRS of this operation method. + * @param parameters description of parameters expected by this operation. + * @param redimensioned providers for all combinations between 2D and 3D cases, or {@code null}. */ - GeocentricAffine(int sourceDimensions, int targetDimensions, ParameterDescriptorGroup parameters) { - super(sourceDimensions, targetDimensions, parameters); - } - - /** - * Returns the interface implemented by all coordinate operations that extends this class. - * - * @return Fixed to {@link Transformation}. - */ - @Override - public final Class<Transformation> getOperationType() { - return Transformation.class; + GeocentricAffine(int sourceDimensions, int targetDimensions, ParameterDescriptorGroup parameters, GeodeticOperation[] redimensioned) { + super(sourceDimensions, targetDimensions, parameters, redimensioned); } /** @@ -177,16 +168,6 @@ public abstract class GeocentricAffine e abstract int getType(); /** - * The inverse of this operation is the same operation with parameter signs inverted. - * - * @return {@code true} for all {@code GeocentricAffine}. - */ - @Override - public final boolean isInvertible() { - return true; - } - - /** * Creates a math transform from the specified group of parameter values. * The default implementation creates an affine transform, but some subclasses * will wrap that affine operation into Geographic/Geocentric conversions. @@ -206,12 +187,12 @@ public abstract class GeocentricAffine e boolean reverseRotation = false; switch (getType()) { default: throw new AssertionError(); - case FRAME_ROTATION: reverseRotation = true; // Fall through + case FRAME_ROTATION: reverseRotation = true; // Fall through case SEVEN_PARAM: parameters.rX = pv.doubleValue(RX); parameters.rY = pv.doubleValue(RY); parameters.rZ = pv.doubleValue(RZ); parameters.dS = pv.doubleValue(DS); - case TRANSLATION: parameters.tX = pv.doubleValue(TX); // Fall through + case TRANSLATION: parameters.tX = pv.doubleValue(TX); // Fall through parameters.tY = pv.doubleValue(TY); parameters.tZ = pv.doubleValue(TZ); } @@ -275,7 +256,7 @@ public abstract class GeocentricAffine e @SuppressWarnings("null") int dimension = sourceCS.getDimension(); if (dimension != targetCS.getDimension()) { - dimension = 0; // Sentinal value for mismatched dimensions. + dimension = 4; // Any value greater than 3 means "mismatched dimensions" for this method. } /* * Try to convert the matrix into (tX, tY, tZ, rX, rY, rZ, dS) parameters. @@ -312,7 +293,7 @@ public abstract class GeocentricAffine e } } final Parameters values = createParameters(descriptor, parameters, isTranslation); - if (useMolodensky && dimension != 0) { + if (useMolodensky && dimension <= 3) { values.getOrCreate(Molodensky.DIMENSION).setValue(dimension); } return values;
