+ /**
+ * See whether the SRTM file is already available locally first, then try online
+ * @param inUrl URL for online resource
+ * @return ZipInputStream either on the local file or on the downloaded zip file
+ */
+ private ZipInputStream getStreamToHgtFile(URL inUrl)
+ throws IOException
+ {
+ String diskCachePath = Config.getConfigString(Config.KEY_DISK_CACHE);
+ if (diskCachePath != null)
+ {
+ File srtmDir = new File(diskCachePath, "srtm");
+ if (srtmDir.exists() && srtmDir.isDirectory() && srtmDir.canRead())
+ {
+ File srtmFile = new File(srtmDir, new File(inUrl.getFile()).getName());
+ if (srtmFile.exists() && srtmFile.isFile() && srtmFile.canRead())
+ {
+ // System.out.println("Lookup: Using file " + srtmFile.getAbsolutePath());
+ // File found, use this one
+ return new ZipInputStream(new FileInputStream(srtmFile));
+ }
+ }
+ }
+ // System.out.println("Lookup: Trying online: " + inUrl.toString());
+ _hadToDownload = true;
+ // MAYBE: Only download if we're in online mode?
+ return new ZipInputStream(inUrl.openStream());
+ }
+