mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 18:33:54 +00:00
Fixed an important bug in the racecomittee app: Wind is input by chosing
a "from" value but sent to the server by using a bearing.
This commit is contained in:
1 parent
403803b8fc
commit
ecd8cb2d55
2 files changed
+10
-4
No files matched your search
+8
-2
@@ -27,10 +27,16 @@ public class WindJsonDeserializer implements JsonDeserializer<Wind> {
|
||||
Position position = positionDeserializer.deserialize(positionJsonObject);
|
||||
|
||||
Number timeStamp = (Number) object.get(WindJsonSerializer.FIELD_TIMEPOINT);
|
||||
Number bearing = (Number) object.get(WindJsonSerializer.FIELD_BEARING);
|
||||
Number direction = (Number) object.get(WindJsonSerializer.FIELD_DIRECTION);
|
||||
Number speedInKnots = (Number) object.get(WindJsonSerializer.FIELD_SPEED_IN_KNOTS);
|
||||
|
||||
Bearing degreeBearing = new DegreeBearingImpl(bearing.doubleValue());
|
||||
Bearing degreeBearing = null;
|
||||
if (direction.doubleValue() >= 180) {
|
||||
degreeBearing = new DegreeBearingImpl(direction.doubleValue()-180);
|
||||
} else {
|
||||
degreeBearing = new DegreeBearingImpl(direction.doubleValue()+180);
|
||||
}
|
||||
|
||||
SpeedWithBearing speedBearing = new KnotSpeedWithBearingImpl(speedInKnots.doubleValue(), degreeBearing);
|
||||
Wind wind = new WindImpl(position, new MillisecondsTimePoint(timeStamp.longValue()), speedBearing);
|
||||
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ public class WindJsonSerializer implements JsonSerializer<Wind> {
|
||||
public static final String FIELD_POSITION = "position";
|
||||
public static final String FIELD_TIMEPOINT = "timepoint";
|
||||
public static final String FIELD_SPEED_IN_KNOTS = "speedinknots";
|
||||
public static final String FIELD_BEARING = "bearing";
|
||||
public static final String FIELD_DIRECTION = "direction";
|
||||
|
||||
private final JsonSerializer<Position> positionSerializer;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class WindJsonSerializer implements JsonSerializer<Wind> {
|
||||
result.put(FIELD_POSITION, positionSerializer.serialize(wind.getPosition()));
|
||||
result.put(FIELD_TIMEPOINT, wind.getTimePoint().asMillis());
|
||||
result.put(FIELD_SPEED_IN_KNOTS, wind.getKnots());
|
||||
result.put(FIELD_BEARING, wind.getBearing().getDegrees());
|
||||
result.put(FIELD_DIRECTION, wind.getBearing().getDegrees());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user