result.add(FallbackAuthorityFactory.create(buffer)); buffer.clear();
/** * Wraps the specified authority factories. If the specified collection contains more than one * element, then a chain of {@code FallbackAuthorityFactory} instances is created. The type is * inferred from the factories found in the collection. * * <p>Consider using <code>{@linkplain #create(Class, Collection) create}(type, factories) * </code> instead when the type is known at compile time. * * @param factories The factories to wrap, in iteration order. * @return The given factories as a chain of fallback factories. * @throws FactoryNotFoundException if the collection doesn't contains at least one element. * @since 2.4 */ public static AuthorityFactory create(final Collection<? extends AuthorityFactory> factories) throws FactoryNotFoundException { ensureNonNull("factories", factories); if (factories.isEmpty()) { throw new FactoryNotFoundException( Errors.format(ErrorKeys.FACTORY_NOT_FOUND_$1, AuthorityFactory.class)); } return create(false, interfaceMask(factories), factories.iterator()); }
/** * Wraps the specified authority factories. If the specified collection contains more than one * element, then a chain of {@code FallbackAuthorityFactory} instances is created. * * @param <T> The interface to implement. * @param type The interface to implement. Should be one of {@link DatumAuthorityFactory}, * {@link CSAuthorityFactory}, {@link CRSAuthorityFactory} or {@link * CoordinateOperationAuthorityFactory}. * @param factories The factories to wrap, in iteration order. * @return The given factories as a chain of fallback factories. * @throws FactoryNotFoundException if the collection doesn't contains at least one element. * @throws ClassCastException if {@code type} is illegal. */ public static <T extends AuthorityFactory> T create( final Class<T> type, final Collection<T> factories) throws FactoryNotFoundException, ClassCastException { ensureNonNull("type", type); ensureNonNull("factories", factories); if (factories.isEmpty()) { throw new FactoryNotFoundException(Errors.format(ErrorKeys.FACTORY_NOT_FOUND_$1, type)); } return type.cast(create(false, interfaceMask(type), factories.iterator())); }
/** * Invoked when a factory is requested for a specific version. This method should create a * factory for the exact version specified by the argument, or return {@code null} if no such * factory is available. In the later case, this class will fallback on the factory specified at * {@linkplain #URI_AuthorityFactory(AuthorityFactory, String, Citation) construction time}. * * @param version The version for the factory to create. * @return The factory, of {@code null} if there is none for the specified version. * @throws FactoryException if an error occurred while creating the factory. */ protected AuthorityFactory createVersionedFactory(final Version version) throws FactoryException { final Hints hints = new Hints(factory.getImplementationHints()); hints.put(Hints.VERSION, version); final List<AuthorityFactory> factories = Arrays.asList(new AuthorityFactory[] {new AllAuthoritiesFactory(hints), factory}); return FallbackAuthorityFactory.create(factories); }
/** * 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))); }
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; }
public JCRSList(){ String authority = "EPSG"; this.factory = FallbackAuthorityFactory.create(CRSAuthorityFactory.class, filter(ReferencingFactoryFinder.getCRSAuthorityFactories(null), authority));