summaryrefslogtreecommitdiff
path: root/src/com/benburwell/planes/gui/aircraftmap/GeoPoint.java
blob: 5cd553569080d144c8c4aca6a5a053268278fed2 (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
package com.benburwell.planes.gui.aircraftmap;

/**
 * Created by ben on 11/19/16.
 */
public class GeoPoint {
    private double latitude;
    private double longitude;

    public GeoPoint(double latitude, double longitude) {
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public int getX(AircraftMap map) {
        double degreesFromCenter = map.getCenterLongitude() - this.longitude;
        double pixelsFromCenter = degreesFromCenter * map.getPixelsPerDegreeLongitude();
        double centerPixels = map.getSize().getWidth() / 2;
        int xPosition = (int) (centerPixels - pixelsFromCenter);
        return xPosition;
    }

    public int getY(AircraftMap map) {
        double degreesFromCenter = map.getCenterLatitude() - this.latitude;
        double pixelsFromCenter = degreesFromCenter * map.getPixelsPerDegreeLatitude();
        double centerPixels = map.getSize().getHeight() / 2;
        int yPosition = (int) (centerPixels + pixelsFromCenter);
        return yPosition;
    }
}