System.out.println(…)
calls do not exist in SIS/Geotk.getSupportedCodes(…)
method will not be ported to SIS.
The recommended approach is rather to get the AuthorityFactory
instance for the authority,
then invoke getAuthorityCodes(…)
on that instance.Command line:
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r11873:13074 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/CRS.java
Revision 11873 | Revision 13074 |
---|---|
import java.util.Iterator; import java.util.List; import java.util.ArrayList; // OpenGIS dependencies import org.opengis.metadata.citation.Citation; |
import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.util.Set; import java.util.TreeSet; // OpenGIS dependencies import org.opengis.metadata.citation.Citation; |
Object value = visitor.factory( factory ); if( value != null ) list.add( value ); } catch (Throwable t ){ if( t != null ){ // log trouble - as we can only throw the "last" cause System.err.println( trouble ); } trouble = t; } } |
Object value = visitor.factory( factory ); if( value != null ) list.add( value ); } catch (Throwable t ){ trouble = t; } } |
throw new FactoryException( "Trouble encountered while visiting CoordianteOpperationFactory", trouble ); } } else { if( trouble != null ){ // log trouble - ie the last known cause of failure System.err.println( trouble ); } } return list; } /** * Locate for CoordinateReferenceSystem for specific code. |
throw new FactoryException( "Trouble encountered while visiting CoordianteOpperationFactory", trouble ); } } return list; } /** * Get list of the codes that are supported by the authority. * For example, "EPSG" --> "EPSG:2000", "EPSG:2001", "EPSG:2002" because we know what * they mean. * * @param authority - list of supported codes * @return */ public static Set getSupportedCodes(String AUTHORITY) { TreeSet result = new TreeSet(); for( Iterator i = FactoryFinder.getCRSAuthorityFactories().iterator(); i.hasNext(); ) //for each authority factory { CRSAuthorityFactory factory = (CRSAuthorityFactory) i.next(); //grab a factory try { Citation authority = factory.getAuthority(); // what authorities does this factory produce? if( !authority.getIdentifiers().contains( AUTHORITY ) ) continue; Set s = factory.getAuthorityCodes( CoordinateReferenceSystem.class ); result.addAll(s); } catch (Exception e) { e.printStackTrace(); // we hid errors - hopefully another factory will do the work for us. } } return result; } /** * Locate for CoordinateReferenceSystem for specific code. |
CRSAuthorityFactory factory = (CRSAuthorityFactory) i.next(); try { Citation authority = factory.getAuthority(); System.out.println("Checking "+AUTHORITY+ " authority against "+authority ); System.out.println(" is "+AUTHORITY+ " in "+authority.getIdentifiers() ); System.out.println(" ..."+authority.getIdentifiers().contains( AUTHORITY ) ); if( !authority.getIdentifiers().contains( AUTHORITY ) ) continue; System.out.println("Lookup "+code+ " authority "+factory.getClass().toString() ); CoordinateReferenceSystem crs = (CoordinateReferenceSystem) factory.createObject( code.toUpperCase() ); if( crs != null ) return crs; } catch (FactoryException e) { |
CRSAuthorityFactory factory = (CRSAuthorityFactory) i.next(); try { Citation authority = factory.getAuthority(); //System.out.println("Checking "+AUTHORITY+ " authority against "+authority ); //System.out.println(" is "+AUTHORITY+ " in "+authority.getIdentifiers() ); //System.out.println(" ..."+authority.getIdentifiers().contains( AUTHORITY ) ); if( !authority.getIdentifiers().contains( AUTHORITY ) ) continue; //System.out.println("Lookup "+code+ " authority "+factory.getClass().toString() ); CoordinateReferenceSystem crs = (CoordinateReferenceSystem) factory.createObject( code.toUpperCase() ); if( crs != null ) return crs; } catch (FactoryException e) { |