/** * @return the codetypes as the original strings, each identifiable object has atleast one id. */ public final String[] getOrignalCodeStrings() { String[] result = new String[codes.length]; for ( int i = 0; i < codes.length; ++i ) { result[i] = codes[i].getOriginal(); } return result; }
@Override public String getId() { if ( codes != null && codes.length > 0 ) { return codes[0].getOriginal(); } return null; }
@Override public boolean equals( Object o ) { if ( !( o instanceof CRSCodeType ) ) { return false; } CRSCodeType that = (CRSCodeType) o; return original.equalsIgnoreCase( that.getOriginal() ); }
/** * @return the alias of a concrete CRS is the first Code */ @Override public String getAlias() { return getCode().getOriginal(); } }
@Override public CRSResource getCRSResource( CRSCodeType id ) throws CRSConfigurationException { return getCRSResource( id.getOriginal(), null ); }
@Override public int compare( CRSResource o1, CRSResource o2 ) { String first = o1.getCode().getOriginal(); String second = o2.getCode().getOriginal(); int result = first.compareToIgnoreCase( second ); if ( result == 0 && !o1.equals( o2 ) ) { result = -1; } return result; } }
@Override public List<ICRS> getAvailableCRSs() throws CRSConfigurationException { List<ICRS> allSystems = new LinkedList<ICRS>(); Set<String> knownIds = new HashSet<String>(); List<CRSCodeType[]> allCRSIDs = getAvailableCRSCodes(); final int total = allCRSIDs.size(); // int count = 0; // int percentage = (int) Math.round( total / 100.d ); // int number = 0; LOG.info( "Trying to create a total of " + total + " coordinate systems." ); for ( CRSCodeType[] crsID : allCRSIDs ) { if ( crsID != null ) { String id = crsID[0].getOriginal(); if ( id != null && !"".equals( id.trim() ) ) { // if ( count++ % percentage == 0 ) { // System.out.println( ( number ) + ( ( number++ < 10 ) ? " " : "" ) + "% created" ); // } if ( !knownIds.contains( id.toLowerCase() ) ) { allSystems.add( getCRSByCode( CRSCodeType.valueOf( id ) ) ); for ( CRSCodeType code : crsID ) { knownIds.add( code.getOriginal().toLowerCase() ); } } } } } System.out.println(); return allSystems; }
/** * Export the geocentric CRS to it's appropriate deegree-crs-definitions form. * * @param geocentricCRS * to be exported * @param xmlWriter * to export the geocentric CRS to. * @throws XMLStreamException */ @Override protected void export( IGeocentricCRS geocentricCRS, XMLStreamWriter xmlWriter ) throws XMLStreamException { if ( geocentricCRS != null ) { xmlWriter.writeStartElement( CRSNS, "GeocentricCRS" ); exportAbstractCRS( geocentricCRS, xmlWriter ); xmlWriter.writeStartElement( CRSNS, "UsedDatum" ); xmlWriter.writeCharacters( geocentricCRS.getDatum().getCode().getOriginal().toLowerCase() ); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); } }
/** * Export the geocentric/geographic CRS to it's appropriate deegree-crs-definitions form. * * @param geoGraphicCRS * to be exported * @param xmlWriter * to export the geographic CRS to. * @throws XMLStreamException */ @Override protected void export( IGeographicCRS geoGraphicCRS, XMLStreamWriter xmlWriter ) throws XMLStreamException { if ( geoGraphicCRS != null ) { xmlWriter.writeStartElement( CRSNS, "GeographicCRS" ); exportAbstractCRS( geoGraphicCRS, xmlWriter ); xmlWriter.writeStartElement( CRSNS, "UsedDatum" ); xmlWriter.writeCharacters( geoGraphicCRS.getDatum().getCode().getOriginal().toLowerCase() ); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); } }
/** * Export the projected CRS to it's appropriate deegree-crs-definitions form. * * @param projectedCRS * to be exported * @param xmlWriter * to export the projected CRS to. * @throws XMLStreamException */ @Override protected void export( IProjectedCRS projectedCRS, XMLStreamWriter xmlWriter ) throws XMLStreamException { if ( projectedCRS != null ) { xmlWriter.writeStartElement( CRSNS, "ProjectedCRS" ); exportAbstractCRS( projectedCRS, xmlWriter ); xmlWriter.writeStartElement( CRSNS, "UsedGeographicCRS" ); xmlWriter.writeCharacters( projectedCRS.getGeographicCRS().getCode().getOriginal().toLowerCase() ); xmlWriter.writeEndElement(); // projection xmlWriter.writeStartElement( CRSNS, "UsedProjection" ); xmlWriter.writeCharacters( projectedCRS.getProjection().getCode().getOriginal().toLowerCase() ); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); // projectedcrs } }
xmlWriter.writeCharacters( datum.getEllipsoid().getCode().getOriginal().toLowerCase() ); xmlWriter.writeEndElement(); if ( pm != null ) { xmlWriter.writeStartElement( CRSNS, "UsedPrimeMeridian" ); xmlWriter.writeCharacters( pm.getCode().getOriginal().toLowerCase() ); xmlWriter.writeEndElement();
OMElement idRes = null; try { idRes = getResolver().getURIAsType( id.getOriginal() ); } catch ( IOException e ) { LOG.debug( "Exception occurred: " + e.getLocalizedMessage(), e ); LOG.debug( "Could not get an identifiable for id: " + id.getOriginal() + " because: " + e.getLocalizedMessage(), e ); } catch ( IOException e ) { LOG.debug( "Could not get an identifiable for id: " + id.getOriginal() + " because: " + e.getLocalizedMessage(), e );
xmlWriter.writeCharacters( underCRS.getCode().getOriginal().toLowerCase() ); xmlWriter.writeEndElement();
+ sourceCRS.getCode().getOriginal() ); return null;
throw new UnknownCRSException( crsCodeType.getOriginal() );
throw new UnknownCRSException( crsCodeType.getOriginal() );
public Helmert getWGS84Transformation( IGeographicCRS sourceCRS ) { if ( sourceCRS == null ) { return null; } // convert codes to ids CRSCodeType[] codes = sourceCRS.getCodes(); String[] ids = new String[codes.length]; for ( int i = 0; i < ids.length; i++ ) { ids[i] = codes[i].getOriginal(); } for ( String id : ids ) { Map<String, String> params = null; try { params = getURIAsType( id ); } catch ( IOException e ) { throw new CRSConfigurationException( e ); } if ( params != null ) { return createWGS84ConversionInfo( sourceCRS, params ); } } return null; }
/** * @param sourceCRS * @param targetCRS * @param id * @param gsf * the loaded gridshift file */ public NTv2Transformation( ICRS sourceCRS, ICRS targetCRS, CRSResource id, GridShiftFile gsf ) { this( sourceCRS, targetCRS, id ); this.gsf = gsf; String fromEllips = gsf.getFromEllipsoid(); String toEllips = gsf.getToEllipsoid(); IEllipsoid sourceEl = sourceCRS.getGeodeticDatum().getEllipsoid(); IEllipsoid targetEl = targetCRS.getGeodeticDatum().getEllipsoid(); // rb: patched the gridshift file for access to the axis if ( Math.abs( sourceEl.getSemiMajorAxis() - gsf.getFromSemiMajor() ) > 0.001 || Math.abs( sourceEl.getSemiMinorAxis() - gsf.getFromSemiMinor() ) > 0.001 ) { LOG.warn( "The given source CRS' ellipsoid (" + sourceEl.getCode().getOriginal() + ") does not match the 'from' ellipsoid (" + fromEllips + ")defined in the gridfile: " + gridURL ); } if ( Math.abs( targetEl.getSemiMajorAxis() - gsf.getToSemiMajor() ) > 0.001 || Math.abs( targetEl.getSemiMinorAxis() - gsf.getToSemiMinor() ) > 0.001 ) { LOG.warn( "The given target CRS' ellipsoid (" + targetEl.getCode().getOriginal() + ") does not match the 'to' ellipsoid (" + toEllips + ") defined in the gridfile: " + gridURL ); } isIdentity = ( Math.abs( gsf.getFromSemiMajor() - gsf.getToSemiMajor() ) < 0.001 ) && ( Math.abs( gsf.getFromSemiMinor() - gsf.getToSemiMinor() ) < 0.001 ); }
/** * @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; }