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