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
1024f054
Commit
1024f054
authored
Jun 27, 2017
by
Tobias Meuser
Browse files
Added additional information to RoadNetworkEdge
parent
1d0530f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
1024f054
...
...
@@ -3,6 +3,7 @@ package de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.contr
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -23,6 +24,7 @@ import de.tudresden.sumo.cmd.Simulation;
import
de.tudresden.sumo.cmd.Vehicle
;
import
de.tudresden.sumo.util.SumoCommand
;
import
de.tudresden.ws.container.SumoBoundingBox
;
import
de.tudresden.ws.container.SumoGeometry
;
import
de.tudresden.ws.container.SumoLink
;
import
de.tudresden.ws.container.SumoLinkList
;
import
de.tudresden.ws.container.SumoPosition2D
;
...
...
@@ -485,26 +487,37 @@ public class TraciSimulationController implements VehicleController, SimulationS
Map
<
String
,
RoadNetworkEdge
>
roadNetwork
=
new
HashMap
<>();
SumoStringList
laneIDStringList
=
(
SumoStringList
)
requestObject
(
laneIDCommand
);
//Requesting all lanes from sumo.
for
(
String
laneID
:
laneIDStringList
)
{
SumoCommand
edgeIDCommand
=
Lane
.
getEdgeID
(
laneID
);
SumoLinkList
linkStringList
=
(
SumoLinkList
)
requestObject
(
Lane
.
getLinks
(
laneID
));
double
angle
=
getLaneAngle
(
laneID
);
double
maxSpeed
=
getMaxSpeed
(
laneID
);
if
(
linkStringList
.
size
()
>
0
)
{
String
edgeID
=
(
String
)
requestObject
(
edgeIDCommand
);
if
(!
roadNetwork
.
containsKey
(
edgeID
))
{
roadNetwork
.
put
(
edgeID
,
new
RoadNetworkEdge
(
edgeID
));
roadNetwork
.
put
(
edgeID
,
new
RoadNetworkEdge
(
edgeID
,
angle
));
}
RoadNetworkEdge
edge
=
roadNetwork
.
get
(
edgeID
);
edge
.
setMaxSpeed
(
maxSpeed
);
edge
.
increaseLaneAmount
();
for
(
SumoLink
link
:
linkStringList
)
{
String
notInternalLane
=
link
.
notInternalLane
;
String
connectedEdge
=
(
String
)
requestObject
(
Lane
.
getEdgeID
(
notInternalLane
));
double
linkAngle
=
getLaneAngle
(
laneID
);
if
(!
roadNetwork
.
containsKey
(
connectedEdge
))
{
roadNetwork
.
put
(
connectedEdge
,
new
RoadNetworkEdge
(
connectedEdge
));
roadNetwork
.
put
(
connectedEdge
,
new
RoadNetworkEdge
(
connectedEdge
,
linkAngle
));
}
edge
.
addConnectedEdge
(
roadNetwork
.
get
(
connectedEdge
));
...
...
@@ -517,4 +530,27 @@ public class TraciSimulationController implements VehicleController, SimulationS
}
}
public
double
getMaxSpeed
(
String
laneID
)
{
SumoCommand
maxSpeedCommand
=
Lane
.
getMaxSpeed
(
laneID
);
double
maxSpeed
=
(
Double
)
requestObject
(
maxSpeedCommand
);
return
maxSpeed
;
}
public
double
getLaneAngle
(
String
laneID
)
{
SumoCommand
shapeCommand
=
Lane
.
getShape
(
laneID
);
SumoGeometry
geometry
=
(
SumoGeometry
)
requestObject
(
shapeCommand
);
LinkedList
<
SumoPosition2D
>
coords
=
geometry
.
coords
;
SumoPosition2D
start
=
coords
.
getFirst
();
SumoPosition2D
end
=
coords
.
getLast
();
double
sin
=
(
end
.
y
-
start
.
y
)
/
Math
.
sqrt
(
Math
.
pow
(
end
.
x
-
start
.
x
,
2
)
+
Math
.
pow
(
end
.
y
-
start
.
y
,
2
));
double
angle
=
Math
.
asin
(
sin
)
*
180
/
Math
.
PI
;
if
(
end
.
x
-
start
.
x
<
0
)
{
angle
+=
180
;
}
return
angle
;
}
}
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