Commit a97e1ed7 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

In "PedestrianSpeedInAreaProcessor", replaced "PedestrianVelocityProcessor" by...

In "PedestrianSpeedInAreaProcessor", replaced "PedestrianVelocityProcessor" by "PedestrianTrajectoryProcessor" to calculate speed.
parent ec398152
Pipeline #113001 passed with stages
in 155 minutes and 3 seconds
{
"name" : "TestProcessor",
"name" : "TestSpeedInAreaProcessor-SpeedByHeight",
"description" : "",
"release" : "0.9",
"processWriters" : {
......@@ -33,20 +33,16 @@
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianVelocityProcessor",
"id" : 5,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianVelocityProcessor",
"attributes" : {
"pedestrianPositionProcessorId" : 1,
"backSteps" : 1
}
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTrajectoryProcessor",
"id" : 5
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianSpeedInAreaProcessor",
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesSpeedInAreaProcessor",
"attributes" : {
"measurementAreaId" : 1,
"pedestrianVelocityProcessorId" : 5
"pedestrianTrajectoryProcessorId" : 5,
"speedCalculationStrategy" : "BY_MEASUREMENT_AREA_HEIGHT"
}
} ],
"isTimestamped" : true,
......
{
"name" : "TestSpeedInAreaProcessor-SpeedByTrajectory",
"description" : "",
"release" : "0.9",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "postvis.trajectories",
"processors" : [ 1, 2, 6 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlaps.csv",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTargetIdProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 4,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTrajectoryProcessor",
"id" : 5
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianSpeedInAreaProcessor",
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesSpeedInAreaProcessor",
"attributes" : {
"measurementAreaId" : 1,
"pedestrianTrajectoryProcessorId" : 5,
"speedCalculationStrategy" : "BY_TRAJECTORY"
}
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"varyStepDirection" : true,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.1,
"minimumStepLength" : true,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : true,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ ]
},
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
},
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT"
}
}
},
"attributesSimulation" : {
"finishTime" : 30.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -4846208968571738224,
"simulationSeed" : 0,
"useSalientBehavior" : false
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 20.0,
"height" : 10.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true
},
"obstacles" : [ ],
"measurementAreas" : [ {
"shape" : {
"x" : 2.8,
"y" : 2.2,
"width" : 7.2,
"height" : 5.9,
"type" : "RECTANGLE"
},
"id" : 1
} ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 17.4,
"y" : 3.7,
"width" : 1.6,
"height" : 3.6,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ ],
"dynamicElements" : [ {
"source" : null,
"targetIds" : [ 1 ],
"position" : {
"x" : 1.0,
"y" : 5.6
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"nextTargetListIndex" : 0,
"freeFlowSpeed" : 1.7573879731780782,
"attributes" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0
},
"idAsTarget" : -1,
"isChild" : false,
"isLikelyInjured" : false,
"mostImportantEvent" : null,
"salientBehavior" : "TARGET_ORIENTED",
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
} ],
"attributesPedestrian" : {
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0
},
"teleporter" : null,
"attributesCar" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0,
"length" : 4.5,
"width" : 1.7,
"direction" : {
"x" : 1.0,
"y" : 0.0
}
}
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
{
"name" : "TestSpeedInAreaProcessor-SpeedByWidth",
"description" : "",
"release" : "0.9",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "postvis.trajectories",
"processors" : [ 1, 2, 6 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlaps.csv",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTargetIdProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 4,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTrajectoryProcessor",
"id" : 5
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianSpeedInAreaProcessor",
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesSpeedInAreaProcessor",
"attributes" : {
"measurementAreaId" : 1,
"pedestrianTrajectoryProcessorId" : 5,
"speedCalculationStrategy" : "BY_MEASUREMENT_AREA_WIDTH"
}
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"varyStepDirection" : true,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.1,
"minimumStepLength" : true,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : true,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ ]
},
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
},
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT"
}
}
},
"attributesSimulation" : {
"finishTime" : 30.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -4846208968571738224,
"simulationSeed" : 0,
"useSalientBehavior" : false
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 20.0,
"height" : 10.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true
},
"obstacles" : [ ],
"measurementAreas" : [ {
"shape" : {
"x" : 2.8,
"y" : 2.2,
"width" : 7.2,
"height" : 5.9,
"type" : "RECTANGLE"
},
"id" : 1
} ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 17.4,
"y" : 3.7,
"width" : 1.6,
"height" : 3.6,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ ],
"dynamicElements" : [ {
"source" : null,
"targetIds" : [ 1 ],
"position" : {
"x" : 1.0,
"y" : 5.6
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"nextTargetListIndex" : 0,
"freeFlowSpeed" : 1.7573879731780782,
"attributes" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0
},
"idAsTarget" : -1,
"isChild" : false,
"isLikelyInjured" : false,
"mostImportantEvent" : null,
"salientBehavior" : "TARGET_ORIENTED",
"groupIds" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"groupSizes" : [ ],
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
} ],
"attributesPedestrian" : {
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0
},
"teleporter" : null,
"attributesCar" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footStepsToStore" : 4,
"searchRadius" : 1.0,
"angleCalculationType" : "USE_CENTER",
"targetOrientationAngleThreshold" : 45.0,
"length" : 4.5,
"width" : 1.7,
"direction" : {
"x" : 1.0,
"y" : 0.0
}
}
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -4,21 +4,19 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdKey;
import org.vadere.state.attributes.processor.AttributesAreaProcessor;
import org.vadere.state.attributes.processor.AttributesPedestrianVelocityProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.attributes.processor.AttributesSpeedInAreaProcessor;
import org.vadere.state.attributes.processor.enums.SpeedCalculationStrategy;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.state.simulation.VTrajectory;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.function.BiFunction;
/**
* Log for each pedestrian the speed within an measurement area.
* Log for each pedestrian the speed within a measurement area.
*
* <pre>
* +--------------------------------------------------+
......@@ -39,7 +37,7 @@ import java.util.stream.Collectors;
*
* Note: If two measurement areas M1 and M2 are disjoint
* and a pedestrian P1 is located within M1, M2 should
* log 0 speed for P1.
* log a speed of -1 for P1.
*
* <pre>
* | timeStep | pedId | ... | M1 | M2 |
......@@ -47,27 +45,34 @@ import java.util.stream.Collectors;
* |1 | 1 | | 0.5 | 0 |
* |1 | 2 | | 0 | 0.6 |
* </pre>
*
* Use the {@link PedestrianTrajectoryProcessor} to access pedestrian's
* trajectory.
*
* This processor offers different methods do calculate pedestrian's speed:
* - ByTrajectory: Use {@link VTrajectory#speed()}, i.e. trajectory.length() / trajectory.duration()
* - ByMeasurementAreaHeight: Use measurementArea.height() / trajectory.duration()
* - ByMeasurementAreaWidth: Use measurementArea.width() / trajectory.duration()
*/
@DataProcessorClass()
public class PedestrianSpeedInAreaProcessor extends DataProcessor<TimestepPedestrianIdKey, Double> {
// Variables
private MeasurementArea measurementArea;
private PedestrianVelocityProcessor pedestrianVelocityProcessor;
private PedestrianTrajectoryProcessor pedestrianTrajectoryProcessor;
private BiFunction<VTrajectory, VRectangle, Double> speedCalculationStrategy;
// Constructors
public PedestrianSpeedInAreaProcessor() {
super("speedInArea");
// "measurementArea" and "pedestrianVelocityProcessor"
// are initialized in "init()" method.
// "init()" method is used by processor manager to initialize variables.
}
// Getter
public MeasurementArea getMeasurementArea() {
return this.measurementArea;
}
public PedestrianVelocityProcessor getPedestrianVelocityProcessor() { return pedestrianVelocityProcessor; }
public PedestrianTrajectoryProcessor getPedestrianTrajectoryProcessor() { return pedestrianTrajectoryProcessor; }
// Methods (overridden)
@Override
......@@ -77,12 +82,31 @@ public class PedestrianSpeedInAreaProcessor extends DataProcessor<TimestepPedest
AttributesSpeedInAreaProcessor processorAttributes = (AttributesSpeedInAreaProcessor) this.getAttributes();
measurementArea = manager.getMeasurementArea(processorAttributes.getMeasurementAreaId());
pedestrianVelocityProcessor = (PedestrianVelocityProcessor) manager.getProcessor(processorAttributes.getPedestrianVelocityProcessorId());
pedestrianTrajectoryProcessor = (PedestrianTrajectoryProcessor) manager.getProcessor(processorAttributes.getPedestrianTrajectoryProcessorId());
if (measurementArea == null)
if (measurementArea == null) {
throw new RuntimeException(String.format("MeasurementArea with index %d does not exist.", processorAttributes.getMeasurementAreaId()));
if (pedestrianVelocityProcessor == null)
throw new RuntimeException(String.format("PedestrianVelocityProcessor with index %d does not exist.", processorAttributes.getPedestrianVelocityProcessorId()));
}
if (measurementArea.getShape() instanceof VRectangle == false) {
throw new RuntimeException("MeasurementArea should be rectangular.");
}
if (pedestrianTrajectoryProcessor == null) {
throw new RuntimeException(String.format("PedestrianVelocityProcessor with index %d does not exist.", processorAttributes.getPedestrianTrajectoryProcessorId()));
}
initSpeedCalculationStrategy(processorAttributes);
}
private void initSpeedCalculationStrategy(AttributesSpeedInAreaProcessor processorAttributes) {
if (processorAttributes.getSpeedCalculationStrategy() == SpeedCalculationStrategy.BY_TRAJECTORY) {
speedCalculationStrategy = this::calculateSpeedByTrajectory;
} else if (processorAttributes.getSpeedCalculationStrategy() == SpeedCalculationStrategy.BY_MEASUREMENT_AREA_HEIGHT) {
speedCalculationStrategy = this::calculateSpeedByMeasurementAreaHeight;
} else if (processorAttributes.getSpeedCalculationStrategy() == SpeedCalculationStrategy.BY_MEASUREMENT_AREA_WIDTH) {
speedCalculationStrategy = this::calculateSpeedByMeasurementAreaWidth;
} else {
throw new RuntimeException("Unsupported speedCalculationStrategy.");
}
}
@Override
......@@ -96,19 +120,44 @@ public class PedestrianSpeedInAreaProcessor extends DataProcessor<TimestepPedest
@Override
protected void doUpdate(final SimulationState state) {
// TODO: "pedestrianVelocityProcessor.doUpdate()" is called by top-level process manager automatically.
// Clarify with Bene if correct update order is always ensured!
// TODO: Clarify with Bene if it ensured, that "pedestrianTrajectoryProcessor.doUpdate()"
// is always invoked automatically by underlying processor manager.
AttributesSpeedInAreaProcessor processorAttributes = (AttributesSpeedInAreaProcessor) this.getAttributes();
for (Pedestrian pedestrian : state.getTopography().getElements(Pedestrian.class)) {
TimestepPedestrianIdKey rowKey = new TimestepPedestrianIdKey(state.getStep(), pedestrian.getId());
double speed = pedestrianVelocityProcessor.getValue(rowKey);
double speed = -1;
if (measurementArea.getShape().contains(pedestrian.getPosition()) == false) {
speed = 0;
if (measurementArea.getShape().contains(pedestrian.getPosition())) {
// Use pedestrian's trajectory to calculate the speed.
VTrajectory wholeTrajectory = pedestrianTrajectoryProcessor.getValue(new PedestrianIdKey(pedestrian.getId()));
VTrajectory cuttedTrajectory = wholeTrajectory.cut(measurementArea.asVRectangle());
speed = speedCalculationStrategy.apply(cuttedTrajectory, measurementArea.asVRectangle());
}
TimestepPedestrianIdKey rowKey = new TimestepPedestrianIdKey(state.getStep(), pedestrian.getId());
this.putValue(rowKey, speed);
}
}
private double calculateSpeedByTrajectory(VTrajectory trajectory, VRectangle measurementArea) {
double speed = Double.NaN;
if (trajectory.speed().isPresent()) {
speed = trajectory.speed().get();
}
return speed;
}
private double calculateSpeedByMeasurementAreaHeight(VTrajectory trajectory, VRectangle measurementArea) {
double speed = (measurementArea.height / trajectory.duration());
return speed;
}
private double calculateSpeedByMeasurementAreaWidth(VTrajectory trajectory, VRectangle measurementArea) {
double speed = measurementArea.width / trajectory.duration();
return speed;
}
}
package org.vadere.state.attributes.processor;
/**
* @author Mario Teixeira Parente
*/
import org.vadere.state.attributes.processor.enums.SpeedCalculationStrategy;
public class AttributesSpeedInAreaProcessor extends AttributesProcessor {