mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-15 16:51:07 +00:00
replace WindDTO with SimulatorWindDTO to reduce data transfer between server/client (and be flexible)
This commit is contained in:
1 parent
8bd986b92d
commit
451ef596dc
14 files changed
+162
-140
No files matched your search
+19
-25
@@ -40,7 +40,7 @@ import com.sap.sailing.gwt.ui.shared.SimulatorResultsDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorResultsDTOAndNotificationMessage;
|
||||
import com.sap.sailing.gwt.ui.shared.SpeedBearingPositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SpeedWithBearingDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldGenParamsDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindLatticeDTO;
|
||||
@@ -261,13 +261,13 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
return posDTO;
|
||||
}
|
||||
|
||||
private WindDTO createWindDTO(final Wind wind) {
|
||||
final WindDTO windDTO = new WindDTO();
|
||||
private SimulatorWindDTO createWindDTO(final Wind wind) {
|
||||
final SimulatorWindDTO windDTO = new SimulatorWindDTO();
|
||||
|
||||
windDTO.trueWindBearingDeg = wind.getBearing().getDegrees();
|
||||
windDTO.trueWindFromDeg = wind.getBearing().reverse().getDegrees();
|
||||
//windDTO.trueWindFromDeg = wind.getBearing().reverse().getDegrees();
|
||||
windDTO.trueWindSpeedInKnots = wind.getKnots();
|
||||
windDTO.trueWindSpeedInMetersPerSecond = wind.getMetersPerSecond();
|
||||
//windDTO.trueWindSpeedInMetersPerSecond = wind.getMetersPerSecond();
|
||||
|
||||
if (wind.getPosition() != null) {
|
||||
windDTO.position = new PositionDTO(wind.getPosition().getLatDeg(), wind.getPosition().getLngDeg());
|
||||
@@ -279,19 +279,13 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
return windDTO;
|
||||
}
|
||||
|
||||
private WindDTO createWindDTO2(final TimedPositionWithSpeed tPos) {
|
||||
private SimulatorWindDTO createWindDTO2(final TimedPositionWithSpeed tPos) {
|
||||
|
||||
final WindDTO windDTO = new WindDTO();
|
||||
final SimulatorWindDTO windDTO = new SimulatorWindDTO();
|
||||
windDTO.trueWindBearingDeg = tPos.getSpeed().getBearing().getDegrees();
|
||||
windDTO.trueWindFromDeg = tPos.getSpeed().getBearing().reverse().getDegrees();
|
||||
//windDTO.trueWindFromDeg = tPos.getSpeed().getBearing().reverse().getDegrees();
|
||||
windDTO.trueWindSpeedInKnots = tPos.getSpeed().getKnots();
|
||||
windDTO.trueWindSpeedInMetersPerSecond = tPos.getSpeed().getMetersPerSecond();
|
||||
|
||||
// FIXME: workaround till i figure out how to get the "dampened" values
|
||||
windDTO.dampenedTrueWindBearingDeg = windDTO.trueWindBearingDeg;
|
||||
windDTO.dampenedTrueWindFromDeg = windDTO.trueWindFromDeg;
|
||||
windDTO.dampenedTrueWindSpeedInKnots = windDTO.trueWindSpeedInKnots;
|
||||
windDTO.dampenedTrueWindSpeedInMetersPerSecond = windDTO.trueWindSpeedInMetersPerSecond;
|
||||
//windDTO.trueWindSpeedInMetersPerSecond = tPos.getSpeed().getMetersPerSecond();
|
||||
|
||||
if (tPos.getPosition() != null) {
|
||||
windDTO.position = new PositionDTO(tPos.getPosition().getLatDeg(), tPos.getPosition().getLngDeg());
|
||||
@@ -313,7 +307,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
final TimePoint timeStep, final boolean isShowLines) {
|
||||
|
||||
final WindFieldDTO windFieldDTO = new WindFieldDTO();
|
||||
final List<WindDTO> wList = new ArrayList<WindDTO>();
|
||||
final List<SimulatorWindDTO> wList = new ArrayList<SimulatorWindDTO>();
|
||||
final Position[][] positionGrid = wf.getPositionGrid();
|
||||
|
||||
if (positionGrid != null && positionGrid.length > 0) {
|
||||
@@ -323,7 +317,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
for (int j = 0; j < positionGrid[i].length; ++j) {
|
||||
final Wind localWind = wf.getWind(new TimedPositionWithSpeedImpl(t, positionGrid[i][j], null));
|
||||
logger.finer(localWind.toString());
|
||||
final WindDTO w = createWindDTO(localWind);
|
||||
final SimulatorWindDTO w = createWindDTO(localWind);
|
||||
wList.add(w);
|
||||
}
|
||||
}
|
||||
@@ -476,9 +470,9 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
pathDTO[pathIndex] = new PathDTO(pathName.split("#")[1]);
|
||||
|
||||
// fill pathDTO with path points where speed is true wind speed
|
||||
final List<WindDTO> wList = new ArrayList<WindDTO>();
|
||||
final List<SimulatorWindDTO> wList = new ArrayList<SimulatorWindDTO>();
|
||||
for (final TimedPositionWithSpeed p : path) {
|
||||
final WindDTO w = createWindDTO2(p);
|
||||
final SimulatorWindDTO w = createWindDTO2(p);
|
||||
wList.add(w);
|
||||
}
|
||||
pathDTO[pathIndex].setMatrix(wList);
|
||||
@@ -562,7 +556,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
final RaceMapDataDTO rcDTO = simulatedPathsEvenTimedResult.getRaceMapDataDTO();
|
||||
|
||||
for (int i = 0; i < pathDTO.length; ++i) {
|
||||
final List<WindDTO> path = pathDTO[i].getMatrix();
|
||||
final List<SimulatorWindDTO> path = pathDTO[i].getMatrix();
|
||||
final int pathLength = path.size();
|
||||
final long pathTime = pathDTO[i].getMatrix().get(pathLength - 1).timepoint - path.get(0).timepoint;
|
||||
longestPathTime = Math.max(longestPathTime, pathTime);
|
||||
@@ -692,9 +686,9 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
}
|
||||
|
||||
final List<TimedPositionWithSpeed> pathPoints = path.getPathPoints();
|
||||
final List<WindDTO> windDTOs = new ArrayList<WindDTO>();
|
||||
final List<SimulatorWindDTO> windDTOs = new ArrayList<SimulatorWindDTO>();
|
||||
|
||||
WindDTO windDTO = null;
|
||||
SimulatorWindDTO windDTO = null;
|
||||
SpeedWithBearing speedWithBearing = null;
|
||||
Bearing bearing = null;
|
||||
Position position = null;
|
||||
@@ -714,16 +708,16 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
}
|
||||
}
|
||||
|
||||
windDTO = new WindDTO();
|
||||
windDTO = new SimulatorWindDTO();
|
||||
windDTO.isTurn = isTurn;
|
||||
|
||||
speedWithBearing = point.getSpeed();
|
||||
bearing = speedWithBearing.getBearing();
|
||||
|
||||
windDTO.trueWindBearingDeg = bearing.getDegrees();
|
||||
windDTO.trueWindFromDeg = bearing.reverse().getDegrees();
|
||||
//windDTO.trueWindFromDeg = bearing.reverse().getDegrees();
|
||||
windDTO.trueWindSpeedInKnots = speedWithBearing.getKnots();
|
||||
windDTO.trueWindSpeedInMetersPerSecond = speedWithBearing.getMetersPerSecond();
|
||||
//windDTO.trueWindSpeedInMetersPerSecond = speedWithBearing.getMetersPerSecond();
|
||||
|
||||
position = point.getPosition();
|
||||
if (position != null) {
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class PathDTO extends NamedDTO implements IsSerializable {
|
||||
|
||||
private List<WindDTO> matrix;
|
||||
private List<SimulatorWindDTO> matrix;
|
||||
|
||||
public PathDTO() {
|
||||
|
||||
@@ -16,11 +16,11 @@ public class PathDTO extends NamedDTO implements IsSerializable {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public List<WindDTO> getMatrix() {
|
||||
public List<SimulatorWindDTO> getMatrix() {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public void setMatrix(List<WindDTO> matrix) {
|
||||
public void setMatrix(List<SimulatorWindDTO> matrix) {
|
||||
this.matrix = matrix;
|
||||
}
|
||||
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class SimulatorWindDTO implements IsSerializable {
|
||||
public boolean isTurn;
|
||||
//public Double trueWindSpeedInMetersPerSecond;
|
||||
public Double trueWindSpeedInKnots;
|
||||
public Double trueWindBearingDeg;
|
||||
//public Double trueWindFromDeg;
|
||||
//public Double dampenedTrueWindSpeedInMetersPerSecond;
|
||||
//public Double dampenedTrueWindSpeedInKnots;
|
||||
//public Double dampenedTrueWindBearingDeg;
|
||||
//public Double dampenedTrueWindFromDeg;
|
||||
public PositionDTO position;
|
||||
public Long timepoint;
|
||||
//public Long originTimepoint;
|
||||
//public Double confidence;
|
||||
|
||||
public SimulatorWindDTO() {
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -6,15 +6,15 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class WindFieldDTO implements IsSerializable {
|
||||
|
||||
private List<WindDTO> matrix;
|
||||
private List<SimulatorWindDTO> matrix;
|
||||
|
||||
private WindLinesDTO windLinesDTO;
|
||||
|
||||
public List<WindDTO> getMatrix() {
|
||||
public List<SimulatorWindDTO> getMatrix() {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public void setMatrix(List<WindDTO> matrix) {
|
||||
public void setMatrix(List<SimulatorWindDTO> matrix) {
|
||||
this.matrix = matrix;
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -16,7 +16,7 @@ import com.sap.sailing.domain.common.Named;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.gwt.ui.client.Timer;
|
||||
import com.sap.sailing.gwt.ui.shared.PositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldGenParamsDTO;
|
||||
|
||||
/**
|
||||
@@ -67,11 +67,11 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
|
||||
@Override
|
||||
protected void drawWindField() {
|
||||
logger.fine("In PathCanvasOverlay.drawWindField");
|
||||
List<WindDTO> windDTOList = wl.getMatrix();
|
||||
List<SimulatorWindDTO> windDTOList = wl.getMatrix();
|
||||
drawWindField(windDTOList);
|
||||
}
|
||||
*/
|
||||
protected void drawWindField(final List<WindDTO> windDTOList) {
|
||||
protected void drawWindField(final List<SimulatorWindDTO> windDTOList) {
|
||||
|
||||
WindFieldGenParamsDTO windParams = new WindFieldGenParamsDTO();
|
||||
|
||||
@@ -102,10 +102,10 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
|
||||
Context2d context2d = canvas.getContext2d();
|
||||
context2d.setGlobalAlpha(0.8);
|
||||
|
||||
Iterator<WindDTO> windDTOIter = windDTOList.iterator();
|
||||
WindDTO prevWindDTO = null;
|
||||
Iterator<SimulatorWindDTO> windDTOIter = windDTOList.iterator();
|
||||
SimulatorWindDTO prevWindDTO = null;
|
||||
while (windDTOIter.hasNext()) {
|
||||
WindDTO windDTO = windDTOIter.next();
|
||||
SimulatorWindDTO windDTO = windDTOIter.next();
|
||||
if (prevWindDTO != null) {
|
||||
drawLine(prevWindDTO, windDTO);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
|
||||
long startTime = windDTOList.get(0).timepoint;
|
||||
prevWindDTO = null; //For the last time arrow was displayed
|
||||
while (windDTOIter.hasNext()) {
|
||||
WindDTO windDTO = windDTOIter.next();
|
||||
SimulatorWindDTO windDTO = windDTOIter.next();
|
||||
|
||||
//if ((displayWindAlongPath) && ((index % arrowInterleave) == 0)) {
|
||||
if (displayWindAlongPath) {
|
||||
@@ -151,7 +151,7 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawLine(WindDTO p1, WindDTO p2) {
|
||||
private void drawLine(SimulatorWindDTO p1, SimulatorWindDTO p2) {
|
||||
|
||||
double weight = 3.0;
|
||||
|
||||
@@ -176,7 +176,7 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
|
||||
// System.out.print("x1:"+x1+" y1:"+y1+" x2:"+x2+" y2:"+y2+"\n");
|
||||
}
|
||||
|
||||
private void drawPoint(WindDTO p) {
|
||||
private void drawPoint(SimulatorWindDTO p) {
|
||||
|
||||
double weight = 3.0;
|
||||
|
||||
@@ -196,7 +196,7 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
|
||||
* @return true if the pixel distance between the two points is greater than
|
||||
* a threshold. returns true if either of the points is null
|
||||
*/
|
||||
private boolean checkPointsAreFarEnough(WindDTO p1, WindDTO p2) {
|
||||
private boolean checkPointsAreFarEnough(SimulatorWindDTO p1, SimulatorWindDTO p2) {
|
||||
if (p1 == null || p2 == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
|
||||
}
|
||||
|
||||
public long getPathTime() {
|
||||
List<WindDTO> windDTOList = wl.getMatrix();
|
||||
List<SimulatorWindDTO> windDTOList = wl.getMatrix();
|
||||
int numPoints = windDTOList.size();
|
||||
long totalTime = windDTOList.get(numPoints - 1).timepoint - windDTOList.get(0).timepoint;
|
||||
return totalTime;
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import com.sap.sailing.gwt.ui.shared.ReceivePolarDiagramDataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RequestPolarDiagramDataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SpeedBearingPositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SpeedWithBearingDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.racemap.TwoDPoint;
|
||||
import com.sap.sailing.gwt.ui.shared.racemap.TwoDSegment;
|
||||
import com.sap.sailing.gwt.ui.shared.racemap.TwoDVector;
|
||||
@@ -409,7 +409,7 @@ public class PathPolyline {
|
||||
|
||||
private SpeedWithBearingDTO getAverageWindSpeed() {
|
||||
|
||||
final List<WindDTO> windDTOs = this.pathDTO.getMatrix();
|
||||
final List<SimulatorWindDTO> windDTOs = this.pathDTO.getMatrix();
|
||||
// PathPolylineUtils.computeMinMaxAverageWindSpeed(windDTOs, USE_DAMPENED_VALUES)
|
||||
return PathPolylineUtils.computeAverageWindSpeed(windDTOs, USE_DAMPENED_VALUES);
|
||||
}
|
||||
|
||||
+24
-17
@@ -5,11 +5,12 @@ import java.util.List;
|
||||
|
||||
import com.google.gwt.maps.client.geom.LatLng;
|
||||
import com.sap.sailing.gwt.ui.shared.SpeedWithBearingDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
|
||||
public class PathPolylineUtils {
|
||||
|
||||
public static final double EARTH_RADIUS_METERS = 6378137;
|
||||
public static final double factor_kn2mps = 0.514444;
|
||||
|
||||
public static double convertFromDegToRad(final double noOfDegrees) {
|
||||
return (noOfDegrees * 0.0174532925);
|
||||
@@ -20,10 +21,14 @@ public class PathPolylineUtils {
|
||||
}
|
||||
|
||||
public static double convertFromKnotsToMPS(final double knots) {
|
||||
return knots * 0.51444;
|
||||
return knots * factor_kn2mps;
|
||||
}
|
||||
|
||||
public static SpeedWithBearingDTO computeAverageWindSpeed(final List<WindDTO> windDTOs, final boolean useDampenedValues) {
|
||||
public static double convertFromMPSToKnots(final double mps) {
|
||||
return mps / factor_kn2mps;
|
||||
}
|
||||
|
||||
public static SpeedWithBearingDTO computeAverageWindSpeed(final List<SimulatorWindDTO> windDTOs, final boolean useDampenedValues) {
|
||||
|
||||
final int count = windDTOs.size();
|
||||
|
||||
@@ -33,10 +38,10 @@ public class PathPolylineUtils {
|
||||
double windBearingDegrees = 0.0;
|
||||
double windBearingRadians = 0.0;
|
||||
|
||||
for (final WindDTO windDTO : windDTOs) {
|
||||
for (final SimulatorWindDTO windDTO : windDTOs) {
|
||||
|
||||
windSpeedKnots = useDampenedValues ? windDTO.dampenedTrueWindSpeedInKnots : windDTO.trueWindSpeedInKnots;
|
||||
windBearingDegrees = useDampenedValues ? windDTO.dampenedTrueWindBearingDeg : windDTO.trueWindBearingDeg;
|
||||
windSpeedKnots = windDTO.trueWindSpeedInKnots; //useDampenedValues ? windDTO.dampenedTrueWindSpeedInKnots : windDTO.trueWindSpeedInKnots;
|
||||
windBearingDegrees = windDTO.trueWindBearingDeg; //useDampenedValues ? windDTO.dampenedTrueWindBearingDeg : windDTO.trueWindBearingDeg;
|
||||
windBearingRadians = PathPolylineUtils.convertFromDegToRad(windBearingDegrees);
|
||||
|
||||
sumOfProductOfSpeedAndCosBearing += (windSpeedKnots * Math.cos(windBearingRadians));
|
||||
@@ -62,18 +67,18 @@ public class PathPolylineUtils {
|
||||
return new SpeedWithBearingDTO(averageSpeed, averageBearing);
|
||||
}
|
||||
|
||||
public static SpeedWithBearingDTO computeMinMaxAverageWindSpeed(final List<WindDTO> windDTOs, final boolean useDampenedValues) {
|
||||
public static SpeedWithBearingDTO computeMinMaxAverageWindSpeed(final List<SimulatorWindDTO> windDTOs, final boolean useDampenedValues) {
|
||||
|
||||
WindDTO minWindDTO = windDTOs.get(0);
|
||||
WindDTO maxWindDTO = windDTOs.get(0);
|
||||
WindDTO currentWindDTO = null;
|
||||
SimulatorWindDTO minWindDTO = windDTOs.get(0);
|
||||
SimulatorWindDTO maxWindDTO = windDTOs.get(0);
|
||||
SimulatorWindDTO currentWindDTO = null;
|
||||
final int count = windDTOs.size();
|
||||
|
||||
for (int index = 1; index < count; index++) {
|
||||
|
||||
currentWindDTO = windDTOs.get(index);
|
||||
|
||||
if (useDampenedValues) {
|
||||
/* if (useDampenedValues) {
|
||||
if (currentWindDTO.dampenedTrueWindSpeedInKnots < minWindDTO.dampenedTrueWindSpeedInKnots) {
|
||||
minWindDTO = currentWindDTO;
|
||||
}
|
||||
@@ -81,7 +86,7 @@ public class PathPolylineUtils {
|
||||
if (currentWindDTO.dampenedTrueWindSpeedInKnots > maxWindDTO.dampenedTrueWindSpeedInKnots) {
|
||||
maxWindDTO = currentWindDTO;
|
||||
}
|
||||
} else {
|
||||
} else {*/
|
||||
if (currentWindDTO.trueWindSpeedInKnots < minWindDTO.trueWindSpeedInKnots) {
|
||||
minWindDTO = currentWindDTO;
|
||||
}
|
||||
@@ -89,13 +94,15 @@ public class PathPolylineUtils {
|
||||
if (currentWindDTO.trueWindSpeedInKnots > maxWindDTO.trueWindSpeedInKnots) {
|
||||
maxWindDTO = currentWindDTO;
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
final double speedInKnots = useDampenedValues ? ((minWindDTO.dampenedTrueWindSpeedInKnots + maxWindDTO.dampenedTrueWindSpeedInKnots) / 2)
|
||||
: ((minWindDTO.trueWindSpeedInKnots + maxWindDTO.trueWindSpeedInKnots) / 2);
|
||||
final double bearingInDegrees = useDampenedValues ? ((minWindDTO.dampenedTrueWindBearingDeg + maxWindDTO.dampenedTrueWindBearingDeg) / 2)
|
||||
: ((minWindDTO.trueWindBearingDeg + maxWindDTO.trueWindBearingDeg) / 2);
|
||||
final double speedInKnots = ((minWindDTO.trueWindSpeedInKnots + maxWindDTO.trueWindSpeedInKnots) / 2);
|
||||
//useDampenedValues ? ((minWindDTO.dampenedTrueWindSpeedInKnots + maxWindDTO.dampenedTrueWindSpeedInKnots) / 2)
|
||||
// : ((minWindDTO.trueWindSpeedInKnots + maxWindDTO.trueWindSpeedInKnots) / 2);
|
||||
final double bearingInDegrees = ((minWindDTO.trueWindBearingDeg + maxWindDTO.trueWindBearingDeg) / 2);
|
||||
//useDampenedValues ? ((minWindDTO.dampenedTrueWindBearingDeg + maxWindDTO.dampenedTrueWindBearingDeg) / 2)
|
||||
// : ((minWindDTO.trueWindBearingDeg + maxWindDTO.trueWindBearingDeg) / 2);
|
||||
|
||||
return new SpeedWithBearingDTO(speedInKnots, bearingInDegrees);
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,13 +6,13 @@ import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.gwt.ui.client.Timer;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
|
||||
public class ReplayPathCanvasOverlay extends PathCanvasOverlay {
|
||||
|
||||
private static final long serialVersionUID = -6284996043723173190L;
|
||||
private static Logger logger = Logger.getLogger(ReplayPathCanvasOverlay.class.getName());
|
||||
private List<WindDTO> windDTOToDraw;
|
||||
private List<SimulatorWindDTO> windDTOToDraw;
|
||||
|
||||
public ReplayPathCanvasOverlay(String name, Timer timer) {
|
||||
super(name, timer);
|
||||
@@ -34,8 +34,8 @@ public class ReplayPathCanvasOverlay extends PathCanvasOverlay {
|
||||
canvas.getContext2d().clearRect(0/* canvas.getAbsoluteLeft() */, 0/* canvas.getAbsoluteTop() */,
|
||||
canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight());
|
||||
|
||||
windDTOToDraw = new ArrayList<WindDTO>();
|
||||
for (WindDTO windDTO : wl.getMatrix()) {
|
||||
windDTOToDraw = new ArrayList<SimulatorWindDTO>();
|
||||
for (SimulatorWindDTO windDTO : wl.getMatrix()) {
|
||||
if (windDTO.timepoint <= date.getTime()) {
|
||||
windDTOToDraw.add(windDTO);
|
||||
}
|
||||
|
||||
+1
@@ -813,4 +813,5 @@ public class SimulatorMainPanel extends SplitLayoutPanel {
|
||||
|
||||
return dialogBox;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -27,7 +27,7 @@ import com.sap.sailing.gwt.ui.shared.PathDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.PositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorResultsDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorResultsDTOAndNotificationMessage;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldGenParamsDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.panels.SimpleBusyIndicator;
|
||||
@@ -685,10 +685,10 @@ public class SimulatorMap extends AbsolutePanel implements RequiresDataInitializ
|
||||
|
||||
private static PathPolyline createPathPolyline(final PathDTO pathDTO, final ErrorReporter errorReporter, final SimulatorServiceAsync simulatorService,
|
||||
final MapWidget map) {
|
||||
final List<WindDTO> pathPoints = pathDTO.getMatrix();
|
||||
final List<SimulatorWindDTO> pathPoints = pathDTO.getMatrix();
|
||||
|
||||
final int noOfPathPoints = pathPoints.size();
|
||||
WindDTO currentPathPoint = null;
|
||||
SimulatorWindDTO currentPathPoint = null;
|
||||
final List<LatLng> points = new ArrayList<LatLng>();
|
||||
|
||||
for (int index = 0; index < noOfPathPoints; index++) {
|
||||
|
||||
+17
-17
@@ -20,7 +20,7 @@ import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.gwt.ui.client.TimeListenerWithStoppingCriteria;
|
||||
import com.sap.sailing.gwt.ui.client.Timer;
|
||||
import com.sap.sailing.gwt.ui.shared.PositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
|
||||
import com.sap.sailing.gwt.ui.simulator.util.ToolTip;
|
||||
@@ -40,10 +40,10 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
/*
|
||||
* Map containing the windfield for easy retrieval with key as time point.
|
||||
*/
|
||||
protected SortedMap<Long, List<WindDTO>> timePointWindDTOMap;
|
||||
protected SortedMap<Long, List<SimulatorWindDTO>> timePointWindDTOMap;
|
||||
|
||||
/* The points where ToolTip is to be displayed */
|
||||
protected Map<ToolTip, WindDTO> windFieldPoints;
|
||||
protected Map<ToolTip, SimulatorWindDTO> windFieldPoints;
|
||||
protected String arrowColor = "Blue";
|
||||
protected String arrowHeadColor = "Blue";
|
||||
protected WindFieldMapMouseMoveHandler mmHandler;
|
||||
@@ -67,13 +67,13 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
|
||||
private void init() {
|
||||
wl = null;
|
||||
windFieldPoints = new HashMap<ToolTip, WindDTO>();
|
||||
windFieldPoints = new HashMap<ToolTip, SimulatorWindDTO>();
|
||||
|
||||
mmHandler = new WindFieldMapMouseMoveHandler(this);
|
||||
|
||||
mmHandler.setWindFieldPoints(windFieldPoints);
|
||||
|
||||
timePointWindDTOMap = new TreeMap<Long, List<WindDTO>>();
|
||||
timePointWindDTOMap = new TreeMap<Long, List<SimulatorWindDTO>>();
|
||||
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
|
||||
timePointWindDTOMap.clear();
|
||||
if (wl != null) {
|
||||
for(WindDTO w : wl.getMatrix()) {
|
||||
for(SimulatorWindDTO w : wl.getMatrix()) {
|
||||
if (!timePointWindDTOMap.containsKey(w.timepoint)) {
|
||||
timePointWindDTOMap.put(w.timepoint, new LinkedList<WindDTO>());
|
||||
timePointWindDTOMap.put(w.timepoint, new LinkedList<SimulatorWindDTO>());
|
||||
}
|
||||
timePointWindDTOMap.get(w.timepoint).add(w);
|
||||
}
|
||||
@@ -151,26 +151,26 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
|
||||
}
|
||||
|
||||
protected void drawScaledArrow(WindDTO windDTO, double angle, int index, boolean drawHead) {
|
||||
protected void drawScaledArrow(SimulatorWindDTO windDTO, double angle, int index, boolean drawHead) {
|
||||
|
||||
double aWidth = Math.max(1., (windDTO.trueWindSpeedInMetersPerSecond/2.));
|
||||
double aLength = Math.max(10., (4.*windDTO.trueWindSpeedInMetersPerSecond));
|
||||
double aWidth = Math.max(1., (PathPolylineUtils.convertFromKnotsToMPS(windDTO.trueWindSpeedInKnots)/2.));
|
||||
double aLength = Math.max(10., (4.*PathPolylineUtils.convertFromKnotsToMPS(windDTO.trueWindSpeedInKnots)));
|
||||
//System.out.println("arrow speed: "+windDTO.trueWindSpeedInMetersPerSecond+" angle:"+angle+" aWidth: "+aWidth+" aLength: "+aLength);
|
||||
drawArrow(windDTO, angle, aLength, aWidth, index, drawHead);
|
||||
|
||||
}
|
||||
|
||||
protected void drawWindField(final List<WindDTO> windDTOList) {
|
||||
protected void drawWindField(final List<SimulatorWindDTO> windDTOList) {
|
||||
boolean drawHead = true;
|
||||
clear();
|
||||
Context2d context2d = canvas.getContext2d();
|
||||
context2d.setGlobalAlpha(0.4);
|
||||
|
||||
if (windDTOList != null && windDTOList.size() > 0) {
|
||||
Iterator<WindDTO> windDTOIter = windDTOList.iterator();
|
||||
Iterator<SimulatorWindDTO> windDTOIter = windDTOList.iterator();
|
||||
int index = 0;
|
||||
while (windDTOIter.hasNext()) {
|
||||
WindDTO windDTO = windDTOIter.next();
|
||||
SimulatorWindDTO windDTO = windDTOIter.next();
|
||||
//System.out.println("wind angle: "+windDTO.trueWindBearingDeg);
|
||||
DegreeBearingImpl dbi = new DegreeBearingImpl(windDTO.trueWindBearingDeg);
|
||||
drawScaledArrow(windDTO, dbi.getRadians(), ++index, drawHead);
|
||||
@@ -180,9 +180,9 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawArrow(WindDTO windDTO, double angle, double length, double weight, int index, boolean drawHead) {
|
||||
protected void drawArrow(SimulatorWindDTO windDTO, double angle, double length, double weight, int index, boolean drawHead) {
|
||||
String msg = "Wind @ P" + index + ": time : " + windDTO.timepoint + " speed: " + windDTO.trueWindSpeedInKnots
|
||||
+ "knots " + windDTO.trueWindSpeedInMetersPerSecond + "m/s " + windDTO.trueWindBearingDeg;
|
||||
+ "knots " + windDTO.trueWindBearingDeg;
|
||||
logger.fine(msg);
|
||||
|
||||
PositionDTO position = windDTO.position;
|
||||
@@ -241,9 +241,9 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
@Override
|
||||
public void timeChanged(Date date) {
|
||||
|
||||
List<WindDTO> windDTOToDraw = new ArrayList<WindDTO>();
|
||||
List<SimulatorWindDTO> windDTOToDraw = new ArrayList<SimulatorWindDTO>();
|
||||
|
||||
SortedMap<Long, List<WindDTO>> headMap = (timePointWindDTOMap.headMap(date.getTime()+1));
|
||||
SortedMap<Long, List<SimulatorWindDTO>> headMap = (timePointWindDTOMap.headMap(date.getTime()+1));
|
||||
|
||||
if (!headMap.isEmpty()) {
|
||||
windDTOToDraw = headMap.get(headMap.lastKey());
|
||||
|
||||
+30
-30
@@ -23,7 +23,7 @@ import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.gwt.ui.client.TimeListenerWithStoppingCriteria;
|
||||
import com.sap.sailing.gwt.ui.client.Timer;
|
||||
import com.sap.sailing.gwt.ui.shared.PositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
|
||||
import com.sap.sailing.gwt.ui.simulator.util.WindGridColorPalette;
|
||||
@@ -41,13 +41,13 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
/*
|
||||
* Map containing the windfield for easy retrieval with key as time point.
|
||||
*/
|
||||
protected SortedMap<Long, List<WindDTO>> timePointWindDTOMap;
|
||||
protected SortedMap<Long, List<SimulatorWindDTO>> timePointWindDTOMap;
|
||||
|
||||
protected final Timer timer;
|
||||
|
||||
private int xRes;
|
||||
private int yRes;
|
||||
private WindDTO[][] windMatrix;
|
||||
private SimulatorWindDTO[][] windMatrix;
|
||||
private Map<Pair<Integer, Integer>, GridCell> gridCellMap;
|
||||
private WindGridColorPalette colorPalette;
|
||||
|
||||
@@ -70,28 +70,28 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
}
|
||||
}
|
||||
|
||||
private class SortByWindSpeed implements Comparator<WindDTO> {
|
||||
private class SortByWindSpeed implements Comparator<SimulatorWindDTO> {
|
||||
|
||||
@Override
|
||||
public int compare(WindDTO w1, WindDTO w2) {
|
||||
public int compare(SimulatorWindDTO w1, SimulatorWindDTO w2) {
|
||||
return Double.compare(w1.trueWindSpeedInKnots, w2.trueWindSpeedInKnots);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SortByLatitude implements Comparator<WindDTO> {
|
||||
private class SortByLatitude implements Comparator<SimulatorWindDTO> {
|
||||
|
||||
@Override
|
||||
public int compare(WindDTO w1, WindDTO w2) {
|
||||
public int compare(SimulatorWindDTO w1, SimulatorWindDTO w2) {
|
||||
return Double.compare(w1.position.latDeg, w2.position.latDeg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SortByLongitude implements Comparator<WindDTO> {
|
||||
private class SortByLongitude implements Comparator<SimulatorWindDTO> {
|
||||
|
||||
@Override
|
||||
public int compare(WindDTO w1, WindDTO w2) {
|
||||
public int compare(SimulatorWindDTO w1, SimulatorWindDTO w2) {
|
||||
return Double.compare(w1.position.lngDeg, w2.position.lngDeg);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
|
||||
private void init() {
|
||||
wl = null;
|
||||
timePointWindDTOMap = new TreeMap<Long, List<WindDTO>>();
|
||||
timePointWindDTOMap = new TreeMap<Long, List<SimulatorWindDTO>>();
|
||||
colorPalette = null;
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
|
||||
timePointWindDTOMap.clear();
|
||||
if (wl != null) {
|
||||
for (WindDTO w : wl.getMatrix()) {
|
||||
for (SimulatorWindDTO w : wl.getMatrix()) {
|
||||
if (!timePointWindDTOMap.containsKey(w.timepoint)) {
|
||||
timePointWindDTOMap.put(w.timepoint, new LinkedList<WindDTO>());
|
||||
timePointWindDTOMap.put(w.timepoint, new LinkedList<SimulatorWindDTO>());
|
||||
}
|
||||
timePointWindDTOMap.get(w.timepoint).add(w);
|
||||
}
|
||||
@@ -142,8 +142,8 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
* Get the wind at first time point to capture the positions on the grid.
|
||||
*/
|
||||
Long firstTimePoint = timePointWindDTOMap.firstKey();
|
||||
SortedMap<Long, List<WindDTO>> headMap = (timePointWindDTOMap.headMap(firstTimePoint + 1));
|
||||
List<WindDTO> windDTOToDraw;
|
||||
SortedMap<Long, List<SimulatorWindDTO>> headMap = (timePointWindDTOMap.headMap(firstTimePoint + 1));
|
||||
List<SimulatorWindDTO> windDTOToDraw;
|
||||
if (!headMap.isEmpty()) {
|
||||
windDTOToDraw = headMap.get(headMap.lastKey());
|
||||
createPositionGrid(windDTOToDraw);
|
||||
@@ -173,9 +173,9 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
|
||||
@Override
|
||||
public void timeChanged(Date date) {
|
||||
List<WindDTO> windDTOToDraw = new ArrayList<WindDTO>();
|
||||
List<SimulatorWindDTO> windDTOToDraw = new ArrayList<SimulatorWindDTO>();
|
||||
|
||||
SortedMap<Long, List<WindDTO>> headMap = (timePointWindDTOMap.headMap(date.getTime() + 1));
|
||||
SortedMap<Long, List<SimulatorWindDTO>> headMap = (timePointWindDTOMap.headMap(date.getTime() + 1));
|
||||
|
||||
if (!headMap.isEmpty()) {
|
||||
windDTOToDraw = headMap.get(headMap.lastKey());
|
||||
@@ -229,7 +229,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
|
||||
}
|
||||
|
||||
protected void drawWindGrid(final List<WindDTO> windDTOList) {
|
||||
protected void drawWindGrid(final List<SimulatorWindDTO> windDTOList) {
|
||||
clear();
|
||||
if (windDTOList != null && windDTOList.size() > 1) {
|
||||
if (windDTOList.size() != xRes * yRes) {
|
||||
@@ -251,13 +251,13 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
* @param windDTOList
|
||||
* @return the horizontal pixel distance between the first two points in the list
|
||||
*/
|
||||
private double getGridWidth(List<WindDTO> windDTOList) {
|
||||
private double getGridWidth(List<SimulatorWindDTO> windDTOList) {
|
||||
if (windDTOList.size() > 1) {
|
||||
SortByLatitude sortLatitude = new SortByLatitude();
|
||||
|
||||
Collections.sort(windDTOList, sortLatitude);
|
||||
WindDTO windDTO1 = windDTOList.get(0);
|
||||
WindDTO windDTO2 = windDTOList.get(1);
|
||||
SimulatorWindDTO windDTO1 = windDTOList.get(0);
|
||||
SimulatorWindDTO windDTO2 = windDTOList.get(1);
|
||||
|
||||
LatLng positionLatLng1 = LatLng.newInstance(windDTO1.position.latDeg, windDTO1.position.lngDeg);
|
||||
Point canvasPositionInPx1 = getMap().convertLatLngToDivPixel(positionLatLng1);
|
||||
@@ -275,13 +275,13 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
* @param windDTOList
|
||||
* @return the horizontal pixel distance between the first two points in the list
|
||||
*/
|
||||
private double getGridHeight(List<WindDTO> windDTOList) {
|
||||
private double getGridHeight(List<SimulatorWindDTO> windDTOList) {
|
||||
if (windDTOList.size() > 1) {
|
||||
SortByLongitude sortLongitude = new SortByLongitude();
|
||||
|
||||
Collections.sort(windDTOList, sortLongitude);
|
||||
WindDTO windDTO1 = windDTOList.get(0);
|
||||
WindDTO windDTO2 = windDTOList.get(1);
|
||||
SimulatorWindDTO windDTO1 = windDTOList.get(0);
|
||||
SimulatorWindDTO windDTO2 = windDTOList.get(1);
|
||||
|
||||
LatLng positionLatLng1 = LatLng.newInstance(windDTO1.position.latDeg, windDTO1.position.lngDeg);
|
||||
Point canvasPositionInPx1 = getMap().convertLatLngToDivPixel(positionLatLng1);
|
||||
@@ -294,14 +294,14 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void createPositionGrid(List<WindDTO> windDTOList) {
|
||||
private void createPositionGrid(List<SimulatorWindDTO> windDTOList) {
|
||||
if (windDTOList.size() != xRes * yRes) {
|
||||
logger.warning("Error in WindGridCanvasOverlay wind field is not rectangular.");
|
||||
this.windMatrix = null;
|
||||
return;
|
||||
}
|
||||
this.windMatrix = new WindDTO[yRes + 2][xRes];
|
||||
Iterator<WindDTO> windDTOIter = windDTOList.iterator();
|
||||
this.windMatrix = new SimulatorWindDTO[yRes + 2][xRes];
|
||||
Iterator<SimulatorWindDTO> windDTOIter = windDTOList.iterator();
|
||||
|
||||
for (int i = 1; i < yRes + 1; ++i) {
|
||||
for (int j = 0; j < xRes; ++j) {
|
||||
@@ -313,12 +313,12 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
createGridCell();
|
||||
}
|
||||
|
||||
private void updatePositionGrid(List<WindDTO> windDTOList) {
|
||||
private void updatePositionGrid(List<SimulatorWindDTO> windDTOList) {
|
||||
if (windDTOList.size() != xRes * yRes) {
|
||||
logger.warning("Error in WindGridCanvasOverlay wind field is not rectangular.");
|
||||
return;
|
||||
}
|
||||
Iterator<WindDTO> windDTOIter = windDTOList.iterator();
|
||||
Iterator<SimulatorWindDTO> windDTOIter = windDTOList.iterator();
|
||||
|
||||
for (int i = 0; i < yRes; ++i) {
|
||||
for (int j = 0; j < xRes; ++j) {
|
||||
@@ -348,7 +348,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
PositionDTO p2 = windMatrix[2][j].position;
|
||||
position.latDeg = 2 * p1.latDeg - p2.latDeg;
|
||||
position.lngDeg = 2 * p1.lngDeg - p2.lngDeg;
|
||||
WindDTO windDTO = new WindDTO();
|
||||
SimulatorWindDTO windDTO = new SimulatorWindDTO();
|
||||
// Only the position of this windDTO is used
|
||||
windDTO.position = position;
|
||||
windDTO.trueWindSpeedInKnots = 0.0;
|
||||
@@ -364,7 +364,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
PositionDTO p2 = windMatrix[numRow - 3][j].position;
|
||||
position.latDeg = 2 * p1.latDeg - p2.latDeg;
|
||||
position.lngDeg = 2 * p1.lngDeg - p2.lngDeg;
|
||||
WindDTO windDTO = new WindDTO();
|
||||
SimulatorWindDTO windDTO = new SimulatorWindDTO();
|
||||
// Only the position of this windDTO is used
|
||||
windDTO.position = position;
|
||||
// windDTO.trueWindSpeedInKnots = 0.0;
|
||||
|
||||
+18
-20
@@ -20,7 +20,7 @@ import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.gwt.ui.client.TimeListenerWithStoppingCriteria;
|
||||
import com.sap.sailing.gwt.ui.client.Timer;
|
||||
import com.sap.sailing.gwt.ui.shared.PositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WindFieldDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
|
||||
import com.sap.sailing.gwt.ui.simulator.util.ToolTip;
|
||||
@@ -40,10 +40,10 @@ public class WindStreamletsCanvasOverlay extends FullCanvasOverlay implements Ti
|
||||
/*
|
||||
* Map containing the windfield for easy retrieval with key as time point.
|
||||
*/
|
||||
protected SortedMap<Long, List<WindDTO>> timePointWindDTOMap;
|
||||
protected SortedMap<Long, List<SimulatorWindDTO>> timePointWindDTOMap;
|
||||
|
||||
/* The points where ToolTip is to be displayed */
|
||||
protected Map<ToolTip, WindDTO> windFieldPoints;
|
||||
protected Map<ToolTip, SimulatorWindDTO> windFieldPoints;
|
||||
protected String arrowColor = "Black";
|
||||
protected String arrowHeadColor = "Blue";
|
||||
protected WindFieldMapMouseMoveHandler mmHandler;
|
||||
@@ -67,13 +67,13 @@ public class WindStreamletsCanvasOverlay extends FullCanvasOverlay implements Ti
|
||||
|
||||
private void init() {
|
||||
wl = null;
|
||||
windFieldPoints = new HashMap<ToolTip, WindDTO>();
|
||||
windFieldPoints = new HashMap<ToolTip, SimulatorWindDTO>();
|
||||
|
||||
mmHandler = new WindFieldMapMouseMoveHandler(this);
|
||||
|
||||
mmHandler.setWindFieldPoints(windFieldPoints);
|
||||
|
||||
timePointWindDTOMap = new TreeMap<Long, List<WindDTO>>();
|
||||
timePointWindDTOMap = new TreeMap<Long, List<SimulatorWindDTO>>();
|
||||
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ public class WindStreamletsCanvasOverlay extends FullCanvasOverlay implements Ti
|
||||
|
||||
timePointWindDTOMap.clear();
|
||||
if (wl != null) {
|
||||
for(WindDTO w : wl.getMatrix()) {
|
||||
for(SimulatorWindDTO w : wl.getMatrix()) {
|
||||
if (!timePointWindDTOMap.containsKey(w.timepoint)) {
|
||||
timePointWindDTOMap.put(w.timepoint, new LinkedList<WindDTO>());
|
||||
timePointWindDTOMap.put(w.timepoint, new LinkedList<SimulatorWindDTO>());
|
||||
}
|
||||
timePointWindDTOMap.get(w.timepoint).add(w);
|
||||
}
|
||||
@@ -151,25 +151,23 @@ public class WindStreamletsCanvasOverlay extends FullCanvasOverlay implements Ti
|
||||
|
||||
}
|
||||
|
||||
protected void drawScaledArrow(WindDTO windDTO, double angle, int index, double pxLength, boolean drawHead) {
|
||||
protected void drawScaledArrow(SimulatorWindDTO windDTO, double angle, int index, double pxLength, boolean drawHead) {
|
||||
|
||||
double aWidth = 1.0; //Math.max(1., (windDTO.trueWindSpeedInMetersPerSecond/2.));
|
||||
//double aLength = 10.0; //Math.max(10., (4.*windDTO.trueWindSpeedInMetersPerSecond));
|
||||
//System.out.println("arrow speed: "+windDTO.trueWindSpeedInMetersPerSecond+" angle:"+angle+" aWidth: "+aWidth+" aLength: "+aLength);
|
||||
double aWidth = 1.0;
|
||||
drawArrow(windDTO, angle, pxLength, aWidth, index, drawHead);
|
||||
|
||||
}
|
||||
|
||||
protected void drawWindField(final List<WindDTO> windDTOList) {
|
||||
protected void drawWindField(final List<SimulatorWindDTO> windDTOList) {
|
||||
boolean drawHead = false;
|
||||
clear();
|
||||
Context2d context2d = canvas.getContext2d();
|
||||
context2d.setGlobalAlpha(0.4);
|
||||
|
||||
if (windDTOList != null && windDTOList.size() > 0) {
|
||||
Iterator<WindDTO> windDTOIter = windDTOList.iterator();
|
||||
WindDTO w0 = windDTOIter.next();
|
||||
WindDTO w1 = windDTOIter.next();
|
||||
Iterator<SimulatorWindDTO> windDTOIter = windDTOList.iterator();
|
||||
SimulatorWindDTO w0 = windDTOIter.next();
|
||||
SimulatorWindDTO w1 = windDTOIter.next();
|
||||
LatLng pg0 = LatLng.newInstance(w0.position.latDeg, w0.position.lngDeg);
|
||||
LatLng pg1 = LatLng.newInstance(w1.position.latDeg, w1.position.lngDeg);
|
||||
Point px0 = getMap().convertLatLngToDivPixel(pg0);
|
||||
@@ -182,7 +180,7 @@ public class WindStreamletsCanvasOverlay extends FullCanvasOverlay implements Ti
|
||||
windDTOIter = windDTOList.iterator();
|
||||
int index = 0;
|
||||
while (windDTOIter.hasNext()) {
|
||||
WindDTO windDTO = windDTOIter.next();
|
||||
SimulatorWindDTO windDTO = windDTOIter.next();
|
||||
//System.out.println("wind angle: "+windDTO.trueWindBearingDeg);
|
||||
DegreeBearingImpl dbi = new DegreeBearingImpl(windDTO.trueWindBearingDeg);
|
||||
drawScaledArrow(windDTO, dbi.getRadians(), ++index, pxLength, drawHead);
|
||||
@@ -192,9 +190,9 @@ public class WindStreamletsCanvasOverlay extends FullCanvasOverlay implements Ti
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawArrow(WindDTO windDTO, double angle, double length, double weight, int index, boolean drawHead) {
|
||||
protected void drawArrow(SimulatorWindDTO windDTO, double angle, double length, double weight, int index, boolean drawHead) {
|
||||
String msg = "Wind @ P" + index + ": time : " + windDTO.timepoint + " speed: " + windDTO.trueWindSpeedInKnots
|
||||
+ "knots " + windDTO.trueWindSpeedInMetersPerSecond + "m/s " + windDTO.trueWindBearingDeg;
|
||||
+ "knots " + windDTO.trueWindBearingDeg;
|
||||
logger.fine(msg);
|
||||
|
||||
PositionDTO position = windDTO.position;
|
||||
@@ -253,9 +251,9 @@ public class WindStreamletsCanvasOverlay extends FullCanvasOverlay implements Ti
|
||||
@Override
|
||||
public void timeChanged(Date date) {
|
||||
|
||||
List<WindDTO> windDTOToDraw = new ArrayList<WindDTO>();
|
||||
List<SimulatorWindDTO> windDTOToDraw = new ArrayList<SimulatorWindDTO>();
|
||||
|
||||
SortedMap<Long, List<WindDTO>> headMap = (timePointWindDTOMap.headMap(date.getTime()+1));
|
||||
SortedMap<Long, List<SimulatorWindDTO>> headMap = (timePointWindDTOMap.headMap(date.getTime()+1));
|
||||
|
||||
if (!headMap.isEmpty()) {
|
||||
windDTOToDraw = headMap.get(headMap.lastKey());
|
||||
|
||||
+5
-5
@@ -11,11 +11,11 @@ import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.google.gwt.maps.client.event.MapMouseMoveHandler;
|
||||
import com.google.gwt.maps.client.geom.LatLng;
|
||||
import com.google.gwt.maps.client.geom.Point;
|
||||
import com.sap.sailing.gwt.ui.shared.WindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
|
||||
|
||||
/**
|
||||
* To handle MouseMoveEvent to display tool tips around WindDTO objects in a wind field
|
||||
* To handle MouseMoveEvent to display tool tips around SimulatorWindDTO objects in a wind field
|
||||
*
|
||||
* @author Nidhi Sawhney(D054070)
|
||||
*
|
||||
@@ -23,7 +23,7 @@ import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
|
||||
public class WindFieldMapMouseMoveHandler implements MapMouseMoveHandler {
|
||||
|
||||
private FullCanvasOverlay canvasOverlay;
|
||||
private Map<ToolTip, WindDTO> windFieldPoints = null;
|
||||
private Map<ToolTip, SimulatorWindDTO> windFieldPoints = null;
|
||||
private ImageData lastImageData = null;
|
||||
private double lastToolx;
|
||||
private double lastTooly;
|
||||
@@ -37,7 +37,7 @@ public class WindFieldMapMouseMoveHandler implements MapMouseMoveHandler {
|
||||
lastImageData = null;
|
||||
}
|
||||
|
||||
public void setWindFieldPoints(Map<ToolTip, WindDTO> windFieldPoints) {
|
||||
public void setWindFieldPoints(Map<ToolTip, SimulatorWindDTO> windFieldPoints) {
|
||||
this.windFieldPoints = windFieldPoints;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class WindFieldMapMouseMoveHandler implements MapMouseMoveHandler {
|
||||
lastImageData = context2d.getImageData(x, y, ToolTip.toolRectW, ToolTip.toolRectH);
|
||||
|
||||
|
||||
WindDTO windDTO = windFieldPoints.get(point);
|
||||
SimulatorWindDTO windDTO = windFieldPoints.get(point);
|
||||
context2d.setFillStyle("#4f4f4f");
|
||||
context2d.fillRect(x, y, ToolTip.toolRectW, ToolTip.toolRectH);
|
||||
|
||||
|
||||
Reference in new issue
Block a user