Commit 0c80da45 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Removed deprecated `Position`-Interface

parent db566de9
...@@ -270,7 +270,7 @@ public class OSMHotspotStrategy extends StrongWaypointStrategy { ...@@ -270,7 +270,7 @@ public class OSMHotspotStrategy extends StrongWaypointStrategy {
for (int i = 0; i < coordinates.length; i++) { for (int i = 0; i < coordinates.length; i++) {
positionCache[i] = new PositionVector(coordinates[i].x, positionCache[i] = new PositionVector(coordinates[i].x,
coordinates[i].y); coordinates[i].y);
double d = positionCache[i].getDistance(hotspot.position); double d = positionCache[i].distanceTo(hotspot.position);
if (closestDistance > d || closestDistance == -1) { if (closestDistance > d || closestDistance == -1) {
closestDistance = d; closestDistance = d;
...@@ -283,8 +283,8 @@ public class OSMHotspotStrategy extends StrongWaypointStrategy { ...@@ -283,8 +283,8 @@ public class OSMHotspotStrategy extends StrongWaypointStrategy {
PositionVector after = positionCache[closestIdx + 1 == coordinates.length ? 0 PositionVector after = positionCache[closestIdx + 1 == coordinates.length ? 0
: closestIdx + 1]; : closestIdx + 1];
if (before.getDistance(hotspot.position) < after if (before.distanceTo(hotspot.position) < after
.getDistance(hotspot.position)) { .distanceTo(hotspot.position)) {
return new Tuple<PositionVector, PositionVector>( return new Tuple<PositionVector, PositionVector>(
positionCache[closestIdx].clone(), before); positionCache[closestIdx].clone(), before);
} else { } else {
......
...@@ -384,7 +384,7 @@ public abstract class AbstractMap implements Map { ...@@ -384,7 +384,7 @@ public abstract class AbstractMap implements Map {
Waypoint wp = null; Waypoint wp = null;
for (Waypoint w : waypoints) { for (Waypoint w : waypoints) {
double ld = target.getPosition().getDistance(w.getPosition()); double ld = target.getPosition().distanceTo(w.getPosition());
if (ld < d || d == -1) { if (ld < d || d == -1) {
d = ld; d = ld;
...@@ -406,7 +406,8 @@ public abstract class AbstractMap implements Map { ...@@ -406,7 +406,8 @@ public abstract class AbstractMap implements Map {
double d = -1; double d = -1;
for (Tuple<Waypoint, Waypoint> wpT : shortestDistances) { for (Tuple<Waypoint, Waypoint> wpT : shortestDistances) {
double ld = wpT.getA().getPosition().getDistance(wpT.getB().getPosition()); double ld = wpT.getA().getPosition()
.distanceTo(wpT.getB().getPosition());
if (ld < d || d == -1) { if (ld < d || d == -1) {
d = ld; d = ld;
......
...@@ -4,7 +4,6 @@ import java.util.Map; ...@@ -4,7 +4,6 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.impl.network.modular.common.GeoToolkit; import de.tud.kom.p2psim.impl.network.modular.common.GeoToolkit;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.common.Transmitable; import de.tudarmstadt.maki.simonstrator.api.common.Transmitable;
...@@ -17,7 +16,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; ...@@ -17,7 +16,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
* *
* @author Andreas Hemel * @author Andreas Hemel
*/ */
public class GeoSpherePosition implements Transmitable, Position { public class GeoSpherePosition implements Transmitable, Location {
/** Latitude in radians */ /** Latitude in radians */
private final double latitude; private final double latitude;
...@@ -131,7 +130,7 @@ public class GeoSpherePosition implements Transmitable, Position { ...@@ -131,7 +130,7 @@ public class GeoSpherePosition implements Transmitable, Position {
* @return The distance in meters. * @return The distance in meters.
*/ */
@Override @Override
public double getDistance(Position destination) { public double distanceTo(Location destination) {
GeoSpherePosition dest = (GeoSpherePosition) destination; GeoSpherePosition dest = (GeoSpherePosition) destination;
if (enableDistanceCache) { if (enableDistanceCache) {
Double cached = checkDistanceCache(this, dest); Double cached = checkDistanceCache(this, dest);
...@@ -163,8 +162,8 @@ public class GeoSpherePosition implements Transmitable, Position { ...@@ -163,8 +162,8 @@ public class GeoSpherePosition implements Transmitable, Position {
} }
@Override @Override
public double getAngle(Position target) { public float bearingTo(Location target) {
return -getBearing(target) + 180; return (float) (-getBearing(target) + 180);
} }
/** Calculate the initial bearing to target on a great circle in degrees. /** Calculate the initial bearing to target on a great circle in degrees.
...@@ -177,7 +176,7 @@ public class GeoSpherePosition implements Transmitable, Position { ...@@ -177,7 +176,7 @@ public class GeoSpherePosition implements Transmitable, Position {
* *
* @return The initial bearing in degrees. * @return The initial bearing in degrees.
*/ */
public double getBearing(Position target) { public double getBearing(Location target) {
return Math.toDegrees(getBearingRad(target)); return Math.toDegrees(getBearingRad(target));
} }
...@@ -188,7 +187,7 @@ public class GeoSpherePosition implements Transmitable, Position { ...@@ -188,7 +187,7 @@ public class GeoSpherePosition implements Transmitable, Position {
* *
* @return The initial bearing in radians. * @return The initial bearing in radians.
*/ */
public double getBearingRad(Position destination) { public double getBearingRad(Location destination) {
GeoSpherePosition dest = (GeoSpherePosition) destination; GeoSpherePosition dest = (GeoSpherePosition) destination;
if (enableBearingCache) { if (enableBearingCache) {
Double cached = checkBearingCache(this, dest); Double cached = checkBearingCache(this, dest);
...@@ -228,11 +227,6 @@ public class GeoSpherePosition implements Transmitable, Position { ...@@ -228,11 +227,6 @@ public class GeoSpherePosition implements Transmitable, Position {
return getDestinationRad(Math.toRadians(bearing), distance); return getDestinationRad(Math.toRadians(bearing), distance);
} }
@Override
public GeoSpherePosition getTarget(double distance, double angle) {
return getDestinationRad(angle, distance);
}
/** Calculate the destination position given a bearing and a distance. /** Calculate the destination position given a bearing and a distance.
* *
* The formulae used here assume a spherical Earth, so this calculation has * The formulae used here assume a spherical Earth, so this calculation has
...@@ -448,14 +442,4 @@ public class GeoSpherePosition implements Transmitable, Position { ...@@ -448,14 +442,4 @@ public class GeoSpherePosition implements Transmitable, Position {
public long getAgeOfLocation() { public long getAgeOfLocation() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public double distanceTo(Location dest) {
return getDistance((Position) dest);
}
@Override
public float bearingTo(Location dest) {
return (float) getBearing((Position) dest);
}
} }
...@@ -31,7 +31,7 @@ public class WaypointKdTree extends KdTree<Waypoint> { ...@@ -31,7 +31,7 @@ public class WaypointKdTree extends KdTree<Waypoint> {
@Override @Override
protected double pointDist(double[] p1, double[] p2) { protected double pointDist(double[] p1, double[] p2) {
return new PositionVector(p1).getDistance(new PositionVector(p2)); return new PositionVector(p1).distanceTo(new PositionVector(p2));
} }
@Override @Override
......
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