mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-25 05:23:51 +00:00
refactored drawing of course middle line so it becomes re-usable also for course geometry display
This commit is contained in:
1 parent
f96df5c499
commit
8ef0c9a343
6 files changed
+77
-49
No files matched your search
+1
@@ -1320,4 +1320,5 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages, c
|
||||
String hoursAgo(String hours);
|
||||
String selectCompetitor();
|
||||
String courseGeometry();
|
||||
String degreesToWind(String diff);
|
||||
}
|
||||
+2
-1
@@ -1287,4 +1287,5 @@ now=Now
|
||||
minutesAgo={0} min ago
|
||||
hoursAgo={0} h ago
|
||||
selectCompetitor=Please select one competitor
|
||||
courseGeometry=Course Geometry
|
||||
courseGeometry=Course Geometry
|
||||
degreesToWind={0}° to wind
|
||||
+2
-1
@@ -1277,4 +1277,5 @@ now=Jetzt
|
||||
minutesAgo=vor {0} min
|
||||
hoursAgo=vor {0} h
|
||||
selectCompetitor=Bitte einen Teilnehmer auswählen
|
||||
courseGeometry=Kursgeometrie
|
||||
courseGeometry=Kursgeometrie
|
||||
degreesToWind={0}° zum Wind
|
||||
+2
-1
@@ -1225,4 +1225,5 @@ now=в настоящее время
|
||||
minutesAgo={0} минут назад
|
||||
hoursAgo={0} h часов назад
|
||||
selectCompetitor=Please select one competitor
|
||||
courseGeometry=Course Geometry
|
||||
courseGeometry=Course Geometry
|
||||
degreesToWind={0}° to wind
|
||||
+2
-1
@@ -1274,4 +1274,5 @@ raceCalculatedTimeAtEstimatedArrivalAtCompetitorFarthestAheadInSecondsTooltip=Ca
|
||||
sailorInfo=水手信息
|
||||
sailorInfoLongText=Find here Notice Board,\nProtests, Sailor weather:
|
||||
selectCompetitor=Please select one competitor
|
||||
courseGeometry=Course Geometry
|
||||
courseGeometry=Course Geometry
|
||||
degreesToWind={0}° to wind
|
||||
+68
-45
@@ -762,7 +762,6 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
getRaceMapDataCallback(oldTime, newTime, fromAndToAndOverlap.getC(), competitorsToShow, requestID));
|
||||
|
||||
// draw the wind into the map, get the combined wind
|
||||
// TODO bug2057 also fetch wind for LEG_MIDDLE for all legs because this needs to be the basis for the advantage line display
|
||||
List<String> windSourceTypeNames = new ArrayList<String>();
|
||||
windSourceTypeNames.add(WindSourceType.EXPEDITION.name());
|
||||
windSourceTypeNames.add(WindSourceType.COMBINED.name());
|
||||
@@ -1306,7 +1305,8 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
private void showCourseGeometryMetrics(final CoursePositionsDTO courseDTO) {
|
||||
if (settings.getHelpLinesSettings().isVisible(HelpLineTypes.STARTLINETOFIRSTMARKTRIANGLE)
|
||||
&& courseDTO.startMarkPositions.size() > 1 && courseDTO.waypointPositions.size() > 1) {
|
||||
|
||||
// based on the courseDTO, find the symmetrical pairs of marks that form legs, regardless the to/from
|
||||
// direction, draw those
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1515,55 +1515,78 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
|
||||
finishLine = null;
|
||||
}
|
||||
}
|
||||
final int zeroBasedIndexOfStartWaypoint = legOfLeadingCompetitor-1;
|
||||
// draw the course middle line
|
||||
if (legOfLeadingCompetitor > 0 && courseDTO.waypointPositions.size() > legOfLeadingCompetitor &&
|
||||
settings.getHelpLinesSettings().isVisible(HelpLineTypes.COURSEMIDDLELINE)) {
|
||||
Position position1DTO = courseDTO.waypointPositions.get(legOfLeadingCompetitor-1);
|
||||
Position position2DTO = courseDTO.waypointPositions.get(legOfLeadingCompetitor);
|
||||
LatLng courseMiddleLinePoint1 = coordinateSystem.toLatLng(position1DTO);
|
||||
LatLng courseMiddleLinePoint2 = coordinateSystem.toLatLng(position2DTO);
|
||||
if (courseMiddleLine == null) {
|
||||
PolylineOptions options = PolylineOptions.newInstance();
|
||||
options.setClickable(true);
|
||||
options.setGeodesic(true);
|
||||
options.setStrokeColor("#2268a0");
|
||||
options.setStrokeWeight(1);
|
||||
options.setStrokeOpacity(1.0);
|
||||
|
||||
MVCArray<LatLng> pointsAsArray = MVCArray.newInstance();
|
||||
pointsAsArray.insertAt(0, courseMiddleLinePoint1);
|
||||
pointsAsArray.insertAt(1, courseMiddleLinePoint2);
|
||||
final boolean showCourseMiddleLine = legOfLeadingCompetitor > 0 && courseDTO.waypointPositions.size() > legOfLeadingCompetitor &&
|
||||
settings.getHelpLinesSettings().isVisible(HelpLineTypes.COURSEMIDDLELINE);
|
||||
courseMiddleLine = showCourseMiddleLine(courseDTO, courseMiddleLine,
|
||||
zeroBasedIndexOfStartWaypoint, showCourseMiddleLine);
|
||||
}
|
||||
}
|
||||
|
||||
courseMiddleLine = Polyline.newInstance(options);
|
||||
courseMiddleLine.setPath(pointsAsArray);
|
||||
|
||||
courseMiddleLine.addMouseOverHandler(new MouseOverMapHandler() {
|
||||
@Override
|
||||
public void onEvent(MouseOverMapEvent event) {
|
||||
map.setTitle(stringMessages.courseMiddleLine());
|
||||
private Polyline showCourseMiddleLine(final CoursePositionsDTO courseDTO, Polyline lineToShowOrRemoveOrUpdate,
|
||||
final int zeroBasedIndexOfStartWaypoint, final boolean showLine) {
|
||||
if (showLine) {
|
||||
final Position position1DTO = courseDTO.waypointPositions.get(zeroBasedIndexOfStartWaypoint);
|
||||
final Position position2DTO = courseDTO.waypointPositions.get(zeroBasedIndexOfStartWaypoint+1);
|
||||
LatLng courseMiddleLinePoint1 = coordinateSystem.toLatLng(position1DTO);
|
||||
LatLng courseMiddleLinePoint2 = coordinateSystem.toLatLng(position2DTO);
|
||||
final MVCArray<LatLng> pointsAsArray;
|
||||
if (lineToShowOrRemoveOrUpdate == null) {
|
||||
PolylineOptions options = PolylineOptions.newInstance();
|
||||
options.setClickable(true);
|
||||
options.setGeodesic(true);
|
||||
options.setStrokeColor("#2268a0");
|
||||
options.setStrokeWeight(1);
|
||||
options.setStrokeOpacity(1.0);
|
||||
pointsAsArray = MVCArray.newInstance();
|
||||
lineToShowOrRemoveOrUpdate = Polyline.newInstance(options);
|
||||
lineToShowOrRemoveOrUpdate.setPath(pointsAsArray);
|
||||
lineToShowOrRemoveOrUpdate.addMouseOverHandler(new MouseOverMapHandler() {
|
||||
@Override
|
||||
public void onEvent(MouseOverMapEvent event) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(stringMessages.courseMiddleLine());
|
||||
sb.append('\n');
|
||||
sb.append(NumberFormat.getFormat("0").format(
|
||||
Math.abs(position1DTO.getDistance(position2DTO).getMeters()))+stringMessages.metersUnit());
|
||||
if (lastCombinedWindTrackInfoDTO != null) {
|
||||
final WindTrackInfoDTO windTrackAtLegMiddle = lastCombinedWindTrackInfoDTO.getCombinedWindOnLegMiddle(zeroBasedIndexOfStartWaypoint);
|
||||
if (windTrackAtLegMiddle != null && windTrackAtLegMiddle.windFixes != null && !windTrackAtLegMiddle.windFixes.isEmpty()) {
|
||||
WindDTO windAtLegMiddle = windTrackAtLegMiddle.windFixes.get(0);
|
||||
final double legBearingDeg = position1DTO.getBearingGreatCircle(position2DTO).getDegrees();
|
||||
final String diff = NumberFormat.getFormat("0.0").format(
|
||||
Math.min(Math.abs(windAtLegMiddle.dampenedTrueWindBearingDeg-legBearingDeg),
|
||||
Math.abs(windAtLegMiddle.dampenedTrueWindFromDeg-legBearingDeg)));
|
||||
sb.append(", ");
|
||||
sb.append(stringMessages.degreesToWind(diff));
|
||||
}
|
||||
}
|
||||
});
|
||||
courseMiddleLine.addMouseOutMoveHandler(new MouseOutMapHandler() {
|
||||
@Override
|
||||
public void onEvent(MouseOutMapEvent event) {
|
||||
map.setTitle("");
|
||||
}
|
||||
});
|
||||
courseMiddleLine.setMap(map);
|
||||
} else {
|
||||
courseMiddleLine.getPath().removeAt(1);
|
||||
courseMiddleLine.getPath().removeAt(0);
|
||||
courseMiddleLine.getPath().insertAt(0, courseMiddleLinePoint1);
|
||||
courseMiddleLine.getPath().insertAt(1, courseMiddleLinePoint2);
|
||||
}
|
||||
map.setTitle(sb.toString());
|
||||
}
|
||||
});
|
||||
lineToShowOrRemoveOrUpdate.addMouseOutMoveHandler(new MouseOutMapHandler() {
|
||||
@Override
|
||||
public void onEvent(MouseOutMapEvent event) {
|
||||
map.setTitle("");
|
||||
}
|
||||
});
|
||||
lineToShowOrRemoveOrUpdate.setMap(map);
|
||||
} else {
|
||||
pointsAsArray = lineToShowOrRemoveOrUpdate.getPath();
|
||||
pointsAsArray.removeAt(1);
|
||||
pointsAsArray.removeAt(0);
|
||||
}
|
||||
else {
|
||||
if (courseMiddleLine != null) {
|
||||
courseMiddleLine.setMap(null);
|
||||
courseMiddleLine = null;
|
||||
}
|
||||
pointsAsArray.insertAt(0, courseMiddleLinePoint1);
|
||||
pointsAsArray.insertAt(1, courseMiddleLinePoint2);
|
||||
}
|
||||
else {
|
||||
if (lineToShowOrRemoveOrUpdate != null) {
|
||||
lineToShowOrRemoveOrUpdate.setMap(null);
|
||||
lineToShowOrRemoveOrUpdate = null;
|
||||
}
|
||||
}
|
||||
return lineToShowOrRemoveOrUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user