mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Merge branch 'racecommittee_app' into racecommittee_wind
Conflicts: java/com.sap.sailing.domain.shared.android/src/com/sap/sailing/domain/tracking/Positioned.java mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/dialogs/ClassicCourseDesignDialogFragment.java
This commit is contained in:
commit
838dd9f01a
36 files changed
+532
-357
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
|
||||
|
||||
public abstract class AbstractCourseDesignFactory implements CourseDesignFactory{
|
||||
|
||||
@Override
|
||||
public abstract CourseDesign createCourseDesign(Position startBoatPosition, Double windSpeed, Integer windDirection,
|
||||
BoatClassType boatClass, CourseLayouts courseLayout, NumberOfRounds numberOfRounds, TargetTime targetTime);
|
||||
|
||||
protected Position getPositionForGivenPointDistanceAndBearing(Position givenPoint, int ditanceInMeters,
|
||||
float bearingInDegree) {
|
||||
double bearingInRad = Math.toRadians(bearingInDegree);
|
||||
final int earthRadiusInMeters = 6371000;
|
||||
double lat = Math.asin(Math.sin(givenPoint.getLatDeg()) * Math.cos(ditanceInMeters / earthRadiusInMeters)
|
||||
+ Math.cos(givenPoint.getLatDeg()) * Math.sin(ditanceInMeters / earthRadiusInMeters)
|
||||
* Math.cos(bearingInRad));
|
||||
double lon = givenPoint.getLngDeg()
|
||||
+ Math.atan2(
|
||||
Math.sin(bearingInRad) * Math.sin(ditanceInMeters / earthRadiusInMeters)
|
||||
* Math.cos(givenPoint.getLatDeg()),
|
||||
Math.cos(ditanceInMeters / earthRadiusInMeters) - Math.sin(givenPoint.getLatDeg()) * Math.sin(lat));
|
||||
return new DegreePosition(lat, lon);
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@SuppressWarnings("serial")
|
||||
public enum BoatClassType {
|
||||
boatClass470erMen("470er Men", new HashMap<CourseLayouts, Integer>() {
|
||||
{
|
||||
put(TrapezoidCourseLayouts.innerLoopTrapezoid60, 60);
|
||||
put(TrapezoidCourseLayouts.outerLoopTrapezoid60, 60);
|
||||
put(LeewardWindWardCourseLayouts.windWardLeewardLeeward, 30);
|
||||
put(LeewardWindWardCourseLayouts.windWardLeewardWindward, 30);
|
||||
}
|
||||
}, new TreeMap<WindRange, Map<PointOfSail, Float>>() {
|
||||
{
|
||||
put(new WindRange(5, 8), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 15f);
|
||||
put(PointOfSail.Downwind, 11f);
|
||||
put(PointOfSail.Reach, 8f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(8, 12), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 13f);
|
||||
put(PointOfSail.Downwind, 10f);
|
||||
put(PointOfSail.Reach, 7f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(12, 15), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 11f);
|
||||
put(PointOfSail.Downwind, 7.5f);
|
||||
put(PointOfSail.Reach, 5.5f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(15, 99), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 10f);
|
||||
put(PointOfSail.Downwind, 6.5f);
|
||||
put(PointOfSail.Reach, 5.5f);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 290),
|
||||
boatClass470eromen("470er Women", new HashMap<CourseLayouts, Integer>() {
|
||||
{
|
||||
put(TrapezoidCourseLayouts.innerLoopTrapezoid60, 60);
|
||||
put(TrapezoidCourseLayouts.outerLoopTrapezoid60, 60);
|
||||
put(LeewardWindWardCourseLayouts.windWardLeewardLeeward, 30);
|
||||
put(LeewardWindWardCourseLayouts.windWardLeewardWindward, 30);
|
||||
}
|
||||
}, new TreeMap<WindRange, Map<PointOfSail, Float>>() {
|
||||
{
|
||||
put(new WindRange(5, 8), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 15f);
|
||||
put(PointOfSail.Downwind, 11f);
|
||||
put(PointOfSail.Reach, 8f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(8, 12), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 13f);
|
||||
put(PointOfSail.Downwind, 10f);
|
||||
put(PointOfSail.Reach, 7f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(12, 15), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 11f);
|
||||
put(PointOfSail.Downwind, 7.5f);
|
||||
put(PointOfSail.Reach, 5.5f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(15, 99), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 10f);
|
||||
put(PointOfSail.Downwind, 6.5f);
|
||||
put(PointOfSail.Reach, 5.5f);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 110),
|
||||
boatClass49er("49er", new HashMap<CourseLayouts, Integer>() {
|
||||
{
|
||||
put(LeewardWindWardCourseLayouts.windWardLeewardLeeward, 30);
|
||||
put(LeewardWindWardCourseLayouts.windWardLeewardWindward, 30);
|
||||
}
|
||||
}, new TreeMap<WindRange, Map<PointOfSail, Float>>() {
|
||||
{
|
||||
put(new WindRange(5, 8), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 15f);
|
||||
put(PointOfSail.Downwind, 11f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(8, 12), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 11f);
|
||||
put(PointOfSail.Downwind, 5.5f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(12, 15), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 9f);
|
||||
put(PointOfSail.Downwind, 4.5f);
|
||||
}
|
||||
});
|
||||
put(new WindRange(15, 99), new EnumMap<PointOfSail, Float>(PointOfSail.class) {
|
||||
{
|
||||
put(PointOfSail.Upwind, 7.5f);
|
||||
put(PointOfSail.Downwind, 4f);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 255);
|
||||
|
||||
private String displayName;
|
||||
private Map<CourseLayouts, Integer> possipleCourseLayoutsWithStandardTargetTime;
|
||||
private Integer startLineLengthInMeters;
|
||||
|
||||
private BoatClassType(String displayName, Map<CourseLayouts, Integer> possipleCourseLayoutsWithStandardTargetTime,
|
||||
Map<WindRange, Map<PointOfSail, Float>> boatSpeedTable, Integer startLineLengthInMeters) {
|
||||
this.displayName = displayName;
|
||||
this.possipleCourseLayoutsWithStandardTargetTime = possipleCourseLayoutsWithStandardTargetTime;
|
||||
this.startLineLengthInMeters = startLineLengthInMeters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public Map<CourseLayouts, Integer> getPossibleCourseLayoutsWithTargetTime() {
|
||||
return possipleCourseLayoutsWithStandardTargetTime;
|
||||
}
|
||||
|
||||
public Integer getStartLineLengthInMeters() {
|
||||
return startLineLengthInMeters;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public interface CourseDesign {
|
||||
PositionedMark getPinEnd();
|
||||
public void setPinEnd(PositionedMark pinEnd);
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
|
||||
public interface CourseDesignFactory {
|
||||
CourseDesign createCourseDesign(Position startBoatPosition, Double windSpeed, Integer windDirection, BoatClassType boatClass, CourseLayouts courseLayout, NumberOfRounds numberOfRounds, TargetTime targetTime);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public interface CourseLayouts {
|
||||
public String getShortName();
|
||||
public Class<? extends CourseDesignFactory> getCourseDesignFactoryClass();
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public enum LeewardWindWardCourseLayouts implements CourseLayouts{
|
||||
windWardLeewardWindward("Windward/Leeward with Windward finish", "W", WindWardLeewardCourseDesignFactoryImpl.class),
|
||||
windWardLeewardLeeward("Windward/Leeward with Leeward finish", "L", WindWardLeewardCourseDesignFactoryImpl.class);
|
||||
|
||||
private String displayName;
|
||||
private String shortName;
|
||||
private Class<? extends CourseDesignFactory> courseDesignFactoryClass;
|
||||
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
private LeewardWindWardCourseLayouts(String displayName, String shortName, Class<? extends CourseDesignFactory> courseDesignFactoryClass){
|
||||
this.courseDesignFactoryClass = courseDesignFactoryClass;
|
||||
this.displayName = displayName;
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends CourseDesignFactory> getCourseDesignFactoryClass() {
|
||||
return this.courseDesignFactoryClass;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public enum NumberOfRounds {
|
||||
TWO(2),
|
||||
THREE(3),
|
||||
FOUR(4);
|
||||
|
||||
private final Integer numberOfRounds;
|
||||
|
||||
public Integer getNumberOfRounds() {
|
||||
return numberOfRounds;
|
||||
}
|
||||
|
||||
private NumberOfRounds(Integer numberOfRounds){
|
||||
this.numberOfRounds = numberOfRounds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
String toString(){
|
||||
return this.numberOfRounds.toString();
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public enum PointOfSail{
|
||||
Upwind,
|
||||
Downwind,
|
||||
Reach
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.tracking.Positioned;
|
||||
|
||||
public interface PositionedMark extends Mark, Positioned {
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.MarkImpl;
|
||||
import com.sap.sailing.domain.common.MarkType;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
public class PositionedMarkImpl extends MarkImpl implements PositionedMark {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7903960088124343841L;
|
||||
private Position position;
|
||||
|
||||
public PositionedMarkImpl(String name, Position position) {
|
||||
super(name);
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColor() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShape() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPattern() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarkType getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public enum TargetTime {
|
||||
thirty(30),
|
||||
sixty(60);
|
||||
|
||||
private final Integer timeInMinutes;
|
||||
|
||||
public Integer getTimeInMinutes() {
|
||||
return timeInMinutes;
|
||||
}
|
||||
|
||||
private TargetTime(Integer timeInMinutes){
|
||||
this.timeInMinutes = timeInMinutes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
String toString(){
|
||||
return this.timeInMinutes.toString();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public enum TrapezoidCourseLayouts implements CourseLayouts{
|
||||
innerLoopTrapezoid60("Trapezoid 60° Inner Loop", "I", 60),
|
||||
outerLoopTrapezoid60("Trapezoid 60° Outer Loop", "O", 60),
|
||||
innerLoopTrapezoid70("Trapezoid 70° Inner Loop", "I", 70),
|
||||
outerLoopTrapezoid70("Trapezoid 70° Outer Loop", "O", 70);
|
||||
|
||||
private String displayName;
|
||||
private String shortName;
|
||||
private Integer reachAngle;
|
||||
private Class<? extends CourseDesignFactory> courseDesignFactoryClass;
|
||||
|
||||
public Integer getReachAngle() {
|
||||
return reachAngle;
|
||||
}
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
private TrapezoidCourseLayouts(String displayName, String shortName, Integer reachAngle){
|
||||
this.displayName = displayName;
|
||||
this.shortName = shortName;
|
||||
this.reachAngle = reachAngle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends CourseDesignFactory> getCourseDesignFactoryClass() {
|
||||
return this.courseDesignFactoryClass;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public class WindRange implements Comparable<WindRange>{
|
||||
private final Integer lowerBound;
|
||||
private final Integer upperBound;
|
||||
|
||||
public WindRange(Integer lowerBound, Integer upperBound){
|
||||
this.lowerBound = lowerBound;
|
||||
this.upperBound = upperBound;
|
||||
}
|
||||
|
||||
public Integer getLowerBound() {
|
||||
return lowerBound;
|
||||
}
|
||||
|
||||
public Integer getUpperBound() {
|
||||
return upperBound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(WindRange o) {
|
||||
if(o.getUpperBound() <= this.lowerBound)
|
||||
return 1;
|
||||
if(o.getLowerBound() >= this.upperBound)
|
||||
return -1;
|
||||
if(o.getLowerBound().equals(this.lowerBound) && o.getUpperBound().equals(this.upperBound))
|
||||
return 0;
|
||||
else
|
||||
throw new IllegalArgumentException("WindRanges are not comparable");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
public class WindWardLeewardCourseDesignFactoryImpl extends AbstractCourseDesignFactory {
|
||||
|
||||
@Override
|
||||
public CourseDesign createCourseDesign(Position startBoatPosition, Double windSpeed, Integer windDirection,
|
||||
BoatClassType boatClass, CourseLayouts courseLayout, NumberOfRounds numberOfRounds, TargetTime targetTime) {
|
||||
CourseDesign windWardLeewardCourseDesign = new WindwardLeewardCourseDesignImpl();
|
||||
setPinEnd(windWardLeewardCourseDesign, boatClass, startBoatPosition, windDirection);
|
||||
return windWardLeewardCourseDesign;
|
||||
}
|
||||
|
||||
private void setPinEnd(CourseDesign windWardLeewardCourseDesign, BoatClassType boatClass,
|
||||
Position startBoatPosition, Integer windDirection) {
|
||||
PositionedMark pinEnd = new PositionedMarkImpl("pinEnd", getPositionForGivenPointDistanceAndBearing(
|
||||
startBoatPosition, boatClass.getStartLineLengthInMeters(), windDirection));
|
||||
windWardLeewardCourseDesign.setPinEnd(pinEnd);
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.sap.sailing.domain.coursedesign;
|
||||
|
||||
public class WindwardLeewardCourseDesignImpl implements CourseDesign{
|
||||
|
||||
PositionedMark pinEnd;
|
||||
|
||||
@Override
|
||||
public PositionedMark getPinEnd() {
|
||||
return pinEnd;
|
||||
}
|
||||
@Override
|
||||
public void setPinEnd(PositionedMark pinEnd) {
|
||||
this.pinEnd = pinEnd;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user