blob: 2ecbeda5f7af35acee31f0079956e4cd9c3cdb31 (
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
41
42
43
44
45
46
47
48
49
50
|
package com.benburwell.planes.gui.aircraftmap;
import com.benburwell.planes.data.Position;
/**
* Created by ben on 11/19/16.
*/
public class GeoPoint {
private double latitude;
private double longitude;
private double altitude;
public GeoPoint(Position position) {
this.latitude = position.getLatitude();
this.longitude = position.getLongitude();
this.altitude = position.getAltitude();
}
public GeoPoint(double latitude, double longitude, double altitude) {
this.latitude = latitude;
this.longitude = longitude;
this.altitude = altitude;
}
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;
}
public boolean shouldDrawOn(AircraftMap map) {
int x = this.getX(map);
int y = this.getY(map);
return (x >= 0 && x <= map.getWidth() && y >= 0 && y <= map.getHeight());
}
public double getAltitude() {
return this.altitude;
}
}
|