In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Commit be7b6ad2 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

add getCoordinateReference to simulation api

parent 285a9beb
Pipeline #312156 passed with stages
in 126 minutes and 14 seconds
......@@ -471,6 +471,11 @@ public class TestClient extends org.vadere.manager.client.AbstractTestClient imp
}
@Override
public void simulationapi_getCoordinateReference(String[] args) throws IOException {
}
@Override
public void simulationapi_getTime(String[] args) throws IOException {
TraCIResponse res = simulationapi.getTime();
......
......@@ -16,6 +16,7 @@ import org.vadere.manager.traci.commands.TraCISetCommand;
import org.vadere.manager.traci.commands.get.TraCIGetCacheHashCommand;
import org.vadere.manager.traci.commands.get.TraCIGetCompoundPayload;
import org.vadere.manager.traci.compound.CompoundObject;
import org.vadere.manager.traci.compound.object.CoordRef;
import org.vadere.manager.traci.compound.object.PointConverter;
import org.vadere.manager.traci.compound.object.SimulationCfg;
import org.vadere.manager.traci.response.TraCIGetResponse;
......@@ -250,6 +251,23 @@ public class SimulationCommandHandler extends CommandHandler<SimulationVar> {
}
@SimulationHandler(cmd = TraCICmd.GET_SIMULATION_VALUE, var = SimulationVar.COORD_REF,
name = "getCoordinateReference", dataTypeStr = "ArrayList<String>", ignoreElementId = true)
public TraCICommand process_GetCoordinateReference(TraCIGetCommand cmd, RemoteManager remoteManager){
remoteManager.accessState((manager, state) -> {
ReferenceCoordinateSystem coord =
state.getScenarioStore().getTopography()
.getAttributes().getReferenceCoordinateSystem();
coord.initialize();
CompoundObject o = CoordRef.asCompoundObject(
coord.getEpsgCode(),
coord.getTranslation()
);
cmd.setResponse(responseOK(SimulationVar.COORD_REF.type, o));
});
return cmd;
}
public TraCICommand processValueSub(TraCICommand rawCmd, RemoteManager remoteManager) {
......
......@@ -21,6 +21,7 @@ public enum SimulationVar {
VEHICLES_END_TELEPORT_IDS(0x78, TraCIDataType.STRING_LIST),
VEHICLES_START_PARKING_IDS(0x6d, TraCIDataType.STRING_LIST),
VEHICLES_STOP_PARKING_IDS(0x6f, TraCIDataType.STRING_LIST),
COORD_REF(0x90, TraCIDataType.COMPOUND_OBJECT),
//
NETWORK_BOUNDING_BOX_2D(0x7c, TraCIDataType.POLYGON),
CACHE_HASH(0x7d, TraCIDataType.STRING),
......
package org.vadere.manager.traci.compound.object;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.manager.traci.compound.CompoundObject;
import org.vadere.manager.traci.compound.CompoundObjectBuilder;
import org.vadere.util.geometry.Vector3D;
import org.vadere.util.geometry.shapes.VPoint;
public class CoordRef {
private String epgsCode;
private VPoint offset;
public CoordRef(CompoundObject obj){
if (obj.size() != 3){
throw new TraCIException("Expected 4 elements for PointConverter");
}
epgsCode = (String) obj.getData(0, TraCIDataType.STRING);
VPoint p = new VPoint();
p.x = (Double) obj.getData(1, TraCIDataType.DOUBLE);
p.y = (Double) obj.getData(2, TraCIDataType.DOUBLE);
offset = p;
}
public CoordRef(String epgsCode, VPoint offset) {
this.epgsCode = epgsCode;
this.offset = offset;
}
public static CompoundObject asCompoundObject(String epgsCode,
VPoint offset){
return CompoundObjectBuilder.builder()
.rest()
.add(TraCIDataType.STRING)
.add(TraCIDataType.DOUBLE, 2)
.build(epgsCode, offset.x, offset.y);
}
}
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