@ -59,13 +59,7 @@ public class Race implements Runnable {
this . scaleFactor = scaleFactor ;
this . mockOutput = mockOutput ;
this . startTime = System . currentTimeMillis ( ) + ( this . PRERACE_TIME / this . scaleFactor ) ;
if ( startingBoats ! = null & & startingBoats . size ( ) > 0 ) {
initialiseBoats ( ) ;
}
}
public Race ( RaceDataSource raceData , int scaleFactor , MockOutput mockOutput ) {
@ -201,7 +195,7 @@ public class Race implements Runnable {
boat . getCurrentLeg ( ) . getLegNumber ( ) > = 0 ? BoatStatusEnum . RACING : BoatStatusEnum . DNF , boat . getCurrentLeg ( ) . getLegNumber ( ) ) ) ;
}
if ( startingBoats . size ( ) = = finished ) {
RaceStatus raceStatus = new RaceStatus ( System . currentTimeMillis ( ) , raceId , 4 , startTime , 0 , 2300 , 2 , boatStatuses ) ; //TODO FIX the second currentTime is a placeholder! Also, replace magic values.
RaceStatus raceStatus = new RaceStatus ( System . currentTimeMillis ( ) , raceId , 4 , startTime , 0 , 2300 , 2 , boatStatuses ) ;
mockOutput . parseRaceStatus ( raceStatus ) ;
}
} else {
@ -209,8 +203,7 @@ public class Race implements Runnable {
}
}
boatOffset = ( boatOffset + 1 ) % ( startingBoats . size ( ) ) ;
RaceStatus raceStatus = new RaceStatus ( System . currentTimeMillis ( ) , raceId , 3 , startTime , 0 , 2300 , 2 , boatStatuses ) ; //TODO FIX the second currentTime is a placeholder! Also, replace magic values.
System . out . println ( raceStatus . getBoatStatuses ( ) . get ( 0 ) . getLegNumber ( ) ) ;
RaceStatus raceStatus = new RaceStatus ( System . currentTimeMillis ( ) , raceId , 3 , startTime , 0 , 2300 , 2 , boatStatuses ) ;
mockOutput . parseRaceStatus ( raceStatus ) ;
}
}
@ -218,7 +211,6 @@ public class Race implements Runnable {
}
public void initialiseBoats ( ) {
Leg officialStart = legs . get ( 0 ) ;
String name = officialStart . getName ( ) ;
ArrayList < GPSCoordinate > startingPositions = getSpreadStartingPositions ( ) ;
for ( int i = 0 ; i < startingBoats . size ( ) ; i + + ) {
@ -226,6 +218,7 @@ public class Race implements Runnable {
if ( boat ! = null ) {
boat . setScaledVelocity ( boat . getVelocity ( ) * scaleFactor ) ;
boat . setCurrentPosition ( startingPositions . get ( i ) ) ;
System . out . println ( boat . getCurrentPosition ( ) ) ;
boat . setCurrentLeg ( officialStart ) ;
boat . setHeading ( boat . calculateHeading ( ) ) ;
}
@ -242,6 +235,8 @@ public class Race implements Runnable {
int nBoats = startingBoats . size ( ) ;
Marker compoundMark = legs . get ( 0 ) . getStartCompoundMark ( ) ;
System . out . println ( compoundMark . getAverageGPSCoordinate ( ) ) ;
GeodeticCalculator initialCalc = new GeodeticCalculator ( ) ;
initialCalc . setStartingGeographicPoint ( compoundMark . getMark1 ( ) . getLongitude ( ) , compoundMark . getMark1 ( ) . getLatitude ( ) ) ;
initialCalc . setDestinationGeographicPoint ( compoundMark . getMark2 ( ) . getLongitude ( ) , compoundMark . getMark2 ( ) . getLatitude ( ) ) ;
@ -259,6 +254,7 @@ public class Race implements Runnable {
Point2D position = positionCalc . getDestinationGeographicPoint ( ) ;
positions . add ( new GPSCoordinate ( position . getY ( ) , position . getX ( ) ) ) ;
System . out . println ( position . getX ( ) ) ;
positionCalc = new GeodeticCalculator ( ) ;
positionCalc . setStartingGeographicPoint ( position ) ;
}