/** * Invoked by JAXB at marshalling time for getting the actual element to write * inside the {@code <gml:CoordinateOperation>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the element to be marshalled. */ @XmlElementRef public AbstractCoordinateOperation getElement() { return AbstractCoordinateOperation.castOrCopy(metadata); }
this.interpolationCRS = interpolationCRS; this.transform = transform; checkDimensions(properties);
/** * {@inheritDoc} * * @return {@inheritDoc} */ @Override protected long computeHashCode() { return super.computeHashCode() + 31 * operation.hashCode(); }
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; append(formatter, getInterpolationCRS(), WKTKeywords.InterpolationCRS); final double accuracy = getLinearAccuracy(); if (accuracy > 0) { formatter.append(new FormattableObject() {
final double accuracy = AbstractCoordinateOperation.castOrCopy(operation).getLinearAccuracy(); assertFalse(accuracy < 0); if (!Double.isNaN(accuracy)) {
return Double.NaN; } else if (operation instanceof AbstractCoordinateOperation) { return ((AbstractCoordinateOperation) operation).getLinearAccuracy(); } else { return PositionalAccuracyConstant.getLinearAccuracy(operation);
/** * Invoked by JAXB after unmarshalling. This method needs information provided by: * * <ul> * <li>{@link #setSource(CoordinateReferenceSystem)}</li> * <li>{@link #setTarget(CoordinateReferenceSystem)}</li> * <li>{@link #setParameters(GeneralParameterValue[])}</li> * </ul> * * @see <a href="http://issues.apache.org/jira/browse/SIS-291">SIS-291</a> */ @Override final void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { super.afterUnmarshal(unmarshaller, parent); final CoordinateReferenceSystem sourceCRS = super.getSourceCRS(); final CoordinateReferenceSystem targetCRS = super.getTargetCRS(); if (transform == null && sourceCRS != null && targetCRS != null && parameters != null) try { transform = DefaultFactories.forBuildin(MathTransformFactory.class) .createBaseToDerived(sourceCRS, parameters, targetCRS.getCoordinateSystem()); } catch (FactoryException e) { Context.warningOccured(Context.current(), AbstractSingleOperation.class, "afterUnmarshal", e, true); } } }
/** * Creates a new coordinate operation with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param operation the coordinate operation to copy. * * @see #castOrCopy(CoordinateOperation) */ protected AbstractCoordinateOperation(final CoordinateOperation operation) { super(operation); sourceCRS = operation.getSourceCRS(); targetCRS = operation.getTargetCRS(); interpolationCRS = getInterpolationCRS(operation); operationVersion = operation.getOperationVersion(); coordinateOperationAccuracy = operation.getCoordinateOperationAccuracy(); domainOfValidity = operation.getDomainOfValidity(); scope = operation.getScope(); transform = operation.getMathTransform(); if (operation instanceof AbstractCoordinateOperation) { wrapAroundChanges = ((AbstractCoordinateOperation) operation).wrapAroundChanges; } else { computeTransientFields(); } }
/** * Invoked by JAXB after unmarshalling. */ void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { computeTransientFields(); } }
/** * Compares this concatenated operation with the specified object for equality. If the {@code mode} argument * is {@link ComparisonMode#STRICT} or {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}, then all available * properties are compared including the {@linkplain #getDomainOfValidity() domain of validity} and the * {@linkplain #getScope() scope}. * * @return {@inheritDoc} */ @Override public boolean equals(final Object object, final ComparisonMode mode) { if (object == this) { return true; // Slight optimization. } if (super.equals(object, mode)) { if (mode == ComparisonMode.STRICT) { return Objects.equals(operation, ((DefaultPassThroughOperation) object).operation); } else { return deepEquals(getOperation(), ((PassThroughOperation) object).getOperation(), mode); } } return false; }
return (AbstractCoordinateOperation) object; return new AbstractCoordinateOperation(object);
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; append(formatter, getInterpolationCRS(), WKTKeywords.InterpolationCRS); final double accuracy = getLinearAccuracy(); if (accuracy > 0) { formatter.append(new FormattableObject() {
assertTrue(org.apache.sis.referencing.operation.AbstractCoordinateOperation.castOrCopy(operation).getLinearAccuracy() <= 25);
return Double.NaN; } else if (operation instanceof AbstractCoordinateOperation) { return ((AbstractCoordinateOperation) operation).getLinearAccuracy(); } else { return PositionalAccuracyConstant.getLinearAccuracy(operation);
/** * Invoked by JAXB after unmarshalling. This method needs information provided by: * * <ul> * <li>{@link #setSource(CoordinateReferenceSystem)}</li> * <li>{@link #setTarget(CoordinateReferenceSystem)}</li> * <li>{@link #setParameters(GeneralParameterValue[])}</li> * </ul> * * @see <a href="http://issues.apache.org/jira/browse/SIS-291">SIS-291</a> */ @Override final void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { super.afterUnmarshal(unmarshaller, parent); final CoordinateReferenceSystem sourceCRS = super.getSourceCRS(); final CoordinateReferenceSystem targetCRS = super.getTargetCRS(); if (transform == null && sourceCRS != null && targetCRS != null && parameters != null) try { transform = DefaultFactories.forBuildin(MathTransformFactory.class) .createBaseToDerived(sourceCRS, parameters, targetCRS.getCoordinateSystem()); } catch (FactoryException e) { Context.warningOccured(Context.current(), AbstractSingleOperation.class, "afterUnmarshal", e, true); } } }
/** * Creates a new coordinate operation with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param operation the coordinate operation to copy. * * @see #castOrCopy(CoordinateOperation) */ protected AbstractCoordinateOperation(final CoordinateOperation operation) { super(operation); sourceCRS = operation.getSourceCRS(); targetCRS = operation.getTargetCRS(); interpolationCRS = getInterpolationCRS(operation); operationVersion = operation.getOperationVersion(); coordinateOperationAccuracy = operation.getCoordinateOperationAccuracy(); domainOfValidity = operation.getDomainOfValidity(); scope = operation.getScope(); transform = operation.getMathTransform(); if (operation instanceof AbstractCoordinateOperation) { wrapAroundChanges = ((AbstractCoordinateOperation) operation).wrapAroundChanges; } else { computeTransientFields(); } }
/** * Invoked by JAXB after unmarshalling. */ void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { computeTransientFields(); } }
/** * Compares this concatenated operation with the specified object for equality. If the {@code mode} argument * is {@link ComparisonMode#STRICT} or {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}, then all available * properties are compared including the {@linkplain #getDomainOfValidity() domain of validity} and the * {@linkplain #getScope() scope}. * * @return {@inheritDoc} */ @Override public boolean equals(final Object object, final ComparisonMode mode) { if (object == this) { return true; // Slight optimization. } if (super.equals(object, mode)) { if (mode == ComparisonMode.STRICT) { return Objects.equals(operations, ((DefaultConcatenatedOperation) object).operations); } else { return deepEquals(getOperations(), ((ConcatenatedOperation) object).getOperations(), mode); } } return false; }
return (AbstractCoordinateOperation) object; return new AbstractCoordinateOperation(object);
/** * Tests the creation of an operation from a geographic CRS to WGS84 which is expected * to be explicitly described in the database. The transformation involves a datum shift. * * @throws FactoryException Should not happen. */ @Test @Ignore("CachingCoordinateOperationFactory is (for now) hidden by SIS factory.") public final void testGeographicBacked() throws FactoryException { assumeNotNull(factory); final CoordinateReferenceSystem sourceCRS; final CoordinateReferenceSystem targetCRS; final CoordinateOperation operation; sourceCRS = factory.createCoordinateReferenceSystem("4230"); targetCRS = factory.createCoordinateReferenceSystem("4326"); operation = opFactory.createOperation(sourceCRS, targetCRS); assertSame(sourceCRS, operation.getSourceCRS()); assertSame(targetCRS, operation.getTargetCRS()); assertSame(operation, opFactory.createOperation(sourceCRS, targetCRS)); assertEquals("1133", getIdentifier(operation)); // See comment in DefaultDataSourceTest. assertEquals(10.0, org.apache.sis.referencing.operation.AbstractCoordinateOperation.castOrCopy(operation).getLinearAccuracy(), 1E-6); assertTrue(operation instanceof Transformation); }