mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-25 05:23:51 +00:00
Merge branch 'ubilabs--rcapp--develop' of ssh://sapsailing.com/home/trac/git into ubilabs--rcapp--develop
This commit is contained in:
commit
217cf0b3c6
6 files changed
+65
-81
No files matched your search
@@ -209,12 +209,15 @@ public interface PolarDataService {
|
||||
* For Upwind and Downwind returns the typical angle needed for a maneuver.
|
||||
*
|
||||
* @param boatClass
|
||||
* @param legType needs to be Upwind or Downwind
|
||||
* @param windSpeed Since the maneuver angle is windSpeed depended, supply it here
|
||||
* @param maneuverType
|
||||
* needs to be Tack or Jibe
|
||||
* @param windSpeed
|
||||
* Since the maneuver angle is windSpeed depended, supply it here
|
||||
* @return angle with confidence as supplied by polars. Angle is always >= 0
|
||||
* @throws NotEnoughDataHasBeenAddedException
|
||||
* @throws NotEnoughDataHasBeenAddedException
|
||||
*/
|
||||
BearingWithConfidence<Void> getManeuverAngle(BoatClass boatClass, LegType legType, Speed windSpeed) throws NotEnoughDataHasBeenAddedException;
|
||||
BearingWithConfidence<Void> getManeuverAngle(BoatClass boatClass, ManeuverType maneuverType, Speed windSpeed)
|
||||
throws NotEnoughDataHasBeenAddedException;
|
||||
|
||||
void raceFinishedLoading(TrackedRace race);
|
||||
|
||||
|
||||
+10
-24
@@ -2752,13 +2752,21 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
||||
result = usePolarsIfPossible(wind, defaultAngle, LegType.DOWNWIND, threshold);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Pair<Double, Double> getMinimumAngleBetweenDifferentTacksUpwind(Wind wind) {
|
||||
Pair<Double, Double> result;
|
||||
double defaultAngle = getRace().getBoatClass().getMinimumAngleBetweenDifferentTacksUpwind();
|
||||
double threshold = 10;
|
||||
result = usePolarsIfPossible(wind, defaultAngle, LegType.UPWIND, threshold);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Pair<Double, Double> usePolarsIfPossible(Wind wind, double defaultAngle, LegType legType, double threshold) {
|
||||
Pair<Double, Double> result;
|
||||
if (polarDataService != null) {
|
||||
try {
|
||||
BearingWithConfidence<Void> average = polarDataService
|
||||
.getManeuverAngle(getRace().getBoatClass(), legType, wind);
|
||||
BearingWithConfidence<Void> average = polarDataService.getManeuverAngle(getRace().getBoatClass(),
|
||||
legType == LegType.DOWNWIND ? ManeuverType.JIBE : ManeuverType.TACK, wind);
|
||||
double averageAngleInDegMinusThreshold = average.getObject().getDegrees() - threshold;
|
||||
if (averageAngleInDegMinusThreshold < defaultAngle) {
|
||||
result = new Pair<Double, Double>(defaultAngle, 0.1);
|
||||
@@ -2774,28 +2782,6 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
||||
return result;
|
||||
}
|
||||
|
||||
private Pair<Double, Double> getMinimumAngleBetweenDifferentTacksUpwind(Wind wind) {
|
||||
Pair<Double, Double> result;
|
||||
double defaultAngle = getRace().getBoatClass().getMinimumAngleBetweenDifferentTacksUpwind();
|
||||
if (polarDataService != null) {
|
||||
try {
|
||||
BearingWithConfidence<Void> average = polarDataService
|
||||
.getManeuverAngle(getRace().getBoatClass(), LegType.UPWIND, wind);
|
||||
double averageAngleInDegMinusThreshold = average.getObject().getDegrees() - 10;
|
||||
if (averageAngleInDegMinusThreshold < defaultAngle) {
|
||||
result = new Pair<Double, Double>(defaultAngle, 0.1);
|
||||
} else {
|
||||
result = new Pair<Double, Double>(averageAngleInDegMinusThreshold, average.getConfidence());
|
||||
}
|
||||
} catch (NotEnoughDataHasBeenAddedException e) {
|
||||
result = new Pair<Double, Double>(defaultAngle, 0.1);
|
||||
}
|
||||
} else {
|
||||
result = new Pair<Double, Double>(defaultAngle, 0.1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private long getApproximateManeuverDurationInMilliseconds() {
|
||||
return getRace().getBoatClass().getApproximateManeuverDurationInMilliseconds();
|
||||
}
|
||||
|
||||
+5
-4
@@ -18,9 +18,9 @@ import com.sap.sailing.domain.common.PolarSheetsData;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.Tack;
|
||||
import com.sap.sailing.domain.common.confidence.BearingWithConfidence;
|
||||
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.common.confidence.impl.BearingWithConfidenceImpl;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.polars.NotEnoughDataHasBeenAddedException;
|
||||
import com.sap.sailing.domain.polars.PolarDataService;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
@@ -162,11 +162,12 @@ public class PolarDataServiceImpl implements PolarDataService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BearingWithConfidence<Void> getManeuverAngle(BoatClass boatClass, LegType legType, Speed windSpeed)
|
||||
public BearingWithConfidence<Void> getManeuverAngle(BoatClass boatClass, ManeuverType maneuverType, Speed windSpeed)
|
||||
throws NotEnoughDataHasBeenAddedException {
|
||||
if (legType != LegType.DOWNWIND && legType != LegType.UPWIND) {
|
||||
throw new IllegalArgumentException("LegType needs to be upwind or downwind.");
|
||||
if (maneuverType != ManeuverType.TACK && maneuverType != ManeuverType.JIBE) {
|
||||
throw new IllegalArgumentException("ManeuverType needs to be tack or jibe.");
|
||||
}
|
||||
LegType legType = maneuverType == ManeuverType.TACK ? LegType.UPWIND : LegType.DOWNWIND;
|
||||
if (boatClass == null || windSpeed == null) {
|
||||
throw new IllegalArgumentException("Boatclass and windspeed cannot be null.");
|
||||
}
|
||||
|
||||
@@ -14,30 +14,16 @@
|
||||
android:contentDescription="@string/compass_view_compass"
|
||||
android:src="?compass_back"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/numbers"
|
||||
android:layout_width="wrap_content"
|
||||
<TextView
|
||||
android:id="@+id/compass_view_degree"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/compass_view_degree"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:inputType="number"
|
||||
android:textAppearance="?textLarge"
|
||||
tools:text="0"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/compass_view_degree"
|
||||
android:layout_toEndOf="@+id/compass_view_degree"
|
||||
android:layout_toRightOf="@+id/compass_view_degree"
|
||||
android:text="°"
|
||||
android:textAppearance="?textLarge"/>
|
||||
</RelativeLayout>
|
||||
android:layout_alignParentEnd="false"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:textAppearance="?textLarge"
|
||||
tools:text="300°"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/compass_view_needle"
|
||||
|
||||
+11
-7
@@ -72,12 +72,19 @@ public class StartTimeFragment extends BaseFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void onPause() {
|
||||
super.onDetach();
|
||||
|
||||
getRaceState().removeChangedListener(raceStateChangedListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
getRaceState().addChangedListener(raceStateChangedListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
@@ -89,7 +96,6 @@ public class StartTimeFragment extends BaseFragment
|
||||
notifyTick();
|
||||
}
|
||||
};
|
||||
getRaceState().addChangedListener(raceStateChangedListener);
|
||||
Calendar time = Calendar.getInstance();
|
||||
if (getArguments() != null && getArguments().getInt(START_MODE, 0) == 2) {
|
||||
if (getRace() != null && getRaceState() != null) {
|
||||
@@ -124,15 +130,13 @@ public class StartTimeFragment extends BaseFragment
|
||||
|
||||
mDatePicker = ViewHolder.get(getView(), R.id.start_date_picker);
|
||||
if (mDatePicker != null) {
|
||||
ThemeHelper.setPickerTextColor(getActivity(), mDatePicker,
|
||||
ThemeHelper.getColor(getActivity(), R.attr.white));
|
||||
ThemeHelper.setPickerTextColor(getActivity(), mDatePicker, ThemeHelper.getColor(getActivity(), R.attr.white));
|
||||
mDatePicker.setOnValueChangedListener(this);
|
||||
initDatePicker();
|
||||
}
|
||||
mTimePicker = ViewHolder.get(getView(), R.id.start_time_picker);
|
||||
if (mTimePicker != null) {
|
||||
ThemeHelper.setPickerTextColor(getActivity(), mTimePicker,
|
||||
ThemeHelper.getColor(getActivity(), R.attr.white));
|
||||
ThemeHelper.setPickerTextColor(getActivity(), mTimePicker, ThemeHelper.getColor(getActivity(), R.attr.white));
|
||||
mTimePicker.setOnTimeChangedListener(this);
|
||||
mTimePicker.setIs24HourView(true);
|
||||
int hours = time.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
+23
-19
@@ -2,13 +2,12 @@ package com.sap.sailing.racecommittee.app.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -16,10 +15,6 @@ import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class CompassView extends RelativeLayout {
|
||||
|
||||
public interface CompassDirectionListener {
|
||||
void onDirectionChanged(float degree);
|
||||
}
|
||||
|
||||
private CompassDirectionListener changeListener = null;
|
||||
private RotateAnimation rotation = null;
|
||||
private ImageView needleView = null;
|
||||
@@ -27,9 +22,6 @@ public class CompassView extends RelativeLayout {
|
||||
private float currentDegrees = 0.0f;
|
||||
private Float deferredToDegrees = null;
|
||||
|
||||
private float getNeedlePivotX() { return needleView.getMeasuredWidth() / 2; }
|
||||
private float getNeedlePivotY() { return needleView.getMeasuredHeight() / 2; }
|
||||
|
||||
public CompassView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
inflate();
|
||||
@@ -45,6 +37,14 @@ public class CompassView extends RelativeLayout {
|
||||
inflate();
|
||||
}
|
||||
|
||||
private float getNeedlePivotX() {
|
||||
return needleView.getMeasuredWidth() / 2;
|
||||
}
|
||||
|
||||
private float getNeedlePivotY() {
|
||||
return needleView.getMeasuredHeight() / 2;
|
||||
}
|
||||
|
||||
private void inflate() {
|
||||
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.compass_view, this);
|
||||
@@ -65,7 +65,7 @@ public class CompassView extends RelativeLayout {
|
||||
|
||||
float toDegrees = (float) Math.toDegrees(Math.atan2(rotateY, rotateX));
|
||||
cancelAndStartAnimation(toDegrees, 0);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,10 @@ public class CompassView extends RelativeLayout {
|
||||
doDeferredRotation();
|
||||
}
|
||||
|
||||
public float getDirection() {
|
||||
return currentDegrees;
|
||||
}
|
||||
|
||||
public void setDirection(float toDegrees) {
|
||||
if (isNeedleReady()) {
|
||||
deferredToDegrees = toDegrees;
|
||||
@@ -84,10 +88,6 @@ public class CompassView extends RelativeLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public float getDirection() {
|
||||
return currentDegrees;
|
||||
}
|
||||
|
||||
private void cancelAndStartAnimation(float toDegrees, long duration) {
|
||||
if (rotation != null) {
|
||||
if (!rotation.hasEnded()) {
|
||||
@@ -104,7 +104,7 @@ public class CompassView extends RelativeLayout {
|
||||
if (degree < 0) {
|
||||
degree += 360;
|
||||
}
|
||||
degreeView.setText(String.format("%.0f", degree));
|
||||
degreeView.setText(String.format("%.0f°", degree));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class CompassView extends RelativeLayout {
|
||||
changeListener.onDirectionChanged(degree);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void doDeferredRotation() {
|
||||
if (deferredToDegrees != null) {
|
||||
float toDegrees = deferredToDegrees;
|
||||
@@ -129,15 +129,19 @@ public class CompassView extends RelativeLayout {
|
||||
setDirection(toDegrees);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedleReady() {
|
||||
return getNeedlePivotX() == 0.0;
|
||||
}
|
||||
|
||||
public interface CompassDirectionListener {
|
||||
void onDirectionChanged(float degree);
|
||||
}
|
||||
|
||||
private class NeedleRotationListener implements AnimationListener {
|
||||
|
||||
|
||||
private float targetDegrees;
|
||||
|
||||
|
||||
public NeedleRotationListener(float toDegrees) {
|
||||
this.targetDegrees = toDegrees;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user