public CRSCodeType getCode() { return getReferencedObject().getCode(); }
private synchronized <V extends CRSResource> V addIdToCache( Map<CRSCodeType, CRSResource> cache, V identifiable, boolean update ) { if ( identifiable == null ) { return null; } for ( CRSCodeType idString : identifiable.getCodes() ) { // if ( idString != null && !"".equals( idString.trim() ) ) { if ( idString != null ) { if ( cache.containsKey( idString ) && cache.get( idString ) != null ) { if ( update ) { LOG.debug( "Updating cache with new identifiable: " + idString ); cache.put( idString, identifiable ); } } else { LOG.debug( "Adding new identifiable to cache: " + idString ); cache.put( idString, identifiable ); } } else { LOG.debug( "Not adding the null string id to the cache of identifiable: " + identifiable.getCode() ); } } return identifiable; }
case NOT_SUPPORTED: default: LOG.error( "The conversion method (Projection): " + conversionMethodID.getCode() + " is currently not supported by the deegree crs package." );
/** * Get a {@link CRSIdentifiable} (actually a type V that extends it) from the cache that corresponds to the a * {@link CRSCodeType}. * * @param <V> * @param id * a {@link CRSCodeType} * @return a {@link CRSIdentifiable}-extending object that corresponds to the given id */ @SuppressWarnings("unchecked") public <V extends CRSResource> V getCachedIdentifiable( CRSCodeType id ) { if ( id == null ) { return null; } V result = (V) cachedIdentifiables.get( id ); if ( LOG.isDebugEnabled() ) { LOG.debug( "Searched for id: " + id + " resulted in: " + ( ( result == null ) ? "null" : result.getCode() ) ); } return result; }
/** * The id is as it is, not trimming 'upcasing' or other modifications will be done in this method. * * @param <V> * the type to cast to if the casting fails, null will be returned. * * @param id * to search the cache for * @return the {@link CRSIdentifiable} or <code>null</code> if it was not found or the wrong type was found. */ @SuppressWarnings("unchecked") public <V extends CRSResource> V getCachedIdentifiable( String id ) { if ( id == null ) { return null; } V result = (V) cachedIdentifiables.get( CRSCodeType.valueOf( id ) ); if ( LOG.isDebugEnabled() ) { LOG.debug( "Searched for id: " + id + " resulted in: " + ( ( result == null ) ? "null" : result.getCode() ) ); } return result; }
/** * Get a {@link CRSIdentifiable} (actually a type V that extends it) from the cache that corresponds to the a * {@link CRSCodeType}. An array of code types is given; the first identifiable that is found in (for a code, when * they are checked in order) is returned * * @param <V> * @param expectedType * the type of the sought object * @param ids * an array of {@link CRSCodeType}s * @return the identifiable found in the cache corresponding to the (first) id */ public <V extends CRSResource> V getCachedIdentifiable( Class<V> expectedType, CRSCodeType[] ids ) { if ( ids == null || ids.length == 0 ) { return null; } V result = null; for ( int i = 0; i < ids.length && result == null; i++ ) { result = getCachedIdentifiable( expectedType, ids[i] ); if ( LOG.isDebugEnabled() ) { LOG.debug( "Searched for id: " + ids[i] + " resulted in: " + ( ( result == null ) ? "null" : result.getCode() ) ); } } return result; }
/** * Get a {@link CRSIdentifiable} (actually a type V that extends it) from the cache that corresponds to the a * {@link CRSCodeType}. * * @param <V> * @param expectedType * the type of the sought object * @param id * a {@link CRSCodeType} * @return the identifiable found in the cache corresponding to the id */ @SuppressWarnings("unchecked") private <V extends CRSResource> V getCachedIdentifiable( Class<V> expectedType, CRSCodeType id ) { if ( id == null ) { return null; } V result = null; try { result = (V) cachedIdentifiables.get( id ); } catch ( ClassCastException cce ) { LOG.error( "Given id is not of type: " + expectedType.getCanonicalName() + " found following error: " + cce.getLocalizedMessage() ); } if ( LOG.isDebugEnabled() ) { LOG.debug( "Searched for id: " + id + " resulted in: " + ( ( result == null ) ? "null" : result.getCode() ) ); } return result; }
/** * The id are what they are, not trimming 'upcasing' or other modifications will be done in this method. * * @param expectedType * The class of type T which is expected. * @param <V> * the type to cast to if the casting fails, null will be returned. * @param ids * to search the cache for * @return the {@link CRSIdentifiable} of the first matching id or <code>null</code> if it was not found. */ public <V extends CRSResource> V getCachedIdentifiable( Class<V> expectedType, String[] ids ) { if ( ids == null || ids.length == 0 ) { return null; } V result = null; for ( int i = 0; i < ids.length && result == null; i++ ) { result = getCachedIdentifiable( expectedType, ids[i] ); if ( LOG.isDebugEnabled() ) { LOG.debug( "Searched for id: " + ids[i] + " resulted in: " + ( ( result == null ) ? "null" : result.getCode() ) ); } } return result; }
/** * The id is as it is, not trimming 'upcasing' or other modifications will be done in this method. * * @param expectedType * The class of type T which is expected. * @param <V> * the type to cast to if the casting fails, null will be returned. * * @param id * to search the cache for * @return the {@link CRSIdentifiable} or <code>null</code> if it was not found or the wrong type was found. */ @SuppressWarnings("unchecked") public <V extends CRSResource> V getCachedIdentifiable( Class<V> expectedType, String id ) { if ( id == null ) { return null; } V result = null; try { result = (V) cachedIdentifiables.get( CRSCodeType.valueOf( id ) ); } catch ( ClassCastException cce ) { LOG.error( "Given id is not of type: " + expectedType.getCanonicalName() + " found following error: " + cce.getLocalizedMessage() ); } if ( LOG.isDebugEnabled() ) { LOG.debug( "Searched for id: " + id + " resulted in: " + ( ( result == null ) ? "null" : result.getCode() ) ); } return result; }
/** * @param reader * from which the crs is to be created (using cached datums, conversioninfos and projections). * @return a geocentric coordinatesystem based on the given xml-element. * @throws CRSConfigurationException * if a required element could not be found, or an xmlParsingException occurred. * @throws XMLStreamException */ protected CRS parseGeocentricCRS( XMLStreamReader reader ) throws CRSConfigurationException, XMLStreamException { // no need to get it from the cache, because the abstract provider checked it already. CRSResource id = parseIdentifiable( reader ); Axis[] axis = parseAxisOrder( reader ); List<Transformation> transformations = parseAlternativeTransformations( reader ); IGeodeticDatum usedDatum = parseReferencedGeodeticDatum( reader, id.getCode().getOriginal() ); GeocentricCRS result = new GeocentricCRS( transformations, usedDatum, axis, id ); // adding to cache will be done in AbstractCRSProvider. return result; }
/** * @param reader * positioned on the crs to be created (using cached datums, conversioninfos and projections). * * @return a geographic coordinatesystem based on the given xml-element. * @throws CRSConfigurationException * if a required element could not be found, or an xmlParsingException occurred. * @throws XMLStreamException */ protected CRS parseGeographicCRS( XMLStreamReader reader ) throws CRSConfigurationException, XMLStreamException { if ( reader == null ) { return null; } CRSResource id = parseIdentifiable( reader ); // no need to get it from the cache, because the abstract provider checked it already. Axis[] axis = parseAxisOrder( reader ); List<Transformation> transformations = parseAlternativeTransformations( reader ); // get the datum IGeodeticDatum usedDatum = parseReferencedGeodeticDatum( reader, id.getCode().getOriginal() ); GeographicCRS result = new GeographicCRS( transformations, usedDatum, axis, id ); // adding to cache will be done in AbstractCRSProvider. return result; }
id.getCode() ) );
"UsedGeographicCRS", id.getCode() ) );