mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-09 22:01:02 +00:00
enabled WEB wind record removal from UI
This commit is contained in:
1 parent
c86c2e6810
commit
3229c49bc7
6 files changed
+93
No files matched your search
+18
@@ -10,6 +10,13 @@ import java.net.URISyntaxException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.GPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.NoWindException;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sailing.domain.tractracadapter.ReceiverType;
|
||||
import com.sap.sailing.util.Util;
|
||||
|
||||
@@ -29,4 +36,15 @@ public class WindEstimationOnKielerWoche505Race2DataTest extends KielerWoche2011
|
||||
assertNotNull(getTrackedRace());
|
||||
assertTrue(Util.size(getTrackedRace().getTrack(getCompetitorByName("Dr.Plattner")).getFixes()) > 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleWindEstimation() throws NoWindException {
|
||||
Competitor hasso = getCompetitorByName("Dr.Plattner");
|
||||
GPSFixTrack<Competitor, GPSFixMoving> hassosTrack = getTrackedRace().getTrack(hasso);
|
||||
TimePoint start = hassosTrack.getFirstRawFix().getTimePoint();
|
||||
TimePoint stop = hassosTrack.getLastRawFix().getTimePoint();
|
||||
TimePoint middle = new MillisecondsTimePoint(start.asMillis() + (stop.asMillis()-start.asMillis())*3/4);
|
||||
Wind estimatedWindDirection = getTrackedRace().getEstimatedWindDirection(/* position */ null, middle);
|
||||
assertNotNull(estimatedWindDirection);
|
||||
}
|
||||
}
|
||||
@@ -51,4 +51,6 @@ public interface SailingService extends RemoteService {
|
||||
int numberOfFixes, double latDeg, double lngDeg) throws Exception;
|
||||
|
||||
void setWindSource(String eventName, String raceName, String windSourceName);
|
||||
|
||||
void removeWind(String eventName, String raceName, WindDAO windDAO);
|
||||
}
|
||||
@@ -42,6 +42,8 @@ public interface SailingServiceAsync {
|
||||
double latDeg, double lngDeg, AsyncCallback<WindInfoForRaceDAO> callback);
|
||||
|
||||
void setWind(String eventName, String raceName, WindDAO wind, AsyncCallback<Void> callback);
|
||||
|
||||
void removeWind(String eventName, String raceName, WindDAO wind, AsyncCallback<Void> callback);
|
||||
|
||||
/**
|
||||
* @param tailLengthInMilliseconds
|
||||
|
||||
@@ -3,11 +3,14 @@ package com.sap.sailing.gwt.ui.client;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gwt.cell.client.ActionCell;
|
||||
import com.google.gwt.cell.client.ActionCell.Delegate;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
@@ -18,6 +21,7 @@ import com.google.gwt.user.cellview.client.ColumnSortEvent.Handler;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortList;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo;
|
||||
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;
|
||||
@@ -38,6 +42,7 @@ import com.sap.sailing.gwt.ui.shared.WindInfoForRaceDAO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindTrackInfoDAO;
|
||||
|
||||
public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectionProvider, WindShower {
|
||||
private static final String WEB_WIND_SOURCE_NAME = "WEB";
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final ErrorReporter errorReporter;
|
||||
private EventRefresher eventRefresher;
|
||||
@@ -45,6 +50,7 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
private final StringConstants stringConstants;
|
||||
private final WindSettingPanel windSettingPanel;
|
||||
private ColumnSortList columnSortList;
|
||||
private final IdentityColumn<WindDAO> removeColumn;
|
||||
private final TextColumn<WindDAO> timeColumn;
|
||||
private final TextColumn<WindDAO> speedInKnotsColumn;
|
||||
private final TextColumn<WindDAO> windDirectionInDegColumn;
|
||||
@@ -53,6 +59,7 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
private final Set<RaceSelectionChangeListener> raceSelectionChangeListeners;
|
||||
private final RaceTreeView trackedRacesTree;
|
||||
private final ListBox windSourceSelection;
|
||||
private final Map<String, ListDataProvider<WindDAO>> windLists;
|
||||
|
||||
public WindPanel(final SailingServiceAsync sailingService, ErrorReporter errorReporter, EventRefresher eventRefresher, StringConstants stringConstants) {
|
||||
this.sailingService = sailingService;
|
||||
@@ -60,6 +67,7 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
this.eventRefresher = eventRefresher;
|
||||
this.stringConstants = stringConstants;
|
||||
raceSelectionChangeListeners = new HashSet<RaceSelectionChangeListener>();
|
||||
windLists = new HashMap<String, ListDataProvider<WindDAO>>();
|
||||
windSourceSelection = new ListBox();
|
||||
windSourceSelection.addChangeHandler(new ChangeHandler() {
|
||||
@Override
|
||||
@@ -67,6 +75,24 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
setWindSource();
|
||||
}
|
||||
});
|
||||
removeColumn = new IdentityColumn<WindDAO>(new ActionCell<WindDAO>("Remove", new Delegate<WindDAO>() {
|
||||
@Override
|
||||
public void execute(final WindDAO wind) {
|
||||
List<Triple<EventDAO, RegattaDAO, RaceDAO>> eventAndRaces = getSelectedEventAndRace();
|
||||
final Triple<EventDAO, RegattaDAO, RaceDAO> eventAndRace = eventAndRaces.get(eventAndRaces.size()-1);
|
||||
sailingService.removeWind(eventAndRace.getA().name, eventAndRace.getC().name, wind, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
// remove row from underlying list:
|
||||
windLists.get(WEB_WIND_SOURCE_NAME).getList().remove(wind);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
WindPanel.this.errorReporter.reportError("Error setting wind for race "+eventAndRace.getC().name+": "+caught.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
timeColumn = new TextColumn<WindDAO>() {
|
||||
@Override
|
||||
public String getValue(WindDAO object) {
|
||||
@@ -185,6 +211,7 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
private void clearWindDisplay() {
|
||||
grid.setWidget(2, 0, null);
|
||||
windSettingPanel.setEnabled(false);
|
||||
windLists.clear();
|
||||
}
|
||||
|
||||
private void showWindForRace(WindInfoForRaceDAO result) {
|
||||
@@ -201,12 +228,17 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
dampenedSpeedInKnotsColumn.setSortable(true);
|
||||
dampenedWindDirectionInDegColumn.setSortable(true);
|
||||
CellTable<WindDAO> windTable = new CellTable<WindDAO>(/* pageSize */ 100);
|
||||
if (e.getKey().equals(WEB_WIND_SOURCE_NAME)) {
|
||||
// only the WEB wind source is editable, hence has a "Remove" column
|
||||
windTable.addColumn(removeColumn, "Remove");
|
||||
}
|
||||
windTable.addColumn(timeColumn, "Time");
|
||||
windTable.addColumn(speedInKnotsColumn, "Speed (kn)");
|
||||
windTable.addColumn(windDirectionInDegColumn, "From (deg)");
|
||||
windTable.addColumn(dampenedSpeedInKnotsColumn, "Avg Speed (kn)");
|
||||
windTable.addColumn(dampenedWindDirectionInDegColumn, "Avg From (deg)");
|
||||
ListDataProvider<WindDAO> windList = new ListDataProvider<WindDAO>(e.getValue().windFixes);
|
||||
windLists.put(e.getKey(), windList);
|
||||
windList.addDataDisplay(windTable);
|
||||
Handler columnSortHandler = getWindTableColumnSortHandler(windList.getList(), timeColumn,
|
||||
speedInKnotsColumn, windDirectionInDegColumn, dampenedSpeedInKnotsColumn, dampenedWindDirectionInDegColumn);
|
||||
|
||||
@@ -476,4 +476,38 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWind(String eventName, String raceName, WindDAO windDAO) {
|
||||
Event event = service.getEventByName(eventName);
|
||||
RaceDefinition race = getRaceByName(event, raceName);
|
||||
Position p = null;
|
||||
if (windDAO.position != null) {
|
||||
p = new DegreePosition(windDAO.position.latDeg, windDAO.position.lngDeg);
|
||||
}
|
||||
TimePoint at = null;
|
||||
if (windDAO.timepoint != null) {
|
||||
at = new MillisecondsTimePoint(windDAO.timepoint);
|
||||
}
|
||||
SpeedWithBearing speedWithBearing = null;
|
||||
Speed speed = null;
|
||||
if (windDAO.trueWindSpeedInKnots != null) {
|
||||
speed = new KnotSpeedImpl(windDAO.trueWindSpeedInKnots);
|
||||
} else if (windDAO.trueWindSpeedInMetersPerSecond != null) {
|
||||
speed = new KilometersPerHourSpeedImpl(windDAO.trueWindSpeedInMetersPerSecond * 3600. / 1000.);
|
||||
} else if (windDAO.dampenedTrueWindSpeedInKnots != null) {
|
||||
speed = new KnotSpeedImpl(windDAO.dampenedTrueWindSpeedInKnots);
|
||||
} else if (windDAO.dampenedTrueWindSpeedInMetersPerSecond != null) {
|
||||
speed = new KilometersPerHourSpeedImpl(windDAO.dampenedTrueWindSpeedInMetersPerSecond * 3600. / 1000.);
|
||||
}
|
||||
if (speed != null) {
|
||||
if (windDAO.trueWindBearingDeg != null) {
|
||||
speedWithBearing = new KnotSpeedWithBearingImpl(speed.getKnots(), new DegreeBearingImpl(windDAO.trueWindBearingDeg));
|
||||
} else if (windDAO.trueWindFromDeg != null) {
|
||||
speedWithBearing = new KnotSpeedWithBearingImpl(speed.getKnots(), new DegreeBearingImpl(windDAO.trueWindFromDeg).reverse());
|
||||
}
|
||||
}
|
||||
Wind wind = new WindImpl(p, at, speedWithBearing);
|
||||
service.getDomainFactory().getTrackedEvent(event).getTrackedRace(race).removeWind(wind, WindSource.WEB);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user