]> gitweb.fperrin.net Git - GpsPrune.git/blob - src/tim/prune/function/srtm/TileFinder.java
Use SRTM 1deg data from NASA servers
[GpsPrune.git] / src / tim / prune / function / srtm / TileFinder.java
1 package tim.prune.function.srtm;
2
3 import java.io.InputStream;
4 import java.net.MalformedURLException;
5 import java.net.URL;
6 import java.util.ArrayList;
7
8
9 /**
10  * Class to get the URLs of the SRTM tiles
11  * using the srtmtiles.dat file
12  */
13 public abstract class TileFinder
14 {
15         /** URL prefix for all tiles */
16         private static final String URL_PREFIX = "https://fred_earthdata:Xaev0oca@e4ftl01.cr.usgs.gov/MEASURES/SRTMGL1.003/2000.02.11/";
17
18         /**
19          * Get the Urls for the given list of tiles
20          * @param inTiles list of Tiles to get
21          * @return array of URLs
22          */
23         public static URL[] getUrls(ArrayList<SrtmTile> inTiles)
24         {
25                 if (inTiles == null || inTiles.size() < 1) {return null;}
26                 URL[] urls = new URL[inTiles.size()];
27                 // Read dat file into array
28                 for (int t=0; t<inTiles.size(); t++)
29                 {
30                         SrtmTile tile = inTiles.get(t);
31                         // Get byte from lookup array
32                         try {
33                                 urls[t] = new URL(URL_PREFIX + tile.getTileName());
34                         } catch (MalformedURLException e) {} // ignore error, url stays null
35                 }
36                 return urls;
37         }
38 }