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]
This commit is contained in:
@@ -164,4 +164,91 @@ public class CompoundMark {
|
||||
public void setRoundingType(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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user