/** * Constructs a new derived CRS with the same values than the specified one. This copy * constructor provides a way to wrap an arbitrary implementation into a Geotools one or a * user-defined one (as a subclass), usually in order to leverage some implementation-specific * API. This constructor performs a shallow copy, i.e. the properties are not cloned. * * @param crs The coordinate reference system to copy. * @since 2.2 */ protected AbstractDerivedCRS(final GeneralDerivedCRS crs) { super(crs); baseCRS = crs.getBaseCRS(); conversionFromBase = crs.getConversionFromBase(); }
final CoordinateReferenceSystem base = target.getBaseCRS(); final Set<CoordinateOperation> step1 = findOperations(sourceCRS, base, limit); final CoordinateOperation step2 = target.getConversionFromBase(); return concatenate(step1, Collections.singleton(step2)); final CoordinateReferenceSystem base = source.getBaseCRS(); final Set<CoordinateOperation> step2 = findOperations(base, targetCRS, limit); CoordinateOperation step1 = source.getConversionFromBase(); MathTransform transform = step1.getMathTransform(); try {
/** * Returns {@code true} if this coordinate operation is for the definition of a * {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS derived} or * {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS projected CRS}. * The standard (ISO 19111) approach constructs <cite>defining conversion</cite> * as an operation of type {@link org.opengis.referencing.operation.Conversion} * with null {@linkplain #getSourceCRS() source} and {@linkplain #getTargetCRS() target CRS}. * But SIS supports also defining conversions with non-null CRS provided that: * * <ul> * <li>{@link GeneralDerivedCRS#getBaseCRS()} is the {@linkplain #getSourceCRS() source CRS} of this operation, and</li> * <li>{@link GeneralDerivedCRS#getConversionFromBase()} is this operation instance.</li> * </ul> * * When this method returns {@code true}, the source and target CRS are not marshalled in XML documents. * * @return {@code true} if this coordinate operation is for the definition of a derived or projected CRS. */ public boolean isDefiningConversion() { /* * Trick: we do not need to verify if (this instanceof Conversion) because: * - Only DefaultConversion constructor accepts null source and target CRS. * - GeneralDerivedCRS.getConversionFromBase() return type is Conversion. */ return (sourceCRS == null && targetCRS == null) || ((targetCRS instanceof GeneralDerivedCRS) && ((GeneralDerivedCRS) targetCRS).getBaseCRS() == sourceCRS && ((GeneralDerivedCRS) targetCRS).getConversionFromBase() == this); }
/** * Returns {@code true} if this coordinate operation is for the definition of a * {@linkplain org.apache.sis.referencing.crs.DefaultDerivedCRS derived} or * {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS projected CRS}. * The standard (ISO 19111) approach constructs <cite>defining conversion</cite> * as an operation of type {@link org.opengis.referencing.operation.Conversion} * with null {@linkplain #getSourceCRS() source} and {@linkplain #getTargetCRS() target CRS}. * But SIS supports also defining conversions with non-null CRS provided that: * * <ul> * <li>{@link GeneralDerivedCRS#getBaseCRS()} is the {@linkplain #getSourceCRS() source CRS} of this operation, and</li> * <li>{@link GeneralDerivedCRS#getConversionFromBase()} is this operation instance.</li> * </ul> * * When this method returns {@code true}, the source and target CRS are not marshalled in XML documents. * * @return {@code true} if this coordinate operation is for the definition of a derived or projected CRS. */ public boolean isDefiningConversion() { /* * Trick: we do not need to verify if (this instanceof Conversion) because: * - Only DefaultConversion constructor accepts null source and target CRS. * - GeneralDerivedCRS.getConversionFromBase() return type is Conversion. */ return (sourceCRS == null && targetCRS == null) || ((targetCRS instanceof GeneralDerivedCRS) && ((GeneralDerivedCRS) targetCRS).getBaseCRS() == sourceCRS && ((GeneralDerivedCRS) targetCRS).getConversionFromBase() == this); }
/** * Constructs a new coordinate reference system 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 crs the coordinate reference system to copy. */ AbstractDerivedCRS(final GeneralDerivedCRS crs) { super(crs); conversionFromBase = createConversionFromBase(null, (SingleCRS) crs.getBaseCRS(), crs.getConversionFromBase()); }
/** * Constructs a new coordinate reference system 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 crs the coordinate reference system to copy. */ AbstractDerivedCRS(final GeneralDerivedCRS crs) { super(crs); conversionFromBase = createConversionFromBase(null, (SingleCRS) crs.getBaseCRS(), crs.getConversionFromBase()); }
final ReferencingFactoryContainer factories = getFactoryContainer(true); final CRSFactory crsFactory = factories.getCRSFactory(); Conversion fromBase = derivedCRS.getConversionFromBase(); fromBase = new DefiningConversion(
crs = ((CRSAuthorityFactory) factory).createCoordinateReferenceSystem(String.valueOf(base)); if (crs instanceof GeneralDerivedCRS) { return ((GeneralDerivedCRS) crs).getConversionFromBase();
crs = ((CRSAuthorityFactory) factory).createCoordinateReferenceSystem(String.valueOf(base)); if (crs instanceof GeneralDerivedCRS) { return ((GeneralDerivedCRS) crs).getConversionFromBase();
final ListIterator<CoordinateOperation> it = operations.listIterator(); if (it.hasNext()) { final CoordinateOperation step2 = targetCRS.getConversionFromBase(); do { final CoordinateOperation step1 = it.next();
/** * Returns an error message for "Can not invert operation XYZ.". * This is used for the construction of {@link OperationNotFoundException}. * * @param crs the CRS having a conversion that can not be inverted. * @return a default error message. */ private static String canNotInvert(final GeneralDerivedCRS crs) { return Resources.format(Resources.Keys.NonInvertibleOperation_1, crs.getConversionFromBase().getName().getCode()); } }
/** * Returns an error message for "Can not invert operation XYZ.". * This is used for the construction of {@link OperationNotFoundException}. * * @param crs the CRS having a conversion that can not be inverted. * @return a default error message. */ private static String canNotInvert(final GeneralDerivedCRS crs) { return Resources.format(Resources.Keys.NonInvertibleOperation_1, crs.getConversionFromBase().getName().getCode()); } }
final ListIterator<CoordinateOperation> it = operations.listIterator(); if (it.hasNext()) { final CoordinateOperation step3 = targetCRS.getConversionFromBase(); final CoordinateOperation step1; try { step1 = inverse(sourceCRS.getConversionFromBase()); } catch (OperationNotFoundException exception) { throw exception;
/** * Creates an operation from an arbitrary single CRS to a derived coordinate reference system. * Conversions from {@code GeographicCRS} to {@code ProjectedCRS} are also handled by this method, * since projected CRS are a special kind of {@code GeneralDerivedCRS}. * * <p>The default implementation constructs the following operation chain:</p> * <blockquote><code>sourceCRS → {@linkplain GeneralDerivedCRS#getBaseCRS() baseCRS} → targetCRS</code></blockquote> * * where the conversion from {@code baseCRS} to {@code targetCRS} is obtained from * <code>targetCRS.{@linkplain GeneralDerivedCRS#getConversionFromBase() getConversionFromBase()}</code>. * * @param sourceCRS input coordinate reference system. * @param targetCRS output coordinate reference system. * @return a coordinate operation from {@code sourceCRS} to {@code targetCRS}. * @throws FactoryException if the operation can not be constructed. */ protected CoordinateOperation createOperationStep(final SingleCRS sourceCRS, final GeneralDerivedCRS targetCRS) throws FactoryException { final CoordinateOperation step1 = createOperation(sourceCRS, targetCRS.getBaseCRS()); final CoordinateOperation step2 = targetCRS.getConversionFromBase(); return concatenate(step1, step2); }
/** * Validates the conversion in the given derived CRS. This method is private because * it doesn't perform a full validation; only the one not already done by the public * {@link #validate(ProjectedCRS)} and {@link #validate(DerivedCRS)} methods. * * @param object The object to validate, or {@code null}. */ private void validateGeneralDerivedCRS(final GeneralDerivedCRS object) { if (!Boolean.TRUE.equals(VALIDATING.get())) try { VALIDATING.set(Boolean.TRUE); final Conversion conversion = object.getConversionFromBase(); if (conversion != null) { container.coordinateOperation.validate(conversion); final CoordinateReferenceSystem baseCRS = object.getBaseCRS(); final CoordinateReferenceSystem sourceCRS = conversion.getSourceCRS(); final CoordinateReferenceSystem targetCRS = conversion.getTargetCRS(); if (baseCRS != null && sourceCRS != null) { assertSame("GeneralDerivedCRS: The base CRS should be " + "the source CRS of the conversion.", baseCRS, sourceCRS); } if (targetCRS != null) { assertSame("GeneralDerivedCRS: The derived CRS should be " + "the target CRS of the conversion.", object, targetCRS); } } } finally { VALIDATING.set(Boolean.FALSE); } }
/** * Validates the conversion in the given derived CRS. This method is private because * it doesn't perform a full validation; only the one not already done by the public * {@link #validate(ProjectedCRS)} and {@link #validate(DerivedCRS)} methods. * * @param object the object to validate, or {@code null}. */ private void validateGeneralDerivedCRS(final GeneralDerivedCRS object) { if (!Boolean.TRUE.equals(VALIDATING.get())) try { VALIDATING.set(Boolean.TRUE); final Conversion conversion = object.getConversionFromBase(); if (conversion != null) { container.validate(conversion); final CoordinateReferenceSystem baseCRS = object.getBaseCRS(); final CoordinateReferenceSystem sourceCRS = conversion.getSourceCRS(); final CoordinateReferenceSystem targetCRS = conversion.getTargetCRS(); if (baseCRS != null && sourceCRS != null) { assertSame("GeneralDerivedCRS: The base CRS should be " + "the source CRS of the conversion.", baseCRS, sourceCRS); } if (targetCRS != null) { assertSame("GeneralDerivedCRS: The derived CRS should be " + "the target CRS of the conversion.", object, targetCRS); } } } finally { VALIDATING.set(Boolean.FALSE); } }
final CoordinateOperation step3 = targetCRS.getConversionFromBase(); final CoordinateOperation step1; try { step1 = inverse(sourceCRS.getConversionFromBase()); } catch (OperationNotFoundException exception) { throw exception;
if (!Utilities.equalsApproximatively(crsA, crsG)) { if (crsA instanceof GeneralDerivedCRS && crsG instanceof GeneralDerivedCRS) { final Conversion cnvA = ((GeneralDerivedCRS) crsA).getConversionFromBase(); final Conversion cnvG = ((GeneralDerivedCRS) crsG).getConversionFromBase(); if (!Utilities.equalsApproximatively(cnvA, cnvG)) { return Utilities.equalsApproximatively(cnvA.getMethod(), cnvG.getMethod()) ? CONVERSION : METHOD;
return deepEquals(strict ? conversionFromBase : getConversionFromBase(), strict ? ((AbstractDerivedCRS) object).conversionFromBase : ((GeneralDerivedCRS) object).getConversionFromBase(), mode); } finally { Semaphores.clear(Semaphores.CONVERSION_AND_CRS);
final CoordinateOperation step1; try { step1 = inverse(sourceCRS.getConversionFromBase()); } catch (OperationNotFoundException exception) { throw exception;