Commit 7b731771 authored by Julian Zobel's avatar Julian Zobel
Browse files

GraphHopper Update to 6.0

parent ad328a37
......@@ -231,19 +231,14 @@
</dependency>
<!-- Routing and navigation ... TODO: new version! -->
<!-- Routing and navigation -->
<!-- https://mvnrepository.com/artifact/com.graphhopper/graphhopper-core -->
<dependency>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-core</artifactId>
<version>0.13.0</version>
<version>6.0</version>
</dependency>
<dependency>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-reader-osm</artifactId>
<version>0.13.0</version>
</dependency>
<!-- JSON in Java -->
<!-- https://mvnrepository.com/artifact/org.json/json -->
......
......@@ -29,6 +29,7 @@ import com.graphhopper.util.PointList;
import com.graphhopper.util.shapes.GHPoint3D;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.GPSCalculation;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.Route;
......@@ -68,11 +69,7 @@ public class RouteImpl implements Route {
private int currentIndex;
private int currentSegmentIndex;
private int routeLength;
private int routeSegmentsLength;
private boolean reachedTarget;
/**
......@@ -92,16 +89,12 @@ public class RouteImpl implements Route {
this.destination = destination;
this.pointList = pointList;
this.positionsList = new LinkedList<>();
// Create Position vectors ONCE
// Create PositionVectors ONCE
for (GHPoint3D temp : pointList) {
positionsList
.add(RealWorldStreetsMovement.transformGPSWindowToOwnWorld(
temp.getLat(), temp.getLon()));
positionsList.add(GPSCalculation.transformGPSWindowToOwnWorld(temp.getLat(), temp.getLon()));
}
routeLength = positionsList.size();
this.segmentListeners = segmentListeners;
this.routeSegments = routeSegments;
this.routeSegmentsLength = routeSegments.size();
}
/**
......@@ -131,7 +124,7 @@ public class RouteImpl implements Route {
@Override
public boolean hasSegmentInformation() {
return routeSegmentsLength != 0;
return this.routeSegments.size() != 0;
}
@Override
......@@ -150,7 +143,7 @@ public class RouteImpl implements Route {
"To access segments within a Route, you need to enable the respective functionality in the local movement strategy (usually: calculateRouteSegments=true)");
}
return Collections.unmodifiableList(routeSegments
.subList(currentSegmentIndex, routeSegmentsLength));
.subList(currentSegmentIndex, this.routeSegments.size()));
}
@Override
......@@ -172,8 +165,7 @@ public class RouteImpl implements Route {
*/
public PositionVector updateCurrentLocation(SimLocationActuator comp,
double speed, double tolerance) {
List<PositionVector> sublist = positionsList.subList(currentIndex,
routeLength);
List<PositionVector> sublist = positionsList.subList(currentIndex, this.pointList.size());
PositionVector newPosition = null;
for (PositionVector candidate : sublist) {
newPosition = comp.getRealPosition().moveStep(candidate, speed);
......@@ -187,10 +179,10 @@ public class RouteImpl implements Route {
/*
* Segment handling (also inform listeners!)
*/
if (routeSegmentsLength > 0
&& routeSegmentsLength > currentSegmentIndex) {
if (this.routeSegments.size() > 0
&& this.routeSegments.size() > currentSegmentIndex) {
List<RouteSegmentImpl> segmentSublist = routeSegments
.subList(currentSegmentIndex + 1, routeSegmentsLength);
.subList(currentSegmentIndex + 1, this.routeSegments.size());
for (RouteSegmentImpl candidate : segmentSublist) {
if (candidate.getFromRouteIndex() >= currentIndex) {
break;
......@@ -205,7 +197,7 @@ public class RouteImpl implements Route {
/*
* Reached target flag
*/
if (currentIndex >= routeLength) {
if (currentIndex >= this.pointList.size()) {
reachedTarget = true;
}
......@@ -224,7 +216,7 @@ public class RouteImpl implements Route {
@Override
public String toString() {
return "\n\tfrom " + start.toString() + " to " + destination.toString()
+ "\n\tstep: " + currentIndex + " length: " + routeLength;
+ "\n\tstep: " + currentIndex + " points: " + this.pointList.size();
}
public PointList getPointList() {
......
......@@ -141,7 +141,8 @@ public class GPSCalculation {
}
/**
* Projects the gps coordinates in the given gps window to the world-coordinates given in world-dimensions
* Projects the GPS coordinates in the given GPS-based world window to coordinates given in world-dimensions.
*
* @param lat
* @param lon
* @return The projected position in world-dimensions
......@@ -153,6 +154,24 @@ public class GPSCalculation {
return new PositionVector(x, y);
}
/**
* Projects the world coordinates in the given GPS-based world window to GPS-coordinates.
*
* @param x
* @param y
* @return The projected position in GPS-coordinates (lat, long)
*/
public static double[] transformOwnWorldWindowToGPS(double x, double y) {
double[] gps_coordinates = new double[2];
gps_coordinates[0] = getLatLower() + (getLatUpper() - getLatLower()) * (getWorldDimensionsY() - y) / getWorldDimensionsY();
gps_coordinates[1] = getLonLeft() + (getLonRight() - getLonLeft()) * x / getWorldDimensionsX();
return gps_coordinates;
}
public static double[] transformOwnWorldWindowToGPS(PositionVector v) {
return transformOwnWorldWindowToGPS(v.getX(), v.getY());
}
/**
* Checks if the given latitute and longitude is within the simulated GPS area.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment