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' into simulator. Brought back WindLattice and WindLatticeImpl.
Conflicts: java/com.sap.sailing.simulator/src/com/sap/sailing/simulator/impl/WindLatticeImpl.java
This commit is contained in:
commit
085cf73838
8 files changed
+112
-46
No files matched your search
+4
-3
@@ -164,10 +164,11 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
Position se = new DegreePosition(params.getSouthEast().latDeg, params.getSouthEast().lngDeg);
|
||||
List<Position> course = new ArrayList<Position>();
|
||||
course.add(nw);
|
||||
course.add(se);
|
||||
course.add(se);
|
||||
|
||||
RectangularBoundary bd = new RectangularBoundary(nw, se);
|
||||
RectangularBoundary bd = new RectangularBoundary(nw, se, 0.1);
|
||||
// List<Position> lattice = bd.extractLattice(params.getxRes(), params.getyRes());
|
||||
|
||||
retreiveWindControlParameters(pattern);
|
||||
|
||||
controlParameters.baseWindBearing = bd.getSouth().getDegrees();
|
||||
@@ -206,7 +207,7 @@ public class SimulatorServiceImpl extends RemoteServiceServlet implements Simula
|
||||
course.add(nw);
|
||||
course.add(se);
|
||||
|
||||
RectangularBoundary bd = new RectangularBoundary(nw, se);
|
||||
RectangularBoundary bd = new RectangularBoundary(nw, se, 0.1);
|
||||
retreiveWindControlParameters(pattern);
|
||||
|
||||
controlParameters.baseWindBearing = bd.getSouth().getDegrees();
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<intAttribute key="default_start_level" value="4"/>
|
||||
<booleanAttribute key="includeOptional" value="true"/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console -clean"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
|
||||
+15
-3
@@ -50,7 +50,7 @@ public class SimulatorTest {
|
||||
course.add(start);
|
||||
course.add(end);
|
||||
PolarDiagram pd = new PolarDiagramImpl(0);
|
||||
RectangularBoundary bd = new RectangularBoundary(start, end);
|
||||
RectangularBoundary bd = new RectangularBoundary(start, end, 0.1);
|
||||
KilometersPerHourSpeedImpl kmhrSpeed = new KilometersPerHourSpeedImpl(7.2);
|
||||
WindControlParameters windParameters = new WindControlParameters(kmhrSpeed.getKnots(), 45);
|
||||
WindField wf = new WindFieldImpl(bd, windParameters);
|
||||
@@ -72,7 +72,7 @@ public class SimulatorTest {
|
||||
Position p1 = new DegreePosition(25.661333, -90.752563);
|
||||
Position p2 = new DegreePosition(24.522137, -90.774536);
|
||||
|
||||
Boundary b = new RectangularBoundary(p1, p2);
|
||||
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
|
||||
@@ -102,7 +102,19 @@ public class SimulatorTest {
|
||||
|
||||
assertEquals("Number of path points", 30, pth.getPathPoints().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRectangularBoundary1() {
|
||||
Position p1 = new DegreePosition(25.661333, -90.752563);
|
||||
Position p2 = new DegreePosition(24.522137, -90.774536);
|
||||
|
||||
Boundary b = new RectangularBoundary(p1, p2, 0.1);
|
||||
|
||||
assertEquals("Number of lattice points",400,b.extractLattice(20,20).size());
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void testPolarDiagram49_1() {
|
||||
|
||||
@@ -136,5 +148,5 @@ public class SimulatorTest {
|
||||
tableRow.put(new DegreeBearingImpl(180), new KnotSpeedImpl(0));
|
||||
table.put(new KnotSpeedImpl(6), tableRow);
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class WindFieldGeneratorTest {
|
||||
course.add(end);
|
||||
|
||||
WindControlParameters windParameters = new WindControlParameters(3, 180);
|
||||
RectangularBoundary bd = new RectangularBoundary(start, end);
|
||||
RectangularBoundary bd = new RectangularBoundary(start, end, 0.1);
|
||||
WindFieldGeneratorBlastImpl wf = new WindFieldGeneratorBlastImpl(bd, windParameters);
|
||||
int hSteps = 10;
|
||||
int vSteps = 5;
|
||||
|
||||
@@ -15,11 +15,14 @@ public interface Boundary {
|
||||
static Bearing TRUEEAST = new DegreeBearingImpl(90);
|
||||
static Bearing TRUEWEST = new DegreeBearingImpl(270);
|
||||
|
||||
double getTolerance();
|
||||
|
||||
Map<String, Position> getCorners();
|
||||
|
||||
boolean isWithinBoundaries(Position P);
|
||||
|
||||
List<Position> extractLattice(int hPoints, int vPoints);
|
||||
Position[][] extractGrid(int hPoints, int vPoints);
|
||||
List<Position> extractLattice(Distance hStep, Distance vstep);
|
||||
|
||||
Bearing getNorth();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.sap.sailing.simulator;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
public interface WindLattice {
|
||||
|
||||
Position[][] getPoints();
|
||||
|
||||
}
|
||||
package com.sap.sailing.simulator;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
|
||||
public interface WindLattice {
|
||||
|
||||
Position[][] getPoints();
|
||||
|
||||
}
|
||||
+79
-28
@@ -16,6 +16,12 @@ public class RectangularBoundary implements Boundary {
|
||||
private Position southWest;
|
||||
private Position northEast;
|
||||
|
||||
private Position appNorthWest;
|
||||
private Position appSouthEast;
|
||||
private Position appSouthWest;
|
||||
private Position appNorthEast;
|
||||
|
||||
|
||||
private Bearing north;
|
||||
private Bearing south;
|
||||
private Bearing east;
|
||||
@@ -24,35 +30,51 @@ public class RectangularBoundary implements Boundary {
|
||||
private Distance width;
|
||||
private Distance height;
|
||||
|
||||
public RectangularBoundary(Position p1, Position p2) {
|
||||
|
||||
private Distance appWidth;
|
||||
private Distance appHeight;
|
||||
|
||||
double tolerance;
|
||||
|
||||
public RectangularBoundary(Position p1, Position p2, double tlr) {
|
||||
|
||||
tolerance = tlr;
|
||||
|
||||
north = p2.getBearingGreatCircle(p1);
|
||||
south = north.reverse();
|
||||
east = north.add(TRUEEAST);
|
||||
west = north.add(TRUEWEST);
|
||||
|
||||
Distance dist = p1.getDistance(p2);
|
||||
Position pp1 = p1.translateGreatCircle(getNorth(), dist.scale(0.1));
|
||||
Position pp2 = p2.translateGreatCircle(getSouth(), dist.scale(0.1)) ;
|
||||
appHeight = p1.getDistance(p2);
|
||||
appWidth = appHeight.scale(2);
|
||||
|
||||
height = p1.getDistance(pp2);
|
||||
width = height.scale(2);
|
||||
appNorthWest = p1.translateGreatCircle(west, appWidth.scale(0.5));
|
||||
appNorthEast = p1.translateGreatCircle(east, appWidth.scale(0.5));
|
||||
appSouthEast = appNorthEast.translateGreatCircle(south, appHeight);
|
||||
appSouthWest = appNorthWest.translateGreatCircle(south, appHeight);
|
||||
|
||||
northWest = pp1.translateGreatCircle(west, width.scale(0.5));
|
||||
northEast = pp1.translateGreatCircle(east, width.scale(0.5));
|
||||
southEast = northEast.translateGreatCircle(south, height);
|
||||
southWest = northWest.translateGreatCircle(south, height);
|
||||
|
||||
Distance diag = appNorthWest.getDistance(appSouthEast);
|
||||
|
||||
Bearing diag1 = appSouthEast.getBearingGreatCircle(appNorthWest);
|
||||
northWest = appNorthWest.translateGreatCircle(diag1, diag.scale(tolerance));
|
||||
diag1 = diag1.reverse();
|
||||
southEast = appSouthEast.translateGreatCircle(diag1, diag.scale(tolerance));
|
||||
Bearing diag2 = appSouthWest.getBearingGreatCircle(appNorthEast);
|
||||
northEast = appNorthEast.translateGreatCircle(diag2, diag.scale(tolerance));
|
||||
diag2 = diag2.reverse();
|
||||
southWest = appSouthWest.translateGreatCircle(diag2, diag.scale(tolerance));
|
||||
|
||||
height = northWest.getDistance(southWest);
|
||||
width = southWest.getDistance(southEast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Position> getCorners() {
|
||||
|
||||
Map<String, Position> map = new HashMap<String, Position>();
|
||||
map.put("NorthWest", northWest);
|
||||
map.put("SouthWest", southWest);
|
||||
map.put("SouthEast", southEast);
|
||||
map.put("NorthEast", northEast);
|
||||
map.put("NorthWest", appNorthWest);
|
||||
map.put("SouthWest", appSouthWest);
|
||||
map.put("SouthEast", appSouthEast);
|
||||
map.put("NorthEast", appNorthEast);
|
||||
|
||||
return map;
|
||||
|
||||
@@ -77,19 +99,43 @@ public class RectangularBoundary implements Boundary {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position[][] extractGrid(int hPoints, int vPoints) {
|
||||
|
||||
Distance hStep = appWidth.scale(1.0/(hPoints-1));
|
||||
Distance vStep = appHeight.scale(1.0/(vPoints-1));
|
||||
Position[][] grid = new Position[vPoints][hPoints];
|
||||
|
||||
for (int i = 0; i < vPoints; i++) {
|
||||
for (int j = 0; j < hPoints; j++) {
|
||||
grid[i][j] = appSouthWest.
|
||||
translateGreatCircle(getNorth(), vStep.scale(j)).
|
||||
translateGreatCircle(getEast(), hStep.scale(i));
|
||||
}
|
||||
}
|
||||
|
||||
return grid;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Position> extractLattice(int hPoints, int vPoints) {
|
||||
|
||||
return extractLattice(width.scale(1.0/hPoints), height.scale(1.0/vPoints));
|
||||
|
||||
Position[][] grid = extractGrid(hPoints, vPoints);
|
||||
List<Position> lst = new ArrayList<Position>();
|
||||
for(Position[] line : grid) {
|
||||
for(Position p : line) {
|
||||
lst.add(p);
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
@Override
|
||||
//may not return a rectangular lattice!
|
||||
public List<Position> extractLattice(Distance hStep, Distance vStep) {
|
||||
|
||||
Bearing diagBearing = southWest.getBearingGreatCircle(northEast);
|
||||
Distance diag = southWest.getDistance(northEast);
|
||||
Position startPoint = southWest.translateGreatCircle(diagBearing, diag.scale(0.01));
|
||||
Position startPoint = appSouthWest;
|
||||
|
||||
Bearing vBearing = getNorth();
|
||||
Bearing hBearing = getEast();
|
||||
@@ -146,12 +192,12 @@ public class RectangularBoundary implements Boundary {
|
||||
|
||||
@Override
|
||||
public Distance getWidth() {
|
||||
return width;
|
||||
return appWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getHeight() {
|
||||
return height;
|
||||
return appHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,21 +205,26 @@ public class RectangularBoundary implements Boundary {
|
||||
if (!isWithinBoundaries(p)) return null;
|
||||
|
||||
Map<String,Double> map = new HashMap<String,Double>();
|
||||
Position px = p.projectToLineThrough(southWest, getEast());
|
||||
Position py = p.projectToLineThrough(southWest, getNorth());
|
||||
Position px = p.projectToLineThrough(appSouthWest, getEast());
|
||||
Position py = p.projectToLineThrough(appSouthWest, getNorth());
|
||||
|
||||
map.put("X", px.getDistance(southWest).getMeters()/getWidth().getMeters());
|
||||
map.put("Y", py.getDistance(southWest).getMeters()/getHeight().getMeters());
|
||||
map.put("X", px.getDistance(appSouthWest).getMeters()/getWidth().getMeters());
|
||||
map.put("Y", py.getDistance(appSouthWest).getMeters()/getHeight().getMeters());
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getRelativePoint(double x, double y) {
|
||||
|
||||
Position point = southWest;
|
||||
Position point = appSouthWest;
|
||||
point = point.translateGreatCircle(getEast(), getWidth().scale(x));
|
||||
point = point.translateGreatCircle(getNorth(), getHeight().scale(y));
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTolerance() {
|
||||
return tolerance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.sap.sailing.domain.common.Distance;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.simulator.WindLattice;
|
||||
import com.sap.sailing.simulator.impl.WindLatticeImpl.LatticePoint;
|
||||
|
||||
public class WindLatticeImpl implements WindLattice {
|
||||
|
||||
|
||||
Reference in new issue
Block a user