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
686eca40
Commit
686eca40
authored
Sep 19, 2017
by
Björn Richerzhagen
Browse files
Modular Movement model segment calculation
parent
cff5d31b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/local/RealWorldStreetsMovement.java
View file @
686eca40
...
...
@@ -31,12 +31,16 @@ import java.util.UUID;
import
com.graphhopper.GHRequest
;
import
com.graphhopper.GHResponse
;
import
com.graphhopper.GraphHopper
;
import
com.graphhopper.PathWrapper
;
import
com.graphhopper.routing.util.EdgeFilter
;
import
com.graphhopper.routing.util.EncodingManager
;
import
com.graphhopper.routing.util.TraversalMode
;
import
com.graphhopper.storage.index.LocationIndex
;
import
com.graphhopper.storage.index.QueryResult
;
import
com.graphhopper.util.DistanceCalc2D
;
import
com.graphhopper.util.EdgeIteratorState
;
import
com.graphhopper.util.Instruction
;
import
com.graphhopper.util.InstructionList
;
import
com.graphhopper.util.PointList
;
import
com.graphhopper.util.shapes.GHPoint
;
...
...
@@ -186,7 +190,7 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
trajectory
=
new
RouteImpl
(
comp
.
getRealPosition
(),
destination
,
pointList
,
routeSensor
.
getSegmentListeners
(),
routeSensor
,
calculateSegments
(
pointList
));
calculateSegments
(
rsp
.
getBest
()
));
}
else
{
trajectory
=
new
RouteImpl
(
comp
.
getRealPosition
(),
destination
,
pointList
);
...
...
@@ -204,6 +208,45 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
return
new
Left
<
PositionVector
,
Boolean
>(
newPosition
);
}
/**
* Calculate RouteSegments using the PathWrapper
* @param pathWrapper
* @return
*/
private
List
<
RouteSegmentImpl
>
calculateSegments
(
PathWrapper
pathWrapper
)
{
InstructionList
instructions
=
pathWrapper
.
getInstructions
();
int
ptIdx
=
0
;
List
<
RouteSegmentImpl
>
segments
=
new
LinkedList
<>();
RouteSegmentImpl
lastSegment
=
null
;
for
(
Instruction
instr
:
instructions
)
{
RouteSegmentImpl
segment
=
null
;
PointList
points
=
instr
.
getPoints
();
String
name
=
instr
.
getName
();
if
(
name
.
isEmpty
())
{
name
=
Integer
.
toString
(
instr
.
getPoints
().
toGHPoint
(
0
).
hashCode
());
}
for
(
GHPoint
point
:
points
)
{
if
(
segment
==
null
)
{
if
(
lastSegment
!=
null
)
{
lastSegment
.
addRouteLocation
(
transformGPSWindowToOwnWorld
(
point
.
getLat
(),
point
.
getLon
()));
}
segment
=
new
RouteSegmentImpl
(
name
,
ptIdx
,
transformGPSWindowToOwnWorld
(
point
.
getLat
(),
point
.
getLon
()));
}
else
{
segment
.
addRouteLocation
(
transformGPSWindowToOwnWorld
(
point
.
getLat
(),
point
.
getLon
()));
}
ptIdx
++;
}
lastSegment
=
segment
;
segments
.
add
(
segment
);
}
return
segments
;
}
/**
* Calculate the route segments along the given point list.
*
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/ModularMovementModelViz.java
View file @
686eca40
...
...
@@ -207,7 +207,7 @@ public class ModularMovementModelViz extends JComponent
private
class
TrajectoryVis
{
private
final
RouteSensor
routeSensor
;
public
TrajectoryVis
(
RouteSensor
routeSensor
)
{
this
.
routeSensor
=
routeSensor
;
}
...
...
@@ -217,14 +217,24 @@ public class ModularMovementModelViz extends JComponent
if
(!
rt
.
hasSegmentInformation
())
{
return
;
}
boolean
alt
=
false
;
for
(
RouteSegment
segment
:
rt
.
getSegmentsAhead
())
{
Location
lastLoc
=
null
;
g2
.
setColor
(
Color
.
MAGENTA
);
if
(
alt
)
{
g2
.
setColor
(
Color
.
ORANGE
);
}
alt
=
!
alt
;
for
(
Location
loc
:
segment
.
getSegmentLocations
())
{
if
(
lastLoc
==
null
)
{
lastLoc
=
loc
;
g2
.
drawString
(
segment
.
getSegmentId
(),
VisualizationInjector
.
scaleValue
(
lastLoc
.
getLongitude
()),
VisualizationInjector
.
scaleValue
(
lastLoc
.
getLatitude
()));
continue
;
}
g2
.
setColor
(
Color
.
MAGENTA
);
g2
.
setStroke
(
new
BasicStroke
(
3.0f
));
g2
.
drawLine
(
VisualizationInjector
...
...
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