Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
0ccc0896
Commit
0ccc0896
authored
Aug 08, 2018
by
Benedikt Kleinmeier
Browse files
Committed "StateJsonConverter", which was forgotten in last commit and caused compilation errors.
parent
db0af421
Pipeline
#64952
failed with stages
in 44 minutes and 43 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereModelTests/TestOSM/scenarios/events_traffic_light_waiting.scenario
View file @
0ccc0896
{
"name" : "events_traffic_light_waiting",
"description" : "",
"release" : "0.
2
",
"release" : "0.
3
",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...
...
@@ -55,7 +55,7 @@
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"timeCostAttributes" : {
"standardDe
ri
vation" : 0.7,
"standardDev
i
ation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
...
...
@@ -210,6 +210,18 @@
"y" : 0.0
}
}
}
},
"eventInfos" : [ {
"eventTimeframe" : {
"startTime" : 5.0,
"endTime" : 30.0,
"repeat" : false,
"waitTimeBetweenRepetition" : 0.0
},
"events" : [ {
"type" : "WaitEvent",
"targets" : [ ]
} ]
} ]
}
}
}
\ No newline at end of file
VadereModelTests/TestOSM/scenarios/events_wait_in_area.scenario
View file @
0ccc0896
{
"name" : "events_wait_in_area",
"description" : "",
"release" : "0.
2
",
"release" : "0.
3
",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...
...
@@ -55,7 +55,7 @@
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"timeCostAttributes" : {
"standardDe
ri
vation" : 0.7,
"standardDev
i
ation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
...
...
@@ -194,6 +194,25 @@
"y" : 0.0
}
}
}
},
"eventInfos" : [ {
"eventTimeframe" : {
"startTime" : 5.0,
"endTime" : 30.0,
"repeat" : false,
"waitTimeBetweenRepetition" : 0.0
},
"events" : [ {
"type" : "WaitInAreaEvent",
"targets" : [ ],
"area" : {
"x" : 12.5,
"y" : 0.0,
"width" : 5.0,
"height" : 6.0,
"type" : "RECTANGLE"
}
} ]
} ]
}
}
}
\ No newline at end of file
VadereState/src/org/vadere/state/util/StateJsonConverter.java
View file @
0ccc0896
...
...
@@ -22,6 +22,7 @@ import org.vadere.state.attributes.scenario.AttributesStairs;
import
org.vadere.state.attributes.scenario.AttributesTarget
;
import
org.vadere.state.attributes.scenario.AttributesTeleporter
;
import
org.vadere.state.attributes.scenario.AttributesTopography
;
import
org.vadere.state.events.json.EventInfo
;
import
org.vadere.state.events.json.EventInfoStore
;
import
org.vadere.state.events.types.Event
;
import
org.vadere.state.scenario.Car
;
...
...
@@ -163,6 +164,24 @@ public abstract class StateJsonConverter {
}
}
/**
* Pass a node representing an array of @see EventInfo objects.
*
* Usually, this array is extracted by reading in a scenario file as @see JsonNode
* an you call "get("eventInfos") on this @see JsonNode.
*/
public
static
EventInfoStore
deserializeEventsFromNode
(
JsonNode
node
)
throws
IllegalArgumentException
{
EventInfoStore
eventInfoStore
=
new
EventInfoStore
();
if
(
node
!=
null
)
{
List
<
EventInfo
>
eventInfoList
=
new
ArrayList
<>();
node
.
forEach
(
eventInfoNode
->
eventInfoList
.
add
(
mapper
.
convertValue
(
eventInfoNode
,
EventInfo
.
class
)));
eventInfoStore
.
setEventInfos
(
eventInfoList
);
}
return
eventInfoStore
;
}
public
static
EventInfoStore
deserializeEvents
(
String
json
)
throws
IOException
{
return
mapper
.
readValue
(
json
,
EventInfoStore
.
class
);
}
...
...
Write
Preview
Supports
Markdown
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