mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Merge branch 'racecommittee_app'
This commit is contained in:
commit
538b0dab4a
6 files changed
+7
-8
No files matched your search
-45
@@ -1,45 +0,0 @@
|
||||
package com.sap.sailing.domain.common.racelog.utils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.sap.sailing.domain.common.Bearing;
|
||||
import com.sap.sailing.domain.common.Distance;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
|
||||
public class GeoUtils {
|
||||
public static Position getPositionForGivenPointDistanceAndBearing(Position givenPoint, Distance distance,
|
||||
Bearing windDirection) {
|
||||
final double earthRadiusInMeters = 6371000.0;
|
||||
double brng = windDirection.getRadians();
|
||||
double lat1 = givenPoint.getLatRad();
|
||||
double lon1 = givenPoint.getLngRad();
|
||||
double dist = distance.getMeters() / earthRadiusInMeters;
|
||||
|
||||
double lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + Math.cos(lat1) * Math.sin(dist) * Math.cos(brng));
|
||||
double lon2 = lon1
|
||||
+ Math.atan2(Math.sin(brng) * Math.sin(dist) * Math.cos(lat1),
|
||||
Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2));
|
||||
lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
|
||||
|
||||
return new DegreePosition(Math.toDegrees(lat2), Math.toDegrees(lon2));
|
||||
}
|
||||
|
||||
public static String getDegMinSecFormatForDecimalDegree(double degree) {
|
||||
degree = java.lang.Math.abs(degree);
|
||||
int d = (int) degree;
|
||||
degree = (degree - d) * 60.0;
|
||||
int m = (int) degree;
|
||||
double s = (degree - m) * 60;
|
||||
if (degree < 0) { // put the sign back on the degrees
|
||||
d = -d;
|
||||
}
|
||||
DecimalFormat df = new DecimalFormat("##.###", new DecimalFormatSymbols(Locale.US));
|
||||
String dms = "" + d + '\u00B0' + m + '\u2032' + df.format(s) + '\u2033'; // add º, ', " symbols
|
||||
|
||||
return dms;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-3
@@ -18,7 +18,6 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sailing.domain.common.racelog.utils.GeoUtils;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceInfoDTO.GateStartInfoDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceInfoDTO.RRS26InfoDTO;
|
||||
@@ -165,8 +164,8 @@ public class RaceDetailPanel extends SimplePanel {
|
||||
String windText = stringMessages.unknown();
|
||||
if (data.raceInfo.lastWind != null) {
|
||||
if (data.raceInfo.lastWind.position != null) {
|
||||
vesselPositionText = new HTML(GeoUtils.getDegMinSecFormatForDecimalDegree(data.raceInfo.lastWind.position.latDeg)+" "
|
||||
+ GeoUtils.getDegMinSecFormatForDecimalDegree(data.raceInfo.lastWind.position.lngDeg)+" ").getHTML();
|
||||
vesselPositionText = new HTML(data.raceInfo.lastWind.position.latDeg+" "
|
||||
+ data.raceInfo.lastWind.position.lngDeg+" ").getHTML();
|
||||
}
|
||||
windText = new HTML(decimalFormat.format(data.raceInfo.lastWind.trueWindFromDeg) + "° "
|
||||
+ decimalFormat.format(data.raceInfo.lastWind.trueWindSpeedInKnots) + "knts").getHTML();
|
||||
|
||||
Reference in new issue
Block a user