mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-01 16:50:48 +00:00
started to benefit from unification of PositionDTO with Position by eliminating some conversions and copy constructor calls
This commit is contained in:
1 parent
6972ac9171
commit
c00b60e9b0
7 files changed
+36
-63
No files matched your search
+1
-1
@@ -1407,7 +1407,7 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
* still in the pre-start phase, show a {@link SmallTransparentInfoOverlay} at the
|
||||
* start line that shows the count down.
|
||||
*/
|
||||
private void updateCountdownCanvas(List<DegreePosition> startMarkPositions) {
|
||||
private void updateCountdownCanvas(List<Position> startMarkPositions) {
|
||||
if (!settings.isShowSelectedCompetitorsInfo() || startMarkPositions == null || startMarkPositions.isEmpty()
|
||||
|| lastRaceTimesInfo.startOfRace == null || timer.getTime().after(lastRaceTimesInfo.startOfRace)) {
|
||||
if (countDownOverlay != null) {
|
||||
|
||||
+10
-15
@@ -1498,7 +1498,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
windField.generate(startTimePoint, null, timeStep);
|
||||
|
||||
// prepare simulation-parameters
|
||||
List<Position> course = new ArrayList<Position>();
|
||||
List<Position> course = new ArrayList<>();
|
||||
course.add(startPosition);
|
||||
course.add(endPosition);
|
||||
BoatClass boatClass = trackedRace.getRace().getBoatClass();
|
||||
@@ -1531,12 +1531,9 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
RaceMapDataDTO rcDTO;
|
||||
rcDTO = new RaceMapDataDTO();
|
||||
rcDTO.coursePositions = new CoursePositionsDTO();
|
||||
rcDTO.coursePositions.waypointPositions = new ArrayList<DegreePosition>();
|
||||
DegreePosition posDTO;
|
||||
posDTO = SimulatorServiceUtils.toPositionDTO(startPosition);
|
||||
rcDTO.coursePositions.waypointPositions.add(posDTO);
|
||||
posDTO = SimulatorServiceUtils.toPositionDTO(endPosition);
|
||||
rcDTO.coursePositions.waypointPositions.add(posDTO);
|
||||
rcDTO.coursePositions.waypointPositions = new ArrayList<>();
|
||||
rcDTO.coursePositions.waypointPositions.add(startPosition);
|
||||
rcDTO.coursePositions.waypointPositions.add(endPosition);
|
||||
result = new SimulatorResultsDTO(startTimePoint.asDate(), timeStep.asMillis(), legDuration, rcDTO, pathDTOs, null, null);
|
||||
}
|
||||
}
|
||||
@@ -1560,7 +1557,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
if (position != null) {
|
||||
result.position = SimulatorServiceUtils.toPositionDTO(position);
|
||||
result.position = position;
|
||||
}
|
||||
|
||||
if (timePoint != null) {
|
||||
@@ -1903,7 +1900,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
dateAsTimePoint = new MillisecondsTimePoint(date);
|
||||
}
|
||||
result.marks = new HashSet<MarkDTO>();
|
||||
result.waypointPositions = new ArrayList<DegreePosition>();
|
||||
result.waypointPositions = new ArrayList<>();
|
||||
Set<Mark> marks = new HashSet<Mark>();
|
||||
Course course = trackedRace.getRace().getCourse();
|
||||
for (Waypoint waypoint : course.getWaypoints()) {
|
||||
@@ -1929,8 +1926,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
if (firstWaypoint != null && Util.size(firstWaypoint.getMarks()) == 2) {
|
||||
final LineDetails markPositionDTOsAndLineAdvantage = trackedRace.getStartLine(dateAsTimePoint);
|
||||
if (markPositionDTOsAndLineAdvantage != null) {
|
||||
final List<DegreePosition> startMarkPositionDTOs = getMarkPositionDTOs(dateAsTimePoint, trackedRace,
|
||||
firstWaypoint);
|
||||
final List<Position> startMarkPositionDTOs = getMarkPositionDTOs(dateAsTimePoint, trackedRace, firstWaypoint);
|
||||
result.startMarkPositions = startMarkPositionDTOs;
|
||||
result.startLineLengthInMeters = markPositionDTOsAndLineAdvantage.getLength().getMeters();
|
||||
Bearing absoluteAngleDifferenceToTrueWind = markPositionDTOsAndLineAdvantage
|
||||
@@ -1947,8 +1943,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
if (lastWaypoint != null && Util.size(lastWaypoint.getMarks()) == 2) {
|
||||
final LineDetails markPositionDTOsAndLineAdvantage = trackedRace.getFinishLine(dateAsTimePoint);
|
||||
if (markPositionDTOsAndLineAdvantage != null) {
|
||||
final List<DegreePosition> finishMarkPositionDTOs = getMarkPositionDTOs(dateAsTimePoint, trackedRace,
|
||||
lastWaypoint);
|
||||
final List<Position> finishMarkPositionDTOs = getMarkPositionDTOs(dateAsTimePoint, trackedRace, lastWaypoint);
|
||||
result.finishMarkPositions = finishMarkPositionDTOs;
|
||||
result.finishLineLengthInMeters = markPositionDTOsAndLineAdvantage.getLength().getMeters();
|
||||
Bearing absoluteAngleDifferenceToTrueWind = markPositionDTOsAndLineAdvantage
|
||||
@@ -2059,9 +2054,9 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
}
|
||||
|
||||
private List<DegreePosition> getMarkPositionDTOs(
|
||||
private List<Position> getMarkPositionDTOs(
|
||||
TimePoint timePoint, TrackedRace trackedRace, Waypoint waypoint) {
|
||||
List<DegreePosition> markPositionDTOs = new ArrayList<DegreePosition>();
|
||||
List<Position> markPositionDTOs = new ArrayList<>();
|
||||
for (Mark startMark : waypoint.getMarks()) {
|
||||
final Position estimatedMarkPosition = trackedRace.getOrCreateTrack(startMark)
|
||||
.getEstimatedPosition(timePoint, /* extrapolate */false);
|
||||
|
||||
+13
-18
@@ -518,11 +518,11 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
PolarDiagram polarDiagram = polarDiagramAndNotificationMessage.getA();
|
||||
String notificationMessage = polarDiagramAndNotificationMessage.getB();
|
||||
|
||||
Position edgeStart = SimulatorServiceUtils.toPosition(requestData.edgeStart);
|
||||
Position edgeEnd = SimulatorServiceUtils.toPosition(requestData.edgeEnd);
|
||||
Position edgeStart = requestData.edgeStart;
|
||||
Position edgeEnd = requestData.edgeEnd;
|
||||
|
||||
Position oldMovedPosition = SimulatorServiceUtils.toPosition(requestData.oldMovedPoint);
|
||||
Position newMovedPosition = SimulatorServiceUtils.toPosition(requestData.newMovedPoint);
|
||||
Position oldMovedPosition = requestData.oldMovedPoint;
|
||||
Position newMovedPosition = requestData.newMovedPoint;
|
||||
Bearing oldMovedToNewMovedBearing = oldMovedPosition.getBearingGreatCircle(newMovedPosition);
|
||||
boolean areTowardsSameDirection = SimulatorServiceUtils.areTowardsSameDirection(oldMovedToNewMovedBearing, new DegreeBearingImpl(
|
||||
requestData.startToEndBearingDegrees));
|
||||
@@ -553,13 +553,13 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
leftSide1Turner = pathGenerator.get1Turner(windFieldGenerator, polarDiagram, realStart, realEnd, startTime, true, DEFAULT_STEP_MAX, DEFAULT_TIMESTEP);
|
||||
rightSide1Turner = pathGenerator.get1Turner(windFieldGenerator, polarDiagram, realStart, realEnd, startTime, false, DEFAULT_STEP_MAX, DEFAULT_TIMESTEP);
|
||||
|
||||
boolean isLeftSide1TurnerOnTheInside = SimulatorServiceUtils.isPointInsideTriangle(SimulatorServiceUtils.toPositionDTO(leftSide1Turner.getPosition()),
|
||||
boolean isLeftSide1TurnerOnTheInside = SimulatorServiceUtils.isPointInsideTriangle(leftSide1Turner.getPosition(),
|
||||
requestData.beforeMovedPoint,
|
||||
requestData.newMovedPoint, requestData.edgeStart);
|
||||
System.out.println("isLeftSide1TurnerOnTheInside = " + isLeftSide1TurnerOnTheInside);
|
||||
|
||||
boolean isRightSide1TurnerOnTheInside = SimulatorServiceUtils.isPointInsideTriangle(
|
||||
SimulatorServiceUtils.toPositionDTO(rightSide1Turner.getPosition()),
|
||||
rightSide1Turner.getPosition(),
|
||||
requestData.beforeMovedPoint,
|
||||
requestData.newMovedPoint, requestData.edgeStart);
|
||||
System.out.println("isRightSide1TurnerOnTheInside = " + isRightSide1TurnerOnTheInside);
|
||||
@@ -597,8 +597,8 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
|
||||
|
||||
return new Response1TurnerDTO(SimulatorServiceUtils.toSimulatorWindDTOList(path), SimulatorServiceUtils.toSimulatorWindDTO(leftSide1Turner),
|
||||
SimulatorServiceUtils.toSimulatorWindDTO(rightSide1Turner), SimulatorServiceUtils.toPositionDTO(oldMovedPosition),
|
||||
SimulatorServiceUtils.toPositionDTO(newMovedPosition),
|
||||
SimulatorServiceUtils.toSimulatorWindDTO(rightSide1Turner), oldMovedPosition,
|
||||
newMovedPosition,
|
||||
notificationMessage);
|
||||
}
|
||||
|
||||
@@ -672,7 +672,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
result.trueWindSpeedInKnots = wind.getKnots();
|
||||
|
||||
if (position != null) {
|
||||
result.position = SimulatorServiceUtils.toPositionDTO(position);
|
||||
result.position = position;
|
||||
}
|
||||
if (timePoint != null) {
|
||||
result.timepoint = timePoint.asMillis();
|
||||
@@ -697,7 +697,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
}
|
||||
|
||||
if (position != null) {
|
||||
result.position = SimulatorServiceUtils.toPositionDTO(position);
|
||||
result.position = position;
|
||||
}
|
||||
|
||||
if (timePoint != null) {
|
||||
@@ -904,15 +904,10 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
if (mode == SailingSimulatorConstants.ModeMeasured) {
|
||||
rcDTO = new RaceMapDataDTO();
|
||||
rcDTO.coursePositions = new CoursePositionsDTO();
|
||||
rcDTO.coursePositions.waypointPositions = new ArrayList<DegreePosition>();
|
||||
|
||||
rcDTO.coursePositions.waypointPositions = new ArrayList<>();
|
||||
Path rc = simulator.getRaceCourse();
|
||||
DegreePosition posDTO;
|
||||
posDTO = SimulatorServiceUtils.toPositionDTO(rc.getPathPoints().get(0).getPosition());
|
||||
|
||||
rcDTO.coursePositions.waypointPositions.add(posDTO);
|
||||
posDTO = SimulatorServiceUtils.toPositionDTO(rc.getPathPoints().get(1).getPosition());
|
||||
rcDTO.coursePositions.waypointPositions.add(posDTO);
|
||||
rcDTO.coursePositions.waypointPositions.add(rc.getPathPoints().get(0).getPosition());
|
||||
rcDTO.coursePositions.waypointPositions.add(rc.getPathPoints().get(1).getPosition());
|
||||
} else {
|
||||
rcDTO = null;
|
||||
}
|
||||
|
||||
+2
-19
@@ -126,13 +126,11 @@ public class SimulatorServiceUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<Position> getIntermediatePoints2(List<DegreePosition> points, double stepSizeMeters) {
|
||||
List<Position> newPoints = new ArrayList<Position>();
|
||||
|
||||
public static List<Position> getIntermediatePoints2(List<Position> points, double stepSizeMeters) {
|
||||
List<Position> newPoints = new ArrayList<>();
|
||||
for (Position point : points) {
|
||||
newPoints.add(new DegreePosition(point.getLatDeg(), point.getLngDeg()));
|
||||
}
|
||||
|
||||
return SimulatorServiceUtils.getIntermediatePoints(newPoints, stepSizeMeters);
|
||||
}
|
||||
|
||||
@@ -419,32 +417,17 @@ public class SimulatorServiceUtils {
|
||||
}
|
||||
|
||||
public static SimulatorWindDTO toSimulatorWindDTO(TimedPositionWithSpeed point) {
|
||||
|
||||
Position position = point.getPosition();
|
||||
SpeedWithBearing windSpeedWithBearing = point.getSpeed();
|
||||
TimePoint timePoint = point.getTimePoint();
|
||||
|
||||
double latDeg = position.getLatDeg();
|
||||
double lngDeg = position.getLngDeg();
|
||||
double windSpeedKn = windSpeedWithBearing.getKnots();
|
||||
double windBearingDeg = windSpeedWithBearing.getBearing().getDegrees();
|
||||
long timepointMsec = timePoint.asMillis();
|
||||
|
||||
return new SimulatorWindDTO(latDeg, lngDeg, windSpeedKn, windBearingDeg, timepointMsec);
|
||||
}
|
||||
|
||||
public static DegreePosition toPositionDTO(Position position) {
|
||||
return new DegreePosition(position.getLatDeg(), position.getLngDeg());
|
||||
}
|
||||
|
||||
public static Position toPosition(Position positionDTO) {
|
||||
return new DegreePosition(positionDTO.getLatDeg(), positionDTO.getLngDeg());
|
||||
}
|
||||
|
||||
public static boolean equals(Position position, Position positonDTO) {
|
||||
return (position.getLatDeg() == positonDTO.getLatDeg() && position.getLngDeg() == positonDTO.getLngDeg());
|
||||
}
|
||||
|
||||
public static SimulatorUISelection toSimulatorUISelection(SimulatorUISelectionDTO selection) {
|
||||
return new SimulatorUISelectionImpl(selection.boatClassIndex, selection.raceIndex, selection.competitorIndex, selection.legIndex);
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,12 +5,12 @@ import java.util.Set;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import com.sap.sailing.domain.common.NauticalSide;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
public class CoursePositionsDTO implements IsSerializable {
|
||||
public List<DegreePosition> waypointPositions;
|
||||
public List<DegreePosition> startMarkPositions;
|
||||
public List<DegreePosition> finishMarkPositions;
|
||||
public List<Position> waypointPositions;
|
||||
public List<Position> startMarkPositions;
|
||||
public List<Position> finishMarkPositions;
|
||||
public Set<MarkDTO> marks;
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -4,25 +4,25 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
public class RequestTotalTimeDTO implements IsSerializable {
|
||||
|
||||
public SimulatorUISelectionDTO selection = null;
|
||||
public List<SimulatorWindDTO> allPoints = null;
|
||||
public List<DegreePosition> turnPoints = null;
|
||||
public List<Position> turnPoints = null;
|
||||
public boolean useRealAverageWindSpeed = false;
|
||||
public int stepDurationMilliseconds = 0;
|
||||
|
||||
public RequestTotalTimeDTO() {
|
||||
this.selection = null;
|
||||
this.allPoints = new ArrayList<SimulatorWindDTO>();
|
||||
this.turnPoints = new ArrayList<DegreePosition>();
|
||||
this.turnPoints = new ArrayList<>();
|
||||
this.useRealAverageWindSpeed = true;
|
||||
this.stepDurationMilliseconds = 2000;
|
||||
}
|
||||
|
||||
public RequestTotalTimeDTO(SimulatorUISelectionDTO selection, int stepDurationMilliseconds, List<SimulatorWindDTO> allPoints, List<DegreePosition> turnPoints,
|
||||
public RequestTotalTimeDTO(SimulatorUISelectionDTO selection, int stepDurationMilliseconds, List<SimulatorWindDTO> allPoints, List<Position> turnPoints,
|
||||
boolean useRealAverageWindSpeed) {
|
||||
this.selection = selection;
|
||||
this.allPoints = allPoints;
|
||||
|
||||
+2
-2
@@ -1085,7 +1085,7 @@ public class PathPolyline {
|
||||
* - the LatLng object used
|
||||
* @returns a PositionDTO object.
|
||||
*/
|
||||
private static DegreePosition toPositionDTO(LatLng position) {
|
||||
private static Position toPositionDTO(LatLng position) {
|
||||
return new DegreePosition(position.getLatitude(), position.getLongitude());
|
||||
}
|
||||
|
||||
@@ -1107,7 +1107,7 @@ public class PathPolyline {
|
||||
}
|
||||
|
||||
private void getTotalTime() {
|
||||
List<DegreePosition> turnPointsAsPositionDTO = new ArrayList<DegreePosition>();
|
||||
List<Position> turnPointsAsPositionDTO = new ArrayList<>();
|
||||
|
||||
for (LatLng point : this.turnPoints) {
|
||||
turnPointsAsPositionDTO.add(toPositionDTO(point));
|
||||
|
||||
Reference in new issue
Block a user