mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-14 16:20:57 +00:00
removed little jumping of compass needle
This commit is contained in:
1 parent
fb300c8a8a
commit
fc9d70d3ba
2 files changed
+9
-3
No files matched your search
+1
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.dashboards.gwt.client.windchart.compass;
|
||||
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.AbsolutePanel;
|
||||
import com.google.gwt.user.client.ui.HasWidgets;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
+8
-3
@@ -33,7 +33,7 @@ public class LocationPointerCompassAngleDistance implements LocationListener, Co
|
||||
* compass events from the device.
|
||||
* */
|
||||
private double angle;
|
||||
|
||||
private double compassHeading;
|
||||
private static Double degreesToRadiansFactor = Math.PI / 180.0;
|
||||
|
||||
public LocationPointerCompassAngleDistance() {
|
||||
@@ -96,11 +96,16 @@ public class LocationPointerCompassAngleDistance implements LocationListener, Co
|
||||
private void calulateNewAngleAndDistance() {
|
||||
angle = getAngleBetweenGPSPoints(latDevice, lonDevice, latBot, lonBot);
|
||||
double distance = getDistanceBetweenGPSPoints(latDevice, lonDevice, latBot, lonBot);
|
||||
notifyListenerAboutAngleAndDistanceChange(angle, distance);
|
||||
notifyListenerAboutAngleAndDistanceChange(calulateNewAngleFromPositionAngleAndCompassHeading(this.angle, this.compassHeading), distance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compassHeadingChanged(double compassHeading) {
|
||||
this.compassHeading = compassHeading;
|
||||
notifyListenerAboutAngleChange(calulateNewAngleFromPositionAngleAndCompassHeading(this.angle, this.compassHeading));
|
||||
}
|
||||
|
||||
private double calulateNewAngleFromPositionAngleAndCompassHeading(double positionAngle, double compassAngle){
|
||||
double compassWidgetAngle;
|
||||
if (compassHeading > angle) {
|
||||
compassWidgetAngle = 360 + (angle - compassHeading);
|
||||
@@ -108,7 +113,7 @@ public class LocationPointerCompassAngleDistance implements LocationListener, Co
|
||||
compassWidgetAngle = angle - compassHeading;
|
||||
}
|
||||
compassWidgetAngle = compassWidgetAngle % 360;
|
||||
notifyListenerAboutAngleChange(compassWidgetAngle);
|
||||
return compassWidgetAngle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user