protected void loadOffsetFile() { InputStream inputStream = WWIO.openFileOrResourceStream(this.offsetsFilePath, typeof(EGM96)); if (inputStream == null) { String msg = Logging.getMessage("generic.CannotOpenFile", this.offsetsFilePath); Logging.logger().severe(msg); throw new WWRuntimeException(msg); } try { AVList bufferParams = new AVListImpl(); bufferParams.setValue(AVKey.DATA_TYPE, AVKey.INT16); bufferParams.setValue(AVKey.BYTE_ORDER, AVKey.BIG_ENDIAN); this.deltas = BufferWrapper.wrap(WWIO.readStreamToBuffer(is, true), bufferParams); } catch (IOException e) { String msg = Logging.getMessage("generic.ExceptionAttemptingToReadFile", this.offsetsFilePath); Logging.logger().log(java.util.logging.Level.SEVERE, msg, e); throw e; } finally { WWIO.closeStream(is, this.offsetsFilePath); } }
/** * Reads XML document and extracts raster sources * * @param config Parsed configuration document. * * @return TRUE, if all raster sources are available, FALSE otherwise * */ protected bool readRasterSources(RasterServerConfiguration config) { long startTime = System.currentTimeMillis(); bool hasUnavailableRasterSources = false; int numSources = 0; Sector extent = null; try { List <RasterServerConfiguration.Source> sources = config.getSources(); if (sources == null || sources.size() == 0) { return(false); } numSources = sources.size(); foreach (RasterServerConfiguration.Source source in sources) { Thread.yield(); try { String rasterSourcePath = source.getPath(); if (WWUtil.isEmpty(rasterSourcePath)) { continue; } AVList rasterMetadata = new AVListImpl(); File rasterSourceFile = new File(rasterSourcePath); // normalize rasterSourcePath = rasterSourceFile.getAbsolutePath(); if (!rasterSourceFile.exists()) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.FileDoesNotExists", rasterSourcePath); Logging.logger().warning(reason); continue; } if (!rasterSourceFile.canRead()) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.FileNoReadPermission", rasterSourcePath); Logging.logger().warning(reason); continue; } DataRasterReader rasterReader = this.findDataRasterReader(rasterSourceFile, rasterMetadata); if (null == rasterReader) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.UnknownFileFormatOrMatchingReaderNotFound", rasterSourcePath); Logging.logger().warning(reason); continue; } Sector sector = source.getSector(); if (null == sector) { rasterReader.readMetadata(rasterSourceFile, rasterMetadata); Object o = rasterMetadata.getValue(AVKey.SECTOR); sector = (o is Sector) ? (Sector)o : null; } else { rasterMetadata.setValue(AVKey.SECTOR, sector); } Object rasterPixelFormat = rasterMetadata.getValue(AVKey.PIXEL_FORMAT); String datasetPixelFormat = this.getDataSetPixelFormat(); if (!WWUtil.isEmpty(datasetPixelFormat)) { // verify all data rasters are the same type - we do not allow to mix elevations and imagery if (!datasetPixelFormat.Equals(rasterPixelFormat)) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.UnexpectedRasterType", rasterSourcePath); Logging.logger().warning(reason); continue; } } else { if (AVKey.IMAGE.Equals(rasterPixelFormat) || AVKey.ELEVATION.Equals(rasterPixelFormat)) { this.setDataSetPixelFormat((String)rasterPixelFormat); } else { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.UnknownFileFormat", rasterSourcePath); Logging.logger().warning(reason); continue; } } if (null != sector) { extent = Sector.union(extent, sector); this.dataRasterList.add( new CachedDataRaster(rasterSourceFile, rasterMetadata, rasterReader, this.getCache()) ); } else { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.NoSectorSpecified", rasterSourcePath); Logging.logger().warning(reason); } } catch (Throwable t) { String message = t.getMessage(); message = (WWUtil.isEmpty(message)) ? t.getCause().getMessage() : message; Logging.logger().log(java.util.logging.Level.WARNING, message, t); } } if (null != extent && extent.getDeltaLatDegrees() > 0d && extent.getDeltaLonDegrees() > 0d) { this.setValue(AVKey.SECTOR, extent); } } catch (Throwable t) { String message = t.getMessage(); message = (WWUtil.isEmpty(message)) ? t.getCause().getMessage() : message; Logging.logger().log(java.util.logging.Level.SEVERE, message, t); } finally { Logging.logger().finest(this.getStringValue(AVKey.DISPLAY_NAME) + ": " + numSources + " files in " + (System.currentTimeMillis() - startTime) + " milli-seconds"); } return(!hasUnavailableRasterSources); }