mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
Path now able to use the wind patterns.
This commit is contained in:
1 parent
68c5a3409b
commit
9875307cd1
6 files changed
+67
-12
No files matched your search
+6
@@ -220,6 +220,12 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
WindFieldGenerator wf = WindFieldGeneratorFactory.INSTANCE.createWindFieldGenerator(pattern.getWindPattern()
|
||||
.name(), bd, controlParameters);
|
||||
|
||||
List<Position> lattice = bd.extractLattice(params.getxRes(),params.getyRes());//wf.extractLattice(params.getxRes(), params.getyRes());
|
||||
wf.setPositionGrid(bd.extractGrid(params.getxRes(), params.getyRes()));
|
||||
TimePoint start = new MillisecondsTimePoint(0);
|
||||
TimePoint timeStep = new MillisecondsTimePoint(30*1000);
|
||||
wf.generate(start,null,timeStep);
|
||||
|
||||
// TODO Get all the paths that need to be displayed
|
||||
List<WindDTO> path = getOptimumPath(course, wf);
|
||||
PathDTO[] pathDTO = new PathDTO[1];
|
||||
|
||||
+4
-4
@@ -52,7 +52,7 @@ public class WindPatternDisplayManagerImpl implements WindPatternDisplayManager
|
||||
1);
|
||||
display.addSetting(maxBlastSize);
|
||||
WindPatternSetting<Double> blastWindSpeed = new WindPatternSettingSliderBar("blastWindSpeed",
|
||||
"Average Blast Wind Speed (%)", 0, 100, 0);
|
||||
"Average Blast Wind Speed (%)", 0, 100, 100);
|
||||
display.addSetting(blastWindSpeed);
|
||||
WindPatternSetting<Double> blastWindSpeedVar = new WindPatternSettingSliderBar("blastWindSpeedVar",
|
||||
"Blast Wind Speed Variance (%)", 0, 100, 0);
|
||||
@@ -70,13 +70,13 @@ public class WindPatternDisplayManagerImpl implements WindPatternDisplayManager
|
||||
"Oscillation Amplitude (Degrees)", 0, 20, 0);
|
||||
display.addSetting(amplitude);
|
||||
WindPatternSetting<Double> leftWindSpeed = new WindPatternSettingSliderBar("leftWindSpeed",
|
||||
"Wind Speed Left Side (%)", 0, 200, 0);
|
||||
"Wind Speed Left Side (%)", 0, 200, 100);
|
||||
display.addSetting(leftWindSpeed);
|
||||
WindPatternSetting<Double> middleWindSpeed = new WindPatternSettingSliderBar("middleWindSpeed",
|
||||
"Wind Speed Middle (%)", 0, 200, 0);
|
||||
"Wind Speed Middle (%)", 0, 200, 100);
|
||||
display.addSetting(middleWindSpeed);
|
||||
WindPatternSetting<Double> rightWindSpeed = new WindPatternSettingSliderBar("rightWindSpeed",
|
||||
"Wind Speed Right Side (%)", 0, 200, 0);
|
||||
"Wind Speed Right Side (%)", 0, 200, 100);
|
||||
display.addSetting(rightWindSpeed);
|
||||
}
|
||||
|
||||
|
||||
+44
@@ -10,9 +10,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.Distance;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.impl.KilometersPerHourSpeedImpl;
|
||||
import com.sap.sailing.simulator.Boundary;
|
||||
@@ -23,11 +25,13 @@ import com.sap.sailing.simulator.SimulationParameters;
|
||||
import com.sap.sailing.simulator.TimedPositionWithSpeed;
|
||||
import com.sap.sailing.simulator.WindControlParameters;
|
||||
import com.sap.sailing.simulator.WindField;
|
||||
import com.sap.sailing.simulator.WindFieldGenerator;
|
||||
import com.sap.sailing.simulator.impl.PolarDiagramImpl;
|
||||
import com.sap.sailing.simulator.impl.RectangularBoundary;
|
||||
import com.sap.sailing.simulator.impl.SailingSimulatorImpl;
|
||||
import com.sap.sailing.simulator.impl.SimulationParametersImpl;
|
||||
import com.sap.sailing.simulator.impl.TimedPositionWithSpeedSimple;
|
||||
import com.sap.sailing.simulator.impl.WindFieldGeneratorOscillationImpl;
|
||||
import com.sap.sailing.simulator.impl.WindFieldImpl;
|
||||
|
||||
public class SimulatorTest {
|
||||
@@ -96,4 +100,44 @@ public class SimulatorTest {
|
||||
assertEquals("Number of path points", 37, pth.getPathPoints().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSailingSimulatorWithOscillation() {
|
||||
Position p1 = new DegreePosition(25.661333, -90.752563);
|
||||
Position p2 = new DegreePosition(24.522137, -90.774536);
|
||||
|
||||
Boundary b = new RectangularBoundary(p1, p2, 0.1);
|
||||
|
||||
Distance dist = p1.getDistance(p2);
|
||||
// the Speed required to go from p1 to p2 in 10 minutes
|
||||
Speed requiredSpeed10 = dist.inTime(600000);
|
||||
|
||||
// I am creating the WindField such as the course goes mainly against the wind (as it should)
|
||||
// and the speed of the wind would go over the course in 10 minutes (for the sake of the running time)
|
||||
WindControlParameters windParameters = new WindControlParameters(requiredSpeed10.getKnots(), b.getSouth().getDegrees());
|
||||
WindFieldGenerator wf = new WindFieldGeneratorOscillationImpl(b, windParameters);
|
||||
|
||||
|
||||
wf.setPositionGrid(b.extractGrid(5, 5));
|
||||
TimePoint start = new MillisecondsTimePoint(0);
|
||||
TimePoint timeStep = new MillisecondsTimePoint(30*1000);
|
||||
wf.generate(start,null,timeStep);
|
||||
|
||||
PolarDiagram pd = new PolarDiagramImpl(1);
|
||||
List<Position> course = new ArrayList<Position>();
|
||||
course.add(p1);
|
||||
course.add(p2);
|
||||
SimulationParameters sp = new SimulationParametersImpl(course, pd, wf);
|
||||
SailingSimulator solver = new SailingSimulatorImpl(sp);
|
||||
|
||||
Path pth = solver.getOptimumPath();
|
||||
logger.info("Path with " + pth.getPathPoints().size() + " points");
|
||||
for (TimedPositionWithSpeed p : pth.getPathPoints()) {
|
||||
System.out.println("Position: " + p.getPosition() + " Wind: "
|
||||
+ wf.getWind(pth.getPositionAtTime(p.getTimePoint())));
|
||||
// Wind wind = wf.getWind(pth.getPositionAtTime(p.getTimePoint()));
|
||||
}
|
||||
|
||||
assertEquals("Number of path points", 37, pth.getPathPoints().size());
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -91,9 +91,9 @@ public class WindControlParameters {
|
||||
baseWindBearing = 0.0;
|
||||
frequency = 0.0;
|
||||
amplitude = 0.0;
|
||||
leftWindSpeed = 0.0;
|
||||
middleWindSpeed = 0.0;
|
||||
rightWindSpeed = 0.0;
|
||||
leftWindSpeed = 100.0;
|
||||
middleWindSpeed = 100.0;
|
||||
rightWindSpeed = 100.0;
|
||||
|
||||
blastProbability = 0.0;
|
||||
maxBlastSize = 1.0;
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class SailingSimulatorImpl implements SailingSimulator {
|
||||
|
||||
TimePoint nextTime = new MillisecondsTimePoint(currentTime.asMillis() + 30000);
|
||||
|
||||
pd.setWind(wf.getWind(new TimedPositionWithSpeedSimple(currentPosition)));
|
||||
pd.setWind(wf.getWind(new TimedPositionWithSpeedImpl(nextTime, currentPosition, null)));
|
||||
|
||||
Bearing lft = pd.optimalDirectionsDownwind()[0];
|
||||
Bearing rght = pd.optimalDirectionsUpwind()[1];
|
||||
|
||||
+9
-4
@@ -5,6 +5,8 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.base.SpeedWithBearing;
|
||||
@@ -30,7 +32,7 @@ public abstract class WindFieldGeneratorImpl implements WindFieldGenerator {
|
||||
|
||||
protected Position[][] positions;
|
||||
protected Map<Pair<Integer, Integer>, Position> indexPositionMap;
|
||||
protected Map<Position,Pair<Integer, Integer>> positionIndexMap;
|
||||
protected TreeMap<Position,Pair<Integer, Integer>> positionIndexMap;
|
||||
|
||||
protected Map<TimePoint, SpeedWithBearing[][]> timeSpeedWithBearingMap;
|
||||
|
||||
@@ -71,7 +73,7 @@ public abstract class WindFieldGeneratorImpl implements WindFieldGenerator {
|
||||
this.windParameters = windParameters;
|
||||
this.positions = null;
|
||||
this.indexPositionMap = new HashMap<Pair<Integer, Integer>, Position>();
|
||||
this.positionIndexMap = new HashMap<Position, Pair<Integer, Integer>>();
|
||||
this.positionIndexMap = new TreeMap<Position, Pair<Integer, Integer>>(new LatLngComparator());
|
||||
}
|
||||
|
||||
private List<Position> extractLattice(int hPoints, int vPoints) {
|
||||
@@ -147,8 +149,11 @@ public abstract class WindFieldGeneratorImpl implements WindFieldGenerator {
|
||||
}
|
||||
|
||||
public Pair<Integer,Integer> getPositionIndex(Position p) {
|
||||
return positionIndexMap.get(p);
|
||||
|
||||
Entry<Position,Pair<Integer,Integer>> entry = positionIndexMap.floorEntry(p);
|
||||
if (entry != null) {
|
||||
return entry.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user