Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
vadere
vadere
Commits
4949ad47
Commit
4949ad47
authored
May 22, 2019
by
Benedikt Kleinmeier
Browse files
Refactored "TrajectoryReader".
parent
b362f17f
Changes
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/projects/io/TrajectoryReader.java
View file @
4949ad47
...
...
@@ -73,7 +73,7 @@ public class TrajectoryReader {
private
int
mostImportantEventIndex
;
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
)
{
this
(
trajectoryFilePath
,
scenario
.
getAttributesPedestrian
());
...
...
@@ -112,16 +112,16 @@ public class TrajectoryReader {
mostImportantEventKeys
.
add
(
"mostImportantEvent"
);
salientBehaviorKeys
.
add
(
"salientBehavior"
);
pedIdIndex
=
notSetColumnIndexIdentifier
;
stepIndex
=
notSetColumnIndexIdentifier
;
xIndex
=
notSetColumnIndexIdentifier
;
yIndex
=
notSetColumnIndexIdentifier
;
targetIdIndex
=
notSetColumnIndexIdentifier
;
groupIdIndex
=
notSetColumnIndexIdentifier
;
groupSizeIndex
=
notSetColumnIndexIdentifier
;
stridesIndex
=
notSetColumnIndexIdentifier
;
mostImportantEventIndex
=
notSetColumnIndexIdentifier
;
salientBehaviorIndex
=
notSetColumnIndexIdentifier
;
pedIdIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
stepIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
xIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
yIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
targetIdIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
groupIdIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
groupSizeIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
stridesIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
mostImportantEventIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
salientBehaviorIndex
=
NOT_SET_COLUMN_INDEX_IDENTIFIER
;
}
public
Map
<
Step
,
List
<
Agent
>>
readFile
()
throws
IOException
{
...
...
@@ -130,7 +130,7 @@ public class TrajectoryReader {
}
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 "
+
"unwanted side effects"
);
}
...
...
@@ -185,12 +185,13 @@ public class TrajectoryReader {
}
}
if
(!
(
pedIdIndex
!=
notSetColumnIndexIdentifier
&&
xIndex
!=
notSetColumnIndexIdentifier
&&
yIndex
!=
notSetColumnIndexIdentifier
&&
stepIndex
!=
notSetColumnIndexIdentifier
))
{
// load default values with no groups
throw
new
IOException
(
String
.
format
(
"All columns with "
+
notSetColumnIndexIdentifier
+
" value could "
+
"not be found in the trajectory file pedIdIndex=%d, x-values=%d, y-values=%d, step "
+
"values=%d"
,
pedIdIndex
,
xIndex
,
yIndex
,
stepIndex
));
if
(
pedIdIndex
==
NOT_SET_COLUMN_INDEX_IDENTIFIER
||
xIndex
==
NOT_SET_COLUMN_INDEX_IDENTIFIER
||
yIndex
==
NOT_SET_COLUMN_INDEX_IDENTIFIER
||
stepIndex
==
NOT_SET_COLUMN_INDEX_IDENTIFIER
)
{
throw
new
IOException
(
String
.
format
(
"No valid header found in output file: "
+
"pedIdIndex=%d, x-values=%d, y-values=%d, step values=%d"
,
pedIdIndex
,
xIndex
,
yIndex
,
stepIndex
));
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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