11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit 4949ad47 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Refactored "TrajectoryReader".

parent b362f17f
...@@ -73,7 +73,7 @@ public class TrajectoryReader { ...@@ -73,7 +73,7 @@ public class TrajectoryReader {
private int mostImportantEventIndex; private int mostImportantEventIndex;
private int salientBehaviorIndex; private int salientBehaviorIndex;
private static final int notSetColumnIndexIdentifier = -1; private static final int NOT_SET_COLUMN_INDEX_IDENTIFIER = -1;
public TrajectoryReader(final Path trajectoryFilePath, final Scenario scenario) { public TrajectoryReader(final Path trajectoryFilePath, final Scenario scenario) {
this(trajectoryFilePath, scenario.getAttributesPedestrian()); this(trajectoryFilePath, scenario.getAttributesPedestrian());
...@@ -112,16 +112,16 @@ public class TrajectoryReader { ...@@ -112,16 +112,16 @@ public class TrajectoryReader {
mostImportantEventKeys.add("mostImportantEvent"); mostImportantEventKeys.add("mostImportantEvent");
salientBehaviorKeys.add("salientBehavior"); salientBehaviorKeys.add("salientBehavior");
pedIdIndex = notSetColumnIndexIdentifier; pedIdIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
stepIndex = notSetColumnIndexIdentifier; stepIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
xIndex = notSetColumnIndexIdentifier; xIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
yIndex = notSetColumnIndexIdentifier; yIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
targetIdIndex = notSetColumnIndexIdentifier; targetIdIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
groupIdIndex = notSetColumnIndexIdentifier; groupIdIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
groupSizeIndex = notSetColumnIndexIdentifier; groupSizeIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
stridesIndex = notSetColumnIndexIdentifier; stridesIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
mostImportantEventIndex = notSetColumnIndexIdentifier; mostImportantEventIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
salientBehaviorIndex = notSetColumnIndexIdentifier; salientBehaviorIndex = NOT_SET_COLUMN_INDEX_IDENTIFIER;
} }
public Map<Step, List<Agent>> readFile() throws IOException { public Map<Step, List<Agent>> readFile() throws IOException {
...@@ -130,7 +130,7 @@ public class TrajectoryReader { ...@@ -130,7 +130,7 @@ public class TrajectoryReader {
} }
private void errorWhenNotUniqueColumn(int currentValue, String columnName) throws IOException{ private void errorWhenNotUniqueColumn(int currentValue, String columnName) throws IOException{
if(currentValue != notSetColumnIndexIdentifier){ if(currentValue != NOT_SET_COLUMN_INDEX_IDENTIFIER){
throw new IOException("The header " + columnName + " is not unique in the file. This is likely to have " + throw new IOException("The header " + columnName + " is not unique in the file. This is likely to have " +
"unwanted side effects"); "unwanted side effects");
} }
...@@ -185,12 +185,13 @@ public class TrajectoryReader { ...@@ -185,12 +185,13 @@ public class TrajectoryReader {
} }
} }
if (! (pedIdIndex != notSetColumnIndexIdentifier && xIndex != notSetColumnIndexIdentifier && if (pedIdIndex == NOT_SET_COLUMN_INDEX_IDENTIFIER
yIndex != notSetColumnIndexIdentifier && stepIndex != notSetColumnIndexIdentifier)) { || xIndex == NOT_SET_COLUMN_INDEX_IDENTIFIER
// load default values with no groups || yIndex == NOT_SET_COLUMN_INDEX_IDENTIFIER
throw new IOException(String.format("All columns with " + notSetColumnIndexIdentifier + " value could " + || stepIndex == NOT_SET_COLUMN_INDEX_IDENTIFIER) {
"not be found in the trajectory file pedIdIndex=%d, x-values=%d, y-values=%d, step " + throw new IOException(String.format("No valid header found in output file: " +
"values=%d", pedIdIndex, xIndex, yIndex, stepIndex)); "pedIdIndex=%d, x-values=%d, y-values=%d, step values=%d",
pedIdIndex, xIndex, yIndex, stepIndex));
} }
} }
......
Markdown is supported
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