/** * Returns an operation for conversion or transformation between two coordinate reference * systems. If an operation exists, it is returned. If more than one operation exists, the * default is returned. If no operation exists, then the exception is thrown. * * <p>The default implementation inspects the CRS and delegates the work to one or many {@code * createOperationStep(...)} methods. This method fails if no path between the CRS is found. * * @param sourceCRS Input coordinate reference system. * @param targetCRS Output coordinate reference system. * @param limit The maximum number of operations to be returned. Use -1 to return all the * available operations. Use 1 to return just one operation. Currently, the behavior for * other values of {@code limit} is undefined. * @return A coordinate operation from {@code sourceCRS} to {@code targetCRS}. * @throws OperationNotFoundException if no operation path was found from {@code sourceCRS} to * {@code targetCRS}. * @throws FactoryException if the operation creation failed for some other reason. */ public CoordinateOperation createOperation( CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) throws OperationNotFoundException, FactoryException { Set<CoordinateOperation> operations = findOperations(sourceCRS, targetCRS, 1); for (CoordinateOperation op : operations) { return op; } throw new OperationNotFoundException(getErrorMessage(sourceCRS, targetCRS)); }
return AbstractCS.swapAndScaleAxis(sourceCS, targetCS); } catch (IllegalArgumentException exception) { throw new OperationNotFoundException(getErrorMessage(sourceCS, targetCS), exception);
transform = transform.inverse(); } catch (NoninvertibleTransformException exception) { throw new OperationNotFoundException(getErrorMessage(sourceCRS, base), exception);
/** * Creates an operation between two vertical coordinate reference systems. The default * implementation checks if both CRS use the same datum, and then adjusts for axis direction and * units. * * @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't be constructed. */ protected CoordinateOperation createOperationStep( final VerticalCRS sourceCRS, final VerticalCRS targetCRS) throws FactoryException { final VerticalDatum sourceDatum = sourceCRS.getDatum(); final VerticalDatum targetDatum = targetCRS.getDatum(); if (!equalsIgnoreMetadata(sourceDatum, targetDatum)) { throw new OperationNotFoundException(getErrorMessage(sourceDatum, targetDatum)); } final VerticalCS sourceCS = sourceCRS.getCoordinateSystem(); final VerticalCS targetCS = targetCRS.getCoordinateSystem(); final Matrix matrix = swapAndScaleAxis(sourceCS, targetCS); return createFromAffineTransform(AXIS_CHANGES, sourceCRS, targetCRS, matrix); }
/** * Creates an operation between a geographic and a vertical coordinate reference systems. The * default implementation accepts the conversion only if the geographic CRS is a tri dimensional * one and the vertical CRS is for {@linkplain VerticalDatumType#ELLIPSOIDAL height above the * ellipsoid}. More elaborated operation, like transformation from ellipsoidal to geoidal * height, should be implemented here. * * @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't be constructed. * @todo Implement GEOT-352 here. */ protected CoordinateOperation createOperationStep( final GeographicCRS sourceCRS, final VerticalCRS targetCRS) throws FactoryException { if (VerticalDatumType.ELLIPSOIDAL.equals(targetCRS.getDatum().getVerticalDatumType())) { final Matrix matrix = swapAndScaleAxis( sourceCRS.getCoordinateSystem(), targetCRS.getCoordinateSystem()); return createFromAffineTransform(AXIS_CHANGES, sourceCRS, targetCRS, matrix); } throw new OperationNotFoundException(getErrorMessage(sourceCRS, targetCRS)); }
final TemporalDatum targetDatum = targetCRS.getDatum(); if (!equalsIgnoreMetadata(sourceDatum, targetDatum)) { throw new OperationNotFoundException(getErrorMessage(sourceDatum, targetDatum));
throw new OperationNotFoundException("Rotation of prime meridian not yet implemented"); identifier = ELLIPSOID_SHIFT; } else { throw new OperationNotFoundException( Errors.format(ErrorKeys.BURSA_WOLF_PARAMETERS_REQUIRED)); matrix.multiply(normalizeSource); } catch (SingularMatrixException cause) { throw new OperationNotFoundException(getErrorMessage(sourceDatum, targetDatum), cause);
/** * A datum identical to the specified datum except for the prime meridian, which is replaced by * Greenwich. This datum is processed in a special way by {@link #equalsIgnorePrimeMeridian}. */ private static final class TemporaryDatum extends DefaultGeodeticDatum { /** For cros-version compatibility. */ private static final long serialVersionUID = -8964199103509187219L; /** The wrapped datum. */ private final GeodeticDatum datum; /** Wrap the specified datum. */ public TemporaryDatum(final GeodeticDatum datum) { super(getTemporaryName(datum), datum.getEllipsoid(), DefaultPrimeMeridian.GREENWICH); this.datum = datum; } /** Unwrap the datum. */ public static GeodeticDatum unwrap(GeodeticDatum datum) { while (datum instanceof TemporaryDatum) { datum = ((TemporaryDatum) datum).datum; } return datum; } /** Compares this datum with the specified object for equality. */ @Override public boolean equals( final AbstractIdentifiedObject object, final boolean compareMetadata) { if (super.equals(object, compareMetadata)) {
transform = transform.inverse(); } catch (NoninvertibleTransformException exception) { throw new OperationNotFoundException(getErrorMessage(sourceCRS, base), exception);
return operations.get(0); throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS));
throw exception; } catch (FactoryException | NoninvertibleTransformException exception) { throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
throw exception; } catch (FactoryException | NoninvertibleTransformException exception) { throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
final VerticalDatum targetDatum = targetCRS.getDatum(); if (!equalsIgnoreMetadata(sourceDatum, targetDatum)) { throw new OperationNotFoundException(notFoundMessage(sourceDatum, targetDatum)); matrix = CoordinateSystems.swapAndScaleAxes(sourceCS, targetCS); } catch (IllegalArgumentException | IncommensurableException exception) { throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
final VerticalDatum targetDatum = targetCRS.getDatum(); if (!equalsIgnoreMetadata(sourceDatum, targetDatum)) { throw new OperationNotFoundException(notFoundMessage(sourceDatum, targetDatum)); matrix = CoordinateSystems.swapAndScaleAxes(sourceCS, targetCS); } catch (IllegalArgumentException | IncommensurableException exception) { throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
throw exception; } catch (FactoryException | NoninvertibleTransformException exception) { throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
throw exception; } catch (FactoryException | NoninvertibleTransformException exception) { throw new OperationNotFoundException(canNotInvert(sourceCRS), exception);
matrix = CoordinateSystems.swapAndScaleAxes(sourceCS, targetCS); } catch (IllegalArgumentException | IncommensurableException exception) { throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
matrix = CoordinateSystems.swapAndScaleAxes(sourceCS, targetCS); } catch (IllegalArgumentException | IncommensurableException exception) { throw new OperationNotFoundException(notFoundMessage(sourceCRS, targetCRS), exception);
cause = e; throw new OperationNotFoundException(Resources.format(Resources.Keys.CoordinateOperationNotFound_2, WKTUtilities.toType(CoordinateSystem.class, source.getClass()), WKTUtilities.toType(CoordinateSystem.class, target.getClass())), cause);
cause = e; throw new OperationNotFoundException(Resources.format(Resources.Keys.CoordinateOperationNotFound_2, WKTUtilities.toType(CoordinateSystem.class, source.getClass()), WKTUtilities.toType(CoordinateSystem.class, target.getClass())), cause);