/** * Constructs a {@code NADCONTransform} from the specified grid shift files. * * @param latGridName path and name (or just name if {@link #GRID_LOCATION} is set) to the * latitude difference file. This will have a {@code .las} or {@code .laa} file extention. * @param longGridName path and name (or just name if {@link #GRID_LOCATION} is set) to the * longitude difference file. This will have a {@code .los} or {@code .loa} file extention. * @throws ParameterNotFoundException if a math transform parameter cannot be found. * @throws FactoryException if there is a problem creating this math transform (ie file * extentions are unknown or there is an error reading the grid files) */ public NADCONTransform(final URI latGridName, final URI longGridName) throws ParameterNotFoundException, FactoryException { if (latGridName == null) { throw new NoSuchIdentifierException("Latitud grid shift file name is null", null); } if (longGridName == null) { throw new NoSuchIdentifierException("Latitud grid shift file name is null", null); } this.latGridName = latGridName; this.longGridName = longGridName; URL latGridURL = locateGrid(latGridName); URL longGridURL = locateGrid(longGridName); this.grid = FACTORY.loadGridShift(latGridURL, longGridURL); this.gridShiftTransform = grid.getMathTransform(); }
@Test public void testReleaseGrids() throws IOException, FactoryException { File gridShifts = new File("src/test/resources/org/geotools/referencing/factory/gridshift"); File las = new File(gridShifts, "stpaul.las"); File los = new File(gridShifts, "stpaul.los"); File tlas = new File("./target/stpaul.las"); File tlos = new File("./target/stpaul.los"); copyFile(las, tlas); copyFile(los, tlos); NADCONGridShiftFactory factory = new NADCONGridShiftFactory(); NADConGridShift shift = factory.loadGridShift(URLs.fileToUrl(tlas), URLs.fileToUrl(tlos)); // minor checks on the grid assertNotNull(shift); // now the good part, try to delete the files, on windows this will fail // unless the sources were properly closed assertTrue(tlas.delete()); assertTrue(tlos.delete()); }