/** * Creates a NTv2 Grid. * * @param name The NTv2 grid name * @return the grid * @throws FactoryException if grid cannot be created */ public GridShiftFile createNTv2Grid(URL gridLocation) throws FactoryException { if (gridLocation == null) { throw new FactoryException("The grid location must be not null"); } synchronized (ntv2GridCache) { // Prevent simultaneous threads trying to load same grid GridShiftFile grid = ntv2GridCache.get(gridLocation.toExternalForm()); if (grid != null) { // Cached: return grid; // - Return } else { // Not cached: if (gridLocation != null) { grid = loadNTv2Grid(gridLocation); // - Load if (grid != null) { ntv2GridCache.put(gridLocation.toExternalForm(), grid); // - Cache return grid; // - Return } } throw new FactoryException("NTv2 Grid " + gridLocation + " could not be created."); } } }