1 package tim.prune.function.srtm;
3 import tim.prune.data.Coordinate;
4 import tim.prune.data.DataPoint;
7 * Class to represent a single tile of Srtm data, from a single hgt.zip file
11 /** Latitude in degrees north/south */
12 private int _latitude = 0;
13 /** Longitude in degrees east/west */
14 private int _longitude = 0;
17 * Constructor working out the tile for a single point
18 * @param inPoint data point
20 public SrtmTile(DataPoint inPoint)
22 Coordinate latitude = inPoint.getLatitude();
23 _latitude = (int) Math.floor(latitude.getDouble());
24 Coordinate longitude = inPoint.getLongitude();
25 _longitude = (int) Math.floor(longitude.getDouble());
29 * Constructor working out the tile for a single point
30 * @param inLatitude latitude in degrees
31 * @param inLongitude longitude in degrees
33 public SrtmTile(int inLatitude, int inLongitude)
35 _latitude = inLatitude;
36 _longitude = inLongitude;
41 * @param inOther other tile object
42 * @return true if both represent same tile
44 public boolean equals(SrtmTile inOther)
46 return (_latitude == inOther._latitude) && (_longitude == inOther._longitude);
49 /** @return latitude as int */
50 public int getLatitude() {
54 /** @return longitude as int */
55 public int getLongitude() {
60 * @return filename of tile
62 public String getTileName()
64 return (_latitude >= 0?"N":"S")
65 + (Math.abs(_latitude) < 10?"0":"")
67 + (_longitude >= 0?"E":"W")
68 + (Math.abs(_longitude) < 100?"0":"")
69 + (Math.abs(_longitude) < 10?"0":"")
70 + Math.abs(_longitude);
73 public SrtmSource findBestCachedSource()
75 SrtmSource[] sources = {new SrtmGl1Source(),
77 for (int i = 0; i < sources.length; i++)
79 if (sources[i].isCached(this))