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
API
Commits
e0b6b9a6
Commit
e0b6b9a6
authored
Jul 20, 2017
by
Tobias Meuser
Browse files
Added serialization for RoadNetwork to enable faster startups
parent
03c7c6bf
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/RoadNetwork.java
View file @
e0b6b9a6
...
@@ -27,6 +27,20 @@ import java.util.Map;
...
@@ -27,6 +27,20 @@ import java.util.Map;
public
class
RoadNetwork
{
public
class
RoadNetwork
{
private
Map
<
String
,
RoadNetworkEdge
>
_roadNetwork
;
private
Map
<
String
,
RoadNetworkEdge
>
_roadNetwork
;
public
RoadNetwork
(
SerializableRoadNetwork
pRoadNetwork
)
{
for
(
SerializableRoadNetworkEdge
edge
:
pRoadNetwork
.
getAvailableEdges
())
{
_roadNetwork
.
put
(
edge
.
getEdgeID
(),
new
RoadNetworkEdge
(
edge
));
}
for
(
SerializableRoadNetworkEdge
edge
:
pRoadNetwork
.
getAvailableEdges
())
{
RoadNetworkEdge
roadNetworkEdge
=
_roadNetwork
.
get
(
edge
.
getEdgeID
());
for
(
String
edgeID
:
edge
.
getAccessibleEdges
())
{
roadNetworkEdge
.
addConnectedEdge
(
_roadNetwork
.
get
(
edgeID
));
}
}
}
public
RoadNetwork
(
Map
<
String
,
RoadNetworkEdge
>
pRoadNetwork
)
{
public
RoadNetwork
(
Map
<
String
,
RoadNetworkEdge
>
pRoadNetwork
)
{
_roadNetwork
=
pRoadNetwork
;
_roadNetwork
=
pRoadNetwork
;
}
}
...
@@ -35,7 +49,7 @@ public class RoadNetwork {
...
@@ -35,7 +49,7 @@ public class RoadNetwork {
return
new
ArrayList
<>(
_roadNetwork
.
values
());
return
new
ArrayList
<>(
_roadNetwork
.
values
());
}
}
public
RoadNetworkEdge
getEdge
(
String
p
RouteID
)
{
public
RoadNetworkEdge
getEdge
(
String
p
Edge
)
{
return
_roadNetwork
.
get
(
p
RouteID
);
return
_roadNetwork
.
get
(
p
Edge
);
}
}
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/RoadNetworkEdge.java
View file @
e0b6b9a6
...
@@ -33,6 +33,13 @@ public class RoadNetworkEdge {
...
@@ -33,6 +33,13 @@ public class RoadNetworkEdge {
private
List
<
RoadNetworkEdge
>
_accessibleEdges
=
new
ArrayList
<>();
private
List
<
RoadNetworkEdge
>
_accessibleEdges
=
new
ArrayList
<>();
public
RoadNetworkEdge
(
SerializableRoadNetworkEdge
pEdge
)
{
_edgeID
=
pEdge
.
getEdgeID
();
_angle
=
pEdge
.
getAngle
();
_laneAmount
=
pEdge
.
getLaneAmount
();
_maxSpeed
=
pEdge
.
getMaxSpeed
();
}
public
RoadNetworkEdge
(
String
pEdgeID
,
double
pAngle
)
{
public
RoadNetworkEdge
(
String
pEdgeID
,
double
pAngle
)
{
_edgeID
=
pEdgeID
;
_edgeID
=
pEdgeID
;
_angle
=
pAngle
;
_angle
=
pAngle
;
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/SerializableRoadNetwork.java
0 → 100755
View file @
e0b6b9a6
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
SerializableRoadNetwork
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
8523360385937842443L
;
private
Map
<
String
,
SerializableRoadNetworkEdge
>
_roadNetwork
;
public
SerializableRoadNetwork
(
RoadNetwork
pRoadNetwork
)
{
for
(
RoadNetworkEdge
edge
:
pRoadNetwork
.
getAvailableEdges
())
{
_roadNetwork
.
put
(
edge
.
getEdgeID
(),
new
SerializableRoadNetworkEdge
(
edge
));
}
}
public
List
<
SerializableRoadNetworkEdge
>
getAvailableEdges
()
{
return
new
ArrayList
<>(
_roadNetwork
.
values
());
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/vehicular/roadnetwork/SerializableRoadNetworkEdge.java
0 → 100755
View file @
e0b6b9a6
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
class
SerializableRoadNetworkEdge
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
311466941428215723L
;
private
String
_edgeID
;
private
double
_angle
;
private
int
_laneAmount
;
private
double
_maxSpeed
=
0
;
private
List
<
String
>
_accessibleEdgeIDs
=
new
ArrayList
<>();
public
SerializableRoadNetworkEdge
(
RoadNetworkEdge
pEdge
)
{
_edgeID
=
pEdge
.
getEdgeID
();
_angle
=
pEdge
.
getAngle
();
_laneAmount
=
pEdge
.
getLaneAmount
();
_maxSpeed
=
pEdge
.
getMaxSpeed
();
for
(
RoadNetworkEdge
edge
:
pEdge
.
getAccessibleEdges
())
{
_accessibleEdgeIDs
.
add
(
edge
.
getEdgeID
());
}
}
public
String
getEdgeID
()
{
return
_edgeID
;
}
public
double
getAngle
()
{
return
_angle
;
}
public
double
getMaxSpeed
()
{
return
_maxSpeed
;
}
public
int
getLaneAmount
()
{
return
_laneAmount
;
}
public
void
increaseLaneAmount
()
{
_laneAmount
++;
}
public
void
setMaxSpeed
(
double
pMaxSpeed
)
{
if
(
pMaxSpeed
>
_maxSpeed
)
{
_maxSpeed
=
pMaxSpeed
;
}
}
public
List
<
String
>
getAccessibleEdges
()
{
return
Collections
.
unmodifiableList
(
_accessibleEdgeIDs
);
}
public
String
getDescription
()
{
return
"id: "
+
_edgeID
+
", lanes: "
+
_laneAmount
+
", speed limit: "
+
_maxSpeed
;
}
@Override
public
String
toString
()
{
return
_edgeID
;
}
public
boolean
isInternal
()
{
return
_edgeID
.
startsWith
(
":"
);
}
}
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