Reformatted double value lat and lon to final double VIEW_CORNER_LAT and VIEW_CORNER_LON

This commit is contained in:
zyt10
2017-03-22 12:03:46 +13:00
parent 44b5b0b771
commit 29a0b23670
@@ -31,12 +31,15 @@ import static java.lang.Math.abs;
* Modified by Haoming Yin (hyi25) on 20/3/2017. * Modified by Haoming Yin (hyi25) on 20/3/2017.
*/ */
public class CanvasController { public class CanvasController {
@FXML
private Canvas canvas;
private Race race; private Race race;
private GraphicsContext gc; private GraphicsContext gc;
private HashMap<Boat, TimelineInfo> timelineInfos; private HashMap<Boat, TimelineInfo> timelineInfos;
@FXML private final double VIEW_CORNER_LAT = 32.280808;
private Canvas canvas; private final double VIEW_CORNER_LON = -64.858401;
public void initialize() { public void initialize() {
gc = canvas.getGraphicsContext2D(); gc = canvas.getGraphicsContext2D();
@@ -133,8 +136,8 @@ public class CanvasController {
//Double x = (MAP_WIDTH / 360.0) * (180 + lon); //Double x = (MAP_WIDTH / 360.0) * (180 + lon);
//Double y = (MAP_HEIGHT / 180.0) * (80 - lat); //Double y = (MAP_HEIGHT / 180.0) * (80 - lat);
double x = abs(lat - 32.283808) * 1000; // to prevent negative longitude double x = (lat - VIEW_CORNER_LAT) * 1000; // to prevent negative longitude
double y = abs(lon + 64.854401) * 1000; // to prevent negative latitude double y = (lon - VIEW_CORNER_LON) * 1000; // to prevent negative latitude
double diameter = 0.5; double diameter = 0.5;
gc.setFill(color); gc.setFill(color);
@@ -160,8 +163,8 @@ public class CanvasController {
* @param singleMark * @param singleMark
*/ */
private void drawSingleMark(SingleMark singleMark) { private void drawSingleMark(SingleMark singleMark) {
double x = abs(singleMark.getLatitude() - 32.283808) * 1000; // to prevent negative longitude double x = (singleMark.getLatitude() - VIEW_CORNER_LAT) * 1000; // to prevent negative longitude
double y = abs(singleMark.getLongitude() + 64.854401) * 1000; // to prevent negative latitude double y = (singleMark.getLongitude() - VIEW_CORNER_LON) * 1000; // to prevent negative latitude
gc.setFill(Color.BLACK); gc.setFill(Color.BLACK);
gc.fillOval(x, y, 0.5, 0.5); gc.fillOval(x, y, 0.5, 0.5);