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
c5a8f78e
Commit
c5a8f78e
authored
Sep 05, 2018
by
Julian Zobel
🦄
Browse files
New naming for X/Y position functions.
3D position functions added to PositionVector class
parent
0ce6cda0
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/network/gnp/topology/GnpPosition.java
View file @
c5a8f78e
...
...
@@ -319,12 +319,12 @@ public class GnpPosition implements Location, Comparable<GnpPosition> {
}
@Override
public
double
getLatitude
()
{
public
double
getLatitude
OrY
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
getLongitude
()
{
public
double
getLongitude
OrX
()
{
throw
new
UnsupportedOperationException
();
}
...
...
src/de/tud/kom/p2psim/impl/topology/PositionVector.java
View file @
c5a8f78e
...
...
@@ -46,6 +46,9 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
* the dubious equals-tolerance, which violates the hashCode contract. Seriously
* guys...
*
* - 05/09/18 Julian Zobel: Added location support for third dimension (altitude)
* and removed a bug in the moveStep() function.
*
* @author Bjoern Richerzhagen
* @version 1.0, 04/25/2011
*/
...
...
@@ -68,7 +71,7 @@ public class PositionVector implements Location {
*/
public
PositionVector
(
int
dimensions
)
{
if
(
dimensions
<
2
)
{
throw
new
AssertionError
(
"
L
ess than 2
D
imensions
make no sense
."
);
throw
new
AssertionError
(
"
Vector cannot have l
ess than 2
d
imensions."
);
}
this
.
dimensions
=
dimensions
;
this
.
values
=
new
double
[
dimensions
];
...
...
@@ -85,6 +88,34 @@ public class PositionVector implements Location {
setEntry
(
i
,
vec
.
getEntry
(
i
));
}
}
public
PositionVector
(
double
longitudeOrX
,
double
latitudeOrY
)
{
this
(
2
);
this
.
setLatitudeOrY
(
latitudeOrY
);
this
.
setLongitudeOrX
(
longitudeOrX
);
}
public
PositionVector
(
double
longitudeOrX
,
double
latitudeOrY
,
double
altitude
)
{
this
(
3
);
this
.
setLatitudeOrY
(
latitudeOrY
);
this
.
setLongitudeOrX
(
longitudeOrX
);
this
.
setAltitude
(
altitude
);
}
public
PositionVector
(
Location
location
)
{
if
(
location
.
hasAltitude
())
{
this
.
dimensions
=
3
;
this
.
values
=
new
double
[
3
];
this
.
setAltitude
(
location
.
getAltitude
());
}
else
{
this
.
dimensions
=
2
;
this
.
values
=
new
double
[
2
];
}
this
.
setLatitudeOrY
(
location
.
getLatitudeOrY
());
this
.
setLongitudeOrX
(
location
.
getLongitudeOrX
());
}
/**
* Convenience Constructor, initializes a Vector with values.length
...
...
@@ -100,15 +131,15 @@ public class PositionVector implements Location {
}
@Override
public
void
setLatitude
(
double
latitude
)
public
void
setLatitude
OrY
(
double
latitude
OrY
)
throws
UnsupportedOperationException
{
this
.
setEntry
(
1
,
latitude
);
this
.
setEntry
(
1
,
latitude
OrY
);
}
@Override
public
void
setLongitude
(
double
longitude
)
public
void
setLongitude
OrX
(
double
longitude
OrX
)
throws
UnsupportedOperationException
{
this
.
setEntry
(
0
,
longitude
);
this
.
setEntry
(
0
,
longitude
OrX
);
}
@Override
...
...
@@ -331,8 +362,12 @@ public class PositionVector implements Location {
@Override
public
String
toString
()
{
return
"PositionVector "
+
Arrays
.
toString
(
values
);
return
"PV ["
+
Arrays
.
toString
(
values
)
+
"]"
;
}
@Override
public
PositionVector
clone
()
{
...
...
@@ -422,6 +457,10 @@ public class PositionVector implements Location {
*/
public
PositionVector
moveStep
(
PositionVector
destination
,
double
speed
)
{
if
(
speed
==
0
)
{
return
new
PositionVector
(
this
);
}
double
distance
=
destination
.
distanceTo
(
this
);
if
(
distance
<
speed
)
{
/*
...
...
@@ -456,23 +495,25 @@ public class PositionVector implements Location {
}
@Override
public
double
getLatitude
()
{
/*
* TODO this is only a stub, as we do not work on long/lat in the
* simulator (yet?)
*/
public
double
getLatitudeOrY
()
{
return
getY
();
}
@Override
public
double
getLongitude
()
{
/*
* TODO this is only a stub, as we do not work on long/lat in the
* simulator (yet?)
*/
public
double
getLongitudeOrX
()
{
return
getX
();
}
@Override
public
double
getAltitude
()
{
return
getZ
();
}
@Override
public
boolean
hasAltitude
()
{
return
dimensions
>
2
;
}
@Override
public
long
getAgeOfLocation
()
{
return
0
;
// always a fresh location
...
...
@@ -490,7 +531,8 @@ public class PositionVector implements Location {
*
(
pv
.
getEntry
(
i
)
-
getEntry
(
i
));
}
return
Math
.
sqrt
(
dist
);
}
else
{
}
else
{
throw
new
AssertionError
(
"Can not compute distance between Vectors of different length!"
);
}
...
...
@@ -515,4 +557,6 @@ public class PositionVector implements Location {
"Can only calculate an Angle on elements of type position vector"
);
}
}
}
src/de/tud/kom/p2psim/impl/topology/movement/RSUMovementModel.java
View file @
c5a8f78e
...
...
@@ -113,7 +113,7 @@ public class RSUMovementModel implements MovementModel {
if
(
_currentIndex
<
_intersections
.
size
())
{
// Initial placement
Location
intersection
=
_intersections
.
get
(
_currentIndex
);
actuator
.
updateCurrentLocation
(
new
PositionVector
(
intersection
.
getLongitude
(),
intersection
.
getLatitude
()));
actuator
.
updateCurrentLocation
(
new
PositionVector
(
intersection
.
getLongitude
OrX
(),
intersection
.
getLatitude
OrY
()));
hostIntersectionMatching
.
put
(
actuator
.
getHost
().
getId
(),
_currentIndex
);
...
...
src/de/tud/kom/p2psim/impl/topology/movement/StreetMovement.java
View file @
c5a8f78e
...
...
@@ -151,13 +151,13 @@ public class StreetMovement implements MovementModel, EventHandler {
double
longMin
,
longMax
,
latMin
,
latMax
,
longNew
,
latNew
;
// Points have different longitude, so only search for random value for longitude
if
(
a
.
getLongitude
()
!=
b
.
getLongitude
())
{
if
(
a
.
getLongitude
()
<
b
.
getLongitude
())
{
longMin
=
a
.
getLongitude
();
longMax
=
b
.
getLongitude
();
if
(
a
.
getLongitude
OrX
()
!=
b
.
getLongitude
OrX
())
{
if
(
a
.
getLongitude
OrX
()
<
b
.
getLongitude
OrX
())
{
longMin
=
a
.
getLongitude
OrX
();
longMax
=
b
.
getLongitude
OrX
();
}
else
{
longMin
=
b
.
getLongitude
();
longMax
=
a
.
getLongitude
();
longMin
=
b
.
getLongitude
OrX
();
longMax
=
a
.
getLongitude
OrX
();
}
do
{
...
...
@@ -165,17 +165,17 @@ public class StreetMovement implements MovementModel, EventHandler {
}
while
(
longNew
<
longMin
);
assert
longNew
>
longMin
&&
longNew
<=
longMax
;
return
new
PositionVector
(
longNew
,
a
.
getLatitude
());
return
new
PositionVector
(
longNew
,
a
.
getLatitude
OrY
());
}
// Points have different latitude, so only search for random value for latitude
if
(
a
.
getLatitude
()
!=
b
.
getLatitude
())
{
if
(
a
.
getLatitude
()
<
b
.
getLatitude
())
{
latMin
=
a
.
getLatitude
();
latMax
=
b
.
getLatitude
();
if
(
a
.
getLatitude
OrY
()
!=
b
.
getLatitude
OrY
())
{
if
(
a
.
getLatitude
OrY
()
<
b
.
getLatitude
OrY
())
{
latMin
=
a
.
getLatitude
OrY
();
latMax
=
b
.
getLatitude
OrY
();
}
else
{
latMin
=
b
.
getLatitude
();
latMax
=
a
.
getLatitude
();
latMin
=
b
.
getLatitude
OrY
();
latMax
=
a
.
getLatitude
OrY
();
}
do
{
...
...
@@ -183,7 +183,7 @@ public class StreetMovement implements MovementModel, EventHandler {
}
while
(
latNew
<
latMin
);
assert
latNew
>
latMin
&&
latNew
<=
latMax
;
return
new
PositionVector
(
a
.
getLongitude
(),
latNew
);
return
new
PositionVector
(
a
.
getLongitude
OrX
(),
latNew
);
}
return
null
;
...
...
src/de/tud/kom/p2psim/impl/topology/movement/VehicleMovementModel.java
View file @
c5a8f78e
...
...
@@ -293,7 +293,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
e
.
printStackTrace
();
}
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
getLongitude
(),
position
.
getLatitude
()));
component
.
updateCurrentLocation
(
new
PositionVector
(
position
.
getLongitude
OrX
(),
position
.
getLatitude
OrY
()));
component
.
setMovementSpeed
(
_controller
.
getVehicleSpeed
(
vehicle
));
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/ModularMovementModelViz.java
View file @
c5a8f78e
...
...
@@ -230,21 +230,21 @@ public class ModularMovementModelViz extends JComponent
lastLoc
=
loc
;
g2
.
drawString
(
segment
.
getSegmentId
(),
VisualizationInjector
.
scaleValue
(
lastLoc
.
getLongitude
()),
.
scaleValue
(
lastLoc
.
getLongitude
OrX
()),
VisualizationInjector
.
scaleValue
(
lastLoc
.
getLatitude
()));
.
scaleValue
(
lastLoc
.
getLatitude
OrY
()));
continue
;
}
g2
.
setStroke
(
new
BasicStroke
(
3.0f
));
g2
.
drawLine
(
VisualizationInjector
.
scaleValue
(
lastLoc
.
getLongitude
()),
.
scaleValue
(
lastLoc
.
getLongitude
OrX
()),
VisualizationInjector
.
scaleValue
(
lastLoc
.
getLatitude
()),
.
scaleValue
(
lastLoc
.
getLatitude
OrY
()),
VisualizationInjector
.
scaleValue
(
loc
.
getLongitude
()),
.
scaleValue
(
loc
.
getLongitude
OrX
()),
VisualizationInjector
.
scaleValue
(
loc
.
getLatitude
()));
.
scaleValue
(
loc
.
getLatitude
OrY
()));
lastLoc
=
loc
;
}
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/RandomInAreaTransitionStrategy.java
View file @
c5a8f78e
...
...
@@ -127,8 +127,8 @@ public class RandomInAreaTransitionStrategy implements ITransitionStrategy
{
assert
radius
>
0
:
"An area radius must be specified for the RandomInAreaTransitionStrategy! Did you set the 'DefaultRadius' property for this transition?"
;
double
x
=
center
.
getLongitude
();
double
y
=
center
.
getLatitude
();
double
x
=
center
.
getLongitude
OrX
();
double
y
=
center
.
getLatitude
OrY
();
double
newX
=
-
1
;
double
newY
=
-
1
;
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/csv/RoadSideUnitInformationHandler.java
View file @
c5a8f78e
...
...
@@ -27,8 +27,8 @@ public class RoadSideUnitInformationHandler {
List
<
Location
>
result
=
new
ArrayList
<>();
for
(
Location
position
:
_positions
)
{
if
(
_startX
<=
position
.
getLongitude
()
&&
position
.
getLongitude
()
<=
_endX
&&
_startY
<=
position
.
getLatitude
()
&&
position
.
getLatitude
()
<=
_endY
)
{
result
.
add
(
new
PositionVector
(
position
.
getLongitude
()
-
_startX
,
position
.
getLatitude
()
-
_startY
,
0
));
if
(
_startX
<=
position
.
getLongitude
OrX
()
&&
position
.
getLongitude
OrX
()
<=
_endX
&&
_startY
<=
position
.
getLatitude
OrY
()
&&
position
.
getLatitude
OrY
()
<=
_endY
)
{
result
.
add
(
new
PositionVector
(
position
.
getLongitude
OrX
()
-
_startX
,
position
.
getLatitude
OrY
()
-
_startY
,
0
));
}
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
c5a8f78e
...
...
@@ -786,8 +786,8 @@ public class TraciSimulationController implements VehicleController, SimulationS
int
count
=
0
;
for
(
Location
position
:
positions
)
{
x
+=
position
.
getLongitude
();
y
+=
position
.
getLatitude
();
x
+=
position
.
getLongitude
OrX
();
y
+=
position
.
getLatitude
OrY
();
count
++;
}
...
...
src/de/tud/kom/p2psim/impl/topology/placement/RSUPlacement.java
View file @
c5a8f78e
...
...
@@ -108,7 +108,7 @@ public class RSUPlacement implements PlacementModel {
if
(
_currentIndex
<
_intersections
.
size
())
{
Location
intersection
=
_intersections
.
get
(
_currentIndex
);
_currentIndex
++;
return
new
PositionVector
(
intersection
.
getLongitude
(),
intersection
.
getLatitude
());
return
new
PositionVector
(
intersection
.
getLongitude
OrX
(),
intersection
.
getLatitude
OrY
());
}
else
{
return
new
PositionVector
(
Double
.
NaN
,
Double
.
NaN
);
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/VisualizationTopologyView.java
View file @
c5a8f78e
...
...
@@ -374,8 +374,8 @@ public class VisualizationTopologyView extends JFrame
@Override
public
void
onLocationChanged
(
Host
host
,
Location
location
)
{
this
.
position
.
setLocation
(
VisualizationInjector
.
scaleValue
(
location
.
getLongitude
()),
VisualizationInjector
.
scaleValue
(
location
.
getLatitude
()));
VisualizationInjector
.
scaleValue
(
location
.
getLongitude
OrX
()),
VisualizationInjector
.
scaleValue
(
location
.
getLatitude
OrY
()));
}
}
...
...
src/de/tud/kom/p2psim/impl/util/positioning/GeoSpherePosition.java
View file @
c5a8f78e
...
...
@@ -90,13 +90,13 @@ public class GeoSpherePosition implements Transmitable, Location {
/** Get the latitude in degrees */
@Override
public
double
getLatitude
()
{
public
double
getLatitude
OrY
()
{
return
Math
.
toDegrees
(
latitude
);
}
/** Get the longitude in degrees */
@Override
public
double
getLongitude
()
{
public
double
getLongitude
OrX
()
{
return
Math
.
toDegrees
(
longitude
);
}
...
...
@@ -260,7 +260,7 @@ public class GeoSpherePosition implements Transmitable, Location {
@Override
public
String
toString
()
{
return
"GeoSpherePos["
+
getLatitude
()+
";"
+
getLongitude
()+
"]"
;
return
"GeoSpherePos["
+
getLatitude
OrY
()+
";"
+
getLongitude
OrX
()+
"]"
;
}
@Override
...
...
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