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
6c75b16b
Commit
6c75b16b
authored
May 14, 2019
by
Daniel Lehmberg
Browse files
adapt mock in test and clean code
parent
4bd57b11
Pipeline
#113071
passed with stages
in 139 minutes and 17 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/ProcessorManager.java
View file @
6c75b16b
...
...
@@ -63,7 +63,7 @@ public class ProcessorManager {
}
if
(
requireRectangular
&&
!
measurementArea
.
isRectangular
())
{
throw
new
RuntimeException
(
"DataProcessor only supports R
ectangular measurement
a
rea
s."
);
throw
new
RuntimeException
(
String
.
format
(
"Measurement area for %d is required to be r
ectangular
"
,
measurement
A
rea
Id
)
);
}
return
measurementArea
;
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/AreaDensityVoronoiAlgorithm.java
View file @
6c75b16b
...
...
@@ -35,27 +35,27 @@ public class AreaDensityVoronoiAlgorithm extends AreaDensityAlgorithm {
// compute everything
List
<
Face
>
faces
=
generateFaces
(
state
);
double
area
=
0.0
;
int
pedCount
=
0
;
double
area
=
0.0
;
int
pedCount
=
0
;
for
(
Face
face
:
faces
)
{
if
(
this
.
measurementArea
.
contains
(
face
.
getSite
()))
{
area
+=
face
.
computeArea
();
pedCount
++;
area
+=
face
.
computeArea
();
pedCount
++;
}
}
return
pedCount
>
0
?
pedCount
/
area
:
0
;
}
private
List
<
Face
>
generateFaces
(
@NotNull
final
SimulationState
state
)
{
VoronoiDiagram
voronoiDiagram
=
new
VoronoiDiagram
(
this
.
voronoiArea
);
private
List
<
Face
>
generateFaces
(
@NotNull
final
SimulationState
state
)
{
VoronoiDiagram
voronoiDiagram
=
new
VoronoiDiagram
(
this
.
voronoiArea
);
// convert pedestrians to positions
List
<
VPoint
>
pedestrianPositions
=
Agent
.
getPositions
(
state
.
getTopography
().
getElements
(
Agent
.
class
));
voronoiDiagram
.
computeVoronoiDiagram
(
pedestrianPositions
);
// convert pedestrians to positions
List
<
VPoint
>
pedestrianPositions
=
Agent
.
getPositions
(
state
.
getTopography
().
getElements
(
Agent
.
class
));
voronoiDiagram
.
computeVoronoiDiagram
(
pedestrianPositions
);
// compute everything
List
<
Face
>
faces
=
voronoiDiagram
.
getFaces
();
return
faces
==
null
?
Collections
.
emptyList
()
:
faces
;
}
// compute everything
List
<
Face
>
faces
=
voronoiDiagram
.
getFaces
();
return
faces
==
null
?
Collections
.
emptyList
()
:
faces
;
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/AreaDensityVoronoiProcessor.java
View file @
6c75b16b
...
...
@@ -7,6 +7,9 @@ import org.vadere.state.attributes.processor.AttributesProcessor;
import
org.vadere.annotation.factories.dataprocessors.DataProcessorClass
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.util.factory.processors.Flag
;
import
java.util.List
;
/**
* @author Mario Teixeira Parente
...
...
@@ -23,11 +26,12 @@ public class AreaDensityVoronoiProcessor extends AreaDensityProcessor implements
@Override
public
void
init
(
final
ProcessorManager
manager
)
{
super
.
init
(
manager
);
AttributesAreaDensityVoronoiProcessor
att
=
(
AttributesAreaDensityVoronoiProcessor
)
this
.
getAttributes
();
MeasurementArea
measurementArea
=
manager
.
getMeasurementArea
(
att
.
getMeasurementAreaId
(),
true
);
MeasurementArea
measurementVoronoiArea
=
manager
.
getMeasurementArea
(
att
.
getVoronoiMeasurementAreaId
(),
true
);
this
.
setAlgorithm
(
new
AreaDensityVoronoiAlgorithm
(
this
.
getM
easurementArea
()
,
measurementArea
));
this
.
setAlgorithm
(
new
AreaDensityVoronoiAlgorithm
(
m
easurement
Voronoi
Area
,
measurementArea
));
}
@Override
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/AreaSpeedProcessor.java
View file @
6c75b16b
...
...
@@ -43,7 +43,8 @@ public class AreaSpeedProcessor extends AreaDataProcessor<Double> {
final
int
pedId
=
entry
.
getKey
().
getPedestrianId
();
final
VPoint
pos
=
entry
.
getValue
();
if
(
getMeasurementArea
().
asVRectangle
().
contains
(
pos
))
{
//getMeasurementArea from AreaDataProcessor
if
(
this
.
getMeasurementArea
().
getShape
().
contains
(
pos
))
{
sumVelocities
+=
this
.
pedVelProc
.
getValue
(
new
TimestepPedestrianIdKey
(
step
,
pedId
));
pedCount
++;
}
...
...
VadereSimulator/tests/org/vadere/simulator/projects/dataprocessing/processor/AreaDensityVoronoiProcessorTestEnv.java
View file @
6c75b16b
...
...
@@ -36,6 +36,7 @@ public class AreaDensityVoronoiProcessorTestEnv extends ProcessorTestEnv<Timeste
attr
.
setMeasurementAreaId
(
42
);
MeasurementArea
measurementArea
=
new
MeasurementArea
(
new
AttributesMeasurementArea
(
42
,
new
VRectangle
(
0
,
0
,
16
,
16
)));
Mockito
.
when
(
manager
.
getMeasurementArea
(
42
,
false
)).
thenReturn
(
measurementArea
);
Mockito
.
when
(
manager
.
getMeasurementArea
(
42
,
true
)).
thenReturn
(
measurementArea
);
}
...
...
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