compound marks now can give the mark they have that needs to be rounded this is used to draw the line around the correct mark

#story[1101]
main
hba56 8 years ago
parent e2605c3c7c
commit e53d72f24b

@ -164,4 +164,91 @@ public class CompoundMark {
public void setRoundingType(RoundingType roundingType) { public void setRoundingType(RoundingType roundingType) {
this.roundingType = roundingType; this.roundingType = roundingType;
} }
/**
* Used to find the mark that is to be rounded at a gate when approaching from the south
* will also give the single mark if there is only one
* @param bearing the bearing a boat will approach form
* @return the mark to round
*/
public Mark getMarkForRounding(Bearing bearing){
Mark westMostMark;
Mark eastMostMark;
Mark northMostMark;
Mark southMostMark;
//check to see if there are two marks
if (mark2 == null){
return mark1;
}
//finds the mark furthest west and east
if(this.getMark1Position().getLatitude() > this.getMark2Position().getLatitude()){
westMostMark = this.mark1;
eastMostMark = this.mark2;
}else{
westMostMark = this.mark2;
eastMostMark = this.mark1;
}
//finds the mark furthest north and south
if(this.getMark1Position().getLongitude() > this.getMark2Position().getLongitude()){
northMostMark = this.mark1;
southMostMark = this.mark2;
}else{
northMostMark = this.mark2;
southMostMark = this.mark1;
}
if (bearing.degrees() > 315 || bearing.degrees() <= 45){
//north
switch (this.getRoundingType()){
case SP:
case Port:
return westMostMark;
case PS:
case Starboard:
return eastMostMark;
default:return null;
}
}else if(bearing.degrees() > 45 && bearing.degrees() <= 135){
//east
switch (this.getRoundingType()){
case SP:
case Port:
return northMostMark;
case PS:
case Starboard:
return southMostMark;
default:return null;
}
}else if(bearing.degrees() > 135 && bearing.degrees() <= 225){
//south
switch (this.getRoundingType()){
case SP:
case Port:
return eastMostMark;
case PS:
case Starboard:
return westMostMark;
default:return null;
}
}else if(bearing.degrees() > 225 && bearing.degrees() <= 315){
//west
switch (this.getRoundingType()){
case SP:
case Port:
return southMostMark;
case PS:
case Starboard:
return northMostMark;
default:return null;
}
}else{
return null;
}
}
} }

@ -1,12 +1,13 @@
package visualiser.model; package visualiser.model;
import javafx.scene.Node;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.paint.*; import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.transform.Rotate; import javafx.scene.transform.Rotate;
import network.Messages.Enums.BoatStatusEnum; import network.Messages.Enums.BoatStatusEnum;
import shared.dataInput.RaceDataSource; import shared.dataInput.RaceDataSource;
import shared.enums.RoundingType;
import shared.model.*; import shared.model.*;
import java.util.List; import java.util.List;
@ -510,7 +511,12 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//finds the direction of the current leg as a bearing //finds the direction of the current leg as a bearing
startDirectionLinePoint = legStartPoint; startDirectionLinePoint = legStartPoint;
endDirectionLinePoint = legs.get(index).getEndCompoundMark().getMark1Position(); GPSCoordinate tempEndDirectionLinePoint = legs.get(index).getEndCompoundMark().getAverageGPSCoordinate();
bearingOfDirectionLine = GPSCoordinate.calculateBearing(startDirectionLinePoint, tempEndDirectionLinePoint);
//after finding the initial bearing pick the mark used for rounding
endDirectionLinePoint = legs.get(index).getEndCompoundMark().getMarkForRounding(bearingOfDirectionLine).getPosition();
bearingOfDirectionLine = GPSCoordinate.calculateBearing(startDirectionLinePoint, endDirectionLinePoint); bearingOfDirectionLine = GPSCoordinate.calculateBearing(startDirectionLinePoint, endDirectionLinePoint);
//finds the direction of the next leg as a bearing //finds the direction of the next leg as a bearing
@ -519,13 +525,22 @@ public class ResizableRaceCanvas extends ResizableCanvas {
endNextDirectionLinePoint = legs.get(index + 1).getEndCompoundMark().getMark1Position(); endNextDirectionLinePoint = legs.get(index + 1).getEndCompoundMark().getMark1Position();
bearingOfNextDirectionLine = GPSCoordinate.calculateBearing(startNextDirectionLinePoint, endNextDirectionLinePoint); bearingOfNextDirectionLine = GPSCoordinate.calculateBearing(startNextDirectionLinePoint, endNextDirectionLinePoint);
double degreesToAdd;
//find which side is need to be used
if (legs.get(index).getEndCompoundMark().getRoundingType() == RoundingType.Port ||
legs.get(index).getEndCompoundMark().getRoundingType() == RoundingType.SP){
degreesToAdd = 90;
}else{
degreesToAdd = -90;
}
//use the direction line to find a point parallel to it by the mark //use the direction line to find a point parallel to it by the mark
GPSCoordinate pointToStartCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint, GPSCoordinate pointToStartCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
100, Azimuth.fromDegrees(bearingOfDirectionLine.degrees()+90)); 100, Azimuth.fromDegrees(bearingOfDirectionLine.degrees()+degreesToAdd));
//use the direction line to find a point to curve too //use the direction line to find a point to curve too
GPSCoordinate pointToEndCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint, GPSCoordinate pointToEndCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
100, Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees()+90)); 100, Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees()+degreesToAdd));
//use the curve points to find the two control points for the bezier curve //use the curve points to find the two control points for the bezier curve
GPSCoordinate controlPoint; GPSCoordinate controlPoint;
@ -534,14 +549,14 @@ public class ResizableRaceCanvas extends ResizableCanvas {
if ((bearingOfDirectionLine.degrees() - bearingOfNextDirectionLine.degrees() +360)%360< 145){ if ((bearingOfDirectionLine.degrees() - bearingOfNextDirectionLine.degrees() +360)%360< 145){
//small turn //small turn
controlPoint = GPSCoordinate.calculateNewPosition(pointToStartCurve, controlPoint = GPSCoordinate.calculateNewPosition(pointToStartCurve,
50, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+45)); 50, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+(degreesToAdd/2)));
controlPoint2 = controlPoint; controlPoint2 = controlPoint;
}else{ }else{
//large turn //large turn
controlPoint = GPSCoordinate.calculateNewPosition(pointToStartCurve, controlPoint = GPSCoordinate.calculateNewPosition(pointToStartCurve,
150, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+90)); 150, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+degreesToAdd));
controlPoint2 = GPSCoordinate.calculateNewPosition(pointToEndCurve, controlPoint2 = GPSCoordinate.calculateNewPosition(pointToEndCurve,
150, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+90)); 150, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+degreesToAdd));
} }
@ -618,7 +633,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
* @see TrackPoint * @see TrackPoint
*/ */
private void drawTrack(VisualiserBoat boat) { private void drawTrack(VisualiserBoat boat) {
//Check that track points are enabled. //Check that track points are enabled.
if (this.annoPath) { if (this.annoPath) {

Loading…
Cancel
Save