CoordinateOperationFactoryUsingWKT extends DeferredAuthorityFactory implements CoordinateOperationAuthorityFactory { public CoordinateOperation createCoordinateOperation(String code) throws NoSuchAuthorityCodeException, FactoryException { CoordinateOperation coordop = super.createCoordinateOperation(code); if (coordop == null) { CoordinateOperationAuthorityFactory fallback = getFallbackAuthorityFactory(); if (fallback != null) { coordop = fallback.createCoordinateOperation(code); } } return coordop; } CoordinateOperationFactoryUsingWKT();  CoordinateOperationFactoryUsingWKT(Hints userHints); protected  CoordinateOperationFactoryUsingWKT(final Hints userHints, final int priority); synchronized Citation getAuthority(); @Override Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(
            String sourceCRS, String targetCRS); CoordinateOperation createCoordinateOperation(String code); static final String FILENAME; static final int PRIORITY; }
@Test public void testExtraDirectoryHint() throws Exception { Hints hints = new Hints(Hints.COORDINATE_OPERATION_AUTHORITY_FACTORY, CoordinateOperationFactoryUsingWKT.class); try { hints.put(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY, "invalid"); fail("Should of been tossed out as an invalid hint"); } catch (IllegalArgumentException expected) { } String directory = new File(".").getAbsolutePath(); hints = new Hints(Hints.COORDINATE_OPERATION_AUTHORITY_FACTORY, CoordinateOperationFactoryUsingWKT.class); hints.put(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY, directory); CoordinateOperationFactoryUsingWKT fact = (CoordinateOperationFactoryUsingWKT) ReferencingFactoryFinder.getCoordinateOperationAuthorityFactory("EPSG", new Hints(Hints.COORDINATE_OPERATION_AUTHORITY_FACTORY, CoordinateOperationFactoryUsingWKT.class)); CoordinateOperation co = fact.createCoordinateOperation(INVERSE_CRS_PAIR); CoordinateReferenceSystem crs = CRS.decode(TARGET_CRS); assertSame(crs, co.getSourceCRS()); crs = CRS.decode(SOURCE_CRS); assertSame(crs, co.getTargetCRS()); assertTrue(co.getMathTransform() instanceof MathTransform); double[] p = new double[2]; co.getMathTransform().transform(DST_TEST_POINT, 0, p, 0, 1); assertEquals(p[0], SRC_TEST_POINT[0], 1e-8); assertEquals(p[1], SRC_TEST_POINT[1], 1e-8); }
@Test public void testCreateCoordinateOperation() throws TransformException { try { assertNull(factory.createCoordinateOperation(INVALID_CRS)); } catch (FactoryException e) { fail(factory.getClass().getSimpleName() + " threw a FactoryException when requesting" + "a nonexistent operation. Instead, a NoSuchAuthorityCodeException was expected."); } try { CoordinateOperation co = factory.createCoordinateOperation(CRS_PAIR); assertNotNull(co); CoordinateReferenceSystem crs = CRS.decode(SOURCE_CRS); assertSame(crs, co.getSourceCRS()); crs = CRS.decode(TARGET_CRS); assertSame(crs, co.getTargetCRS()); assertTrue(co.getMathTransform() instanceof MathTransform); double[] p = new double[2]; co.getMathTransform().transform(SRC_TEST_POINT, 0, p, 0, 1); assertEquals(p[0], DST_TEST_POINT[0], 1e-8); assertEquals(p[1], DST_TEST_POINT[1], 1e-8); } catch (FactoryException e) { fail(factory.getClass().getSimpleName() + " threw a FactoryException when creating" + " coordinate operation from an existing code."); } }