blob: 2b766245356feb096571eb47736d3e56483dd611 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package cgeo.geocaching.geopoint;
public class Viewport {
public final Geopoint bottomLeft;
public final Geopoint topRight;
public Viewport(final Geopoint bottomLeft, final Geopoint topRight) {
this.bottomLeft = bottomLeft;
this.topRight = topRight;
}
public Viewport(final Geopoint center, final double latSpan, final double lonSpan) {
final double centerLat = center.getLatitude();
final double centerLon = center.getLongitude();
bottomLeft = new Geopoint(centerLat - latSpan / 2, centerLon - lonSpan / 2);
topRight = new Geopoint(centerLat + latSpan / 2, centerLon + lonSpan / 2);
}
public double getLatitudeMin() {
return bottomLeft.getLatitude();
}
public double getLatitudeMax() {
return topRight.getLatitude();
}
public double getLongitudeMin() {
return bottomLeft.getLongitude();
}
public double getLongitudeMax() {
return topRight.getLongitude();
}
@Override
public String toString() {
return "(" + bottomLeft.toString() + "," + topRight.toString() + ")";
}
}
|