/** * 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(); }
IdentifiedObject dependency; if (object instanceof GeneralDerivedCRS) { dependency = ((GeneralDerivedCRS) object).getBaseCRS(); where = "SOURCE_GEOGCRS_CODE"; } else if (object instanceof SingleCRS) {
IdentifiedObject dependency; if (object instanceof GeneralDerivedCRS) { dependency = ((GeneralDerivedCRS) object).getBaseCRS(); where = "SOURCE_GEOGCRS_CODE"; } else if (object instanceof SingleCRS) {
/** * Returns the class of the given CRS after unwrapping derived and projected CRS. * The returned type is for use with {@link #COMPATIBLE_TYPES}. */ private static Class<?> type(SingleCRS crs) { while (crs instanceof GeneralDerivedCRS) { crs = (SingleCRS) ((GeneralDerivedCRS) crs).getBaseCRS(); } return crs.getClass(); }
/** * Returns the class of the given CRS after unwrapping derived and projected CRS. * The returned type is for use with {@link #COMPATIBLE_TYPES}. */ private static Class<?> type(SingleCRS crs) { while (crs instanceof GeneralDerivedCRS) { crs = (SingleCRS) ((GeneralDerivedCRS) crs).getBaseCRS(); } return crs.getClass(); }
final CoordinateReferenceSystem base = target.getBaseCRS(); final Set<CoordinateOperation> step1 = findOperations(sourceCRS, base, limit); final CoordinateOperation step2 = target.getConversionFromBase(); final CoordinateReferenceSystem base = source.getBaseCRS(); final Set<CoordinateOperation> step2 = findOperations(base, targetCRS, limit); CoordinateOperation step1 = source.getConversionFromBase();
crs = ((GeneralDerivedCRS) crs).getBaseCRS();
/** * 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()); }
base = ((GeneralDerivedCRS) base).getBaseCRS();
if (crs instanceof GeneralDerivedCRS) { final GeneralDerivedCRS derivedCRS = (GeneralDerivedCRS) crs; final CoordinateReferenceSystem oldBaseCRS = derivedCRS.getBaseCRS(); final CoordinateReferenceSystem baseCRS = replace(oldBaseCRS); if (sameCS && Utilities.equals(baseCRS, oldBaseCRS)) {
throws FactoryException final List<CoordinateOperation> operations = createOperations(sourceCRS.getBaseCRS(), targetCRS.getBaseCRS()); final ListIterator<CoordinateOperation> it = operations.listIterator(); if (it.hasNext()) {
/** * 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 step2 = createOperation(sourceCRS.getBaseCRS(), targetCRS.getBaseCRS()); final CoordinateOperation step3 = targetCRS.getConversionFromBase(); final CoordinateOperation step1;
final CoordinateOperation step2 = createOperation(sourceCRS.getBaseCRS(), targetCRS); final CoordinateOperation step1; try {
crs = ((GeneralDerivedCRS) crs).getBaseCRS();