public ReferenceIdentifier getName() { return delegate.getName(); }
final CoordinateReferenceSystem targetCRS = step2.getTargetCRS(); CoordinateOperation step = null; if (step1.getName() == AXIS_CHANGES && mt1.getSourceDimensions() == mt1.getTargetDimensions()) step = step2; if (step2.getName() == AXIS_CHANGES && mt2.getSourceDimensions() == mt2.getTargetDimensions()) step = step1; if (step instanceof Operation) {
if (isIdentity(step2)) return concatenate(step1, step3); if (isIdentity(step3)) return concatenate(step1, step2); if (step1.getName() == AXIS_CHANGES) return concatenate(concatenate(step1, step2), step3); if (step3.getName() == AXIS_CHANGES) return concatenate(step1, concatenate(step2, step3)); final CoordinateReferenceSystem sourceCRS = step1.getSourceCRS(); final CoordinateReferenceSystem targetCRS = step3.getTargetCRS();
/** * Concatenates three transformation steps. If the first and/or the last operation is an {@link #AXIS_CHANGES}, * then it will be included as part of the second operation instead of creating a {@link ConcatenatedOperation}. * If a concatenated operation is created, it will get an automatically generated name. * * @param step1 the first step, or {@code null} for the identity operation. * @param step2 the second step, or {@code null} for the identity operation. * @param step3 the third step, or {@code null} for the identity operation. * @return a concatenated operation, or {@code null} if all arguments were null. * @throws FactoryException if the operation can not be constructed. */ private CoordinateOperation concatenate(final CoordinateOperation step1, final CoordinateOperation step2, final CoordinateOperation step3) throws FactoryException { if (isIdentity(step1)) return concatenate(step2, step3); if (isIdentity(step2)) return concatenate(step1, step3); if (isIdentity(step3)) return concatenate(step1, step2); if (canHide(step1.getName())) return concatenate(concatenate(step1, step2), step3); if (canHide(step3.getName())) return concatenate(step1, concatenate(step2, step3)); final Map<String,?> properties = defaultName(step1.getSourceCRS(), step3.getTargetCRS()); return factory.createConcatenatedOperation(properties, step1, step2, step3); }
/** * Concatenates three transformation steps. If the first and/or the last operation is an {@link #AXIS_CHANGES}, * then it will be included as part of the second operation instead of creating a {@link ConcatenatedOperation}. * If a concatenated operation is created, it will get an automatically generated name. * * @param step1 the first step, or {@code null} for the identity operation. * @param step2 the second step, or {@code null} for the identity operation. * @param step3 the third step, or {@code null} for the identity operation. * @return a concatenated operation, or {@code null} if all arguments were null. * @throws FactoryException if the operation can not be constructed. */ private CoordinateOperation concatenate(final CoordinateOperation step1, final CoordinateOperation step2, final CoordinateOperation step3) throws FactoryException { if (isIdentity(step1)) return concatenate(step2, step3); if (isIdentity(step2)) return concatenate(step1, step3); if (isIdentity(step3)) return concatenate(step1, step2); if (canHide(step1.getName())) return concatenate(concatenate(step1, step2), step3); if (canHide(step3.getName())) return concatenate(step1, concatenate(step2, step3)); final Map<String,?> properties = defaultName(step1.getSourceCRS(), step3.getTargetCRS()); return factory.createConcatenatedOperation(properties, step1, step2, step3); }
/** * Tests a single case of Geographic ↔︎ Geocentric conversions. */ private void testGeocentricConversion(final CoordinateReferenceSystem sourceCRS, final CoordinateReferenceSystem targetCRS) throws FactoryException { final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS); assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS()); assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertEquals ("name", "Geocentric conversion", operation.getName().getCode()); assertInstanceOf("operation", Conversion.class, operation); }
/** * Verifies the datum shift parameters in the <cite>"NTF to WGS 84 (1)"</cite> transformation. * Those parameters depends on whether an EPSG database have been used or not. * * @param steps the list returned by {@link DefaultConcatenatedOperation#getOperations()}. * @param datumShiftIndex index of the datum shift operations in the {@code steps} list. * @return the {@link #isUsingEpsgFactory()} value, returned for convenience. */ private static boolean verifyParametersNTF(final List<? extends CoordinateOperation> steps, final int datumShiftIndex) throws FactoryException { if (isUsingEpsgFactory()) { final SingleOperation step1 = (SingleOperation) steps.get(datumShiftIndex); final SingleOperation step2 = (SingleOperation) steps.get(datumShiftIndex + 1); assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (1)", 1763, step1); assertEpsgNameAndIdentifierEqual("NTF to WGS 84 (1)", 1193, step2); final ParameterValueGroup p1 = step1.getParameterValues(); final ParameterValueGroup p2 = step2.getParameterValues(); assertEquals("Longitude offset", 2.5969213, p1.parameter("Longitude offset") .doubleValue(), STRICT); assertEquals("X-axis translation", -168, p2.parameter("X-axis translation").doubleValue(), STRICT); assertEquals("Y-axis translation", -60, p2.parameter("Y-axis translation").doubleValue(), STRICT); assertEquals("Z-axis translation", 320, p2.parameter("Z-axis translation").doubleValue(), STRICT); return true; } else { assertSame(CoordinateOperationFinder.ELLIPSOID_CHANGE, steps.get(datumShiftIndex).getName()); return false; } }
/** * Tests a conversion of the temporal axis. We convert 1899-12-31 from a CRS having its epoch at 1970-1-1 * to an other CRS having its epoch at 1858-11-17, so the new value shall be approximately 41 years * after the new epoch. This conversion also implies a change of units from seconds to days. * * @throws FactoryException if the operation can not be created. * @throws TransformException if an error occurred while converting the test points. */ @Test @DependsOnMethod("testIdentityTransform") public void testTemporalConversion() throws FactoryException, TransformException { final TemporalCRS sourceCRS = CommonCRS.Temporal.UNIX.crs(); final TemporalCRS targetCRS = CommonCRS.Temporal.MODIFIED_JULIAN.crs(); final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS); assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS()); assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertEquals ("name", "Axis changes", operation.getName().getCode()); assertInstanceOf("operation", Conversion.class, operation); transform = operation.getMathTransform(); tolerance = 1E-12; verifyTransform(new double[] { // December 31, 1899 at 12:00 UTC in seconds. CommonCRS.Temporal.DUBLIN_JULIAN.datum().getOrigin().getTime() / 1000 }, new double[] { 15019.5 }); validate(); }
assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertFalse ("isIdentity", operation.getMathTransform().isIdentity()); assertEquals ("name", "Datum shift", operation.getName().getCode()); assertSetEquals (Arrays.asList(DATUM_SHIFT_APPLIED), operation.getCoordinateOperationAccuracy()); assertInstanceOf("operation", Transformation.class, operation);
assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertFalse ("isIdentity", operation.getMathTransform().isIdentity()); assertEquals ("name", "Datum shift", operation.getName().getCode()); assertSetEquals (Arrays.asList(DATUM_SHIFT_APPLIED), operation.getCoordinateOperationAccuracy()); assertInstanceOf("operation", Transformation.class, operation);
assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertFalse ("isIdentity", operation.getMathTransform().isIdentity()); assertEquals ("name", "Datum shift", operation.getName().getCode()); assertSetEquals (Arrays.asList(DATUM_SHIFT_APPLIED), operation.getCoordinateOperationAccuracy()); assertInstanceOf("operation", Transformation.class, operation);
assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertInstanceOf("operation", ConcatenatedOperation.class, operation); assertEquals ("name", "CompoundCRS[“Test3D”] ⟶ CompoundCRS[“Test4D”]", operation.getName().getCode());
assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS()); assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertEquals ("name", "Axis changes", operation.getName().getCode()); assertInstanceOf("operation", Conversion.class, operation);
assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS()); assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertEquals ("name", "Axis changes", operation.getName().getCode()); assertInstanceOf("operation", Conversion.class, operation);
assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS()); assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertEquals ("name", "Axis changes", operation.getName().getCode()); assertInstanceOf("operation", Conversion.class, operation);
assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS()); assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertEquals ("name", "Axis changes", operation.getName().getCode()); assertInstanceOf("operation", Conversion.class, operation);
assertSame ("sourceCRS", sourceCRS, operation.getSourceCRS()); assertSame ("targetCRS", targetCRS, operation.getTargetCRS()); assertEquals ("name", "TM", operation.getName().getCode()); assertInstanceOf("operation", Projection.class, operation);