disposeAuthorityFactories(ReferencingFactoryFinder.getCRSAuthorityFactories(null)); } catch (Throwable e) { LOGGER.log(
/** * Implementation of {@link CRS#getSupportedAuthorities}. Provided here in order to reduce the * amount of class loading when using {@link CRS} for other purpose than CRS decoding. */ static Set<String> getSupportedAuthorities(final boolean returnAliases) { final Set<String> result = new LinkedHashSet<String>(); for (final CRSAuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(null)) { for (final Identifier id : factory.getAuthority().getIdentifiers()) { result.add(id.getCode()); if (!returnAliases) { break; } } } return result; }
/** * Returns the factories to be used by {@link ManyAuthoritiesFactory}. If the registered * factories changed since the last time this method has been invoked, then this method recreate * the set. */ @Override Collection<AuthorityFactory> getFactories() { final Collection<String> authorities = ReferencingFactoryFinder.getAuthorityNames(); if (authorities != authorityNames) { authorityNames = authorities; final Hints hints = getHints(); final Set<AuthorityFactory> factories = new LinkedHashSet<AuthorityFactory>(); factories.addAll(ReferencingFactoryFinder.getCRSAuthorityFactories(hints)); factories.addAll(ReferencingFactoryFinder.getCSAuthorityFactories(hints)); factories.addAll(ReferencingFactoryFinder.getDatumAuthorityFactories(hints)); factories.addAll( ReferencingFactoryFinder.getCoordinateOperationAuthorityFactories(hints)); setFactories(factories); } return super.getFactories(); }
ReferencingFactoryFinder.getCRSAuthorityFactories(hints); if (Boolean.TRUE.equals(hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.FALSE))) { ReferencingFactoryFinder.getCRSAuthorityFactories(hints)) { final Citation authority = factory.getAuthority(); if (authorities.contains(authority)) {
/** * Implementation of {@link CRS#getSupportedCodes}. Provided here in order to reduce the amount * of class loading when using {@link CRS} for other purpose than CRS decoding. */ static Set<String> getSupportedCodes(final String authority) { final Set<String> result = new LinkedHashSet<String>(AUTHORITY_LESS); for (final CRSAuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(null)) { if (Citations.identifierMatches(factory.getAuthority(), authority)) { final Set<String> codes; try { codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class); } catch (Exception exception) { /* * Failed to fetch the codes either because of a database connection problem * (FactoryException), or because we are using a simple factory that doesn't * support this operation (UnsupportedOperationException), or any unexpected * reason. No codes from this factory will be added to the set. */ CRS.unexpectedException("getSupportedCodes", exception); continue; } if (codes != null) { result.addAll(codes); } } } return result; }
switch (i) { case 0: factories = getCRSAuthorityFactories(hints); break; case 1:
/** * Makes sure that the testing {@link FactoryEPSGExtra} has precedence over {@link * FactoryUsingWKT}. */ @Test public void testFactoryOrdering() { Set<CRSAuthorityFactory> factories = ReferencingFactoryFinder.getCRSAuthorityFactories(null); for (CRSAuthorityFactory factory : factories) { // System.out.println("--> " + factory.getClass().getSimpleName()); } boolean foundWkt = false; boolean foundExtra = false; for (Iterator<CRSAuthorityFactory> it = factories.iterator(); it.hasNext(); ) { CRSAuthorityFactory factory = (CRSAuthorityFactory) it.next(); Class<?> type = factory.getClass(); if (VERBOSE) { // System.out.println(type); } if (type == FactoryEPSGExtra.class) { foundExtra = true; } else if (type == FactoryUsingWKT.class) { foundWkt = true; assertTrue( "We should have encountered WKT factory after the extra one", foundExtra); } } assertTrue(foundWkt); assertTrue(foundExtra); }
@BeforeClass public static void setupCRS() throws FactoryException { CRS.reset("all"); Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); // the following is only to make the test work in Eclipse, where the test // classpath is tainted by the test classpath of dependent modules (whilst in Maven it's // not) Set<CRSAuthorityFactory> factories = ReferencingFactoryFinder.getCRSAuthorityFactories(null); for (CRSAuthorityFactory factory : factories) { if (factory.getClass().getSimpleName().equals("EPSGCRSAuthorityFactory")) { ReferencingFactoryFinder.removeAuthorityFactory(factory); } } assertEquals( AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.decode("urn:ogc:def:crs:EPSG::4326"))); }
ReferencingFactoryFinder.getCRSAuthorityFactories( FORCE_LONGITUDE_FIRST_AXIS_ORDER)) { if (!Citations.identifierMatches(factory.getAuthority(), authority)) {
table.write(Vocabulary.format(VocabularyKeys.NOTE)); table.writeHorizontalSeparator(); for (AuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(HINTS)) { final Citation authority = factory.getAuthority(); final Iterator<? extends Identifier> identifiers =
/** * Creates a CRS chooser backed by the specified authority factory. * * @param authority The authority identifier (e.g. {@code "EPSG"}). * @throws FactoryRegistryException if no authority factory has been found. * @throws FactoryException if the factory can't provide CRS codes. * * @since 2.4 */ public AuthorityCodesComboBox(final String authority) throws FactoryRegistryException, FactoryException { // TODO: remove the cast when we will be allowed to compile for J2SE 1.5. this((CRSAuthorityFactory) FallbackAuthorityFactory.create(CRSAuthorityFactory.class, filter(ReferencingFactoryFinder.getCRSAuthorityFactories(null), authority))); }
for( Object object : ReferencingFactoryFinder.getCRSAuthorityFactories(null) ) { CRSAuthorityFactory factory = (CRSAuthorityFactory) object; try {
static List<CrsInfo> generateCRSList() { // todo - (mp/mz) this method takes time (2 sec.) try to speed up Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, true); Set<CRSAuthorityFactory> factories = ReferencingFactoryFinder.getCRSAuthorityFactories(hints); final List<CRSAuthorityFactory> filtered = new ArrayList<CRSAuthorityFactory>(); for (final CRSAuthorityFactory factory : factories) { if (Citations.identifierMatches(factory.getAuthority(), AUTHORITY)) { filtered.add(factory); } } CRSAuthorityFactory crsAuthorityFactory = FallbackAuthorityFactory.create(CRSAuthorityFactory.class, filtered); Set<String> codes = new HashSet<String>(); List<CrsInfo> crsList = new ArrayList<CrsInfo>(1024); retrieveCodes(codes, GeodeticCRS.class, crsAuthorityFactory); retrieveCodes(codes, ProjectedCRS.class, crsAuthorityFactory); for (String code : codes) { final String authCode = String.format("%s:%s", AUTHORITY, code); crsList.add(new CrsInfo(authCode, crsAuthorityFactory)); } codes.clear(); AutoCRSFactory autoCRSFactory = new AutoCRSFactory(); retrieveCodes(codes, ProjectedCRS.class, autoCRSFactory); for (String code : codes) { final String authCode = String.format("AUTO:%s", code); crsList.add(new AutoCrsInfo(authCode, autoCRSFactory)); } Collections.sort(crsList); return crsList; }
static List<CrsInfo> generateCRSList() { // todo - (mp/mz) this method takes time (2 sec.) try to speed up Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, true); Set<CRSAuthorityFactory> factories = ReferencingFactoryFinder.getCRSAuthorityFactories(hints); final List<CRSAuthorityFactory> filtered = new ArrayList<CRSAuthorityFactory>(); for (final CRSAuthorityFactory factory : factories) { if (Citations.identifierMatches(factory.getAuthority(), AUTHORITY)) { filtered.add(factory); } } CRSAuthorityFactory crsAuthorityFactory = FallbackAuthorityFactory.create(CRSAuthorityFactory.class, filtered); Set<String> codes = new HashSet<String>(); List<CrsInfo> crsList = new ArrayList<CrsInfo>(1024); retrieveCodes(codes, GeodeticCRS.class, crsAuthorityFactory); retrieveCodes(codes, ProjectedCRS.class, crsAuthorityFactory); for (String code : codes) { final String authCode = String.format("%s:%s", AUTHORITY, code); crsList.add(new CrsInfo(authCode, crsAuthorityFactory)); } codes.clear(); AutoCRSFactory autoCRSFactory = new AutoCRSFactory(); retrieveCodes(codes, ProjectedCRS.class, autoCRSFactory); for (String code : codes) { final String authCode = String.format("AUTO:%s", code); crsList.add(new AutoCrsInfo(authCode, autoCRSFactory)); } Collections.sort(crsList); return crsList; }
for (AuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(hints)) { String authorityCode = NOT_SET_CRS;
public JCRSList(){ String authority = "EPSG"; this.factory = FallbackAuthorityFactory.create(CRSAuthorityFactory.class, filter(ReferencingFactoryFinder.getCRSAuthorityFactories(null), authority));