Fixed course rotation #fix

This commit is contained in:
Michael Rausch
2017-03-22 14:05:55 +13:00
parent c12760b70a
commit 7591a79323
2 changed files with 36 additions and 48 deletions
+18 -18
View File
@@ -6,57 +6,57 @@
<name type="start-line">Start</name> <name type="start-line">Start</name>
<mark> <mark>
<name>Start1</name> <name>Start1</name>
<latitude>32.296038</latitude> <latitude>32.296577</latitude>
<longitude>-64.854401</longitude> <longitude>-64.854304</longitude>
</mark> </mark>
<mark> <mark>
<name>Start2</name> <name>Start2</name>
<latitude>32.293834</latitude> <latitude>32.293771</latitude>
<longitude>-64.855195</longitude> <longitude>-64.855242</longitude>
</mark> </mark>
</gate> </gate>
<mark> <mark>
<name>Mid Mark</name> <name>Mid Mark</name>
<latitude>32.292881</latitude> <latitude>32.293039</latitude>
<longitude>-64.843231</longitude> <longitude>-64.843983</longitude>
</mark> </mark>
<gate> <gate>
<name>Leeward Gate</name> <name>Leeward Gate</name>
<mark> <mark>
<name>Leeward Gate1</name> <name>Leeward Gate1</name>
<latitude>32.283808</latitude> <latitude>32.284680</latitude>
<longitude>-64.850012</longitude> <longitude>-64.850045</longitude>
</mark> </mark>
<mark> <mark>
<name>Leeward Gate2</name> <name>Leeward Gate2</name>
<latitude>32.283216</latitude> <latitude>32.280164</latitude>
<longitude>-64.847686</longitude> <longitude>-64.847591</longitude>
</mark> </mark>
</gate> </gate>
<gate> <gate>
<name>Windward Gate</name> <name>Windward Gate</name>
<mark> <mark>
<name>Windward Gate1</name> <name>Windward Gate1</name>
<latitude>32.309908</latitude> <latitude>32.309693</latitude>
<longitude>-64.833665</longitude> <longitude>-64.835249</longitude>
</mark> </mark>
<mark> <mark>
<name>Windward Gate2</name> <name>Windward Gate2</name>
<latitude>32.309158</latitude> <latitude>32.308046</latitude>
<longitude>-64.830834</longitude> <longitude>-64.831785</longitude>
</mark> </mark>
</gate> </gate>
<gate type="finish-line"> <gate type="finish-line">
<name>Finish</name> <name>Finish</name>
<mark> <mark>
<name>Finish1</name> <name>Finish1</name>
<latitude>32.318439</latitude> <latitude>32.317379</latitude>
<longitude>-64.837367</longitude> <longitude>-64.839291</longitude>
</mark> </mark>
<mark> <mark>
<name>Finish2</name> <name>Finish2</name>
<latitude>32.318303</latitude> <latitude>32.317257</latitude>
<longitude>-64.834974</longitude> <longitude>-64.836260</longitude>
</mark> </mark>
</gate> </gate>
</marks> </marks>
@@ -28,8 +28,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import static java.lang.Math.abs;
/** /**
* Created by ptg19 on 15/03/17. * Created by ptg19 on 15/03/17.
* Modified by Haoming Yin (hyi25) on 20/3/2017. * Modified by Haoming Yin (hyi25) on 20/3/2017.
@@ -40,6 +38,9 @@ public class CanvasController {
private GraphicsContext gc; private GraphicsContext gc;
private HashMap<Boat, TimelineInfo> timelineInfos; private HashMap<Boat, TimelineInfo> timelineInfos;
private final double ORIGIN_LAT = 32.320504;
private final double ORIGIN_LON = -64.857063;
@FXML @FXML
private Canvas canvas; private Canvas canvas;
@@ -85,10 +86,16 @@ public class CanvasController {
timer.start(); timer.start();
int i = 0; int i = 0;
Double maxDuration = 0.0;
for (TimelineInfo timelineInfo : timelineInfos.values()) { for (TimelineInfo timelineInfo : timelineInfos.values()) {
Timeline timeline = timelineInfo.getTimeline(); Timeline timeline = timelineInfo.getTimeline();
System.out.println();
if (/*timeline.getTotalDuration().greaterThanOrEqualTo(maxDuration)*/ true){
}
if (i == timelineInfos.values().size() - 1) { if (i == timelineInfos.values().size() - 1) {
timeline.setOnFinished(event -> { timeline.setOnFinished(event -> {
@@ -99,6 +106,10 @@ public class CanvasController {
} }
}); });
System.out.println("B");
}
else{
System.out.println("A");
} }
timeline.play(); timeline.play();
@@ -164,18 +175,11 @@ public class CanvasController {
*/ */
private void drawBoat(double lat, double lon, Color color) { private void drawBoat(double lat, double lon, Color color) {
// Latitude // Latitude
//Double x = (MAP_WIDTH / 360.0) * (180 + lon); double x = (lon - ORIGIN_LON) * 1000;
//Double y = (MAP_HEIGHT / 180.0) * (80 - lat); double y = (ORIGIN_LAT - lat) * 1000;
double yLat = lon;
double yLon = lat;
//double x = abs(yLat - 32.283808) * 1000; // to prevent negative longitude
//double y = abs(yLon + 64.854401) * 1000; // to prevent negative latitude
double y = abs(yLat + 64.854401) * 1000; // to prevent negative longitude
double x = abs(yLon - 32.283808) * 1000; // to prevent negative latitude
double diameter = 0.5; double diameter = 0.5;
gc.setFill(color); gc.setFill(color);
gc.fillOval(x, y, diameter, diameter); gc.fillOval(x, y, diameter, diameter);
} }
@@ -199,24 +203,8 @@ public class CanvasController {
* @param singleMark * @param singleMark
*/ */
private void drawSingleMark(SingleMark singleMark) { private void drawSingleMark(SingleMark singleMark) {
double yLat = singleMark.getLongitude(); double x = (singleMark.getLongitude() - ORIGIN_LON) * 1000;
double yLon = singleMark.getLatitude(); double y = (ORIGIN_LAT - singleMark.getLatitude()) * 1000;
//double yLat = singleMark.getLatitude();
//double yLon = singleMark.getLongitude();
System.out.println(yLat);
System.out.println(yLon);
//double x = abs(yLat - 32.283808) * 1000; // to prevent negative longitude
//double y = abs(yLon + 64.854401) * 1000; // to prevent negative latitude
double x = abs(yLon - 32.283808) * 1000; // to prevent negative longitude
double y = abs(yLat + 64.854401) * 1000; // to prevent negative latitude
System.out.println(x);
System.out.println(y);
System.out.println();
gc.setFill(Color.BLACK); gc.setFill(Color.BLACK);
gc.fillOval(x, y, 0.5, 0.5); gc.fillOval(x, y, 0.5, 0.5);