use response order check also for boat positions and mark positions

This commit is contained in:
Axel Uhl committed 2012-02-29 15:59:47 +01:00
1 parent 69a67b6f15
commit ebf4214609
1 file changed
+28 -28
@@ -298,11 +298,11 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
protected void handleSuccess() {
quickRanks = getQuickRanksCallback.getData();
if (map != null) {
//Do boat specific actions
Map<CompetitorDTO, List<GPSFixDTO>> boatData = getBoatsCallback.getData();
// process response only if not received out of order
if (startedProcessingRequestID < requestID) {
startedProcessingRequestID = requestID;
// Do boat specific actions
Map<CompetitorDTO, List<GPSFixDTO>> boatData = getBoatsCallback.getData();
Date from = new Date(date.getTime() - settings.getTailLengthInMilliseconds());
updateFixes(boatData, fromAndToAndOverlap.getC());
showBoatsOnMap(from, date, getCompetitorsToShow());
@@ -312,25 +312,27 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
if (maneuverMarkers != null) {
removeAllManeuverMarkers();
}
}
//Do mark specific actions
List<MarkDTO> markData = getMarksCallback.getData();
showMarksOnMap(markData);
//Rezoom the map
if (!getSettings().getZoomSettings().contains(ZoomTypes.NONE)) { //Auto zoom if setting is not manual
zoomMapToNewBounds(getSettings().getZoomSettings().getNewBounds(RaceMap.this));
mapFirstZoomDone = true;
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange) { //Zoom once to the boats
zoomMapToNewBounds(new BoatsBoundsCalculater().calculateNewBounds(RaceMap.this));
mapFirstZoomDone = true;
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange && !mapFirstZoomDone) { //Zoom once to the buoys
zoomMapToNewBounds(new BuoysBoundsCalculater().calculateNewBounds(RaceMap.this));
mapFirstZoomDone = true;
/* Reset the mapZoomedOrPannedSinceLastRaceSelection: In spite of the fact that the map was just zoomed
* to the bounds of the buoys, it was not a zoom or pan triggered by the user. As a consequence the
* mapZoomedOrPannedSinceLastRaceSelection option has to reset again.
*/
mapZoomedOrPannedSinceLastRaceSelectionChange = false;
// Do mark specific actions
List<MarkDTO> markData = getMarksCallback.getData();
showMarksOnMap(markData);
// Rezoom the map
if (!getSettings().getZoomSettings().contains(ZoomTypes.NONE)) { // Auto zoom if setting is not manual
zoomMapToNewBounds(getSettings().getZoomSettings().getNewBounds(RaceMap.this));
mapFirstZoomDone = true;
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange) { // Zoom once to the boats
zoomMapToNewBounds(new BoatsBoundsCalculater().calculateNewBounds(RaceMap.this));
mapFirstZoomDone = true;
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange && !mapFirstZoomDone) { // Zoom once to the buoys
zoomMapToNewBounds(new BuoysBoundsCalculater().calculateNewBounds(RaceMap.this));
mapFirstZoomDone = true;
/*
* Reset the mapZoomedOrPannedSinceLastRaceSelection: In spite of the fact that
* the map was just zoomed to the bounds of the buoys, it was not a zoom or pan
* triggered by the user. As a consequence the
* mapZoomedOrPannedSinceLastRaceSelection option has to reset again.
*/
mapZoomedOrPannedSinceLastRaceSelectionChange = false;
}
}
} else {
lastTimeChangeBeforeInitialization = date;
@@ -342,7 +344,6 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
errorReporter.reportError("Error trying to obtain mark and/or boat positions: " + t.getMessage());
}
};
sailingService.getBoatPositions(race, fromAndToAndOverlap.getA(), fromAndToAndOverlap.getB(), true, getBoatsCallback);
sailingService.getMarkPositions(race, date, getMarksCallback);
sailingService.getQuickRanks(race, date, getQuickRanksCallback);
@@ -468,11 +469,10 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
* @param to
* time point for last fix to show in tails
*/
protected void showBoatsOnMap(Date from, Date to, Iterable<CompetitorDTO> competitorsToShow) {
protected void showBoatsOnMap(final Date from, final Date to, final Iterable<CompetitorDTO> competitorsToShow) {
if (map != null) {
Set<CompetitorDTO> competitorDTOsOfUnusedTails = new HashSet<CompetitorDTO>(tails.keySet());
Set<CompetitorDTO> competitorDTOsOfUnusedMarkers = new HashSet<CompetitorDTO>(boatMarkers.keySet());
for (CompetitorDTO competitorDTO : competitorsToShow) {
if (fixes.containsKey(competitorDTO)) {
Polyline tail = tails.get(competitorDTO);
@@ -489,7 +489,6 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
}
}
}
for (CompetitorDTO unusedMarkerCompetitorDTO : competitorDTOsOfUnusedMarkers) {
map.removeOverlay(boatMarkers.remove(unusedMarkerCompetitorDTO));
}
@@ -498,7 +497,7 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
}
}
}
private void zoomMapToNewBounds(LatLngBounds newBounds) {
if (newBounds != null) {
boolean oldMapZoomedOrPannedSinceLastRaceSelectionChange = mapZoomedOrPannedSinceLastRaceSelectionChange;
@@ -919,7 +918,7 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
* When this method returns, {@link #firstShownFix} and {@link #lastShownFix} have been updated accordingly.
*/
protected void updateTail(Polyline tail, CompetitorDTO competitorDTO, Date from, Date to) {
List<GPSFixDTO> fixesForCompetitor = fixes.get(competitorDTO);
final List<GPSFixDTO> fixesForCompetitor = fixes.get(competitorDTO);
int indexOfFirstShownFix = firstShownFix.get(competitorDTO) == null ? -1 : firstShownFix.get(competitorDTO);
while (indexOfFirstShownFix != -1 && tail.getVertexCount() > 0
&& fixesForCompetitor.get(indexOfFirstShownFix).timepoint.before(from)) {
@@ -1107,7 +1106,8 @@ public class RaceMap extends SimplePanel implements TimeListener, CompetitorSele
}
for (CompetitorDTO competitor : competitors) {
List<GPSFixDTO> competitorFixes = forMap.fixes.get(competitor);
GPSFixDTO competitorFix = competitorFixes != null ? competitorFixes.get(forMap.lastShownFix.get(competitor)) : null;
Integer lastShownFixForCompetitor = forMap.lastShownFix.get(competitor);
GPSFixDTO competitorFix = competitorFixes != null && lastShownFixForCompetitor != null ? competitorFixes.get(lastShownFixForCompetitor) : null;
PositionDTO competitorPosition = competitorFix != null ? competitorFix.position : null;
LatLng competitorLatLng = competitorPosition != null ? LatLng.newInstance(competitorPosition.latDeg,
competitorPosition.lngDeg) : null;