/** * Retrieves the {@link ICRS} from the set provider that is identified by the given {@link CRSCodeType} id. * * @param id * the {@link CRSCodeType} of the wanted crs * @return the {@link ICRS} that corresponds to the id * @throws CRSConfigurationException */ public ICRS getCRSByCode( CRSCodeType id ) throws CRSConfigurationException { return getCRSByCode( id, false ); }
private static ICRS getEncodedCrs( final String[] tokens ) { if ( tokens.length % 2 == 1 ) { return getCRSRef( tokens[tokens.length - 1] ); } return null; } }
/** * The default coordinate transformation factory. Will be constructed only when first needed. * * @param provider * used to do lookups of transformations */ public TransformationFactory( CRSStore provider ) { this.provider = provider; this.preferredDSTransform = provider.getPreferedTransformationType(); }
/** * 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<ICRS> getAllCoordinateSystems() { List<ICRS> crss = new ArrayList<ICRS>(); Collection<CRSStore> all = CRSManager.getAll(); for ( CRSStore crsStore : all ) { crss.addAll( crsStore.getAvailableCRSs() ); } return crss; }
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; }
/** * 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 ); }
@Override public void init( Workspace workspace ) { this.workspace = workspace; initDefault(); init( new File( ( (DefaultWorkspace) workspace ).getLocation(), "crs" ) ); }
/** * Add the id to the cache, by mapping it to all its identifiers. * * @param <V> * type of CRSIdentifiable * @param resource * to insert into cache * @param update * if true an existing identifiable in the cache will be overwritten. * @return the identifiable */ public synchronized <V extends CRSResource> V addIdToCache( V resource, boolean update ) { return addIdToCache( cachedIdentifiables, resource, update ); }
/** * 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; }
/** * 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; }
/** * 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; }
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 ); }
/** * @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 ); }
/** * 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 * @param forceXY * true if the axis order of the coordinate system should be x/y (EAST/NORTH; WEST/SOUTH); false id the * defined axis order should be used * @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, boolean forceXY ) throws UnknownCRSException { return lookup( null, name, forceXY ); }
@Override public Object getObject( String uri, String baseURL ) { ICRS crs = null; try { crs = lookup( uri, forceXY ); } catch ( UnknownCRSException e ) { LOG.debug( "Could not find CRS with uri " + uri + "; return null." ); } return crs; } }, uri, null, forceXY );
private ICRS parseCRS( XMLStreamReader in ) throws UnknownCRSException, XMLStreamException { String crs = XMLStreamUtils.getRequiredText( in, new QName( SLDNS, "CRS" ), true ); return CRSManager.lookup( crs ); }