Commit 6c627813 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

Merge branch 'measurementAreaRefactorProcessors_rebased' into 'master'

Measurement area refactor processors rebased

See merge request !55
parents dcffc7d3 83cb5e48
Pipeline #103785 passed with stages
in 137 minutes and 9 seconds
...@@ -25,4 +25,6 @@ public @interface DataProcessorClass { ...@@ -25,4 +25,6 @@ public @interface DataProcessorClass {
String label() default ""; String label() default "";
String description() default ""; String description() default "";
String[] processorFlags() default {};
} }
...@@ -5,6 +5,8 @@ import com.google.auto.service.AutoService; ...@@ -5,6 +5,8 @@ import com.google.auto.service.AutoService;
import org.vadere.annotation.factories.BaseFactoryProcessor; import org.vadere.annotation.factories.BaseFactoryProcessor;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set; import java.util.Set;
import javax.annotation.processing.Processor; import javax.annotation.processing.Processor;
...@@ -12,6 +14,10 @@ import javax.annotation.processing.SupportedAnnotationTypes; ...@@ -12,6 +14,10 @@ import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
@SupportedAnnotationTypes("org.vadere.annotation.factories.dataprocessors.DataProcessorClass") @SupportedAnnotationTypes("org.vadere.annotation.factories.dataprocessors.DataProcessorClass")
@SupportedSourceVersion(SourceVersion.RELEASE_11) @SupportedSourceVersion(SourceVersion.RELEASE_11)
...@@ -32,10 +38,23 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor { ...@@ -32,10 +38,23 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor {
protected void addLastConstructor(Set<? extends Element> elements, PrintWriter writer) { protected void addLastConstructor(Set<? extends Element> elements, PrintWriter writer) {
for (Element e : elements) { for (Element e : elements) {
writer.append(" addMember("); writer.append(" addMember(");
writer.append(e.getSimpleName().toString()).append(".class, ");
writer.append("this::").append("get").append(name(e)).append(", "); writer.append("this::").append("get").append(name(e)).append(", ");
writer.append(quote(label(e))).append(", "); writer.append(quote(label(e))).append(", ");
writer.append(quote(descr(e))).println("); "); writer.append(quote(descr(e))).append(", ");
writer.append(e.getSimpleName().toString()).append(".class");
//if flags are provides here...
String[] flags = processorFlags(e);
if (flags.length > 0){
writer.append(", ");
for (int i = 0; i < flags.length -1; i++) {
writer.append(quote(flags[i])).append(", ");
}
writer.append(quote(flags[flags.length-1]));
writer.println("); ");
} else {
writer.println("); ");
}
} }
} }
...@@ -76,4 +95,29 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor { ...@@ -76,4 +95,29 @@ public class DataProcessorFactoryProcessor extends BaseFactoryProcessor {
return dataProcessorClass.description(); return dataProcessorClass.description();
} }
private String[] processorFlags(Element element){
DataProcessorClass dataProcessorClass = element.getAnnotation(DataProcessorClass.class);
Elements elementUtil = processingEnv.getElementUtils();
Types typeUtil = processingEnv.getTypeUtils();
ArrayList<String> flags = new ArrayList<>();
TypeMirror processorFlag = elementUtil
.getTypeElement("org.vadere.simulator.projects.dataprocessing.flags.ProcessorFlag")
.asType();
// cast possible becuse element is a class
TypeElement e = (TypeElement)element;
for (TypeMirror anInterface : e.getInterfaces()) {
if (typeUtil.isAssignable(anInterface, processorFlag)){
flags.add(typeUtil.asElement(anInterface).getSimpleName().toString());
}
}
flags.addAll(Arrays.asList(dataProcessorClass.processorFlags()));
return flags.toArray(String[]::new);
}
} }
...@@ -7,10 +7,10 @@ import java.lang.annotation.Target; ...@@ -7,10 +7,10 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@FactoryType( @FactoryType(
factoryClassName = "JoltTransformationFactory", factoryClassName = "JsonTransformationFactory",
extendedClassName = "JoltTransformationBaseFactory", extendedClassName = "JsonTransformationBaseFactory",
factoryImports = {"org.vadere.simulator.projects.migration.jolttranformation.JoltTransformationBaseFactory"}, factoryImports = {"org.vadere.simulator.projects.migration.jsontranformation.JsonTransformationBaseFactory"},
factoryPackage = "org.vadere.simulator.projects.migration.jolttranformation" factoryPackage = "org.vadere.simulator.projects.migration.jsontranformation"
) )
public @interface MigrationTransformation { public @interface MigrationTransformation {
......
{ {
"name" : "Neues_Szenario", "name" : "Neues_Szenario",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "warning: no commit hash", "commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
...@@ -75,20 +75,8 @@ ...@@ -75,20 +75,8 @@
"id" : 6, "id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor", "attributesType" : "org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor",
"attributes" : { "attributes" : {
"measurementArea" : { "measurementAreaId" : 1,
"x" : 5.0, "voronoiMeasurementAreaId" : 1
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"voronoiArea" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
} }
}, { }, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.AreaSpeedProcessor", "type" : "org.vadere.simulator.projects.dataprocessing.processor.AreaSpeedProcessor",
...@@ -148,26 +136,14 @@ ...@@ -148,26 +136,14 @@
"id" : 15, "id" : 15,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingTimeProcessor", "attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingTimeProcessor",
"attributes" : { "attributes" : {
"waitingArea" : { "waitingAreaId" : 1
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
} }
}, { }, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianWaitingEndTimeProcessor", "type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianWaitingEndTimeProcessor",
"id" : 16, "id" : 16,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor", "attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor",
"attributes" : { "attributes" : {
"waitingArea" : { "waitingAreaId" : 1
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
}
} }
}, { }, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOSMStrideLengthProcessor", "type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOSMStrideLengthProcessor",
...@@ -341,7 +317,17 @@ ...@@ -341,7 +317,17 @@
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"dynamicElements" : [ ], "dynamicElements" : [ ],
"attributesCar" : null "attributesCar" : null,
"measurementAreas" : [ {
"shape" : {
"x" : 5.0,
"y" : 2.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"id" : 1
} ]
} }
} }
} }
\ No newline at end of file
{ {
"name" : "01_unsupported_event_exception_for_unsupported_models", "name" : "01_unsupported_event_exception_for_unsupported_models",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "02_bang_event_one_agent", "name" : "02_bang_event_one_agent",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "03_bang_event_multiple_agents", "name" : "03_bang_event_multiple_agents",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "04_bang_event_one_agent_one_obstacle", "name" : "04_bang_event_one_agent_one_obstacle",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
}, },
"id" : -1 "id" : -1
} ], } ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "05_bang_event_narrowed_street", "name" : "05_bang_event_narrowed_street",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -834,6 +834,7 @@ ...@@ -834,6 +834,7 @@
}, },
"id" : -1 "id" : -1
} ], } ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "06_bang_event_guimaraes_platz", "name" : "06_bang_event_guimaraes_platz",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -1086,6 +1086,7 @@ ...@@ -1086,6 +1086,7 @@
}, },
"id" : -1 "id" : -1
} ], } ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "01_wait_event_osm_sequential", "name" : "01_wait_event_osm_sequential",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "02_wait_event_osm_event_driven", "name" : "02_wait_event_osm_event_driven",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "03_wait_event_recurring_osm_sequential", "name" : "03_wait_event_recurring_osm_sequential",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "04_wait_in_area_event_osm_sequential", "name" : "04_wait_in_area_event_osm_sequential",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "05_wait_in_area_event_bhm", "name" : "05_wait_in_area_event_bhm",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "06_bang_event_osm_sequential", "name" : "06_bang_event_osm_sequential",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "07_bang_event_osm_event_driven", "name" : "07_bang_event_osm_event_driven",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.8",
"commithash" : "3d1bcfd83a7d3848a4dd5baa50e802a2dce0c3e7",
"processWriters" : { "processWriters" : {
"files" : [ { "files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile", "type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...@@ -129,6 +128,7 @@ ...@@ -129,6 +128,7 @@
"bounded" : true "bounded" : true
}, },
"obstacles" : [ ], "obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ], "stairs" : [ ],
"targets" : [ { "targets" : [ {
"id" : 1, "id" : 1,
......
{ {
"name" : "basic_1_chicken_gnm1", "name" : "basic_1_chicken_gnm1",