aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/geopoint/Viewport.java
blob: ef80ae387076ffa64b466092a6a0eb266be8a74f (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
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();
    }
}