mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
Merge remote-tracking branch 'origin/simulator_dev' into simulator_dev
This commit is contained in:
commit
41ff41cb98
9 files changed
+145
-46
No files matched your search
+8
-3
@@ -13,10 +13,15 @@ public class WindGridColorPaletteTest {
|
||||
int max = 100;
|
||||
WindGridColorPalette cp = new WindGridColorPalette(min,max);
|
||||
|
||||
assertEquals("Lightest color", "#FFFFFF", cp.getColor(min));
|
||||
assertEquals("Darkest color", "#0000FF", cp.getColor(max));
|
||||
//assertEquals("Lightest color", "#FFFFFF", cp.getColor(min));
|
||||
//assertEquals("Darkest color", "#0000FF", cp.getColor(max));
|
||||
|
||||
assertEquals("In between color", "#7F7FFF", cp.getColor((max+min)/2));
|
||||
//assertEquals("In between color", "#7F7FFF", cp.getColor((max+min)/2));
|
||||
|
||||
assertEquals("Lightest color", "#FFFFFF", cp.getColor(min));
|
||||
assertEquals("Darkest color", "#4B7FBB", cp.getColor(max));
|
||||
|
||||
assertEquals("In between color", "#A5BFDD", cp.getColor((max+min)/2));
|
||||
}
|
||||
|
||||
}
|
||||
+53
-28
@@ -344,10 +344,10 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
return windFieldDTO;
|
||||
}
|
||||
|
||||
private void getWindLinesFromStartLine(final WindFieldGenerator wf, final WindFieldDTO windFieldDTO, final TimePoint startTime,
|
||||
private void getWindLinesFromStartLine(final WindFieldGenerator wf, WindFieldDTO windFieldDTO, final TimePoint startTime,
|
||||
final TimePoint endTime, final TimePoint timeStep) {
|
||||
|
||||
final Position[][] positionGrid = wf.getPositionGrid();
|
||||
Position[][] positionGrid = wf.getPositionGrid();
|
||||
WindLinesDTO windLinesDTO = windFieldDTO.getWindLinesDTO();
|
||||
if (windLinesDTO == null) {
|
||||
windLinesDTO = new WindLinesDTO();
|
||||
@@ -355,23 +355,36 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
}
|
||||
if (positionGrid != null && positionGrid.length > 0 && positionGrid[0].length > 2) {
|
||||
for (int j = 1; j < positionGrid[0].length - 1; ++j) {
|
||||
// for (int j = 0; j < positionGrid[0].length; ++j) {
|
||||
|
||||
TimePoint t = startTime;
|
||||
final PositionDTO startPosition = new PositionDTO(positionGrid[0][j].getLatDeg(),
|
||||
positionGrid[0][j].getLngDeg());
|
||||
Position seed = positionGrid[0][j];
|
||||
PositionDTO startPosition = new PositionDTO(seed.getLatDeg(),
|
||||
seed.getLngDeg());
|
||||
while (t.compareTo(endTime) <= 0) {
|
||||
final TimedPosition tp = new TimedPositionImpl(t, positionGrid[0][j]);
|
||||
final Path p = wf.getLine(tp, false /*forward*/);
|
||||
if (p != null) {
|
||||
final List<PositionDTO> positions = new ArrayList<PositionDTO>();
|
||||
for (final TimedPositionWithSpeed pathPoint : p.getPathPoints()) {
|
||||
final Position position = pathPoint.getPosition();
|
||||
final PositionDTO positionDTO = new PositionDTO(position.getLatDeg(), position.getLngDeg());
|
||||
|
||||
TimedPosition tp = new TimedPositionImpl(t, seed);
|
||||
List<PositionDTO> positions = new ArrayList<PositionDTO>();
|
||||
// Get the wind "before" the seed to cover the grid
|
||||
Path p = wf.getLine(tp, true /*forward*/);
|
||||
if (p != null) {
|
||||
for (TimedPositionWithSpeed pathPoint : p.getPathPoints()) {
|
||||
Position position = pathPoint.getPosition();
|
||||
if (!position.equals(seed)) { //Seed is added in the next loop
|
||||
PositionDTO positionDTO = new PositionDTO(position.getLatDeg(), position.getLngDeg());
|
||||
positions.add(positionDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Get the wind "after" the seed
|
||||
p = wf.getLine(tp, false /*forward*/);
|
||||
if (p != null) {
|
||||
for (TimedPositionWithSpeed pathPoint : p.getPathPoints()) {
|
||||
Position position = pathPoint.getPosition();
|
||||
PositionDTO positionDTO = new PositionDTO(position.getLatDeg(), position.getLngDeg());
|
||||
positions.add(positionDTO);
|
||||
}
|
||||
|
||||
windLinesDTO.addWindLine(startPosition, tp.getTimePoint().asMillis(), positions);
|
||||
}
|
||||
windLinesDTO.addWindLine(startPosition, tp.getTimePoint().asMillis(), positions);
|
||||
t = new MillisecondsTimePoint(t.asMillis() + timeStep.asMillis());
|
||||
}
|
||||
}
|
||||
@@ -381,35 +394,47 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
//logger.info("Added : " + windFieldDTO.getWindLinesDTO().getWindLinesMap().size() + " wind lines");
|
||||
}
|
||||
|
||||
private void getWindLinesFromEndLine(final WindFieldGenerator wf, final WindFieldDTO windFieldDTO, final TimePoint startTime,
|
||||
private void getWindLinesFromEndLine(final WindFieldGenerator wf, WindFieldDTO windFieldDTO, final TimePoint startTime,
|
||||
final TimePoint endTime, final TimePoint timeStep) {
|
||||
|
||||
final Position[][] positionGrid = wf.getPositionGrid();
|
||||
Position[][] positionGrid = wf.getPositionGrid();
|
||||
WindLinesDTO windLinesDTO = windFieldDTO.getWindLinesDTO();
|
||||
if (windLinesDTO == null) {
|
||||
windLinesDTO = new WindLinesDTO();
|
||||
windFieldDTO.setWindLinesDTO(windLinesDTO);
|
||||
}
|
||||
if (positionGrid != null && positionGrid.length > 1 && positionGrid[0].length > 2) {
|
||||
final int lastRowIndex = positionGrid.length - 1;
|
||||
int lastRowIndex = positionGrid.length - 1;
|
||||
for (int j = 1; j < positionGrid[lastRowIndex].length - 1; ++j) {
|
||||
|
||||
TimePoint t = startTime;
|
||||
final PositionDTO startPosition = new PositionDTO(positionGrid[lastRowIndex][j].getLatDeg(),
|
||||
positionGrid[lastRowIndex][j].getLngDeg());
|
||||
Position seed = positionGrid[lastRowIndex][j];
|
||||
PositionDTO startPosition = new PositionDTO(seed.getLatDeg(),
|
||||
seed.getLngDeg());
|
||||
while (t.compareTo(endTime) <= 0) {
|
||||
final TimedPosition tp = new TimedPositionImpl(t, positionGrid[lastRowIndex][j]);
|
||||
final Path p = wf.getLine(tp, true /*forward*/);
|
||||
if (p != null) {
|
||||
final List<PositionDTO> positions = new ArrayList<PositionDTO>();
|
||||
for (final TimedPositionWithSpeed pathPoint : p.getPathPoints()) {
|
||||
final Position position = pathPoint.getPosition();
|
||||
final PositionDTO positionDTO = new PositionDTO(position.getLatDeg(), position.getLngDeg());
|
||||
TimedPosition tp = new TimedPositionImpl(t, seed);
|
||||
List<PositionDTO> positions = new ArrayList<PositionDTO>();
|
||||
//Get the wind before the seed
|
||||
Path p = wf.getLine(tp, false /*forward*/);
|
||||
if (p != null) {
|
||||
for (TimedPositionWithSpeed pathPoint : p.getPathPoints()) {
|
||||
Position position = pathPoint.getPosition();
|
||||
if (!position.equals(seed)) { // seed will be added later in the next loop
|
||||
PositionDTO positionDTO = new PositionDTO(position.getLatDeg(), position.getLngDeg());
|
||||
positions.add(positionDTO);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
p = wf.getLine(tp, true /*forward*/);
|
||||
if (p != null) {
|
||||
for (TimedPositionWithSpeed pathPoint : p.getPathPoints()) {
|
||||
Position position = pathPoint.getPosition();
|
||||
PositionDTO positionDTO = new PositionDTO(position.getLatDeg(), position.getLngDeg());
|
||||
positions.add(positionDTO);
|
||||
}
|
||||
|
||||
windLinesDTO.addWindLine(startPosition, tp.getTimePoint().asMillis(), positions);
|
||||
}
|
||||
windLinesDTO.addWindLine(startPosition, tp.getTimePoint().asMillis(), positions);
|
||||
t = new MillisecondsTimePoint(t.asMillis() + timeStep.asMillis());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -42,8 +42,11 @@ public class PositionDTO implements IsSerializable {
|
||||
if (o == null) {
|
||||
return false;
|
||||
} else {
|
||||
return o instanceof PositionDTO && this.latDeg == ((PositionDTO) o).latDeg
|
||||
&& this.lngDeg == ((PositionDTO) o).lngDeg;
|
||||
if (o instanceof PositionDTO) {
|
||||
PositionDTO other = (PositionDTO) o;
|
||||
return Math.abs(this.latDeg-other.latDeg) <= 1e-5 && Math.abs(this.lngDeg-other.lngDeg) <= 1e-5;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -11,6 +11,7 @@ import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gwt.canvas.dom.client.Context2d;
|
||||
import com.google.gwt.maps.client.MapWidget;
|
||||
import com.google.gwt.maps.client.geom.LatLng;
|
||||
import com.google.gwt.maps.client.geom.Point;
|
||||
@@ -161,6 +162,9 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
|
||||
protected void drawWindField(final List<WindDTO> windDTOList) {
|
||||
clear();
|
||||
Context2d context2d = canvas.getContext2d();
|
||||
context2d.setGlobalAlpha(0.4);
|
||||
|
||||
if (windDTOList != null && windDTOList.size() > 0) {
|
||||
Iterator<WindDTO> windDTOIter = windDTOList.iterator();
|
||||
int index = 0;
|
||||
|
||||
+3
-3
@@ -351,7 +351,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
WindDTO windDTO = new WindDTO();
|
||||
// Only the position of this windDTO is used
|
||||
windDTO.position = position;
|
||||
// windDTO.trueWindSpeedInKnots = 0.0;
|
||||
windDTO.trueWindSpeedInKnots = 0.0;
|
||||
windMatrix[0][j] = windDTO;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
windMatrix[i][j + 1].position);
|
||||
PositionDTO tr = getCenter(windMatrix[i][j].position, windMatrix[i][j + 1].position,
|
||||
windMatrix[i + 1][j].position, windMatrix[i + 1][j + 1].position);
|
||||
GridCell cell = new GridCell(bl, br, tl, tr, windMatrix[i][j].trueWindSpeedInKnots);
|
||||
GridCell cell = new GridCell(bl, br, tl, tr, windMatrix[i-1][j].trueWindSpeedInKnots);
|
||||
Pair<Integer, Integer> cellPair = new Pair<Integer, Integer>(i, j);
|
||||
gridCellMap.put(cellPair, cell);
|
||||
// drawGridCell(cell);
|
||||
@@ -413,7 +413,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
for (int j = 1; j < numCol - 1; ++j) {
|
||||
Pair<Integer, Integer> cellPair = new Pair<Integer, Integer>(i, j);
|
||||
GridCell cell = gridCellMap.get(cellPair);
|
||||
cell.windSpeedInKnots = windMatrix[i][j].trueWindSpeedInKnots;
|
||||
cell.windSpeedInKnots = windMatrix[i-1][j].trueWindSpeedInKnots;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -172,12 +172,18 @@ public class WindLineCanvasOverlay extends FullCanvasOverlay implements TimeList
|
||||
while (positionDTOIter.hasNext()) {
|
||||
PositionDTO positionDTO = positionDTOIter.next();
|
||||
if (prevPositionDTO != null) {
|
||||
if (checkPointInGrid(prevPositionDTO) && checkPointInGrid(positionDTO) ) {
|
||||
boolean previousPointInGrid = checkPointInGrid(prevPositionDTO);
|
||||
boolean currentPointInGrid = checkPointInGrid(positionDTO);
|
||||
if (previousPointInGrid && currentPointInGrid) {
|
||||
drawLine(prevPositionDTO, positionDTO);
|
||||
} else {
|
||||
PositionDTO pointOnBoundary = getPointOnBoundary(prevPositionDTO, positionDTO);
|
||||
if (pointOnBoundary != null) {
|
||||
drawLine(prevPositionDTO, pointOnBoundary);
|
||||
if (previousPointInGrid) {
|
||||
drawLine(prevPositionDTO, pointOnBoundary);
|
||||
} else if (currentPointInGrid) {
|
||||
drawLine(pointOnBoundary, positionDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+60
-5
@@ -13,6 +13,14 @@ public class WindGridColorPalette implements ColorPalette {
|
||||
/*Black is 0 or 00 */
|
||||
public int maxColor = 0;//100;
|
||||
|
||||
public int rminColor = 255;
|
||||
public int rmaxColor = 75;
|
||||
public int gminColor = 255;
|
||||
public int gmaxColor = 127;
|
||||
public int bminColor = 255;
|
||||
public int bmaxColor = 187;
|
||||
|
||||
|
||||
private double min;
|
||||
private double max;
|
||||
|
||||
@@ -45,10 +53,10 @@ public class WindGridColorPalette implements ColorPalette {
|
||||
*
|
||||
* @param value
|
||||
* @return a color representation in hex prefixed with a # corresponding to the value
|
||||
* Currently only shades of grea are supported hence RGB have the same values
|
||||
* if the value is in th range [min,max], returns null otherwise
|
||||
* a shade of grey is returned hence RGB have the same values
|
||||
* if the value is in the range [min,max], returns null otherwise
|
||||
*/
|
||||
public String getColor(double value) {
|
||||
public String getGreyColor(double value) {
|
||||
if (min <= value && value <= max) {
|
||||
|
||||
int colorValue = (int)(minColor + (value-min)/Math.max(1,(max - min)) * (maxColor - minColor));
|
||||
@@ -56,11 +64,58 @@ public class WindGridColorPalette implements ColorPalette {
|
||||
if (colorValueHex.length() < 2) {
|
||||
colorValueHex = "0" + colorValueHex;
|
||||
}
|
||||
//String rgb = "#" + colorValueHex + colorValueHex + colorValueHex;
|
||||
String rgb = "#" + colorValueHex + colorValueHex + "FF";
|
||||
String rgb = "#" + colorValueHex + colorValueHex + colorValueHex;
|
||||
return rgb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @return a color representation in hex prefixed with a # corresponding to the value
|
||||
* The base shade is Google map's ocean blue with shading depending on the value
|
||||
* if the value is in the range [min,max], returns null otherwise
|
||||
*/
|
||||
public String getColor(double value) {
|
||||
if (min <= value && value <= max) {
|
||||
int rbase = (rminColor + rmaxColor)/2;
|
||||
int gbase = (gminColor + gmaxColor)/2;
|
||||
int bbase = (bminColor + bmaxColor)/2;
|
||||
double avgValue = (max+min)/2.0;
|
||||
int rColorValue;
|
||||
int gColorValue;
|
||||
int bColorValue;
|
||||
if (value <= avgValue) {
|
||||
|
||||
rColorValue = (int)(rbase - (avgValue - value)/Math.max(1,(avgValue - min)) * (rbase - rminColor));
|
||||
gColorValue = (int)(gbase - (avgValue - value)/Math.max(1,(avgValue - min)) * (gbase - gminColor));
|
||||
bColorValue = (int)(bbase - (avgValue -value)/Math.max(1,(avgValue - min)) * (bbase - bminColor));
|
||||
|
||||
} else {
|
||||
rColorValue = (int)(rbase + (value - avgValue)/Math.max(1,(max - avgValue)) * (rmaxColor - rbase));
|
||||
gColorValue = (int)(gbase + (value - avgValue)/Math.max(1,(max - avgValue)) * (gmaxColor - gbase));
|
||||
bColorValue = (int)(bbase + (value - avgValue)/Math.max(1,(max - avgValue)) * (bmaxColor - bbase));
|
||||
|
||||
}
|
||||
|
||||
|
||||
String rcolorValueHex = Integer.toHexString(rColorValue).toUpperCase();
|
||||
if (rcolorValueHex.length() < 2) {
|
||||
rcolorValueHex = "0" + rcolorValueHex;
|
||||
}
|
||||
String gcolorValueHex = Integer.toHexString(gColorValue).toUpperCase();
|
||||
if (gcolorValueHex.length() < 2) {
|
||||
gcolorValueHex = "0" + gcolorValueHex;
|
||||
}
|
||||
String bcolorValueHex = Integer.toHexString(bColorValue).toUpperCase();
|
||||
if (bcolorValueHex.length() < 2) {
|
||||
bcolorValueHex = "0" + bcolorValueHex;
|
||||
}
|
||||
String rgb = "#" + rcolorValueHex + gcolorValueHex + bcolorValueHex;
|
||||
return rgb;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,6 @@
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
<booleanAttribute key="useDefaultConfigArea" value="false"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.common@default:default,com.sap.sailing.domain.persistence@default:default,com.sap.sailing.domain.swisstimingadapter.persistence@default:default,com.sap.sailing.domain.swisstimingadapter@default:default,com.sap.sailing.domain.tractracadapter.persistence@default:default,com.sap.sailing.domain.tractracadapter@default:default,com.sap.sailing.domain@default:default,com.sap.sailing.ess40.resultimport@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.freg.resultimport@default:default,com.sap.sailing.geocoding@default:default,com.sap.sailing.gwt.ui@default:default,com.sap.sailing.kiworesultimport@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.operationaltransformation@default:default,com.sap.sailing.server.replication@default:default,com.sap.sailing.server@default:default,com.sap.sailing.udpconnector@default:default,com.sap.sailing.www.events@default:default,com.sap.sailing.www@default:default,com.sap.sailing.xcelsiusadapter@default:default,com.tractrac.clientmodule@default:default,org.json.simple@default:default,org.moxieapps.gwt.highcharts@default:default"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.common@default:default,com.sap.sailing.domain.persistence@default:default,com.sap.sailing.domain.swisstimingadapter.persistence@default:default,com.sap.sailing.domain.swisstimingadapter@default:default,com.sap.sailing.domain.tractracadapter.persistence@default:default,com.sap.sailing.domain.tractracadapter@default:default,com.sap.sailing.domain@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.freg.resultimport@default:default,com.sap.sailing.geocoding@default:default,com.sap.sailing.gwt.ui@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.operationaltransformation@default:default,com.sap.sailing.server.replication@default:default,com.sap.sailing.server@default:default,com.sap.sailing.simulator@default:default,com.sap.sailing.udpconnector@default:default,com.tractrac.clientmodule@default:default,org.json.simple@default:default,org.moxieapps.gwt.highcharts@default:default"/>
|
||||
<stringAttribute key="yk-options" value=" additional-options2=onexit\=snapshot "/>
|
||||
</launchConfiguration>
|
||||
+3
-2
@@ -110,8 +110,8 @@ public abstract class WindFieldGeneratorImpl implements WindFieldGenerator {
|
||||
@Override
|
||||
public Path getLine(TimedPosition seed, boolean forward) {
|
||||
|
||||
int maxSteps = 100;
|
||||
long timeStep = 100000; // in milliseconds
|
||||
//int maxSteps = 100;
|
||||
long timeStep = 10000; // in milliseconds
|
||||
|
||||
TimePoint currentTime = seed.getTimePoint();
|
||||
TimePoint startTime = seed.getTimePoint();
|
||||
@@ -130,6 +130,7 @@ public abstract class WindFieldGeneratorImpl implements WindFieldGenerator {
|
||||
middlePosition = currentWind.travelTo(currentPosition, currentTime, middleTime);
|
||||
}
|
||||
Wind middleWind = this.getWind(new TimedPositionImpl(startTime, middlePosition));
|
||||
//Wind middleWind = currentWind;
|
||||
|
||||
TimePoint nextTime = currentTime.plus(timeStep);
|
||||
Position nextPosition;
|
||||
|
||||
Reference in new issue
Block a user