mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
add check for availability of suitable polar diagram (hasPolar) to race-map-settings;
This commit is contained in:
1 parent
0b0b12ef20
commit
5f22bfb93a
5 files changed
+68
-1
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
package com.sap.sailing.gwt.ui.actions;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.shared.racemap.RaceMap;
|
||||
import com.sap.sse.gwt.client.async.AsyncAction;
|
||||
|
||||
/**
|
||||
* An asynchronous action to determine whether a suitable polar diagram is available for the race shown on {@link RaceMap}
|
||||
*
|
||||
* @author Christopher Ronnewinkel (D036654)
|
||||
*
|
||||
*/
|
||||
public class GetPolarAction implements AsyncAction<Boolean> {
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final RegattaAndRaceIdentifier raceIdentifier;
|
||||
|
||||
public GetPolarAction(SailingServiceAsync sailingService, RegattaAndRaceIdentifier raceIdentifier) {
|
||||
this.sailingService = sailingService;
|
||||
this.raceIdentifier = raceIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(AsyncCallback<Boolean> callback) {
|
||||
sailingService.getPolarResults(raceIdentifier, callback);
|
||||
}
|
||||
}
|
||||
+2
@@ -136,6 +136,8 @@ public interface SailingService extends RemoteService {
|
||||
WindInfoForRaceDTO getAveragedWindInfo(RegattaAndRaceIdentifier raceIdentifier, Date from, long millisecondsStepWidth,
|
||||
int numberOfFixes, double latDeg, double lngDeg, Collection<String> windSources) throws NoWindException;
|
||||
|
||||
Boolean getPolarResults(RegattaAndRaceIdentifier raceIdentifier);
|
||||
|
||||
SimulatorResultsDTO getSimulatorResults(RegattaAndRaceIdentifier raceIdentifier, Date from, Date prevStartTime);
|
||||
|
||||
CompactRaceMapDataDTO getRaceMapData(RegattaAndRaceIdentifier raceIdentifier, Date date, Map<String, Date> fromPerCompetitorIdAsString,
|
||||
|
||||
+2
@@ -183,6 +183,8 @@ public interface SailingServiceAsync extends BuildVersionRetriever {
|
||||
int numberOfFixes, Collection<String> windSourceTypeNames, boolean onlyUpToNewestEvent,
|
||||
boolean includeCombinedWindForAllLegMiddles, AsyncCallback<WindInfoForRaceDTO> callback);
|
||||
|
||||
void getPolarResults(RegattaAndRaceIdentifier raceIdentifier, AsyncCallback<Boolean> callback);
|
||||
|
||||
void getSimulatorResults(RegattaAndRaceIdentifier raceIdentifier, Date from, Date prevStartTime, AsyncCallback<SimulatorResultsDTO> callback);
|
||||
|
||||
void setWind(RegattaAndRaceIdentifier raceIdentifier, WindDTO wind, AsyncCallback<Void> callback);
|
||||
|
||||
+28
-1
@@ -81,6 +81,7 @@ import com.sap.sailing.domain.common.impl.BoundsImpl;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.RGBColor;
|
||||
import com.sap.sailing.domain.common.scalablevalue.impl.ScalableBearing;
|
||||
import com.sap.sailing.gwt.ui.actions.GetPolarAction;
|
||||
import com.sap.sailing.gwt.ui.actions.GetRaceMapDataAction;
|
||||
import com.sap.sailing.gwt.ui.actions.GetWindInfoAction;
|
||||
import com.sap.sailing.gwt.ui.client.ClientResources;
|
||||
@@ -123,6 +124,7 @@ import com.sap.sse.common.filter.Filter;
|
||||
import com.sap.sse.common.filter.FilterSet;
|
||||
import com.sap.sse.gwt.client.ErrorReporter;
|
||||
import com.sap.sse.gwt.client.async.AsyncActionsExecutor;
|
||||
import com.sap.sse.gwt.client.async.MarkedAsyncCallback;
|
||||
import com.sap.sse.gwt.client.player.TimeListener;
|
||||
import com.sap.sse.gwt.client.player.Timer;
|
||||
import com.sap.sse.gwt.client.player.Timer.PlayModes;
|
||||
@@ -309,6 +311,8 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
private WindStreamletsRaceboardOverlay streamletOverlay;
|
||||
private final boolean showViewStreamlets;
|
||||
private final boolean showViewSimulation;
|
||||
public static final String GET_POLAR_CATEGORY = "getPolar";
|
||||
private boolean hasPolar;
|
||||
private final RegattaAndRaceIdentifier raceIdentifier;
|
||||
|
||||
public RaceMap(SailingServiceAsync sailingService, AsyncActionsExecutor asyncActionsExecutor,
|
||||
@@ -338,6 +342,7 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
isMapInitialized = false;
|
||||
this.showViewStreamlets = showViewStreamlets;
|
||||
this.showViewSimulation = showViewSimulation;
|
||||
this.hasPolar = false;
|
||||
headerPanel = new FlowPanel();
|
||||
headerPanel.setStyleName("RaceMap-HeaderPanel");
|
||||
panelForLeftHeaderLabels = new AbsolutePanel();
|
||||
@@ -470,6 +475,8 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
}
|
||||
|
||||
if (showViewSimulation) {
|
||||
// determine availability of polar diagram
|
||||
hasPolar();
|
||||
// initialize simulation canvas
|
||||
simulationOverlay = new RaceSimulationOverlay(getMap(), /* zIndex */ 0, timer, raceIdentifier, sailingService, stringMessages, asyncActionsExecutor);
|
||||
simulationOverlay.addToMap();
|
||||
@@ -486,6 +493,26 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
|
||||
LoadApi.go(onLoad, loadLibraries, sensor, "key="+GoogleMapAPIKey.V3_APIKey);
|
||||
}
|
||||
|
||||
public void hasPolar() {
|
||||
GetPolarAction getPolar = new GetPolarAction(sailingService, raceIdentifier);
|
||||
asyncActionsExecutor.execute(getPolar, GET_POLAR_CATEGORY,
|
||||
new MarkedAsyncCallback<>(new AsyncCallback<Boolean>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO: add corresponding message to string-messages
|
||||
// Window.setStatus(stringMessages.errorFetchingWindStreamletData(caught.getMessage()));
|
||||
Window.setStatus(GET_POLAR_CATEGORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
// store results
|
||||
hasPolar = result.booleanValue();
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a header panel where additional information can be displayed by using
|
||||
@@ -1918,7 +1945,7 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
|
||||
@Override
|
||||
public SettingsDialogComponent<RaceMapSettings> getSettingsDialogComponent() {
|
||||
return new RaceMapSettingsDialogComponent(settings, stringMessages, this.showViewSimulation);
|
||||
return new RaceMapSettingsDialogComponent(settings, stringMessages, this.showViewSimulation && this.hasPolar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
@@ -1481,6 +1481,14 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getPolarResults(RegattaAndRaceIdentifier raceIdentifier) {
|
||||
TrackedRace trackedRace = getExistingTrackedRace(raceIdentifier);
|
||||
BoatClass boatClass = trackedRace.getRace().getBoatClass();
|
||||
PolarDiagram polarDiagram = polarDiagramService.getService().getPolarDiagram(boatClass);
|
||||
return new Boolean(polarDiagram != null);
|
||||
};
|
||||
|
||||
@Override
|
||||
public SimulatorResultsDTO getSimulatorResults(RegattaAndRaceIdentifier raceIdentifier, Date from, Date prevStartTime) {
|
||||
TrackedRace trackedRace = getExistingTrackedRace(raceIdentifier);
|
||||
|
||||
Reference in new issue
Block a user