+ private ZipInputStream getStreamToSrtmData(URL inUrl)
+ throws IOException
+ {
+ ZipInputStream localData = null;
+ try {
+ localData = getStreamToLocalHgtFile(inUrl);
+ }
+ catch (IOException ioe) {
+ localData = null;
+ }
+ if (localData != null)
+ {
+ return localData;
+ }
+ // try to download to cache
+ TileDownloader cacher = new TileDownloader();
+ TileDownloader.Result result = cacher.downloadTile(inUrl);
+ System.out.println("Result: " + result);
+ if (result == TileDownloader.Result.DOWNLOADED)
+ {
+ _numCached++;
+ return getStreamToLocalHgtFile(inUrl);
+ }
+ // If we don't have a cache, we may be able to download it temporarily
+ if (result != TileDownloader.Result.DOWNLOAD_FAILED)
+ {
+ _hadToDownload = true;
+ return new ZipInputStream(inUrl.openStream());
+ }
+ // everything failed
+ return null;
+ }
+
+ /**
+ * Get the SRTM file from the local cache, if available
+ * @param inUrl URL for online resource
+ * @return ZipInputStream on the local file or null if not there
+ */
+ private ZipInputStream getStreamToLocalHgtFile(URL inUrl)