|
|
|
|
@ -154,6 +154,12 @@ public class RaceXMLCreator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets an estimate of how long a race will take using an average Speed
|
|
|
|
|
* @param race race to estimate
|
|
|
|
|
* @param averageSpeed average speed that the boats move at
|
|
|
|
|
* @return the estimated amount of time it will take a boat to finish the race (skewed to minimum).
|
|
|
|
|
*/
|
|
|
|
|
public static double getRaceLength(XMLRace race, double averageSpeed){
|
|
|
|
|
double raceRoundingTime = 5000; //5 seconds to round a mark
|
|
|
|
|
double totalDistance = 0; //in nautical miles
|
|
|
|
|
@ -175,13 +181,24 @@ public class RaceXMLCreator {
|
|
|
|
|
return totalTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gets the destance between two marks
|
|
|
|
|
* @param a mark 1
|
|
|
|
|
* @param b mark 2
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private static double getDistance(XMLMark a, XMLMark b){
|
|
|
|
|
GPSCoordinate coorda = new GPSCoordinate(a.getTargetLat(), a.getTargetLng());
|
|
|
|
|
GPSCoordinate coordb = new GPSCoordinate(b.getTargetLat(), b.getTargetLng());
|
|
|
|
|
return GPSCoordinate.calculateDistanceNauticalMiles(coorda, coordb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scales the race based on the windspeed the race is running at and the amount of time it should be completed in.
|
|
|
|
|
* @param race Race to scale
|
|
|
|
|
* @param windSpeed windspeed of the race, this is used with the polars
|
|
|
|
|
* @param milliseconds milliseconds the race should take.
|
|
|
|
|
*/
|
|
|
|
|
private static void scaleRace(XMLRace race, double windSpeed, double milliseconds) {
|
|
|
|
|
GPSCoordinate center = getCenter(race);
|
|
|
|
|
//sort the compound marks
|
|
|
|
|
@ -214,8 +231,12 @@ public class RaceXMLCreator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scales a point from the the center(pivot)
|
|
|
|
|
* @param mark mark the scale
|
|
|
|
|
* @param center center as pivot
|
|
|
|
|
* @param scale scale to scale at.
|
|
|
|
|
*/
|
|
|
|
|
private static void scalePoint(XMLMark mark, GPSCoordinate center, double scale){
|
|
|
|
|
double latDiff = mark.getTargetLat() - center.getLatitude();
|
|
|
|
|
double longDiff = mark.getTargetLng() - center.getLongitude();
|
|
|
|
|
|