/** * Retrieve a {@link Transformation} (chain) which transforms coordinates from the given source into the given * target crs. If no such {@link Transformation} could be found or the implementation does not support inverse * lookup of transformations <code>null<code> will be returned. * * @param storeId * identifier of the store, looking for the {@link Transformation}, may be <code>null</code> if in all * {@link CRSStore}s should be searched * @param sourceCRS * start {@link ICRS} of the transformation (chain) * @param targetCRS * end {@link ICRS} of the transformation (chain). * @return the given {@link Transformation} or <code>null<code> if no such transformation was found. * @throws TransformationException * @throws IllegalArgumentException */ public synchronized static Transformation getTransformation( String storeId, ICRS sourceCRS, ICRS targetCRS ) throws IllegalArgumentException, TransformationException { return getTransformation( storeId, sourceCRS, targetCRS, null ); }
/** * Get a {@link Transformation} with given id, or <code>null</code> if it does not exist. * * @param storeId * identifier of the store, looking for the {@link Transformation}, may be <code>null</code> if in all * {@link CRSStore}s should be searched * @param id * of the {@link Transformation} * @return the identified {@link Transformation} or <code>null<code> if no such transformation is found. */ public synchronized static Transformation getTransformation( String storeId, String id ) { CRSStore crsStore = idToCRSStore.get( storeId ); if ( crsStore == null ) { for ( String sId : storeIds ) { CRSStore store = idToCRSStore.get( sId ); Transformation transformation = getTransformation( store, id ); if ( transformation != null ) { return transformation; } } } else { return getTransformation( crsStore, id ); } return null; }
/** * Creates a transformation chain, which can be used to transform incoming coordinates (in the given source CRS) * into this Transformer's targetCRS. * * @param sourceCRS * in which the coordinates are defined. * @return the Transformation chain. * @throws TransformationException * if no transformation chain could be created. * @throws IllegalArgumentException * if the given ICoordinateSystem is <code>null</code> * @throws UnknownCRSException * if the given crs name could not be mapped to a valid (configured) crs. * */ protected Transformation createCRSTransformation( String sourceCRS ) throws TransformationException, IllegalArgumentException, UnknownCRSException { if ( sourceCRS == null ) { throw new IllegalArgumentException( Messages.getMessage( "CRS_PARAMETER_NOT_NULL", "createCRSTransformation( ICoordinateSystem )", "sourceCRS" ) ); } return CRSManager.getTransformation( null, CRSManager.lookup( sourceCRS ), targetCRS ); }
/** * Simple method to check for the CRS transformation to use. If the Transformer was initialized with a * {@link Transformation} this will be used (if the sourceCRS fits). If it does not fit or no transformation was * given, a new Transformation will be created using the {@link TransformationFactory} * * @param sourceCRS * @param toBeUsedTransformations * @return the transformation needed to convert from given source to the constructed target crs. * @throws TransformationException */ private synchronized Transformation checkOrCreateTransformation( ICRS sourceCRS, List<Transformation> toBeUsedTransformations ) throws TransformationException { if ( definedTransformation == null || !( definedTransformation.getSourceCRS().equals( sourceCRS ) && definedTransformation.getTargetCRS().equals( targetCRS ) ) ) { definedTransformation = CRSManager.getTransformation( null, sourceCRS, targetCRS, toBeUsedTransformations ); if ( LOG.isDebugEnabled() ) { if ( definedTransformation == null ) { LOG.debug( "Identity transformation (null)." ); } else { LOG.debug( "Resulting transform: {}", definedTransformation.getTransformationPath( null ).toString() ); } } } return definedTransformation; } }
List<Transformation> trans = null; if ( transId != null ) { Transformation t = CRSManager.getTransformation( null, transId ); if ( t != null ) { trans = Collections.singletonList( CRSManager.getTransformation( null, transId ) ); } else { throw new IllegalArgumentException( "Specified transformation id '" + transId
case 6: ICRS tarCRS = getCRS( tCrs ); requestedTransform = CRSManager.getTransformation( null, transId ); if ( requestedTransform == null || tarCRS == null ) { sb = new StringBuilder(); sourceCRS = getCRS( sCrs ); targetCRS = getCRS( tCrs ); requestedTransform = CRSManager.getTransformation( null, transId ); if ( targetCRS == null || sourceCRS == null || requestedTransform == null ) { sb = new StringBuilder();