Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
0c80da45
Commit
0c80da45
authored
Nov 06, 2015
by
Björn Richerzhagen
Browse files
Removed deprecated `Position`-Interface
parent
db566de9
Changes
64
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/waypoints/strong/OSMHotspotStrategy.java
View file @
0c80da45
...
...
@@ -270,7 +270,7 @@ public class OSMHotspotStrategy extends StrongWaypointStrategy {
for
(
int
i
=
0
;
i
<
coordinates
.
length
;
i
++)
{
positionCache
[
i
]
=
new
PositionVector
(
coordinates
[
i
].
x
,
coordinates
[
i
].
y
);
double
d
=
positionCache
[
i
].
getD
istance
(
hotspot
.
position
);
double
d
=
positionCache
[
i
].
d
istance
To
(
hotspot
.
position
);
if
(
closestDistance
>
d
||
closestDistance
==
-
1
)
{
closestDistance
=
d
;
...
...
@@ -283,8 +283,8 @@ public class OSMHotspotStrategy extends StrongWaypointStrategy {
PositionVector
after
=
positionCache
[
closestIdx
+
1
==
coordinates
.
length
?
0
:
closestIdx
+
1
];
if
(
before
.
getD
istance
(
hotspot
.
position
)
<
after
.
getD
istance
(
hotspot
.
position
))
{
if
(
before
.
d
istance
To
(
hotspot
.
position
)
<
after
.
d
istance
To
(
hotspot
.
position
))
{
return
new
Tuple
<
PositionVector
,
PositionVector
>(
positionCache
[
closestIdx
].
clone
(),
before
);
}
else
{
...
...
src/de/tud/kom/p2psim/impl/util/geo/maps/AbstractMap.java
View file @
0c80da45
...
...
@@ -384,7 +384,7 @@ public abstract class AbstractMap implements Map {
Waypoint
wp
=
null
;
for
(
Waypoint
w
:
waypoints
)
{
double
ld
=
target
.
getPosition
().
getD
istance
(
w
.
getPosition
());
double
ld
=
target
.
getPosition
().
d
istance
To
(
w
.
getPosition
());
if
(
ld
<
d
||
d
==
-
1
)
{
d
=
ld
;
...
...
@@ -406,7 +406,8 @@ public abstract class AbstractMap implements Map {
double
d
=
-
1
;
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
)
{
d
=
ld
;
...
...
src/de/tud/kom/p2psim/impl/util/positioning/GeoSpherePosition.java
View file @
0c80da45
...
...
@@ -4,7 +4,6 @@ import java.util.Map;
import
java.util.Random
;
import
java.util.WeakHashMap
;
import
de.tud.kom.p2psim.api.common.Position
;
import
de.tud.kom.p2psim.impl.network.modular.common.GeoToolkit
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.common.Transmitable
;
...
...
@@ -17,7 +16,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
*
* @author Andreas Hemel
*/
public
class
GeoSpherePosition
implements
Transmitable
,
Posi
tion
{
public
class
GeoSpherePosition
implements
Transmitable
,
Loca
tion
{
/** Latitude in radians */
private
final
double
latitude
;
...
...
@@ -131,7 +130,7 @@ public class GeoSpherePosition implements Transmitable, Position {
* @return The distance in meters.
*/
@Override
public
double
getD
istance
(
Posi
tion
destination
)
{
public
double
d
istance
To
(
Loca
tion
destination
)
{
GeoSpherePosition
dest
=
(
GeoSpherePosition
)
destination
;
if
(
enableDistanceCache
)
{
Double
cached
=
checkDistanceCache
(
this
,
dest
);
...
...
@@ -163,8 +162,8 @@ public class GeoSpherePosition implements Transmitable, Position {
}
@Override
public
double
getAngle
(
Posi
tion
target
)
{
return
-
getBearing
(
target
)
+
180
;
public
float
bearingTo
(
Loca
tion
target
)
{
return
(
float
)
(
-
getBearing
(
target
)
+
180
)
;
}
/** Calculate the initial bearing to target on a great circle in degrees.
...
...
@@ -177,7 +176,7 @@ public class GeoSpherePosition implements Transmitable, Position {
*
* @return The initial bearing in degrees.
*/
public
double
getBearing
(
Posi
tion
target
)
{
public
double
getBearing
(
Loca
tion
target
)
{
return
Math
.
toDegrees
(
getBearingRad
(
target
));
}
...
...
@@ -188,7 +187,7 @@ public class GeoSpherePosition implements Transmitable, Position {
*
* @return The initial bearing in radians.
*/
public
double
getBearingRad
(
Posi
tion
destination
)
{
public
double
getBearingRad
(
Loca
tion
destination
)
{
GeoSpherePosition
dest
=
(
GeoSpherePosition
)
destination
;
if
(
enableBearingCache
)
{
Double
cached
=
checkBearingCache
(
this
,
dest
);
...
...
@@ -228,11 +227,6 @@ public class GeoSpherePosition implements Transmitable, Position {
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.
*
* The formulae used here assume a spherical Earth, so this calculation has
...
...
@@ -448,14 +442,4 @@ public class GeoSpherePosition implements Transmitable, Position {
public
long
getAgeOfLocation
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
distanceTo
(
Location
dest
)
{
return
getDistance
((
Position
)
dest
);
}
@Override
public
float
bearingTo
(
Location
dest
)
{
return
(
float
)
getBearing
((
Position
)
dest
);
}
}
src/de/tud/kom/p2psim/impl/util/structures/WaypointKdTree.java
View file @
0c80da45
...
...
@@ -31,7 +31,7 @@ public class WaypointKdTree extends KdTree<Waypoint> {
@Override
protected
double
pointDist
(
double
[]
p1
,
double
[]
p2
)
{
return
new
PositionVector
(
p1
).
getD
istance
(
new
PositionVector
(
p2
));
return
new
PositionVector
(
p1
).
d
istance
To
(
new
PositionVector
(
p2
));
}
@Override
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment