Commit 27422176 authored by ZZFTT7's avatar ZZFTT7
Browse files

changes to enable getVehicleHeading

parent aeac2c26
......@@ -44,6 +44,7 @@ import de.tudresden.ws.container.SumoLink;
import de.tudresden.ws.container.SumoLinkList;
import de.tudresden.ws.container.SumoPosition2D;
import de.tudresden.ws.container.SumoStringList;
import edu.emory.mathcs.backport.java.util.Collections;
import it.polito.appeal.traci.SumoTraciConnection;
/**
......@@ -145,6 +146,11 @@ public class TraciSimulationController implements VehicleController, SimulationS
return _positons.get(pVehicleID).getPosition();
}
@Override
public double getVehicleHeading(String pVehicleID) {
return _positons.get(pVehicleID).getHeading();
}
@Override
public Location getVehiclePosition(double pStep, String pVehicleID) {
if (pStep == _step) {
......@@ -743,6 +749,8 @@ public class TraciSimulationController implements VehicleController, SimulationS
public List<Location> getLaneShape(String pLaneID) {
List<Location> positions = new ArrayList<>();
boolean set = true;
SumoCommand laneShapeCommand = Lane.getShape(pLaneID);
SumoGeometry geometry = (SumoGeometry)requestObject(laneShapeCommand);
for (SumoPosition2D location : geometry.coords) {
......@@ -751,11 +759,17 @@ public class TraciSimulationController implements VehicleController, SimulationS
} else {
if (_startX <= location.x && location.x <= _endX && _startY <= location.y && location.y <= _endY) {
positions.add(new PositionVector(location.x - _startX, location.y - _startY));
} else {
set = true;
}
}
}
return positions;
if (set) {
return positions;
} else {
return Collections.emptyList();
}
}
@Override
......
......@@ -210,4 +210,9 @@ public class XMLSimulationController implements VehicleController, SimulationSet
return _vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID).getSpeed();
}
@Override
public double getVehicleHeading(String pVehicleID) {
return _vehicleDataInformationHandler.getVehiclePositions().get(pVehicleID).getHeading();
}
}
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
......@@ -87,6 +87,32 @@ public class DefaultVehicleInformationComponent implements VehicleInformationCom
});
siSComponent.provide().nodeState(SiSTypes.HEADING, new SiSDataCallback<Double>() {
@Override
public Double getValue(INodeID pNodeID,
SiSProviderHandle pProviderHandle)
throws InformationNotAvailableException {
if (pNodeID == getHost().getId()) {
if (isValid()) {
return controller.getVehicleHeading(vehicleID);
}
}
return null;
}
@Override
public Set<INodeID> getObservedNodes() {
return INodeID.getSingleIDSet(getHost().getId());
}
@Override
public SiSInfoProperties getInfoProperties() {
return new SiSInfoProperties();
}
});
if (pRouteKnown) {
siSComponent.provide().nodeState(SiSTypes.ROUTE, new SiSDataCallback<RoadNetworkRoute>() {
......
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