/** * Returns some map projection methods supported by {@literal Proj.4}. * Current implementation can not return the complete list of Proj.4 method, but returns the main ones. * For each operation method in the returned set, the Proj.4 projection name can be obtained as below: * * {@preformat java * String proj = IdentifiedObjects.getName(method, Citations.PROJ4); * } * * The {@code proj} names obtained as above can be given in argument to the * {@link #getOperationMethod(String)} and {@link #getDefaultParameters(String)} methods. * * @param type <code>{@linkplain SingleOperation}.class</code> for fetching all operation methods, or * <code>{@linkplain Projection}.class</code> for fetching only map projection methods. * @return methods available in this factory for coordinate operations of the given type. * * @see org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#getAvailableMethods(Class) */ public Set<OperationMethod> getAvailableMethods(final Class<? extends SingleOperation> type) { return new LazySet<>(CollectionsExt.filter(mtFactory.getAvailableMethods(type).iterator(), Proj4Factory::isSupported)); }
/** * Returns some map projection methods supported by {@literal Proj.4}. * Current implementation can not return the complete list of Proj.4 method, but returns the main ones. * For each operation method in the returned set, the Proj.4 projection name can be obtained as below: * * {@preformat java * String proj = IdentifiedObjects.getName(method, Citations.PROJ4); * } * * The {@code proj} names obtained as above can be given in argument to the * {@link #getOperationMethod(String)} and {@link #getDefaultParameters(String)} methods. * * @param type <code>{@linkplain SingleOperation}.class</code> for fetching all operation methods, or * <code>{@linkplain Projection}.class</code> for fetching only map projection methods. * @return methods available in this factory for coordinate operations of the given type. * * @see org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#getAvailableMethods(Class) */ public Set<OperationMethod> getAvailableMethods(final Class<? extends SingleOperation> type) { return new LazySet<>(CollectionsExt.filter(mtFactory.getAvailableMethods(type).iterator(), new Predicate<IdentifiedObject>() { @Override public boolean test(final IdentifiedObject method) { return isSupported(method); } })); }
/** * Tests {@link CollectionsExt#filter(Iterator, Predicate)}. */ @Test public void testFilter() { final Iterator<Integer> it = CollectionsExt.filter(Arrays.asList(2, 5, 7, 4, 8).iterator(), (Integer n) -> (n & 1) == 0); assertTrue ( it.hasNext()); assertEquals(2, it.next().intValue()); assertEquals(4, it.next().intValue()); assertTrue ( it.hasNext()); assertTrue ( it.hasNext()); assertEquals(8, it.next().intValue()); assertFalse ( it.hasNext()); }