public CRSCodeType[] getCodes() { return getReferencedObject().getCodes(); }
/** * 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, CRSResource ids ) { if ( ids == null ) { return null; } return getCachedIdentifiable( expectedType, ids.getCodes() ); }
@Override public boolean equals( Object other ) { if ( other != null && other instanceof CRSIdentifiable ) { CRSResource that = ( (CRSResource) other ); CRSCodeType[] mId = getCodes(); CRSCodeType[] yId = that.getCodes(); CRSCodeType[] small = mId.length >= yId.length ? yId : mId; CRSCodeType[] large = mId.length < yId.length ? yId : mId; List<CRSCodeType> list = Arrays.asList( large ); boolean result = true; for ( int i = 0; result && ( i < small.length ); ++i ) { CRSCodeType id = small[i]; if ( id != null ) { result = list.contains( id ); } } return result; } return false; }
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; }
private int getEPSGCode( CRSResource crs ) { CRSCodeType[] pCodes = crs.getCodes(); int epsgCode = -1; for ( int i = 0; i < pCodes.length && epsgCode == -1; ++i ) { CRSCodeType pCode = pCodes[i]; if ( "EPSG".equalsIgnoreCase( pCode.getCodeSpace() ) ) { try { epsgCode = Integer.parseInt( pCode.getCode() ); } catch ( NumberFormatException e ) { LOG.warn( "Given epsg code is not an int, ignoring it: " + pCode.getCode() ); } } } return epsgCode; }
/** * @param rootElement * containing a gml:VerticalDatum dom representation. * @return a {@link VerticalDatum} instance initialized with values from the given XML-OM fragment or * <code>null</code> if the given root element is <code>null</code> * @throws XMLParsingException * if the dom tree is not consistent or a required element is missing. * */ protected IVerticalDatum parseVerticalDatum( OMElement rootElement ) throws XMLParsingException { if ( rootElement == null ) { LOG.debug( "The given vertical datum root element is null, returning nothing" ); return null; } CRSResource id = parseIdentifiedObject( rootElement ); if ( id == null ) { return null; } IVerticalDatum result = getCachedIdentifiable( VerticalDatum.class, id ); if ( result == null ) { result = new VerticalDatum( id ); if ( LOG.isDebugEnabled() ) { LOG.debug( "Parsing id of vertical datum resulted in: " + Arrays.toString( id.getCodes() ) ); } } return addIdToCache( result, false ); }
throws XMLStreamException { CRSCodeType[] identifiers = identifiable.getCodes(); for ( CRSCodeType id : identifiers ) { if ( id != null ) {
throws XMLStreamException { CRSCodeType[] identifiers = identifiable.getCodes(); for ( CRSCodeType id : identifiers ) { if ( id != null ) {
/** * Takes the references of the other object and stores them in this CRSIdentifiable Object. * * @param other * identifiable object. */ public CRSIdentifiable( CRSResource other ) { this( other.getCodes(), other.getNames(), other.getVersions(), other.getDescriptions(), other.getAreasOfUse() ); }
LOG.debug( "Parsing id of prime meridian resulted in: " + Arrays.toString( id.getCodes() ) ); IPrimeMeridian result = getCachedIdentifiable( PrimeMeridian.class, id.getCodes() ); CRSCodeType[] foundCodes = id.getCodes(); CRSCodeType[] resultCodes = new CRSCodeType[codes.length + foundCodes.length]; System.arraycopy( codes, 0, resultCodes, 0, codes.length );
CRSResource unitID = parseIdentifiedObject( unitElement ); if ( unitID != null ) { CRSCodeType[] codes = unitID.getCodes(); for ( int i = 0; i < codes.length && result == null; ++i ) { result = createUnitFromString( codes[i].getOriginal() );
CRSResource paramID = paramValue.first; if ( paramID != null ) { SupportedTransformationParameters paramType = SupportedTransformationParameters.fromCodes( paramID.getCodes() ); IUnit unit = second.first;
LOG.debug( "Parsing id of vertical crs resulted in: " + Arrays.toString( id.getCodes() ) );
result = new Ellipsoid( semiMajor, units, inverseFlattening, id.getCodes(), id.getNames(), id.getVersions(), id.getDescriptions(), id.getAreasOfUse() ); } else if ( !Double.isNaN( eccentricity ) ) { result = new Ellipsoid( semiMajor, eccentricity, units, id.getCodes(), id.getNames(), id.getVersions(), id.getDescriptions(), id.getAreasOfUse() ); } else { result = new Ellipsoid( units, semiMajor, semiMinorAxis, id.getCodes(), id.getNames(), id.getVersions(), id.getDescriptions(), id.getAreasOfUse() );
LOG.debug( "Parsing id of datum resulted in: " + Arrays.toString( id.getCodes() ) );
LOG.debug( "Parsing id of compound crs resulted in: " + Arrays.toString( id.getCodes() ) );
LOG.debug( "Parsing id of geodetic crs resulted in: " + Arrays.toString( id.getCodes() ) );
LOG.debug( "Parsing id of ellipsoid resulted in: " + Arrays.toString( id.getCodes() ) );
LOG.debug( "Parsing id of projected crs resulted in: " + Arrays.toString( id.getCodes() ) );