Commit 0ccc0896 authored by Benedikt Kleinmeier's avatar 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
{
"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" : {
"standardDerivation" : 0.7,
"standardDeviation" : 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
{
"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" : {
"standardDerivation" : 0.7,
"standardDeviation" : 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
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment