]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/srtm/SrtmTile.java
Version 16, February 2014
[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 in 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          * Constructor working out the tile for a single point
30          * @param inLatitude latitude in degrees
31          * @param inLongitude longitude in degrees
32          */
33         public SrtmTile(int inLatitude, int inLongitude)
34         {
35                 _latitude = inLatitude;
36                 _longitude = inLongitude;
37         }
38
39         /**
40          * Check for equality
41          * @param inOther other tile object
42          * @return true if both represent same tile
43          */
44         public boolean equals(SrtmTile inOther)
45         {
46                 return (_latitude == inOther._latitude) && (_longitude == inOther._longitude);
47         }
48
49         /** @return latitude as int */
50         public int getLatitude() {
51                 return _latitude;
52         }
53
54         /** @return longitude as int */
55         public int getLongitude() {
56                 return _longitude;
57         }
58
59         /**
60          * @return filename of tile
61          */
62         public String getTileName()
63         {
64                 return (_latitude >= 0?"N":"S")
65                         + (Math.abs(_latitude) < 10?"0":"")
66                         + Math.abs(_latitude)
67                         + (_longitude >= 0?"E":"W")
68                         + (Math.abs(_longitude) < 100?"0":"")
69                         + (Math.abs(_longitude) < 10?"0":"")
70                         + Math.abs(_longitude)
71                         + ".hgt.zip";
72         }
73 }