mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-16 01:01:02 +00:00
removed all TODOs and System.out.println from com.sap.sailing.dashboards.gwt
This commit is contained in:
1 parent
7dc1e72414
commit
69e29a89dd
8 files changed
+163
-402
No files matched your search
-1
@@ -242,7 +242,6 @@ public class RibDashboardDataRetriever implements RacingNotYetStartedPopupListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void didClickedOKWithCompetitorName(String competitorName) {
|
public void didClickedOKWithCompetitorName(String competitorName) {
|
||||||
System.out.println("Did clicked with competitor " + competitorName);
|
|
||||||
this.selectedTeamName = competitorName;
|
this.selectedTeamName = competitorName;
|
||||||
Cookies.setCookie(KEY_SLECTED_TEAM_COOKIE, competitorName, new Date(new Date().getTime()
|
Cookies.setCookie(KEY_SLECTED_TEAM_COOKIE, competitorName, new Date(new Date().getTime()
|
||||||
+ SLECTED_TEAM_COOKIE_EXPIRE_TIME_IN_MILLIS));
|
+ SLECTED_TEAM_COOKIE_EXPIRE_TIME_IN_MILLIS));
|
||||||
|
|||||||
-1
@@ -136,7 +136,6 @@ public class CompetitorSelectionPopup extends Composite implements HasWidgets, C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void didSelectedRowWithCompetitorName(String competitorName) {
|
public void didSelectedRowWithCompetitorName(String competitorName) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
button.getElement().addClassName(style.buttonshow());
|
button.getElement().addClassName(style.buttonshow());
|
||||||
currentCompetitorSelected = competitorName;
|
currentCompetitorSelected = competitorName;
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -231,7 +231,6 @@ public class StartlineAnalysisComponent extends Composite implements HasWidgets,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bottomNotificationClicked() {
|
public void bottomNotificationClicked() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
scrollToLast();
|
scrollToLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -7,7 +7,6 @@ public abstract class StartAnalysisStartRankTableTeamCollumn<T> extends Column<T
|
|||||||
|
|
||||||
public StartAnalysisStartRankTableTeamCollumn() {
|
public StartAnalysisStartRankTableTeamCollumn() {
|
||||||
super(new StartAnalysisStartRankTableTeamCell());
|
super(new StartAnalysisStartRankTableTeamCell());
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-1
@@ -1,7 +1,6 @@
|
|||||||
package com.sap.sailing.dashboards.gwt.client.windchart.compass;
|
package com.sap.sailing.dashboards.gwt.client.windchart.compass;
|
||||||
|
|
||||||
import com.google.gwt.i18n.client.NumberFormat;
|
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.AbsolutePanel;
|
||||||
import com.google.gwt.user.client.ui.HasWidgets;
|
import com.google.gwt.user.client.ui.HasWidgets;
|
||||||
import com.google.gwt.user.client.ui.Image;
|
import com.google.gwt.user.client.ui.Image;
|
||||||
|
|||||||
+162
-383
@@ -1,7 +1,6 @@
|
|||||||
package com.sap.sailing.dashboards.gwt.server;
|
package com.sap.sailing.dashboards.gwt.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -24,24 +23,11 @@ import com.sap.sailing.domain.base.Competitor;
|
|||||||
import com.sap.sailing.domain.base.Fleet;
|
import com.sap.sailing.domain.base.Fleet;
|
||||||
import com.sap.sailing.domain.base.RaceColumn;
|
import com.sap.sailing.domain.base.RaceColumn;
|
||||||
import com.sap.sailing.domain.common.NoWindException;
|
import com.sap.sailing.domain.common.NoWindException;
|
||||||
import com.sap.sailing.domain.common.Position;
|
|
||||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||||
import com.sap.sailing.domain.common.WindSource;
|
|
||||||
import com.sap.sailing.domain.common.WindSourceType;
|
|
||||||
import com.sap.sailing.domain.common.dto.PositionDTO;
|
|
||||||
import com.sap.sailing.domain.common.impl.WindSourceImpl;
|
|
||||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||||
import com.sap.sailing.domain.tracking.TrackedLeg;
|
|
||||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||||
import com.sap.sailing.domain.tracking.Wind;
|
|
||||||
import com.sap.sailing.domain.tracking.WindTrack;
|
|
||||||
import com.sap.sailing.domain.tracking.WindWithConfidence;
|
|
||||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
|
||||||
import com.sap.sailing.gwt.ui.shared.WindInfoForRaceDTO;
|
|
||||||
import com.sap.sailing.gwt.ui.shared.WindTrackInfoDTO;
|
|
||||||
import com.sap.sailing.server.RacingEventService;
|
import com.sap.sailing.server.RacingEventService;
|
||||||
import com.sap.sse.common.TimePoint;
|
import com.sap.sse.common.TimePoint;
|
||||||
import com.sap.sse.common.Util;
|
|
||||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,395 +37,188 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class RibDashboardServiceImpl extends RemoteServiceServlet implements
|
public class RibDashboardServiceImpl extends RemoteServiceServlet implements RibDashboardService,
|
||||||
RibDashboardService, StartAnalysisRacesStoreListener {
|
StartAnalysisRacesStoreListener {
|
||||||
|
|
||||||
private final ServiceTracker<RacingEventService, RacingEventService> racingEventServiceTracker;
|
/**
|
||||||
private final com.sap.sailing.domain.base.DomainFactory baseDomainFactory;
|
* Variable contains last {@link TrackedRace} that is or was live
|
||||||
private final BundleContext context;
|
* */
|
||||||
private static final Logger logger = Logger
|
private TrackedRace runningRace;
|
||||||
.getLogger(RibDashboardServiceImpl.class.getName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variable contains last {@link TrackedRace} that is or was live
|
* {@link MovingAverage} of last 400 start line advantage values during the last races. See initialization at
|
||||||
* */
|
* {@link #RibDashboardServiceImpl()}) Advantage by wind is the advantage in meters that a boat, starting a the pin
|
||||||
private TrackedRace runningRace;
|
* end of the line, has, compared to a boat starting at the very right side of the line.
|
||||||
|
* */
|
||||||
|
private MovingAverage averageStartLineAdvantageByWind;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link MovingAverage} of last 400 start line advantage values during the
|
* {@link MovingAverage} of last 400 start line advantage values during the last races. See initialization at
|
||||||
* last races. See initialization at {@link #RibDashboardServiceImpl()})
|
* {@link #RibDashboardServiceImpl()}) Advantage by geometry is the delta in meters of the distance from race
|
||||||
* Advantage by wind is the advantage in meters that a boat, starting a the
|
* committee boat to first mark and pin end mark to first mark. Wind has no influence on the value.
|
||||||
* pin end of the line, has, compared to a boat starting at the very right
|
* */
|
||||||
* side of the line.
|
private MovingAverage averageStartLineAdvantageByGeometry;
|
||||||
* */
|
|
||||||
private MovingAverage averageStartLineAdvantageByWind;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link MovingAverage} of last 400 start line advantage values during the
|
* The map values contain a Pair, whose first value is a {@link MovingAverage} for the true wind speed and the
|
||||||
* last races. See initialization at {@link #RibDashboardServiceImpl()})
|
* second one contains an average for the true wind direction for a wind bot.
|
||||||
* Advantage by geometry is the delta in meters of the distance from race
|
* */
|
||||||
* committee boat to first mark and pin end mark to first mark. Wind has no
|
|
||||||
* influence on the value.
|
|
||||||
* */
|
|
||||||
private MovingAverage averageStartLineAdvantageByGeometry;
|
|
||||||
|
|
||||||
/**
|
private Map<String, List<StartAnalysisDTO>> startAnalysisDTOsForCompetitor;
|
||||||
* The map values contain a Pair, whose first value is a
|
private StartAnalysisRacesStore startAnalysisRacesStore;
|
||||||
* {@link MovingAverage} for the true wind speed and the second one contains
|
|
||||||
* an average for the true wind direction for a wind bot.
|
private final ServiceTracker<RacingEventService, RacingEventService> racingEventServiceTracker;
|
||||||
* */
|
private final com.sap.sailing.domain.base.DomainFactory baseDomainFactory;
|
||||||
|
private final BundleContext context;
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(RibDashboardServiceImpl.class.getName());
|
||||||
|
|
||||||
private Map<String, List<StartAnalysisDTO>> startAnalysisDTOsForCompetitor;
|
|
||||||
private StartAnalysisRacesStore startAnalysisRacesStore;
|
|
||||||
|
|
||||||
public RibDashboardServiceImpl() {
|
public RibDashboardServiceImpl() {
|
||||||
context = Activator.getDefault();
|
context = Activator.getDefault();
|
||||||
racingEventServiceTracker = createAndOpenRacingEventServiceTracker(context);
|
racingEventServiceTracker = createAndOpenRacingEventServiceTracker(context);
|
||||||
baseDomainFactory = getRacingEventService().getBaseDomainFactory();
|
baseDomainFactory = getRacingEventService().getBaseDomainFactory();
|
||||||
|
|
||||||
startAnalysisRacesStore = new StartAnalysisRacesStore(getRacingEventService());
|
startAnalysisRacesStore = new StartAnalysisRacesStore(getRacingEventService());
|
||||||
startAnalysisRacesStore.addStartAnalyisisRacesStoreListener(this);
|
startAnalysisRacesStore.addStartAnalyisisRacesStoreListener(this);
|
||||||
|
|
||||||
startAnalysisDTOsForCompetitor = new HashMap<String, List<StartAnalysisDTO>>();
|
|
||||||
averageStartLineAdvantageByWind = new MovingAverage(400);
|
|
||||||
averageStartLineAdvantageByGeometry = new MovingAverage(400);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected RacingEventService getRacingEventService() {
|
startAnalysisDTOsForCompetitor = new HashMap<String, List<StartAnalysisDTO>>();
|
||||||
return racingEventServiceTracker.getService(); // grab the service
|
averageStartLineAdvantageByWind = new MovingAverage(400);
|
||||||
}
|
averageStartLineAdvantageByGeometry = new MovingAverage(400);
|
||||||
|
}
|
||||||
|
|
||||||
protected ServiceTracker<RacingEventService, RacingEventService> createAndOpenRacingEventServiceTracker(
|
protected RacingEventService getRacingEventService() {
|
||||||
BundleContext context) {
|
return racingEventServiceTracker.getService(); // grab the service
|
||||||
ServiceTracker<RacingEventService, RacingEventService> result = new ServiceTracker<RacingEventService, RacingEventService>(
|
}
|
||||||
context, RacingEventService.class.getName(), null);
|
|
||||||
result.open();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
protected ServiceTracker<RacingEventService, RacingEventService> createAndOpenRacingEventServiceTracker(
|
||||||
* <param>leaderboardGroupName</param> is used to retrieve the live running
|
BundleContext context) {
|
||||||
* race with the method {@link #getLiveRaceFromLeaderboardName(String)}.
|
ServiceTracker<RacingEventService, RacingEventService> result = new ServiceTracker<RacingEventService, RacingEventService>(
|
||||||
* <param>competitorName</param> If competitorName is null, the response
|
context, RacingEventService.class.getName(), null);
|
||||||
* contains only a list of competitors in the live race. Otherwise the
|
result.open();
|
||||||
* parameter is used to return the right startanalysis for a specific
|
return result;
|
||||||
* competitor with in the returned {@link RibDashboardRaceInfoDTO}.
|
}
|
||||||
* */
|
|
||||||
@Override
|
|
||||||
public RibDashboardRaceInfoDTO getLiveRaceInfo(String leaderboardGroupName,
|
|
||||||
String competitorName) {
|
|
||||||
RibDashboardRaceInfoDTO lRInfo = new RibDashboardRaceInfoDTO();
|
|
||||||
if (leaderboardGroupName != null) {
|
|
||||||
TimePoint timePointOfRequest = MillisecondsTimePoint.now();
|
|
||||||
if (checkIfRaceIsStillRunning(timePointOfRequest,
|
|
||||||
leaderboardGroupName)) {
|
|
||||||
if (competitorName == null) {
|
|
||||||
fillLiveRaceInfoDTOWithRaceData(lRInfo, timePointOfRequest);
|
|
||||||
logger.log(Level.INFO, "NO_COMPETITOR_SELECTED");
|
|
||||||
lRInfo.responseMessage = ResponseMessage.NO_COMPETITOR_SELECTED;
|
|
||||||
return lRInfo;
|
|
||||||
} else {
|
|
||||||
fillLiveRaceInfoDTOWithRaceData(lRInfo, timePointOfRequest);
|
|
||||||
fillLiveRaceInfoDTOWithStartLineAdavantageData(lRInfo,
|
|
||||||
timePointOfRequest);
|
|
||||||
fillLiveRaceInfoDTOWithStartAnalysisData(lRInfo,
|
|
||||||
competitorName);
|
|
||||||
lRInfo.responseMessage = ResponseMessage.OK;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lRInfo.responseMessage = ResponseMessage.NO_RACE_LIVE;
|
|
||||||
}
|
|
||||||
return lRInfo;
|
|
||||||
} else {
|
|
||||||
lRInfo.responseMessage = ResponseMessage.NO_RACE_LIVE;
|
|
||||||
return lRInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillLiveRaceInfoDTOWithRaceData(
|
/**
|
||||||
RibDashboardRaceInfoDTO lRInfo, TimePoint now) {
|
* <param>leaderboardGroupName</param> is used to retrieve the live running race with the method
|
||||||
if (runningRace != null) {
|
* {@link #getLiveRaceFromLeaderboardName(String)}. <param>competitorName</param> If competitorName is null, the
|
||||||
lRInfo.idOfLastTrackedRace = runningRace.getRaceIdentifier();
|
* response contains only a list of competitors in the live race. Otherwise the parameter is used to return the
|
||||||
try {
|
* right startanalysis for a specific competitor with in the returned {@link RibDashboardRaceInfoDTO}.
|
||||||
List<Competitor> competitors = runningRace
|
* */
|
||||||
.getCompetitorsFromBestToWorst(now);
|
@Override
|
||||||
List<String> competitorNames = new ArrayList<String>();
|
public RibDashboardRaceInfoDTO getLiveRaceInfo(String leaderboardGroupName, String competitorName) {
|
||||||
for (Competitor competitor : competitors) {
|
RibDashboardRaceInfoDTO lRInfo = new RibDashboardRaceInfoDTO();
|
||||||
competitorNames.add(competitor.getName());
|
if (leaderboardGroupName != null) {
|
||||||
}
|
TimePoint timePointOfRequest = MillisecondsTimePoint.now();
|
||||||
Collections.sort(competitorNames);
|
if (checkIfRaceIsStillRunning(timePointOfRequest, leaderboardGroupName)) {
|
||||||
lRInfo.competitorNamesFromLastTrackedRace = competitorNames;
|
if (competitorName == null) {
|
||||||
} catch (NoWindException e) {
|
fillLiveRaceInfoDTOWithRaceData(lRInfo, timePointOfRequest);
|
||||||
// TODO Auto-generated catch block
|
logger.log(Level.INFO, "NO_COMPETITOR_SELECTED");
|
||||||
e.printStackTrace();
|
lRInfo.responseMessage = ResponseMessage.NO_COMPETITOR_SELECTED;
|
||||||
}
|
return lRInfo;
|
||||||
}
|
} else {
|
||||||
}
|
fillLiveRaceInfoDTOWithRaceData(lRInfo, timePointOfRequest);
|
||||||
|
fillLiveRaceInfoDTOWithStartLineAdavantageData(lRInfo, timePointOfRequest);
|
||||||
|
fillLiveRaceInfoDTOWithStartAnalysisData(lRInfo, competitorName);
|
||||||
|
lRInfo.responseMessage = ResponseMessage.OK;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lRInfo.responseMessage = ResponseMessage.NO_RACE_LIVE;
|
||||||
|
}
|
||||||
|
return lRInfo;
|
||||||
|
} else {
|
||||||
|
lRInfo.responseMessage = ResponseMessage.NO_RACE_LIVE;
|
||||||
|
return lRInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void fillLiveRaceInfoDTOWithStartAnalysisData(
|
private void fillLiveRaceInfoDTOWithRaceData(RibDashboardRaceInfoDTO lRInfo, TimePoint now) {
|
||||||
RibDashboardRaceInfoDTO lRInfo, String competiorName) {
|
if (runningRace != null) {
|
||||||
lRInfo.startAnalysisDTOList = startAnalysisDTOsForCompetitor
|
lRInfo.idOfLastTrackedRace = runningRace.getRaceIdentifier();
|
||||||
.get(competiorName);
|
try {
|
||||||
}
|
List<Competitor> competitors = runningRace.getCompetitorsFromBestToWorst(now);
|
||||||
|
List<String> competitorNames = new ArrayList<String>();
|
||||||
|
for (Competitor competitor : competitors) {
|
||||||
|
competitorNames.add(competitor.getName());
|
||||||
|
}
|
||||||
|
Collections.sort(competitorNames);
|
||||||
|
lRInfo.competitorNamesFromLastTrackedRace = competitorNames;
|
||||||
|
} catch (NoWindException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// returns true if race is still live
|
private void fillLiveRaceInfoDTOWithStartAnalysisData(RibDashboardRaceInfoDTO lRInfo, String competiorName) {
|
||||||
private boolean checkIfRaceIsStillRunning(TimePoint now,
|
lRInfo.startAnalysisDTOList = startAnalysisDTOsForCompetitor.get(competiorName);
|
||||||
String leaderboardGroupName) {
|
}
|
||||||
if (runningRace == null || !(runningRace.isLive(now))) {
|
|
||||||
runningRace = getLiveRaceFromLeaderboardName(leaderboardGroupName);
|
|
||||||
if (runningRace == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
startAnalysisRacesStore.addAsListener(runningRace);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TrackedRace getLiveRaceFromLeaderboardName(
|
// returns true if race is still live
|
||||||
String leaderboardGroupName) {
|
private boolean checkIfRaceIsStillRunning(TimePoint now, String leaderboardGroupName) {
|
||||||
TrackedRace result = null;
|
if (runningRace == null || !(runningRace.isLive(now))) {
|
||||||
Leaderboard lb = getRacingEventService().getLeaderboardByName(
|
runningRace = getLiveRaceFromLeaderboardName(leaderboardGroupName);
|
||||||
leaderboardGroupName);
|
if (runningRace == null) {
|
||||||
if (lb != null) {
|
return false;
|
||||||
for (RaceColumn column : lb.getRaceColumns()) {
|
} else {
|
||||||
for (Fleet fleet : column.getFleets()) {
|
startAnalysisRacesStore.addAsListener(runningRace);
|
||||||
TrackedRace race = column.getTrackedRace(fleet);
|
return true;
|
||||||
if (race != null
|
}
|
||||||
&& race.isLive(new MillisecondsTimePoint(new Date()))) {
|
} else {
|
||||||
result = race;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillLiveRaceInfoDTOWithStartLineAdavantageData(
|
private TrackedRace getLiveRaceFromLeaderboardName(String leaderboardGroupName) {
|
||||||
RibDashboardRaceInfoDTO lRInfo, TimePoint timepoint) {
|
TrackedRace result = null;
|
||||||
if (runningRace != null && timepoint != null) {
|
Leaderboard lb = getRacingEventService().getLeaderboardByName(leaderboardGroupName);
|
||||||
StartLineAdvantageDTO startLineAdvantageDTO = new StartLineAdvantageDTO();
|
if (lb != null) {
|
||||||
startLineAdvantageDTO.liveWindStartLineAdvantage = getWindStartLineAdvantageAtTimePoint(
|
for (RaceColumn column : lb.getRaceColumns()) {
|
||||||
runningRace, timepoint);
|
for (Fleet fleet : column.getFleets()) {
|
||||||
startLineAdvantageDTO.liveGeometricStartLineAdvantage = getGeometricStartLineAdvantageAtTimePoint(
|
TrackedRace race = column.getTrackedRace(fleet);
|
||||||
runningRace, timepoint);
|
if (race != null && race.isLive(new MillisecondsTimePoint(new Date()))) {
|
||||||
startLineAdvantageDTO.averageWindStartLineAdvantage = averageStartLineAdvantageByWind
|
result = race;
|
||||||
.getAverage();
|
}
|
||||||
startLineAdvantageDTO.averageGeometricStartLineAdvantage = averageStartLineAdvantageByGeometry
|
}
|
||||||
.getAverage();
|
}
|
||||||
lRInfo.startLineAdvantageDTO = startLineAdvantageDTO;
|
}
|
||||||
}
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getWindStartLineAdvantageAtTimePoint(
|
private void fillLiveRaceInfoDTOWithStartLineAdavantageData(RibDashboardRaceInfoDTO lRInfo, TimePoint timepoint) {
|
||||||
TrackedRace trackedRace, TimePoint timePoint) {
|
if (runningRace != null && timepoint != null) {
|
||||||
double result = trackedRace.getStartLine(timePoint).getAdvantage()
|
StartLineAdvantageDTO startLineAdvantageDTO = new StartLineAdvantageDTO();
|
||||||
.getMeters();
|
startLineAdvantageDTO.liveWindStartLineAdvantage = getWindStartLineAdvantageAtTimePoint(runningRace,
|
||||||
averageStartLineAdvantageByWind.add(result);
|
timepoint);
|
||||||
return result;
|
startLineAdvantageDTO.liveGeometricStartLineAdvantage = getGeometricStartLineAdvantageAtTimePoint(
|
||||||
}
|
runningRace, timepoint);
|
||||||
|
startLineAdvantageDTO.averageWindStartLineAdvantage = averageStartLineAdvantageByWind.getAverage();
|
||||||
|
startLineAdvantageDTO.averageGeometricStartLineAdvantage = averageStartLineAdvantageByGeometry.getAverage();
|
||||||
|
lRInfo.startLineAdvantageDTO = startLineAdvantageDTO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private double getGeometricStartLineAdvantageAtTimePoint(
|
private double getWindStartLineAdvantageAtTimePoint(TrackedRace trackedRace, TimePoint timePoint) {
|
||||||
TrackedRace trackedRace, TimePoint timePoint) {
|
double result = trackedRace.getStartLine(timePoint).getAdvantage().getMeters();
|
||||||
double result = trackedRace.getStartLine(timePoint)
|
averageStartLineAdvantageByWind.add(result);
|
||||||
.getGeometricAdvantage().getMeters();
|
return result;
|
||||||
averageStartLineAdvantageByGeometry.add(result);
|
}
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected com.sap.sailing.domain.base.DomainFactory getBaseDomainFactory() {
|
private double getGeometricStartLineAdvantageAtTimePoint(TrackedRace trackedRace, TimePoint timePoint) {
|
||||||
return baseDomainFactory;
|
double result = trackedRace.getStartLine(timePoint).getGeometricAdvantage().getMeters();
|
||||||
}
|
averageStartLineAdvantageByGeometry.add(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private interface PositionAtTimeProvider {
|
protected com.sap.sailing.domain.base.DomainFactory getBaseDomainFactory() {
|
||||||
Position getPosition(TimePoint at);
|
return baseDomainFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WindDTO createWindDTOFromAlreadyAveraged(Wind wind,
|
public TrackedRace getExistingTrackedRace(RegattaAndRaceIdentifier regattaNameAndRaceName) {
|
||||||
TimePoint requestTimepoint) {
|
return null;
|
||||||
WindDTO windDTO = new WindDTO();
|
}
|
||||||
windDTO.requestTimepoint = requestTimepoint.asMillis();
|
|
||||||
windDTO.trueWindBearingDeg = wind.getBearing().getDegrees();
|
|
||||||
windDTO.trueWindFromDeg = wind.getBearing().reverse().getDegrees();
|
|
||||||
windDTO.trueWindSpeedInKnots = wind.getKnots();
|
|
||||||
windDTO.trueWindSpeedInMetersPerSecond = wind.getMetersPerSecond();
|
|
||||||
windDTO.dampenedTrueWindBearingDeg = wind.getBearing().getDegrees();
|
|
||||||
windDTO.dampenedTrueWindFromDeg = wind.getBearing().reverse()
|
|
||||||
.getDegrees();
|
|
||||||
windDTO.dampenedTrueWindSpeedInKnots = wind.getKnots();
|
|
||||||
windDTO.dampenedTrueWindSpeedInMetersPerSecond = wind
|
|
||||||
.getMetersPerSecond();
|
|
||||||
if (wind.getPosition() != null) {
|
|
||||||
windDTO.position = new PositionDTO(wind.getPosition().getLatDeg(),
|
|
||||||
wind.getPosition().getLngDeg());
|
|
||||||
}
|
|
||||||
if (wind.getTimePoint() != null) {
|
|
||||||
windDTO.measureTimepoint = wind.getTimePoint().asMillis();
|
|
||||||
}
|
|
||||||
return windDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
private WindTrackInfoDTO createWindTrackInfoDTO(TimePoint from,
|
@Override
|
||||||
long millisecondsStepWidth, int numberOfFixes,
|
public void startAnalyisisRacesChanged(Map<String, List<StartAnalysisDTO>> startAnalysisDTOCompetitorMap) {
|
||||||
TrackedRace trackedRace, boolean onlyUpToNewestEvent,
|
startAnalysisDTOsForCompetitor = startAnalysisDTOCompetitorMap;
|
||||||
TimePoint newestEvent, WindSource windSource,
|
}
|
||||||
PositionAtTimeProvider positionProvider) {
|
|
||||||
WindTrack windTrack = trackedRace.getOrCreateWindTrack(windSource);
|
|
||||||
WindTrackInfoDTO windTrackInfoDTO = new WindTrackInfoDTO();
|
|
||||||
windTrackInfoDTO.windFixes = new ArrayList<WindDTO>();
|
|
||||||
windTrackInfoDTO.dampeningIntervalInMilliseconds = windTrack
|
|
||||||
.getMillisecondsOverWhichToAverageWind();
|
|
||||||
TimePoint timePoint = from;
|
|
||||||
|
|
||||||
for (int i = 0; i < numberOfFixes
|
|
||||||
&& (!onlyUpToNewestEvent || (newestEvent != null && timePoint
|
|
||||||
.before(newestEvent))); i++) {
|
|
||||||
WindWithConfidence<com.sap.sse.common.Util.Pair<Position, TimePoint>> averagedWindWithConfidence = windTrack
|
|
||||||
.getAveragedWindWithConfidence(
|
|
||||||
positionProvider.getPosition(timePoint), timePoint);
|
|
||||||
if (averagedWindWithConfidence != null) {
|
|
||||||
WindDTO windDTO = createWindDTOFromAlreadyAveraged(
|
|
||||||
averagedWindWithConfidence.getObject(), timePoint);
|
|
||||||
windTrackInfoDTO.windFixes.add(windDTO);
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
timePoint = new MillisecondsTimePoint(timePoint.asMillis()
|
|
||||||
+ millisecondsStepWidth);
|
|
||||||
}
|
|
||||||
return windTrackInfoDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startAnalyisisRacesChanged(
|
|
||||||
Map<String, List<StartAnalysisDTO>> startAnalysisDTOCompetitorMap) {
|
|
||||||
startAnalysisDTOsForCompetitor = startAnalysisDTOCompetitorMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param to
|
|
||||||
* if <code>null</code>, data is returned up to end of race; if
|
|
||||||
* the end of race is not known and <code>null</code> is used for
|
|
||||||
* this parameter, <code>null</code> is returned.
|
|
||||||
* @param onlyUpToNewestEvent
|
|
||||||
* if <code>true</code>, no wind data will be returned for time
|
|
||||||
* points later than
|
|
||||||
* {@link TrackedRace#getTimePointOfNewestEvent()
|
|
||||||
* trackedRace.getTimePointOfNewestEvent()}. This is helpful in
|
|
||||||
* case the client wants to populate a chart during live mode. If
|
|
||||||
* <code>false</code>, the "best effort" readings are provided
|
|
||||||
* for the time interval requested, no matter if based on any
|
|
||||||
* sensor evidence or not, regardless of
|
|
||||||
* {@link TrackedRace#getTimePointOfNewestEvent()
|
|
||||||
* trackedRace.getTimePointOfNewestEvent()}.
|
|
||||||
*/
|
|
||||||
public WindInfoForRaceDTO getAveragedWindInfo(
|
|
||||||
RegattaAndRaceIdentifier raceIdentifier, Date from, Date to,
|
|
||||||
long resolutionInMilliseconds,
|
|
||||||
Collection<String> windSourceTypeNames, boolean onlyUpToNewestEvent) {
|
|
||||||
TrackedRace trackedRace = getExistingTrackedRace(raceIdentifier);
|
|
||||||
WindInfoForRaceDTO result = null;
|
|
||||||
if (trackedRace != null) {
|
|
||||||
TimePoint fromTimePoint = from == null ? trackedRace
|
|
||||||
.getStartOfTracking() : new MillisecondsTimePoint(from);
|
|
||||||
TimePoint toTimePoint = to == null ? trackedRace.getEndOfRace() == null ? MillisecondsTimePoint
|
|
||||||
.now().minus(trackedRace.getDelayToLiveInMillis())
|
|
||||||
: trackedRace.getEndOfRace()
|
|
||||||
: new MillisecondsTimePoint(to);
|
|
||||||
if (fromTimePoint != null && toTimePoint != null) {
|
|
||||||
int numberOfFixes = (int) ((toTimePoint.asMillis() - fromTimePoint
|
|
||||||
.asMillis()) / resolutionInMilliseconds);
|
|
||||||
result = getAveragedWindInfo(fromTimePoint,
|
|
||||||
resolutionInMilliseconds, numberOfFixes,
|
|
||||||
windSourceTypeNames, trackedRace, onlyUpToNewestEvent, /* includeCombinedWindForAllLegMiddles */
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TrackedRace getExistingTrackedRace(
|
|
||||||
RegattaAndRaceIdentifier regattaNameAndRaceName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param onlyUpToNewestEvent
|
|
||||||
* if <code>true</code>, no wind data will be returned for time
|
|
||||||
* points later than
|
|
||||||
* {@link TrackedRace#getTimePointOfNewestEvent()
|
|
||||||
* trackedRace.getTimePointOfNewestEvent()}. This is helpful in
|
|
||||||
* case the client wants to populate a chart during live mode. If
|
|
||||||
* <code>false</code>, the "best effort" readings are provided
|
|
||||||
* for the time interval requested, no matter if based on any
|
|
||||||
* sensor evidence or not, regardless of
|
|
||||||
* {@link TrackedRace#getTimePointOfNewestEvent()
|
|
||||||
* trackedRace.getTimePointOfNewestEvent()}.
|
|
||||||
* @param includeCombinedWindForAllLegMiddles
|
|
||||||
* if <code>true</code>, the result will return non-
|
|
||||||
* <code>null</code> results for calls to
|
|
||||||
* {@link WindInfoForRaceDTO#getCombinedWindOnLegMiddle(int)}.
|
|
||||||
*/
|
|
||||||
private WindInfoForRaceDTO getAveragedWindInfo(TimePoint from,
|
|
||||||
long millisecondsStepWidth, int numberOfFixes,
|
|
||||||
Collection<String> windSourceTypeNames, TrackedRace trackedRace,
|
|
||||||
boolean onlyUpToNewestEvent,
|
|
||||||
boolean includeCombinedWindForAllLegMiddles) {
|
|
||||||
WindInfoForRaceDTO result = null;
|
|
||||||
if (trackedRace != null) {
|
|
||||||
TimePoint newestEvent = trackedRace.getTimePointOfNewestEvent();
|
|
||||||
result = new WindInfoForRaceDTO();
|
|
||||||
result.raceIsKnownToStartUpwind = trackedRace
|
|
||||||
.raceIsKnownToStartUpwind();
|
|
||||||
List<WindSource> windSourcesToExclude = new ArrayList<WindSource>();
|
|
||||||
for (WindSource windSourceToExclude : trackedRace
|
|
||||||
.getWindSourcesToExclude()) {
|
|
||||||
windSourcesToExclude.add(windSourceToExclude);
|
|
||||||
}
|
|
||||||
result.windSourcesToExclude = windSourcesToExclude;
|
|
||||||
Map<WindSource, WindTrackInfoDTO> windTrackInfoDTOs = new HashMap<WindSource, WindTrackInfoDTO>();
|
|
||||||
result.windTrackInfoByWindSource = windTrackInfoDTOs;
|
|
||||||
List<WindSource> windSourcesToDeliver = new ArrayList<WindSource>();
|
|
||||||
Util.addAll(trackedRace.getWindSources(), windSourcesToDeliver);
|
|
||||||
final WindSource combinedWindSource = new WindSourceImpl(
|
|
||||||
WindSourceType.COMBINED);
|
|
||||||
windSourcesToDeliver.add(combinedWindSource);
|
|
||||||
for (WindSource windSource : windSourcesToDeliver) {
|
|
||||||
// TODO consider parallelizing
|
|
||||||
if (windSourceTypeNames == null
|
|
||||||
|| windSourceTypeNames.contains(windSource.getType()
|
|
||||||
.name())) {
|
|
||||||
WindTrackInfoDTO windTrackInfoDTO = createWindTrackInfoDTO(
|
|
||||||
from, millisecondsStepWidth, numberOfFixes,
|
|
||||||
trackedRace, onlyUpToNewestEvent, newestEvent,
|
|
||||||
windSource, new PositionAtTimeProvider() {
|
|
||||||
@Override
|
|
||||||
public Position getPosition(TimePoint at) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
windTrackInfoDTOs.put(windSource, windTrackInfoDTO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (includeCombinedWindForAllLegMiddles) {
|
|
||||||
int zeroBasedLegNumber = 0;
|
|
||||||
for (final TrackedLeg trackedLeg : trackedRace.getTrackedLegs()) {
|
|
||||||
WindTrackInfoDTO windTrackInfoForLegMiddle = createWindTrackInfoDTO(
|
|
||||||
from, millisecondsStepWidth, numberOfFixes,
|
|
||||||
trackedRace, onlyUpToNewestEvent, newestEvent,
|
|
||||||
combinedWindSource, new PositionAtTimeProvider() {
|
|
||||||
@Override
|
|
||||||
public Position getPosition(TimePoint at) {
|
|
||||||
return trackedLeg.getMiddleOfLeg(at);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
result.addWindOnLegMiddle(zeroBasedLegNumber,
|
|
||||||
windTrackInfoForLegMiddle);
|
|
||||||
zeroBasedLegNumber++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+1
-13
@@ -63,15 +63,6 @@ public class StartAnalysisRacesStore {
|
|||||||
* */
|
* */
|
||||||
private Map<String, List<StartAnalysisDTO>> startAnalysisDTOListForCompetitorName;
|
private Map<String, List<StartAnalysisDTO>> startAnalysisDTOListForCompetitorName;
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains {@link StartAnalysisCompetitorDTO}s for every competitor name in every race. This map gets created for a
|
|
||||||
* tracked race when the first mark one rounding of a tracked race gets received. Caching
|
|
||||||
* {@link StartAnalysisCompetitorDTO}s brings the advantage of faster code at creating finished
|
|
||||||
* {@link #startAnalysisDTOListForCompetitorName}
|
|
||||||
* */
|
|
||||||
// private Map<TrackedRace, Map<String, StartAnalysisCompetitorDTO>>
|
|
||||||
// startAnalysisCompetitorDTOsForCompetitorNameForTrackedRace;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains a ranking list of competitor at mark one for every race
|
* Contains a ranking list of competitor at mark one for every race
|
||||||
* */
|
* */
|
||||||
@@ -104,7 +95,6 @@ public class StartAnalysisRacesStore {
|
|||||||
startAnalysisDTOListForCompetitorName = new HashMap<String, List<StartAnalysisDTO>>();
|
startAnalysisDTOListForCompetitorName = new HashMap<String, List<StartAnalysisDTO>>();
|
||||||
rankingListAtMarkOneForTrackedRace = new HashMap<TrackedRace, List<Competitor>>();
|
rankingListAtMarkOneForTrackedRace = new HashMap<TrackedRace, List<Competitor>>();
|
||||||
gpsFixesPathBeforeStartForCompetitor = new HashMap<TrackedRace, Map<String, List<GPSFixDTO>>>();
|
gpsFixesPathBeforeStartForCompetitor = new HashMap<TrackedRace, Map<String, List<GPSFixDTO>>>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,7 +172,6 @@ public class StartAnalysisRacesStore {
|
|||||||
fromPerCompetitorIdAsString.put(competitor.getId().toString(), fiveSecondsBeforeStart);
|
fromPerCompetitorIdAsString.put(competitor.getId().toString(), fiveSecondsBeforeStart);
|
||||||
}
|
}
|
||||||
} catch (NoWindException e) {
|
} catch (NoWindException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return fromPerCompetitorIdAsString;
|
return fromPerCompetitorIdAsString;
|
||||||
@@ -400,7 +389,6 @@ public class StartAnalysisRacesStore {
|
|||||||
.asMillis())), true));
|
.asMillis())), true));
|
||||||
}
|
}
|
||||||
} catch (NoWindException e) {
|
} catch (NoWindException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return gpsFixesPathBeforeStartForCompetitor.get(trackedRace);
|
return gpsFixesPathBeforeStartForCompetitor.get(trackedRace);
|
||||||
@@ -461,7 +449,7 @@ public class StartAnalysisRacesStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
-1
@@ -22,7 +22,6 @@ public class StartAnalysisDTO implements Serializable, Comparable<StartAnalysisD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(StartAnalysisDTO o) {
|
public int compareTo(StartAnalysisDTO o) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return raceName.compareTo(o.raceName);
|
return raceName.compareTo(o.raceName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user