mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 05:11:04 +00:00
optional estimated wind display in WindPanel
This commit is contained in:
1 parent
ace383d953
commit
5f7585ea67
6 files changed
+58
-10
No files matched your search
+2
-1
@@ -40,7 +40,8 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
void stopTrackingRace(String eventName, String raceName) throws Exception;
|
||||
|
||||
WindInfoForRaceDAO getWindInfo(String eventName, String raceName, Date from, Date to);
|
||||
WindInfoForRaceDAO getWindInfo(String eventName, String raceName, Date from, Date to,
|
||||
boolean includeTrackBasedWindEstimation);
|
||||
|
||||
void setWind(String eventName, String raceName, WindDAO wind);
|
||||
|
||||
|
||||
+8
-1
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.leaderboard.RaceInLeaderboard;
|
||||
import com.sap.sailing.domain.tracking.WindSource;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDAO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDAO;
|
||||
import com.sap.sailing.gwt.ui.shared.GPSFixDAO;
|
||||
@@ -47,8 +48,14 @@ public interface SailingServiceAsync {
|
||||
|
||||
void stopTrackingRace(String eventName, String raceName, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
/**
|
||||
* @param includeTrackBasedWindEstimation if <code>true</code>, for each time point for which an
|
||||
* {@link WindSource#EXPEDITION} estimation exists for the event/race requested, a wind estimation
|
||||
* based on the GPS tracks will be performed and included in the result. In this case, the
|
||||
* result will contain a so far non-existing wind source name "ESTIMATION".
|
||||
*/
|
||||
void getWindInfo(String eventName, String raceName, Date from, Date to,
|
||||
AsyncCallback<WindInfoForRaceDAO> callback);
|
||||
boolean includeTrackBasedWindEstimation, AsyncCallback<WindInfoForRaceDAO> callback);
|
||||
|
||||
void getWindInfo(String eventName, String raceName, Date from, long millisecondsStepWidth, int numberOfFixes,
|
||||
double latDeg, double lngDeg, AsyncCallback<WindInfoForRaceDAO> callback);
|
||||
|
||||
+1
@@ -101,4 +101,5 @@ public interface StringConstants extends Constants {
|
||||
String errorWhileTryingToSetWindSourceForRace();
|
||||
String inEvent();
|
||||
String to();
|
||||
String showEstimatedWind();
|
||||
}
|
||||
+2
-1
@@ -95,4 +95,5 @@ errorSettingWindForRace=Error setting wind for race
|
||||
errorFetchingWindInformationForRace=Error fetching wind information for race
|
||||
errorWhileTryingToSetWindSourceForRace=Error while trying to set wind source for race
|
||||
inEvent=in event
|
||||
to=to
|
||||
to=to
|
||||
showEstimatedWind=Show estimated wind
|
||||
+23
-6
@@ -15,6 +15,8 @@ import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.user.cellview.client.CellTable;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent.Handler;
|
||||
@@ -25,6 +27,7 @@ import com.google.gwt.user.cellview.client.IdentityColumn;
|
||||
import com.google.gwt.user.cellview.client.TextColumn;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.CheckBox;
|
||||
import com.google.gwt.user.client.ui.FormPanel;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||
@@ -60,6 +63,7 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
private final RaceTreeView trackedRacesTree;
|
||||
private final ListBox windSourceSelection;
|
||||
private final Map<String, ListDataProvider<WindDAO>> windLists;
|
||||
private final CheckBox showEstimatedWindBox;
|
||||
|
||||
public WindPanel(final SailingServiceAsync sailingService, ErrorReporter errorReporter, EventRefresher eventRefresher, StringConstants stringConstants) {
|
||||
this.sailingService = sailingService;
|
||||
@@ -130,13 +134,10 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
trackedRacesTree.addRaceSelectionChangeListener(new RaceSelectionChangeListener() {
|
||||
@Override
|
||||
public void onRaceSelectionChange(List<Triple<EventDAO, RegattaDAO, RaceDAO>> selectedRaces) {
|
||||
if (selectedRaces.isEmpty()) {
|
||||
clearWindDisplay(); // no wind known for untracked race
|
||||
} else {
|
||||
showWind(selectedRaces.get(0).getA(), selectedRaces.get(0).getC());
|
||||
}
|
||||
clearOrShowWindBasedOnRaceSelection(selectedRaces);
|
||||
fireRaceSelectionChanged(selectedRaces);
|
||||
}
|
||||
|
||||
});
|
||||
grid.setWidget(0, 0, trackedRacesTree);
|
||||
Button btnRefresh = new Button(stringConstants.refresh());
|
||||
@@ -152,12 +153,28 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
windSourceSelectionPanel.setSpacing(10);
|
||||
windSourceSelectionPanel.add(new Label(stringConstants.windSource()));
|
||||
windSourceSelectionPanel.add(windSourceSelection);
|
||||
showEstimatedWindBox = new CheckBox(stringConstants.showEstimatedWind());
|
||||
windSourceSelectionPanel.add(showEstimatedWindBox);
|
||||
showEstimatedWindBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
||||
clearOrShowWindBasedOnRaceSelection(trackedRacesTree.getSelectedEventAndRace());
|
||||
}
|
||||
});
|
||||
grid.setWidget(1, 0, windSourceSelectionPanel);
|
||||
grid.setWidget(2, 1, windSettingPanel);
|
||||
grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
|
||||
this.setWidget(grid);
|
||||
}
|
||||
|
||||
private void clearOrShowWindBasedOnRaceSelection(List<Triple<EventDAO, RegattaDAO, RaceDAO>> selectedRaces) {
|
||||
if (selectedRaces.isEmpty()) {
|
||||
clearWindDisplay(); // no wind known for untracked race
|
||||
} else {
|
||||
showWind(selectedRaces.get(0).getA(), selectedRaces.get(0).getC());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillEvents(List<EventDAO> result) {
|
||||
trackedRacesTree.fillEvents(result);
|
||||
@@ -168,7 +185,7 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
sailingService.getWindInfo(event.name, race.name,
|
||||
// TODO what about the time interval?
|
||||
new Date(/* fromAsMilliseconds */0), new Date(/* toAsMilliseconds */),
|
||||
new AsyncCallback<WindInfoForRaceDAO>() {
|
||||
showEstimatedWindBox.getValue(), new AsyncCallback<WindInfoForRaceDAO>() {
|
||||
@Override
|
||||
public void onSuccess(WindInfoForRaceDAO result) {
|
||||
if (result != null) {
|
||||
|
||||
+22
-1
@@ -55,6 +55,7 @@ import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sailing.domain.tracking.WindSource;
|
||||
import com.sap.sailing.domain.tracking.WindTrack;
|
||||
import com.sap.sailing.domain.tracking.impl.WindImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.WindTrackImpl;
|
||||
import com.sap.sailing.domain.tractracadapter.DomainFactory;
|
||||
import com.sap.sailing.domain.tractracadapter.RaceHandle;
|
||||
import com.sap.sailing.domain.tractracadapter.RaceRecord;
|
||||
@@ -387,7 +388,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public WindInfoForRaceDAO getWindInfo(String eventName, String raceName, Date fromDate, Date toDate) {
|
||||
public WindInfoForRaceDAO getWindInfo(String eventName, String raceName, Date fromDate, Date toDate, boolean includeTrackBasedWindEstimation) {
|
||||
WindInfoForRaceDAO result = null;
|
||||
TrackedRace trackedRace = getTrackedRace(eventName, raceName);
|
||||
if (trackedRace != null) {
|
||||
@@ -396,12 +397,16 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
TimePoint from = new MillisecondsTimePoint(fromDate);
|
||||
TimePoint to = new MillisecondsTimePoint(toDate);
|
||||
Map<String, WindTrackInfoDAO> windTrackInfoDAOs = new HashMap<String, WindTrackInfoDAO>();
|
||||
WindTrack estimatedTrack = null;
|
||||
result.windTrackInfoByWindSourceName = windTrackInfoDAOs;
|
||||
for (WindSource windSource : WindSource.values()) {
|
||||
WindTrackInfoDAO windTrackInfoDAO = new WindTrackInfoDAO();
|
||||
windTrackInfoDAO.windFixes = new ArrayList<WindDAO>();
|
||||
WindTrack windTrack = trackedRace.getWindTrack(windSource);
|
||||
windTrackInfoDAO.dampeningIntervalInMilliseconds = windTrack.getMillisecondsOverWhichToAverageWind();
|
||||
if (includeTrackBasedWindEstimation && windSource == WindSource.EXPEDITION) {
|
||||
estimatedTrack = new WindTrackImpl(windTrack.getMillisecondsOverWhichToAverageWind());
|
||||
}
|
||||
Iterator<Wind> windIter = windTrack.getFixesIterator(from, /* inclusive */true);
|
||||
while (windIter.hasNext()) {
|
||||
Wind wind = windIter.next();
|
||||
@@ -410,9 +415,25 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
}
|
||||
WindDAO windDAO = createWindDAO(wind, windTrack);
|
||||
windTrackInfoDAO.windFixes.add(windDAO);
|
||||
if (includeTrackBasedWindEstimation && windSource == WindSource.EXPEDITION) {
|
||||
try {
|
||||
estimatedTrack.add(trackedRace.getEstimatedWindDirection(wind.getPosition(), wind.getTimePoint()));
|
||||
} catch (NoWindException e) {
|
||||
// no show-stopper; it would just mean that the wind estimation isn't complete which we can tolerate
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
windTrackInfoDAOs.put(windSource.name(), windTrackInfoDAO);
|
||||
}
|
||||
if (includeTrackBasedWindEstimation && estimatedTrack != null) {
|
||||
WindTrackInfoDAO windEstimations = new WindTrackInfoDAO();
|
||||
windEstimations.windFixes = new ArrayList<WindDAO>();
|
||||
for (Wind estimatedWind : estimatedTrack.getFixes()) {
|
||||
windEstimations.windFixes.add(createWindDAO(estimatedWind, estimatedTrack));
|
||||
}
|
||||
windTrackInfoDAOs.put("ESTIMATION", windEstimations);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user