]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/srtm/SrtmTile.java
Version 10, May 2010
[GpsPrune.git] / tim / prune / function / srtm / SrtmTile.java
1 package tim.prune.function.srtm;
2
3 import tim.prune.data.Coordinate;
4 import tim.prune.data.DataPoint;
5
6 /**
7  * Class to represent a single tile of Srtm data, from a single hgt.zip file
8  */
9 public class SrtmTile
10 {
11         /** Latitude in degrees north/south */
12         private int _latitude = 0;
13         /** Longitude ini degrees east/west */
14         private int _longitude = 0;
15
16         /**
17          * Constructor working out the tile for a single point
18          * @param inPoint data point
19          */
20         public SrtmTile(DataPoint inPoint)
21         {
22                 Coordinate latitude = inPoint.getLatitude();
23                 _latitude = (int) Math.floor(latitude.getDouble());
24                 Coordinate longitude = inPoint.getLongitude();
25                 _longitude = (int) Math.floor(longitude.getDouble());
26         }
27
28         /**
29          * Check for equality
30          * @param inOther other tile object
31          * @return true if both represent same tile
32          */
33         public boolean equals(SrtmTile inOther)
34         {
35                 return (_latitude == inOther._latitude) && (_longitude == inOther._longitude);
36         }
37
38         /** @return latitude as int */
39         public int getLatitude() {
40                 return _latitude;
41         }
42
43         /** @return longitude as int */
44         public int getLongitude() {
45                 return _longitude;
46         }
47
48         /**
49          * @return filename of tile
50          */
51         public String getTileName()
52         {
53                 return (_latitude >= 0?"N":"S")
54                         + (Math.abs(_latitude) < 10?"0":"")
55                         + Math.abs(_latitude)
56                         + (_longitude >= 0?"E":"W")
57                         + (Math.abs(_longitude) < 100?"0":"")
58                         + (Math.abs(_longitude) < 10?"0":"")
59                         + Math.abs(_longitude)
60                         + ".hgt.zip";
61         }
62 }