private static ICRS getEncodedCrs( final String[] tokens ) { if ( tokens.length % 2 == 1 ) { return getCRSRef( tokens[tokens.length - 1] ); } return null; } }
/** * Creates a direct {@link ICRS} instance from the given {@link CRSCodeType} not just a {@link CRSRef}, if no * {@link ICRS} was found an {@link UnknownCRSException} will be thrown. All configured {@link CRSStore}s will be * considered and the first match returned. * * @param codeType * the {@link CodeType} of the CRS to return * @return a direct {@link ICRS} instance with the given {@link CodeType} not just a {@link CRSRef} * @throws UnknownCRSException * if a {@link ICRS} with the name is not known */ public synchronized static ICRS lookup( CRSCodeType codeType ) throws UnknownCRSException { return lookup( null, codeType ); }
private List<CRSCodeType[]> getAllCRSCodeTypes() { List<CRSCodeType[]> crss = new ArrayList<CRSCodeType[]>(); Collection<CRSStore> all = CRSManager.getAll(); for ( CRSStore crsStore : all ) { crss.addAll( crsStore.getAvailableCRSCodes() ); } return crss; }
/** * 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 ); }
ICRS crs = CRSManager.getCRSRef( "EPSG:4326", true ); CoordinateDimension dim = DIM_2; GeometryPropertyType.GeometryType geomType = GeometryType.GEOMETRY; if ( rs2.next() ) { if ( rs2.getInt( 2 ) != -1 ) { crs = CRSManager.lookup( "EPSG:" + rs2.getInt( 2 ), true ); srid = "" + rs2.getInt( 2 ); } else { ICRS crs = CRSManager.getCRSRef( "EPSG:4326", true ); CoordinateDimension dim = DIM_2; GeometryPropertyType.GeometryType geomType = GeometryType.GEOMETRY; if ( rs2.next() ) { if ( rs2.getInt( 2 ) != -1 ) { crs = CRSManager.lookup( "EPSG:" + rs2.getInt( 2 ), true ); srid = "" + rs2.getInt( 2 ); } else {
/** * 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 ); }
String sourceCRSId = line.getOptionValue( OPT_S_SRS ); if ( sourceCRSId != null ) { sourceCRS = CRSManager.lookup( sourceCRSId ); ICRS targetCRS = CRSManager.lookup( targetCRSId ); Transformation t = CRSManager.getTransformation( null, transId ); if ( t != null ) { trans = Collections.singletonList( CRSManager.getTransformation( null, transId ) ); } else { throw new IllegalArgumentException( "Specified transformation id '" + transId
/** * 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; }
/** * Returns a {@link CRSRef} instance which is not resolved. * * @param uri * the uri of the resource which is used to resolve the reference * @return an unresolved {@link CRSRef} instance */ public static CRSRef getCRSRef( String uri ) { return getCRSRef( uri, false ); }
/** * returns true if the the passed SRS is available in deegree * * @param srs * @return <code>true</code> if the the passed SRS is available in deegree */ private boolean isAvailable( String srs ) { ICRS crs = null; try { crs = CRSManager.lookup( srs ); } catch ( UnknownCRSException e ) { return false; } return crs != null; }
private List<ICRS> getAllCoordinateSystems() { List<ICRS> crss = new ArrayList<ICRS>(); Collection<CRSStore> all = CRSManager.getAll(); for ( CRSStore crsStore : all ) { crss.addAll( crsStore.getAvailableCRSs() ); } return crss; }
/** * 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; } }
public static ICRS getAxisAwareCrs( final String epsgCode ) { final String identifierWithCorrectOrder = "urn:ogc:def:crs:epsg::" + epsgCode; return CRSManager.getCRSRef( identifierWithCorrectOrder ); }
/** * Creates a direct {@link ICRS} instance from the given name not just a {@link CRSRef}, if no {@link ICRS} was * found an {@link UnknownCRSException} will be thrown. All configured {@link CRSStore}s will be considered and the * first match returned. * * @param name * of the crs, e.g. EPSG:4326 * @return a direct {@link ICRS} instance corresponding to the given name not just a {@link CRSRef}, using all * configured {@link CRSStore}s. * @throws UnknownCRSException * if a {@link ICRS} with the name is not known */ public synchronized static ICRS lookup( String name ) throws UnknownCRSException { return lookup( name, false ); }
/** * This method allows to get all {@link ICRS} from all stores. * * @return all configured CRSs. * @throws CRSConfigurationException * if the implementation was confronted by an exception and could not deliver the requested crs. This * exception should not be thrown if no CoordinateSystems were found, in the latter case an empty List ( * a list with size == 0 ) should be returned. */ public List<ICRS> getAvailableCRSs() throws CRSConfigurationException { List<ICRS> result = new ArrayList<ICRS>(); for ( CRSStore store : getAll() ) { result.addAll( store.getAvailableCRSs() ); } return result; }
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();
/** * @return the defined crs or null if no crs was defined. */ public ICRS getCRS() { String s = options.get( CRS ); if ( s == null || "".equals( s.trim() ) ) { return null; } return CRSManager.getCRSRef( s ); }
/** * Creates a direct {@link ICRS} instance from the given name using not just a {@link CRSRef} the given storeID, if * no {@link ICRS} was found in the given store an {@link UnknownCRSException} will be thrown. * * @param storeId * identifier of the {@link CRSStore} looking for the {@link ICRS} with the given name, may be * <code>null</code> if in all {@link CRSStore}s should be searched * @param name * of the crs, e.g. EPSG:31466 * @return a direct {@link ICRS} instance not just a {@link CRSRef} corresponding to the given name from the * {@link CRSStore} with the given id * @throws UnknownCRSException * if a {@link ICRS} with the name is not known */ public synchronized static ICRS lookup( String storeId, String name ) throws UnknownCRSException { return lookup( storeId, name, false ); }
/** * This methods allows to get all available identifiers and not in the coordinatesystems themselves from all stores. * * @return the identifiers of all configured CRSs. * @throws CRSConfigurationException * if the implementation was confronted by an exception and could not deliver the requested crs. This * exception should not be thrown if no CoordinateSystems were found, in the latter case an empty List ( * a list with size == 0 ) should be returned. */ public List<CRSCodeType[]> getAvailableCRSCodes() throws CRSConfigurationException { List<CRSCodeType[]> result = new ArrayList<CRSCodeType[]>(); for ( CRSStore store : getAll() ) { result.addAll( store.getAvailableCRSCodes() ); } return result; }
/** * @param crs * should be a list of whitespace separated identifiers, may be null */ public static List<ICRS> fromJaxb( String crs ) { ArrayList<ICRS> list = new ArrayList<ICRS>(); if ( crs == null ) { return list; } for ( String c : crs.split( "\\s" ) ) { if ( !c.isEmpty() ) { list.add( CRSManager.getCRSRef( c ) ); } } return list; }