You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by mi...@apache.org on 2020/05/12 18:37:57 UTC

[incubator-streampipes-extensions] branch feature/trajectory created (now 9e7a465)

This is an automated email from the ASF dual-hosted git repository.

micklich pushed a change to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git.


      at 9e7a465  fix STREAMPIPES-123

This branch includes the following new commits:

     new 285c684  added PE
     new f40542f  extended Geometry helper with WKT Reader
     new 0cfd6dc  changed javadoc
     new 225f3eb  trajectory class misc changes (spelling javadoc)
     new 3c2a94a  ontologie
     new 8baaf58  rewrite from labels.from to label.withID
     new c80f858  format code
     new e1fe029  added PE
     new 156b8ca  extended Geometry helper with WKT Reader
     new 1ec0b51  changed javadoc
     new c85b086  trajectory class misc changes (spelling javadoc)
     new 6de2600  ontologie
     new 4526f8c  rewrite from labels.from to label.withID
     new 9c7f951  format code
     new 00bb22f  fix error in extraction and output strategy
     new 3ac10f4  Merge remote-tracking branch 'origin/feature/trajectory' into feature/trajectory
     new 9e7a465  fix STREAMPIPES-123

The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-streampipes-extensions] 05/17: ontologie

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 3c2a94a3df09e3907bc234d666bebc259b9d2f04
Author: micklich <fl...@disy.net>
AuthorDate: Mon May 11 16:34:59 2020 +0200

    ontologie
---
 .../processor/trajectory/CreateTrajectoryFromPointsController.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index 490007f..654a907 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -56,14 +56,14 @@ public class CreateTrajectoryFromPointsController extends  StandaloneEventProces
                         StreamRequirementsBuilder
                                 .create()
                                 .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.stringReq(),
+                                        EpRequirements.domainPropertyReq("http://www.opengis.net/spec/geosparql/1.0#wktLiteral"),
                                         Labels.from(WKT,
                                                 "Geometry WKT",
                                                 "WKT of the requested Geometry"),
                                         PropertyScope.NONE
                                 )
                                 .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.numberReq(),
+                                        EpRequirements.domainPropertyReq("http://streampipes.org/epsg"),
                                         Labels.from(EPSG, "EPSG Field", "EPSG Code for SRID"),
                                         PropertyScope.NONE
                                 )


[incubator-streampipes-extensions] 07/17: format code

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit c80f858a04295debc5dac4d4dd8c3bf0801fa2d7
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 10:14:10 2020 +0200

    format code
---
 .../trajectory/CreateTrajectoryFromPoints.java     |  68 +++++----
 .../CreateTrajectoryFromPointsController.java      | 161 ++++++++++-----------
 .../CreateTrajectoryFromPointsParameter.java       |  69 +++++----
 3 files changed, 146 insertions(+), 152 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
index 26a695e..5ccb42e 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
@@ -31,52 +31,50 @@ import org.locationtech.jts.geom.Point;
 
 public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajectoryFromPointsParameter> {
 
-    private static Logger LOG;
+  private static Logger LOG;
 
-    private SpTrajectoryBuilder trajectory;
+  private SpTrajectoryBuilder trajectory;
 
-    private String geom_wkt;
-    private String epsg_code;
-    private String m_value;
+  private String geom_wkt;
+  private String epsg_code;
+  private String m_value;
 
+  @Override
+  public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
 
-    @Override
-    public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
+    LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
+    this.geom_wkt = params.getWkt();
+    this.epsg_code = params.getEpsg();
+    this.m_value = params.getM();
 
-        LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
-        this.geom_wkt =  params.getWkt();
-        this.epsg_code = params.getEpsg();
-        this.m_value = params.getM();
+    trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
+  }
 
-        trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
-    }
+  @Override
+  public void onEvent(Event in, SpOutputCollector out) {
 
-    @Override
-    public void onEvent(Event in, SpOutputCollector out) {
+    // extract values
+    String wkt = in.getFieldBySelector(geom_wkt).getAsPrimitive().getAsString();
+    Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
+    Integer m = in.getFieldBySelector(m_value).getAsPrimitive().getAsInt();
 
-        // extract values
-        String wkt = in.getFieldBySelector(geom_wkt).getAsPrimitive().getAsString();
-        Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
-        Integer m = in.getFieldBySelector(m_value).getAsPrimitive().getAsInt();
+    //create JTS geometry
+    Point eventGeom = (Point) SpGeometryBuilder.createSPGeom(wkt, epsg);
 
-        //create JTS geometry
-        Point eventGeom =  (Point) SpGeometryBuilder.createSPGeom(wkt,epsg);
+    //adds point and m value to trajectory object
+    trajectory.addPointToTrajectory(eventGeom, m);
+    // returns JTS LineString
+    LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
 
-        //adds point and m value to trajectory object
-        trajectory.addPointToTrajectory(eventGeom, m);
-        // returns JTS LineString
-        LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
+    // adds to stream
+    in.addField("wkt-trajectory", geom.toString());
+    in.addField("description", trajectory.getDescription());
+    out.collect(in);
+  }
 
-        // adds to stream
-        in.addField("wkt-trajectory", geom.toString());
-        in.addField("description", trajectory.getDescription());
-        out.collect(in);
+  @Override
+  public void onDetach() {
 
-    }
-
-    @Override
-    public void onDetach() {
-
-    }
+  }
 }
 
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index a94140c..e3c3021 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -31,86 +31,83 @@ import org.apache.streampipes.vocabulary.SO;
 import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
 import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
 
-public class CreateTrajectoryFromPointsController extends  StandaloneEventProcessingDeclarer<CreateTrajectoryFromPointsParameter> {
-
-
-
-
-    public final static String POINT_KEY = "point-key";
-    public final static String EPSG_KEY = "epsg-key";
-    public final static String M_KEY = "m-key";
-    public final static String DESCRIPTION_KEY = "description-key";
-    public final static String SUBPOINTS_KEY = "subpoints-key";
-
-    public final static String WKT = "trajectory_wkt";
-    public final static String EPA_NAME = "Create Single Trajectory";
-
-
-    @Override
-    public DataProcessorDescription declareModel() {
-      return ProcessingElementBuilder
-          .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory")
-          .category(DataProcessorType.GEO)
-          .withAssets(Assets.DOCUMENTATION, Assets.ICON)
-          .withLocales(Locales.EN)
-          .requiredStream(
-              StreamRequirementsBuilder
-                  .create()
-                  .requiredPropertyWithUnaryMapping(
-                      EpRequirements.domainPropertyReq("http://www.opengis.net/ont/geosparql#Geometry"),
-                      Labels.withId(POINT_KEY), PropertyScope.MEASUREMENT_PROPERTY
-                  )
-                  .requiredPropertyWithUnaryMapping(
-                      EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
-                      Labels.withId(EPSG_KEY), PropertyScope.MEASUREMENT_PROPERTY
-                  )
-                  .requiredPropertyWithUnaryMapping(
-                      EpRequirements.numberReq(),
-                      Labels.withId(M_KEY),  PropertyScope.MEASUREMENT_PROPERTY
-                  )
-                  .build()
-          )
-          .requiredTextParameter(
-              Labels.withId(DESCRIPTION_KEY)
-          )
-          .requiredIntegerParameter(
-              Labels.withId(SUBPOINTS_KEY),
-              2, 30, 1
-          )
-
-          .outputStrategy(OutputStrategies.append(
-              EpProperties.numberEp(
-                  Labels.withId(M_KEY),
-                  "m-value",
-                  SO.Number
-              ),
-              EpProperties.numberEp(
-                  Labels.withId(WKT),
-                  "trajectory-wkt",
-                  "http://www.opengis.net/ont/geosparql#Geometry")
-              )
-          )
-
-          .supportedFormats(SupportedFormats.jsonFormat())
-          .supportedProtocols(SupportedProtocols.kafka())
-          .build();
-    }
-
-
-    @Override
-    public ConfiguredEventProcessor<CreateTrajectoryFromPointsParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
-
-
-        String wkt = extractor.mappingPropertyValue(WKT);
-        String epsg = extractor.mappingPropertyValue(EPSG_KEY);
-        String m = extractor.mappingPropertyValue(M_KEY);
-
-        String description = extractor.singleValueParameter(DESCRIPTION_KEY, String.class);
-        Integer subpoints = extractor.singleValueParameter(SUBPOINTS_KEY, Integer.class);
-
-
-        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg, description, subpoints, m);
-
-        return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
-    }
+public class CreateTrajectoryFromPointsController extends StandaloneEventProcessingDeclarer<CreateTrajectoryFromPointsParameter> {
+
+
+  public final static String POINT_KEY = "point-key";
+  public final static String EPSG_KEY = "epsg-key";
+  public final static String M_KEY = "m-key";
+  public final static String DESCRIPTION_KEY = "description-key";
+  public final static String SUBPOINTS_KEY = "subpoints-key";
+
+  public final static String WKT = "trajectory_wkt";
+
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return ProcessingElementBuilder
+        .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory")
+        .category(DataProcessorType.GEO)
+        .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+        .withLocales(Locales.EN)
+        .requiredStream(
+            StreamRequirementsBuilder
+                .create()
+                .requiredPropertyWithUnaryMapping(
+                    EpRequirements.domainPropertyReq("http://www.opengis.net/ont/geosparql#Geometry"),
+                    Labels.withId(POINT_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                )
+                .requiredPropertyWithUnaryMapping(
+                    EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
+                    Labels.withId(EPSG_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                )
+                .requiredPropertyWithUnaryMapping(
+                    EpRequirements.numberReq(),
+                    Labels.withId(M_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                )
+                .build()
+        )
+        .requiredTextParameter(
+            Labels.withId(DESCRIPTION_KEY)
+        )
+        .requiredIntegerParameter(
+            Labels.withId(SUBPOINTS_KEY),
+            2, 30, 1
+        )
+
+        .outputStrategy(OutputStrategies.append(
+            EpProperties.numberEp(
+                Labels.withId(M_KEY),
+                "m-value",
+                SO.Number
+            ),
+            EpProperties.numberEp(
+                Labels.withId(WKT),
+                "trajectory-wkt",
+                "http://www.opengis.net/ont/geosparql#Geometry")
+            )
+        )
+
+        .supportedFormats(SupportedFormats.jsonFormat())
+        .supportedProtocols(SupportedProtocols.kafka())
+        .build();
+  }
+
+
+  @Override
+  public ConfiguredEventProcessor<CreateTrajectoryFromPointsParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
+
+
+    String wkt = extractor.mappingPropertyValue(WKT);
+    String epsg = extractor.mappingPropertyValue(EPSG_KEY);
+    String m = extractor.mappingPropertyValue(M_KEY);
+
+    String description = extractor.singleValueParameter(DESCRIPTION_KEY, String.class);
+    Integer subpoints = extractor.singleValueParameter(SUBPOINTS_KEY, Integer.class);
+
+
+    CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg, description, subpoints, m);
+
+    return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
+  }
 }
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
index 0397ac5..872fb00 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
@@ -23,39 +23,38 @@ import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams
 
 public class CreateTrajectoryFromPointsParameter extends EventProcessorBindingParams {
 
-    private String epsg;
-    private String wkt;
-    private String description;
-    private Integer subpoints;
-    private String m;
-
-
-    public CreateTrajectoryFromPointsParameter(DataProcessorInvocation graph, String wkt, String epsg, String description, Integer subpoints, String m) {
-        super(graph);
-        this.wkt = wkt;
-        this.epsg = epsg;
-        this.description = description;
-        this.subpoints = subpoints;
-        this.m = m;
-    }
-
-    public String getEpsg() {
-        return epsg;
-    }
-
-    public String getWkt() {
-        return wkt;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public Integer getSubpoints() {
-        return subpoints;
-    }
-
-    public String getM() {
-        return m;
-    }
+  private String epsg;
+  private String wkt;
+  private String description;
+  private Integer subpoints;
+  private String m;
+
+  public CreateTrajectoryFromPointsParameter(DataProcessorInvocation graph, String wkt, String epsg, String description, Integer subpoints, String m) {
+    super(graph);
+    this.wkt = wkt;
+    this.epsg = epsg;
+    this.description = description;
+    this.subpoints = subpoints;
+    this.m = m;
+  }
+
+  public String getEpsg() {
+    return epsg;
+  }
+
+  public String getWkt() {
+    return wkt;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public Integer getSubpoints() {
+    return subpoints;
+  }
+
+  public String getM() {
+    return m;
+  }
 }


[incubator-streampipes-extensions] 15/17: fix error in extraction and output strategy

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 00bb22fdc023dc08189442f2a90e9b7ad3678232
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 13:02:03 2020 +0200

    fix error in extraction and output strategy
---
 .../processor/trajectory/CreateTrajectoryFromPointsController.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index e3c3021..16d6e4f 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -81,7 +81,7 @@ public class CreateTrajectoryFromPointsController extends StandaloneEventProcess
                 "m-value",
                 SO.Number
             ),
-            EpProperties.numberEp(
+            EpProperties.stringEp(
                 Labels.withId(WKT),
                 "trajectory-wkt",
                 "http://www.opengis.net/ont/geosparql#Geometry")
@@ -98,7 +98,7 @@ public class CreateTrajectoryFromPointsController extends StandaloneEventProcess
   public ConfiguredEventProcessor<CreateTrajectoryFromPointsParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
 
 
-    String wkt = extractor.mappingPropertyValue(WKT);
+    String wkt = extractor.mappingPropertyValue(POINT_KEY);
     String epsg = extractor.mappingPropertyValue(EPSG_KEY);
     String m = extractor.mappingPropertyValue(M_KEY);
 


[incubator-streampipes-extensions] 10/17: changed javadoc

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 1ec0b51ffc9eab23a14734534a2bb310bbf5f3a6
Author: micklich <fl...@disy.net>
AuthorDate: Wed Apr 29 15:54:14 2020 +0200

    changed javadoc
---
 .../geo/jvm/jts/helper/SpGeometryBuilder.java      | 42 +++++++++++-----------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
index e6e183a..03e38a5 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
@@ -27,17 +27,16 @@ public class SpGeometryBuilder {
   final static double LONGITUDE_MIN = -180.00;
   final static double LONGITUDE_MAX = 180.00;
   final static double LATITUDE_MIN = -90;
-  final static double LATITIDE_MAX = 90;
+  final static double LATITUDE_MAX = 90;
 
 
   /**
-   * Creates a JTS point geometry from Longitude and Latitude values
+   * Creates a {@link org.locationtech.jts.geom.Point} from <code>Latitude</code> and <code> Longitude</code> values
    *
-   * @param lng Longitude value in the range -180 <Longitude > 180
-   * @param lat Latitude value in the range -90 <LATITUDE > 90
-   * @param epsg EPSG Code for projection info
-   * @return a JTS Point Geometry Object with lat lng values. An empty point geometry is created if Latitude or Longitude values are out of range
-   * or has null values.
+   * @param lng  Longitude value in the range -180 &lt; Longitude &gt; 180
+   * @param lat  Latitude value in the range -90 &lt; LATITUDE &gt; 90
+   * @param epsg EPSG Code representing coordinate reference system
+   * @return a {@link org.locationtech.jts.geom.Point}. An empty point geometry is created if Latitude or Longitude values are out of range or has null values.
    */
   public static Point createSPGeom(Double lng, Double lat, Integer epsg) {
     Point point;
@@ -47,7 +46,7 @@ public class SpGeometryBuilder {
     //check if value is not null due missing stream value
     if ((lng != null) && (lat != null)) {
       //check if lat lng is in typical range
-      if (isInWGSCoordinateRange(lng, LONGITUDE_MIN, LONGITUDE_MAX) || isInWGSCoordinateRange(lat, LATITUDE_MIN, LATITIDE_MAX)) {
+      if (isInWGSCoordinateRange(lng, LONGITUDE_MIN, LONGITUDE_MAX) || isInWGSCoordinateRange(lat, LATITUDE_MIN, LATITUDE_MAX)) {
 
         Coordinate coordinate = new Coordinate(lng, lat);
         point = geomFactory.createPoint(coordinate);
@@ -69,10 +68,9 @@ public class SpGeometryBuilder {
    * geom is returned. method calls getPrecision method and creates a jts geometry factory and a WKT-parser object.
    * from the wktString the
    *
-   * @param wktString wkt text
-   * @param epsg EPSG Code for projection info
-   * @return Geometry geom: a JTS Geometry Object depending on the WKT input. An empty point geometry is created if Latitude or Longitude values are out of range
-   *    * or has null values
+   * @param wktString Well-known text representation of the input geometry
+   * @param epsg      EPSG Code representing SRID
+   * @return {@link org.locationtech.jts.geom.Geometry}. An empty point geometry is created if {@link org.locationtech.jts.io.ParseException} due invalid WKT-String
    */
   public static Geometry createSPGeom(String wktString, Integer epsg) {
 
@@ -93,26 +91,26 @@ public class SpGeometryBuilder {
   }
 
 
-
   /**
+   * Is in wgs coordinate range boolean.
    *
-   * @param checkedvalue Any Value
+   * @param valueToCheck Any Value
    * @param min          Min value to check
    * @param max          max value to check
-   * @return boolean value true or false
+   * @return true if value is in min max range
    */
-  private static boolean isInWGSCoordinateRange(double checkedvalue, double min, double max) {
-    return checkedvalue > min && checkedvalue < max;
+  private static boolean isInWGSCoordinateRange(double valueToCheck, double min, double max){
+    return valueToCheck > min && valueToCheck < max;
   }
 
 
   /**
-   * Creates a JTS PrecisionModel with a specific precision.
-   * WGS84/WGS84 will be created with 7 decimal positions.
-   * Any other epsg code will create a precision with Ffloating type. See JTS PrecisionModel for more information
+   * Creates a {@link org.locationtech.jts.geom.PrecisionModel} with a specific precision.
+   * WGS84/WGS84 will be created a {@link org.locationtech.jts.geom.PrecisionModel#FIXED} with 7 decimal positions (scale 1000000).
+   * Any other epsg code will create a precision with {@link org.locationtech.jts.geom.PrecisionModel#FLOATING}.
    *
-   * @param epsg EPSG alue
-   * @return a JTS PrecisionModel
+   * @param epsg EPSG Code representing SRID
+   * @return {@link org.locationtech.jts.geom.PrecisionModel}
    */
   private static PrecisionModel getPrecisionModel(Integer epsg) {
     PrecisionModel precisionModel;


[incubator-streampipes-extensions] 04/17: trajectory class misc changes (spelling javadoc)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 225f3eb3a1f5841fb6062aa7f20c53141ab47226
Author: micklich <fl...@disy.net>
AuthorDate: Wed Apr 29 16:17:27 2020 +0200

    trajectory class misc changes (spelling javadoc)
---
 .../processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java   | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
index 4c9cc0d..7f6b48b 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
@@ -18,7 +18,6 @@
 
 package org.apache.streampipes.processors.geo.jvm.jts.helper;
 
-
 import org.locationtech.jts.geom.*;
 
 public class SpTrajectoryBuilder {
@@ -29,7 +28,7 @@ public class SpTrajectoryBuilder {
 
     /**
      * Constructor of SpTrajectory
-     * @param numberSubPoints Integer number of allowed subpoints of the trajectory
+     * @param numberSubPoints Integer number of allowed sub-points of the trajectory
      * @param description Text Description of the single Trajectory
      */
     public SpTrajectoryBuilder(int numberSubPoints, String description) {
@@ -41,17 +40,16 @@ public class SpTrajectoryBuilder {
 
     /**
      * getter method for description text
-     * @return
+     * @return description text
      */
     public String getDescription() {
         return description;
     }
 
     /**
-     * Adds a Point to the trajectory object and also handle removement depending on the
-     * number of choosen Subpoints
-     * @param point Point geometry
-     * @param m stores an extra integer to the subpoint of a trajectory
+     * Adds a Point to the trajectory object and also handle removes old point if {link #numberSubPoints} threshold is exceeded.
+     * @param point {@link org.locationtech.jts.geom.Point}
+     * @param m stores an extra integer to the sub-point of a trajectory {@link org.locationtech.jts.geom.CoordinateXYM#M}
      */
     public void addPointToTrajectory(Point point, Integer m) {
         coordinateList.add(createSingleTrajectoryCoordinate(point, m));


[incubator-streampipes-extensions] 03/17: changed javadoc

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 0cfd6dc563be6aecb703cdd2b168fe1a08d33537
Author: micklich <fl...@disy.net>
AuthorDate: Wed Apr 29 15:54:14 2020 +0200

    changed javadoc
---
 .../geo/jvm/jts/helper/SpGeometryBuilder.java      | 48 +++++++++++-----------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
index 136db98..8d7a436 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
@@ -27,16 +27,16 @@ public class SpGeometryBuilder {
   final static double LONGITUDE_MIN = -180.00;
   final static double LONGITUDE_MAX = 180.00;
   final static double LATITUDE_MIN = -90;
-  final static double LATITIDE_MAX = 90;
+  final static double LATITUDE_MAX = 90;
 
 
-  /**Creates a JTS point geometry from Longitude and Latitude values
+  /**
+   * Creates a {@link org.locationtech.jts.geom.Point} from <code>Latitude</code> and <code> Longitude</code> values
    *
-   * @param lng Longitude value in the range -180 <Longitude > 180
-   * @param lat Latitude value in the range -90 <LATITUDE > 90
-   * @param epsg EPSG Code for projection info
-   * @return a JTS Point Geometry Object with lat lng values. An empty point geometry is created if Latitude or Longitude values are out of range
-   * or has null values.
+   * @param lng  Longitude value in the range -180 &lt; Longitude &gt; 180
+   * @param lat  Latitude value in the range -90 &lt; LATITUDE &gt; 90
+   * @param epsg EPSG Code representing coordinate reference system
+   * @return a {@link org.locationtech.jts.geom.Point}. An empty point geometry is created if Latitude or Longitude values are out of range or has null values.
    */
   public static Point createSPGeom(Double lng, Double lat, Integer epsg) {
     Point point;
@@ -46,7 +46,7 @@ public class SpGeometryBuilder {
     //check if value is not null due missing stream value
     if ((lng != null) && (lat != null)) {
       //check if lat lng is in typical range
-      if (isInWGSCoordinateRange(lng, LONGITUDE_MIN, LONGITUDE_MAX) || isInWGSCoordinateRange(lat, LATITUDE_MIN, LATITIDE_MAX)) {
+      if (isInWGSCoordinateRange(lng, LONGITUDE_MIN, LONGITUDE_MAX) || isInWGSCoordinateRange(lat, LATITUDE_MIN, LATITUDE_MAX)) {
 
         Coordinate coordinate = new Coordinate(lng, lat);
         point = geomFactory.createPoint(coordinate);
@@ -68,10 +68,9 @@ public class SpGeometryBuilder {
    * geom is returned. method calls getPrecision method and creates a jts geometry factory and a WKT-parser object.
    * from the wktString the
    *
-   * @param wktString wkt text
-   * @param epsg EPSG Code for projection info
-   * @return Geometry geom: a JTS Geometry Object depending on the WKT input. An empty point geometry is created if Latitude or Longitude values are out of range
-   *    * or has null values
+   * @param wktString Well-known text representation of the input geometry
+   * @param epsg      EPSG Code representing SRID
+   * @return {@link org.locationtech.jts.geom.Geometry}. An empty point geometry is created if {@link org.locationtech.jts.io.ParseException} due invalid WKT-String
    */
   public static Geometry createSPGeom(String wktString, Integer epsg) {
 
@@ -92,25 +91,26 @@ public class SpGeometryBuilder {
   }
 
 
-
   /**
+   * Is in wgs coordinate range boolean.
    *
-   * @param checkedvalue Any Value
-   * @param min Min value to check
-   * @param max max value to check
-   * @return boolean value true or false
+   * @param valueToCheck Any Value
+   * @param min          Min value to check
+   * @param max          max value to check
+   * @return true if value is in min max range
    */
-  private static boolean isInWGSCoordinateRange(double checkedvalue, double min, double max){
-    return checkedvalue > min && checkedvalue < max;
+  private static boolean isInWGSCoordinateRange(double valueToCheck, double min, double max){
+    return valueToCheck > min && valueToCheck < max;
   }
 
 
   /**
-   * Creates a JTS PrecisionModel with a specific precision.
-   * WGS84/WGS84 will be created with 7 decimal positions.
-   * Any other epsg code will create a precision with Ffloating type. See JTS PrecisionModel for more information
-   * @param epsg EPSG alue
-   * @return a JTS PrecisionModel
+   * Creates a {@link org.locationtech.jts.geom.PrecisionModel} with a specific precision.
+   * WGS84/WGS84 will be created a {@link org.locationtech.jts.geom.PrecisionModel#FIXED} with 7 decimal positions (scale 1000000).
+   * Any other epsg code will create a precision with {@link org.locationtech.jts.geom.PrecisionModel#FLOATING}.
+   *
+   * @param epsg EPSG Code representing SRID
+   * @return {@link org.locationtech.jts.geom.PrecisionModel}
    */
   private static PrecisionModel getPrecisionModel(Integer epsg) {
     PrecisionModel precisionModel;


[incubator-streampipes-extensions] 17/17: fix STREAMPIPES-123

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 9e7a465c8e345cc49287e7f07742b099bea19f9b
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 17:05:21 2020 +0200

    fix STREAMPIPES-123
---
 .../trajectory/CreateTrajectoryFromPoints.java          |  4 ++--
 .../CreateTrajectoryFromPointsController.java           | 17 ++++++++++-------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
index 5ccb42e..12fe8aa 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
@@ -67,8 +67,8 @@ public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajecto
     LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
 
     // adds to stream
-    in.addField("wkt-trajectory", geom.toString());
-    in.addField("description", trajectory.getDescription());
+    in.addField(CreateTrajectoryFromPointsController.DESCRIPTION_RUNTIME, trajectory.getDescription());
+    in.addField(CreateTrajectoryFromPointsController.WKT_RUNTIME, geom.toString());
     out.collect(in);
   }
 
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index 16d6e4f..9d9f439 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -40,7 +40,10 @@ public class CreateTrajectoryFromPointsController extends StandaloneEventProcess
   public final static String DESCRIPTION_KEY = "description-key";
   public final static String SUBPOINTS_KEY = "subpoints-key";
 
-  public final static String WKT = "trajectory_wkt";
+  public final static String WKT_KEY = "trajectory-key";
+  public final static String WKT_RUNTIME = "trajectoryWKT";
+
+  public final static String DESCRIPTION_RUNTIME = "trajectoryDescription";
 
 
   @Override
@@ -76,14 +79,14 @@ public class CreateTrajectoryFromPointsController extends StandaloneEventProcess
         )
 
         .outputStrategy(OutputStrategies.append(
-            EpProperties.numberEp(
-                Labels.withId(M_KEY),
-                "m-value",
-                SO.Number
+            EpProperties.stringEp(
+                Labels.withId(DESCRIPTION_KEY),
+                DESCRIPTION_RUNTIME,
+                SO.Text
             ),
             EpProperties.stringEp(
-                Labels.withId(WKT),
-                "trajectory-wkt",
+                Labels.withId(WKT_KEY),
+                WKT_RUNTIME,
                 "http://www.opengis.net/ont/geosparql#Geometry")
             )
         )


[incubator-streampipes-extensions] 16/17: Merge remote-tracking branch 'origin/feature/trajectory' into feature/trajectory

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 3ac10f4abe49f8b4a23f94777cbbf324de3a2120
Merge: 00bb22f c80f858
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 13:03:42 2020 +0200

    Merge remote-tracking branch 'origin/feature/trajectory' into feature/trajectory



[incubator-streampipes-extensions] 11/17: trajectory class misc changes (spelling javadoc)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit c85b086074a67773dbb5528ee1e5d9255cfe0702
Author: micklich <fl...@disy.net>
AuthorDate: Wed Apr 29 16:17:27 2020 +0200

    trajectory class misc changes (spelling javadoc)
---
 .../processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java   | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
index 4c9cc0d..7f6b48b 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
@@ -18,7 +18,6 @@
 
 package org.apache.streampipes.processors.geo.jvm.jts.helper;
 
-
 import org.locationtech.jts.geom.*;
 
 public class SpTrajectoryBuilder {
@@ -29,7 +28,7 @@ public class SpTrajectoryBuilder {
 
     /**
      * Constructor of SpTrajectory
-     * @param numberSubPoints Integer number of allowed subpoints of the trajectory
+     * @param numberSubPoints Integer number of allowed sub-points of the trajectory
      * @param description Text Description of the single Trajectory
      */
     public SpTrajectoryBuilder(int numberSubPoints, String description) {
@@ -41,17 +40,16 @@ public class SpTrajectoryBuilder {
 
     /**
      * getter method for description text
-     * @return
+     * @return description text
      */
     public String getDescription() {
         return description;
     }
 
     /**
-     * Adds a Point to the trajectory object and also handle removement depending on the
-     * number of choosen Subpoints
-     * @param point Point geometry
-     * @param m stores an extra integer to the subpoint of a trajectory
+     * Adds a Point to the trajectory object and also handle removes old point if {link #numberSubPoints} threshold is exceeded.
+     * @param point {@link org.locationtech.jts.geom.Point}
+     * @param m stores an extra integer to the sub-point of a trajectory {@link org.locationtech.jts.geom.CoordinateXYM#M}
      */
     public void addPointToTrajectory(Point point, Integer m) {
         coordinateList.add(createSingleTrajectoryCoordinate(point, m));


[incubator-streampipes-extensions] 01/17: added PE

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 285c684bf33c85de8ec8011896fba95d46718230
Author: micklich <fl...@disy.net>
AuthorDate: Tue Apr 28 17:22:51 2020 +0200

    added PE
---
 .../streampipes/processors/geo/jvm/GeoJvmInit.java |  20 ++--
 .../trajectory/CreateTrajectoryFromPoints.java     |  73 ++++++++++++
 .../CreateTrajectoryFromPointsController.java      | 129 +++++++++++++++++++++
 .../CreateTrajectoryFromPointsParameter.java       |  61 ++++++++++
 4 files changed, 274 insertions(+), 9 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
index f82df33..41b30ce 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
@@ -29,6 +29,7 @@ import org.apache.streampipes.messaging.kafka.SpKafkaProtocolFactory;
 import org.apache.streampipes.processors.geo.jvm.config.GeoJvmConfig;
 import org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo.LatLngToGeoController;
 import org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG.SetEpsgController;
+import org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.CreateTrajectoryFromPointsController;
 import org.apache.streampipes.processors.geo.jvm.processor.distancecalculator.DistanceCalculatorController;
 import org.apache.streampipes.processors.geo.jvm.processor.geocoder.GoogleMapsGeocodingController;
 import org.apache.streampipes.processors.geo.jvm.processor.revgeocoder.ReverseGeocodingController;
@@ -40,15 +41,16 @@ public class GeoJvmInit extends StandaloneModelSubmitter {
 
   public static void main(String[] args) {
     DeclarersSingleton
-        .getInstance()
-        .add(new DistanceCalculatorController())
-        .add(new GoogleMapsGeocodingController())
-        .add(new StaticGoogleMapsGeocodingController())
-        .add(new ReverseGeocodingController())
-        .add(new SetEpsgController())
-        .add(new LatLngToGeoController())
-        .add(new SpeedCalculatorController())
-        .add(new StaticDistanceCalculatorController());
+            .getInstance()
+            .add(new DistanceCalculatorController())
+            .add(new GoogleMapsGeocodingController())
+            .add(new StaticGoogleMapsGeocodingController())
+            .add(new ReverseGeocodingController())
+            .add(new SetEpsgController())
+            .add(new LatLngToGeoController())
+            .add(new CreateTrajectoryFromPointsController())
+            .add(new SpeedCalculatorController())
+            .add(new StaticDistanceCalculatorController());
 
 
     DeclarersSingleton.getInstance().registerDataFormats(new JsonDataFormatFactory(),
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
new file mode 100755
index 0000000..3ad78d9
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory;
+
+import org.apache.streampipes.logging.api.Logger;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.processors.geo.jvm.jts.helper.SpGeometryBuilder;
+import org.apache.streampipes.processors.geo.jvm.jts.helper.SpTrajectoryBuilder;
+import org.apache.streampipes.wrapper.context.EventProcessorRuntimeContext;
+import org.apache.streampipes.wrapper.routing.SpOutputCollector;
+import org.apache.streampipes.wrapper.runtime.EventProcessor;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.Point;
+
+
+public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajectoryFromPointsParameter> {
+
+    private static Logger LOG;
+    private CreateTrajectoryFromPointsParameter params;
+    SpTrajectoryBuilder trajectory;
+
+
+
+    @Override
+    public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
+
+        LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
+        this.params = params;
+
+        trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
+    }
+
+    @Override
+    public void onEvent(Event in, SpOutputCollector out) {
+
+        String wkt = in.getFieldBySelector(params.getWkt()).getAsPrimitive().getAsString();
+        Integer epsg = in.getFieldBySelector(params.getEpsg()).getAsPrimitive().getAsInt();
+        Integer m = in.getFieldBySelector(params.getM()).getAsPrimitive().getAsInt();
+
+        Point eventGeom =  (Point) SpGeometryBuilder.createSPGeom(wkt,epsg);
+
+        //creates single trajectory
+        trajectory.addPointToTrajectory(eventGeom, m);
+        LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
+
+        in.addField(CreateTrajectoryFromPointsController.WKT, geom.toString());
+        in.addField(CreateTrajectoryFromPointsController.DESCRIPTION, trajectory.getDescription());
+        out.collect(in);
+
+    }
+
+    @Override
+    public void onDetach() {
+
+    }
+}
+
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
new file mode 100755
index 0000000..490007f
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory;
+
+import org.apache.streampipes.model.DataProcessorType;
+import org.apache.streampipes.model.graph.DataProcessorDescription;
+import org.apache.streampipes.model.graph.DataProcessorInvocation;
+import org.apache.streampipes.model.schema.PropertyScope;
+import org.apache.streampipes.sdk.builder.ProcessingElementBuilder;
+import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
+import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
+import org.apache.streampipes.sdk.helpers.*;
+import org.apache.streampipes.sdk.utils.Assets;
+import org.apache.streampipes.vocabulary.SO;
+import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
+import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
+
+public class CreateTrajectoryFromPointsController extends  StandaloneEventProcessingDeclarer<CreateTrajectoryFromPointsParameter> {
+
+
+
+    public final static String WKT = "trajectory_wkt";
+    public final static String EPSG = "EPSG";
+    public final static String M = "M-Value";
+    public final static String DESCRIPTION = "description";
+    public final static String SUBPOINTS = "subpoints";
+
+    public final static String EPA_NAME = "Create Single Trajectory";
+
+
+    @Override
+    public DataProcessorDescription declareModel() {
+        return ProcessingElementBuilder
+                .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory",
+                        EPA_NAME,
+                        "Creates a trajectory from Points")
+                .category(DataProcessorType.GEO)
+                .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+                .requiredStream(
+                        StreamRequirementsBuilder
+                                .create()
+                                .requiredPropertyWithUnaryMapping(
+                                        EpRequirements.stringReq(),
+                                        Labels.from(WKT,
+                                                "Geometry WKT",
+                                                "WKT of the requested Geometry"),
+                                        PropertyScope.NONE
+                                )
+                                .requiredPropertyWithUnaryMapping(
+                                        EpRequirements.numberReq(),
+                                        Labels.from(EPSG, "EPSG Field", "EPSG Code for SRID"),
+                                        PropertyScope.NONE
+                                )
+                                .requiredPropertyWithUnaryMapping(
+                                        EpRequirements.numberReq(),
+                                        Labels.from(M, "M Value", "Choose a value add to trajectory"),
+                                        PropertyScope.NONE
+                                )
+                                .build()
+                )
+                .requiredTextParameter(
+                        Labels.from(
+                                DESCRIPTION,
+                                "description of trajectory",
+                                "Add a description for the trajectory")
+                )
+                .requiredIntegerParameter(
+                        Labels.from(
+                                SUBPOINTS,
+                                "number of allowed subpoints",
+                                "Number og allowed subpoints of the trajector"),
+                        2, 10, 1
+                )
+                .outputStrategy(OutputStrategies.append(
+                        EpProperties.stringEp(
+                                Labels.from(
+                                        "trajectory_wkt",
+                                        "trajectory_wkt",
+                                        "trajectory wkt (lineString) of a point stream"),
+                                WKT,
+                                SO.Text),
+                        EpProperties.stringEp(
+                                Labels.from(
+                                        "trajectory_description",
+                                        "trajectory_description",
+                                        "description of trajectory"),
+                                DESCRIPTION,
+                                SO.Text))
+                )
+
+                .supportedFormats(SupportedFormats.jsonFormat())
+                .supportedProtocols(SupportedProtocols.kafka())
+                .build();
+    }
+
+
+    @Override
+    public ConfiguredEventProcessor<CreateTrajectoryFromPointsParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
+
+
+        String wkt = extractor.mappingPropertyValue(WKT);
+        String epsg_value = extractor.mappingPropertyValue(EPSG);
+        String m = extractor.mappingPropertyValue(M);
+
+        String description = extractor.singleValueParameter(DESCRIPTION, String.class);
+        Integer subpoints = extractor.singleValueParameter(SUBPOINTS, Integer.class);
+
+
+        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg_value, description, subpoints, m);
+
+        return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
+    }
+}
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
new file mode 100755
index 0000000..0397ac5
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory;
+
+import org.apache.streampipes.model.graph.DataProcessorInvocation;
+import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams;
+
+public class CreateTrajectoryFromPointsParameter extends EventProcessorBindingParams {
+
+    private String epsg;
+    private String wkt;
+    private String description;
+    private Integer subpoints;
+    private String m;
+
+
+    public CreateTrajectoryFromPointsParameter(DataProcessorInvocation graph, String wkt, String epsg, String description, Integer subpoints, String m) {
+        super(graph);
+        this.wkt = wkt;
+        this.epsg = epsg;
+        this.description = description;
+        this.subpoints = subpoints;
+        this.m = m;
+    }
+
+    public String getEpsg() {
+        return epsg;
+    }
+
+    public String getWkt() {
+        return wkt;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Integer getSubpoints() {
+        return subpoints;
+    }
+
+    public String getM() {
+        return m;
+    }
+}


[incubator-streampipes-extensions] 13/17: rewrite from labels.from to label.withID

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 4526f8cd75744fcc5372f56e027b4bdca8fefa24
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 01:50:52 2020 +0200

    rewrite from labels.from to label.withID
---
 .../trajectory/CreateTrajectoryFromPoints.java     |  27 +++--
 .../CreateTrajectoryFromPointsController.java      | 129 +++++++++------------
 .../strings.en                                     |  24 +++-
 3 files changed, 95 insertions(+), 85 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
index 3ad78d9..26a695e 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
@@ -32,16 +32,21 @@ import org.locationtech.jts.geom.Point;
 public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajectoryFromPointsParameter> {
 
     private static Logger LOG;
-    private CreateTrajectoryFromPointsParameter params;
-    SpTrajectoryBuilder trajectory;
 
+    private SpTrajectoryBuilder trajectory;
+
+    private String geom_wkt;
+    private String epsg_code;
+    private String m_value;
 
 
     @Override
     public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
 
         LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
-        this.params = params;
+        this.geom_wkt =  params.getWkt();
+        this.epsg_code = params.getEpsg();
+        this.m_value = params.getM();
 
         trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
     }
@@ -49,18 +54,22 @@ public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajecto
     @Override
     public void onEvent(Event in, SpOutputCollector out) {
 
-        String wkt = in.getFieldBySelector(params.getWkt()).getAsPrimitive().getAsString();
-        Integer epsg = in.getFieldBySelector(params.getEpsg()).getAsPrimitive().getAsInt();
-        Integer m = in.getFieldBySelector(params.getM()).getAsPrimitive().getAsInt();
+        // extract values
+        String wkt = in.getFieldBySelector(geom_wkt).getAsPrimitive().getAsString();
+        Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
+        Integer m = in.getFieldBySelector(m_value).getAsPrimitive().getAsInt();
 
+        //create JTS geometry
         Point eventGeom =  (Point) SpGeometryBuilder.createSPGeom(wkt,epsg);
 
-        //creates single trajectory
+        //adds point and m value to trajectory object
         trajectory.addPointToTrajectory(eventGeom, m);
+        // returns JTS LineString
         LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
 
-        in.addField(CreateTrajectoryFromPointsController.WKT, geom.toString());
-        in.addField(CreateTrajectoryFromPointsController.DESCRIPTION, trajectory.getDescription());
+        // adds to stream
+        in.addField("wkt-trajectory", geom.toString());
+        in.addField("description", trajectory.getDescription());
         out.collect(in);
 
     }
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index 654a907..a94140c 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -35,78 +35,65 @@ public class CreateTrajectoryFromPointsController extends  StandaloneEventProces
 
 
 
-    public final static String WKT = "trajectory_wkt";
-    public final static String EPSG = "EPSG";
-    public final static String M = "M-Value";
-    public final static String DESCRIPTION = "description";
-    public final static String SUBPOINTS = "subpoints";
 
+    public final static String POINT_KEY = "point-key";
+    public final static String EPSG_KEY = "epsg-key";
+    public final static String M_KEY = "m-key";
+    public final static String DESCRIPTION_KEY = "description-key";
+    public final static String SUBPOINTS_KEY = "subpoints-key";
+
+    public final static String WKT = "trajectory_wkt";
     public final static String EPA_NAME = "Create Single Trajectory";
 
 
     @Override
     public DataProcessorDescription declareModel() {
-        return ProcessingElementBuilder
-                .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory",
-                        EPA_NAME,
-                        "Creates a trajectory from Points")
-                .category(DataProcessorType.GEO)
-                .withAssets(Assets.DOCUMENTATION, Assets.ICON)
-                .requiredStream(
-                        StreamRequirementsBuilder
-                                .create()
-                                .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.domainPropertyReq("http://www.opengis.net/spec/geosparql/1.0#wktLiteral"),
-                                        Labels.from(WKT,
-                                                "Geometry WKT",
-                                                "WKT of the requested Geometry"),
-                                        PropertyScope.NONE
-                                )
-                                .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.domainPropertyReq("http://streampipes.org/epsg"),
-                                        Labels.from(EPSG, "EPSG Field", "EPSG Code for SRID"),
-                                        PropertyScope.NONE
-                                )
-                                .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.numberReq(),
-                                        Labels.from(M, "M Value", "Choose a value add to trajectory"),
-                                        PropertyScope.NONE
-                                )
-                                .build()
-                )
-                .requiredTextParameter(
-                        Labels.from(
-                                DESCRIPTION,
-                                "description of trajectory",
-                                "Add a description for the trajectory")
-                )
-                .requiredIntegerParameter(
-                        Labels.from(
-                                SUBPOINTS,
-                                "number of allowed subpoints",
-                                "Number og allowed subpoints of the trajector"),
-                        2, 10, 1
-                )
-                .outputStrategy(OutputStrategies.append(
-                        EpProperties.stringEp(
-                                Labels.from(
-                                        "trajectory_wkt",
-                                        "trajectory_wkt",
-                                        "trajectory wkt (lineString) of a point stream"),
-                                WKT,
-                                SO.Text),
-                        EpProperties.stringEp(
-                                Labels.from(
-                                        "trajectory_description",
-                                        "trajectory_description",
-                                        "description of trajectory"),
-                                DESCRIPTION,
-                                SO.Text))
-                )
-
-                .supportedFormats(SupportedFormats.jsonFormat())
-                .supportedProtocols(SupportedProtocols.kafka())
-                .build();
+      return ProcessingElementBuilder
+          .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory")
+          .category(DataProcessorType.GEO)
+          .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+          .withLocales(Locales.EN)
+          .requiredStream(
+              StreamRequirementsBuilder
+                  .create()
+                  .requiredPropertyWithUnaryMapping(
+                      EpRequirements.domainPropertyReq("http://www.opengis.net/ont/geosparql#Geometry"),
+                      Labels.withId(POINT_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                  )
+                  .requiredPropertyWithUnaryMapping(
+                      EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
+                      Labels.withId(EPSG_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                  )
+                  .requiredPropertyWithUnaryMapping(
+                      EpRequirements.numberReq(),
+                      Labels.withId(M_KEY),  PropertyScope.MEASUREMENT_PROPERTY
+                  )
+                  .build()
+          )
+          .requiredTextParameter(
+              Labels.withId(DESCRIPTION_KEY)
+          )
+          .requiredIntegerParameter(
+              Labels.withId(SUBPOINTS_KEY),
+              2, 30, 1
+          )
+
+          .outputStrategy(OutputStrategies.append(
+              EpProperties.numberEp(
+                  Labels.withId(M_KEY),
+                  "m-value",
+                  SO.Number
+              ),
+              EpProperties.numberEp(
+                  Labels.withId(WKT),
+                  "trajectory-wkt",
+                  "http://www.opengis.net/ont/geosparql#Geometry")
+              )
+          )
+
+          .supportedFormats(SupportedFormats.jsonFormat())
+          .supportedProtocols(SupportedProtocols.kafka())
+          .build();
     }
 
 
@@ -115,14 +102,14 @@ public class CreateTrajectoryFromPointsController extends  StandaloneEventProces
 
 
         String wkt = extractor.mappingPropertyValue(WKT);
-        String epsg_value = extractor.mappingPropertyValue(EPSG);
-        String m = extractor.mappingPropertyValue(M);
+        String epsg = extractor.mappingPropertyValue(EPSG_KEY);
+        String m = extractor.mappingPropertyValue(M_KEY);
 
-        String description = extractor.singleValueParameter(DESCRIPTION, String.class);
-        Integer subpoints = extractor.singleValueParameter(SUBPOINTS, Integer.class);
+        String description = extractor.singleValueParameter(DESCRIPTION_KEY, String.class);
+        Integer subpoints = extractor.singleValueParameter(SUBPOINTS_KEY, Integer.class);
 
 
-        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg_value, description, subpoints, m);
+        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg, description, subpoints, m);
 
         return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
     }
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
index a0dcba4..f38fef7 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
@@ -1,6 +1,20 @@
-org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.title=Static Google Maps Geocoder
-org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.description=GTrajectory from JTS point events
-appends these coordinates to every input event.
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.title=Single Trajectory Creator
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.description=Creates a trajectory from JTS point events
 
-place.title=Place
-place.description=Trajectory from single point events
+point-key.title=JTS Point Event
+point-key.description=Single Point Event which will be added to the trajectory
+
+point-key.title=JTS Point Event
+point-key.description=Single Point Event which will be added to the trajectory
+
+epsg-key.title=CRS of Input Point
+epsg-key.description=EPSG-Code of input point
+
+m-key.title=measurement value
+m-key.description=Measurement value which will be stored with each point event
+
+description-key.title=description text of trajectory
+description-key.description=A description text for the trajectory
+
+subpoints-key.title=number of allowed sub-points
+subpoints-key.description=amount of allowed sub-points, creating the trajectory


[incubator-streampipes-extensions] 14/17: format code

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 9c7f951d64f11836472bb25ee63717999cae3d78
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 10:14:10 2020 +0200

    format code
---
 .../trajectory/CreateTrajectoryFromPoints.java     |  68 +++++----
 .../CreateTrajectoryFromPointsController.java      | 161 ++++++++++-----------
 .../CreateTrajectoryFromPointsParameter.java       |  69 +++++----
 3 files changed, 146 insertions(+), 152 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
index 26a695e..5ccb42e 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
@@ -31,52 +31,50 @@ import org.locationtech.jts.geom.Point;
 
 public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajectoryFromPointsParameter> {
 
-    private static Logger LOG;
+  private static Logger LOG;
 
-    private SpTrajectoryBuilder trajectory;
+  private SpTrajectoryBuilder trajectory;
 
-    private String geom_wkt;
-    private String epsg_code;
-    private String m_value;
+  private String geom_wkt;
+  private String epsg_code;
+  private String m_value;
 
+  @Override
+  public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
 
-    @Override
-    public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
+    LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
+    this.geom_wkt = params.getWkt();
+    this.epsg_code = params.getEpsg();
+    this.m_value = params.getM();
 
-        LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
-        this.geom_wkt =  params.getWkt();
-        this.epsg_code = params.getEpsg();
-        this.m_value = params.getM();
+    trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
+  }
 
-        trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
-    }
+  @Override
+  public void onEvent(Event in, SpOutputCollector out) {
 
-    @Override
-    public void onEvent(Event in, SpOutputCollector out) {
+    // extract values
+    String wkt = in.getFieldBySelector(geom_wkt).getAsPrimitive().getAsString();
+    Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
+    Integer m = in.getFieldBySelector(m_value).getAsPrimitive().getAsInt();
 
-        // extract values
-        String wkt = in.getFieldBySelector(geom_wkt).getAsPrimitive().getAsString();
-        Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
-        Integer m = in.getFieldBySelector(m_value).getAsPrimitive().getAsInt();
+    //create JTS geometry
+    Point eventGeom = (Point) SpGeometryBuilder.createSPGeom(wkt, epsg);
 
-        //create JTS geometry
-        Point eventGeom =  (Point) SpGeometryBuilder.createSPGeom(wkt,epsg);
+    //adds point and m value to trajectory object
+    trajectory.addPointToTrajectory(eventGeom, m);
+    // returns JTS LineString
+    LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
 
-        //adds point and m value to trajectory object
-        trajectory.addPointToTrajectory(eventGeom, m);
-        // returns JTS LineString
-        LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
+    // adds to stream
+    in.addField("wkt-trajectory", geom.toString());
+    in.addField("description", trajectory.getDescription());
+    out.collect(in);
+  }
 
-        // adds to stream
-        in.addField("wkt-trajectory", geom.toString());
-        in.addField("description", trajectory.getDescription());
-        out.collect(in);
+  @Override
+  public void onDetach() {
 
-    }
-
-    @Override
-    public void onDetach() {
-
-    }
+  }
 }
 
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index a94140c..e3c3021 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -31,86 +31,83 @@ import org.apache.streampipes.vocabulary.SO;
 import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
 import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
 
-public class CreateTrajectoryFromPointsController extends  StandaloneEventProcessingDeclarer<CreateTrajectoryFromPointsParameter> {
-
-
-
-
-    public final static String POINT_KEY = "point-key";
-    public final static String EPSG_KEY = "epsg-key";
-    public final static String M_KEY = "m-key";
-    public final static String DESCRIPTION_KEY = "description-key";
-    public final static String SUBPOINTS_KEY = "subpoints-key";
-
-    public final static String WKT = "trajectory_wkt";
-    public final static String EPA_NAME = "Create Single Trajectory";
-
-
-    @Override
-    public DataProcessorDescription declareModel() {
-      return ProcessingElementBuilder
-          .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory")
-          .category(DataProcessorType.GEO)
-          .withAssets(Assets.DOCUMENTATION, Assets.ICON)
-          .withLocales(Locales.EN)
-          .requiredStream(
-              StreamRequirementsBuilder
-                  .create()
-                  .requiredPropertyWithUnaryMapping(
-                      EpRequirements.domainPropertyReq("http://www.opengis.net/ont/geosparql#Geometry"),
-                      Labels.withId(POINT_KEY), PropertyScope.MEASUREMENT_PROPERTY
-                  )
-                  .requiredPropertyWithUnaryMapping(
-                      EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
-                      Labels.withId(EPSG_KEY), PropertyScope.MEASUREMENT_PROPERTY
-                  )
-                  .requiredPropertyWithUnaryMapping(
-                      EpRequirements.numberReq(),
-                      Labels.withId(M_KEY),  PropertyScope.MEASUREMENT_PROPERTY
-                  )
-                  .build()
-          )
-          .requiredTextParameter(
-              Labels.withId(DESCRIPTION_KEY)
-          )
-          .requiredIntegerParameter(
-              Labels.withId(SUBPOINTS_KEY),
-              2, 30, 1
-          )
-
-          .outputStrategy(OutputStrategies.append(
-              EpProperties.numberEp(
-                  Labels.withId(M_KEY),
-                  "m-value",
-                  SO.Number
-              ),
-              EpProperties.numberEp(
-                  Labels.withId(WKT),
-                  "trajectory-wkt",
-                  "http://www.opengis.net/ont/geosparql#Geometry")
-              )
-          )
-
-          .supportedFormats(SupportedFormats.jsonFormat())
-          .supportedProtocols(SupportedProtocols.kafka())
-          .build();
-    }
-
-
-    @Override
-    public ConfiguredEventProcessor<CreateTrajectoryFromPointsParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
-
-
-        String wkt = extractor.mappingPropertyValue(WKT);
-        String epsg = extractor.mappingPropertyValue(EPSG_KEY);
-        String m = extractor.mappingPropertyValue(M_KEY);
-
-        String description = extractor.singleValueParameter(DESCRIPTION_KEY, String.class);
-        Integer subpoints = extractor.singleValueParameter(SUBPOINTS_KEY, Integer.class);
-
-
-        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg, description, subpoints, m);
-
-        return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
-    }
+public class CreateTrajectoryFromPointsController extends StandaloneEventProcessingDeclarer<CreateTrajectoryFromPointsParameter> {
+
+
+  public final static String POINT_KEY = "point-key";
+  public final static String EPSG_KEY = "epsg-key";
+  public final static String M_KEY = "m-key";
+  public final static String DESCRIPTION_KEY = "description-key";
+  public final static String SUBPOINTS_KEY = "subpoints-key";
+
+  public final static String WKT = "trajectory_wkt";
+
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return ProcessingElementBuilder
+        .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory")
+        .category(DataProcessorType.GEO)
+        .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+        .withLocales(Locales.EN)
+        .requiredStream(
+            StreamRequirementsBuilder
+                .create()
+                .requiredPropertyWithUnaryMapping(
+                    EpRequirements.domainPropertyReq("http://www.opengis.net/ont/geosparql#Geometry"),
+                    Labels.withId(POINT_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                )
+                .requiredPropertyWithUnaryMapping(
+                    EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
+                    Labels.withId(EPSG_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                )
+                .requiredPropertyWithUnaryMapping(
+                    EpRequirements.numberReq(),
+                    Labels.withId(M_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                )
+                .build()
+        )
+        .requiredTextParameter(
+            Labels.withId(DESCRIPTION_KEY)
+        )
+        .requiredIntegerParameter(
+            Labels.withId(SUBPOINTS_KEY),
+            2, 30, 1
+        )
+
+        .outputStrategy(OutputStrategies.append(
+            EpProperties.numberEp(
+                Labels.withId(M_KEY),
+                "m-value",
+                SO.Number
+            ),
+            EpProperties.numberEp(
+                Labels.withId(WKT),
+                "trajectory-wkt",
+                "http://www.opengis.net/ont/geosparql#Geometry")
+            )
+        )
+
+        .supportedFormats(SupportedFormats.jsonFormat())
+        .supportedProtocols(SupportedProtocols.kafka())
+        .build();
+  }
+
+
+  @Override
+  public ConfiguredEventProcessor<CreateTrajectoryFromPointsParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
+
+
+    String wkt = extractor.mappingPropertyValue(WKT);
+    String epsg = extractor.mappingPropertyValue(EPSG_KEY);
+    String m = extractor.mappingPropertyValue(M_KEY);
+
+    String description = extractor.singleValueParameter(DESCRIPTION_KEY, String.class);
+    Integer subpoints = extractor.singleValueParameter(SUBPOINTS_KEY, Integer.class);
+
+
+    CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg, description, subpoints, m);
+
+    return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
+  }
 }
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
index 0397ac5..872fb00 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
@@ -23,39 +23,38 @@ import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams
 
 public class CreateTrajectoryFromPointsParameter extends EventProcessorBindingParams {
 
-    private String epsg;
-    private String wkt;
-    private String description;
-    private Integer subpoints;
-    private String m;
-
-
-    public CreateTrajectoryFromPointsParameter(DataProcessorInvocation graph, String wkt, String epsg, String description, Integer subpoints, String m) {
-        super(graph);
-        this.wkt = wkt;
-        this.epsg = epsg;
-        this.description = description;
-        this.subpoints = subpoints;
-        this.m = m;
-    }
-
-    public String getEpsg() {
-        return epsg;
-    }
-
-    public String getWkt() {
-        return wkt;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public Integer getSubpoints() {
-        return subpoints;
-    }
-
-    public String getM() {
-        return m;
-    }
+  private String epsg;
+  private String wkt;
+  private String description;
+  private Integer subpoints;
+  private String m;
+
+  public CreateTrajectoryFromPointsParameter(DataProcessorInvocation graph, String wkt, String epsg, String description, Integer subpoints, String m) {
+    super(graph);
+    this.wkt = wkt;
+    this.epsg = epsg;
+    this.description = description;
+    this.subpoints = subpoints;
+    this.m = m;
+  }
+
+  public String getEpsg() {
+    return epsg;
+  }
+
+  public String getWkt() {
+    return wkt;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public Integer getSubpoints() {
+    return subpoints;
+  }
+
+  public String getM() {
+    return m;
+  }
 }


[incubator-streampipes-extensions] 08/17: added PE

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit e1fe0292c449281cedfb207154f393a4dbe0a32c
Author: micklich <fl...@disy.net>
AuthorDate: Tue Apr 28 17:22:51 2020 +0200

    added PE
---
 .../streampipes/processors/geo/jvm/GeoJvmInit.java |  20 ++--
 .../trajectory/CreateTrajectoryFromPoints.java     |  73 ++++++++++++
 .../CreateTrajectoryFromPointsController.java      | 129 +++++++++++++++++++++
 .../CreateTrajectoryFromPointsParameter.java       |  61 ++++++++++
 4 files changed, 274 insertions(+), 9 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
index f82df33..41b30ce 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/GeoJvmInit.java
@@ -29,6 +29,7 @@ import org.apache.streampipes.messaging.kafka.SpKafkaProtocolFactory;
 import org.apache.streampipes.processors.geo.jvm.config.GeoJvmConfig;
 import org.apache.streampipes.processors.geo.jvm.jts.processor.latLngToGeo.LatLngToGeoController;
 import org.apache.streampipes.processors.geo.jvm.jts.processor.setEPSG.SetEpsgController;
+import org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.CreateTrajectoryFromPointsController;
 import org.apache.streampipes.processors.geo.jvm.processor.distancecalculator.DistanceCalculatorController;
 import org.apache.streampipes.processors.geo.jvm.processor.geocoder.GoogleMapsGeocodingController;
 import org.apache.streampipes.processors.geo.jvm.processor.revgeocoder.ReverseGeocodingController;
@@ -40,15 +41,16 @@ public class GeoJvmInit extends StandaloneModelSubmitter {
 
   public static void main(String[] args) {
     DeclarersSingleton
-        .getInstance()
-        .add(new DistanceCalculatorController())
-        .add(new GoogleMapsGeocodingController())
-        .add(new StaticGoogleMapsGeocodingController())
-        .add(new ReverseGeocodingController())
-        .add(new SetEpsgController())
-        .add(new LatLngToGeoController())
-        .add(new SpeedCalculatorController())
-        .add(new StaticDistanceCalculatorController());
+            .getInstance()
+            .add(new DistanceCalculatorController())
+            .add(new GoogleMapsGeocodingController())
+            .add(new StaticGoogleMapsGeocodingController())
+            .add(new ReverseGeocodingController())
+            .add(new SetEpsgController())
+            .add(new LatLngToGeoController())
+            .add(new CreateTrajectoryFromPointsController())
+            .add(new SpeedCalculatorController())
+            .add(new StaticDistanceCalculatorController());
 
 
     DeclarersSingleton.getInstance().registerDataFormats(new JsonDataFormatFactory(),
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
new file mode 100755
index 0000000..3ad78d9
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory;
+
+import org.apache.streampipes.logging.api.Logger;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.processors.geo.jvm.jts.helper.SpGeometryBuilder;
+import org.apache.streampipes.processors.geo.jvm.jts.helper.SpTrajectoryBuilder;
+import org.apache.streampipes.wrapper.context.EventProcessorRuntimeContext;
+import org.apache.streampipes.wrapper.routing.SpOutputCollector;
+import org.apache.streampipes.wrapper.runtime.EventProcessor;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.Point;
+
+
+public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajectoryFromPointsParameter> {
+
+    private static Logger LOG;
+    private CreateTrajectoryFromPointsParameter params;
+    SpTrajectoryBuilder trajectory;
+
+
+
+    @Override
+    public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
+
+        LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
+        this.params = params;
+
+        trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
+    }
+
+    @Override
+    public void onEvent(Event in, SpOutputCollector out) {
+
+        String wkt = in.getFieldBySelector(params.getWkt()).getAsPrimitive().getAsString();
+        Integer epsg = in.getFieldBySelector(params.getEpsg()).getAsPrimitive().getAsInt();
+        Integer m = in.getFieldBySelector(params.getM()).getAsPrimitive().getAsInt();
+
+        Point eventGeom =  (Point) SpGeometryBuilder.createSPGeom(wkt,epsg);
+
+        //creates single trajectory
+        trajectory.addPointToTrajectory(eventGeom, m);
+        LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
+
+        in.addField(CreateTrajectoryFromPointsController.WKT, geom.toString());
+        in.addField(CreateTrajectoryFromPointsController.DESCRIPTION, trajectory.getDescription());
+        out.collect(in);
+
+    }
+
+    @Override
+    public void onDetach() {
+
+    }
+}
+
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
new file mode 100755
index 0000000..490007f
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory;
+
+import org.apache.streampipes.model.DataProcessorType;
+import org.apache.streampipes.model.graph.DataProcessorDescription;
+import org.apache.streampipes.model.graph.DataProcessorInvocation;
+import org.apache.streampipes.model.schema.PropertyScope;
+import org.apache.streampipes.sdk.builder.ProcessingElementBuilder;
+import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
+import org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
+import org.apache.streampipes.sdk.helpers.*;
+import org.apache.streampipes.sdk.utils.Assets;
+import org.apache.streampipes.vocabulary.SO;
+import org.apache.streampipes.wrapper.standalone.ConfiguredEventProcessor;
+import org.apache.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
+
+public class CreateTrajectoryFromPointsController extends  StandaloneEventProcessingDeclarer<CreateTrajectoryFromPointsParameter> {
+
+
+
+    public final static String WKT = "trajectory_wkt";
+    public final static String EPSG = "EPSG";
+    public final static String M = "M-Value";
+    public final static String DESCRIPTION = "description";
+    public final static String SUBPOINTS = "subpoints";
+
+    public final static String EPA_NAME = "Create Single Trajectory";
+
+
+    @Override
+    public DataProcessorDescription declareModel() {
+        return ProcessingElementBuilder
+                .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory",
+                        EPA_NAME,
+                        "Creates a trajectory from Points")
+                .category(DataProcessorType.GEO)
+                .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+                .requiredStream(
+                        StreamRequirementsBuilder
+                                .create()
+                                .requiredPropertyWithUnaryMapping(
+                                        EpRequirements.stringReq(),
+                                        Labels.from(WKT,
+                                                "Geometry WKT",
+                                                "WKT of the requested Geometry"),
+                                        PropertyScope.NONE
+                                )
+                                .requiredPropertyWithUnaryMapping(
+                                        EpRequirements.numberReq(),
+                                        Labels.from(EPSG, "EPSG Field", "EPSG Code for SRID"),
+                                        PropertyScope.NONE
+                                )
+                                .requiredPropertyWithUnaryMapping(
+                                        EpRequirements.numberReq(),
+                                        Labels.from(M, "M Value", "Choose a value add to trajectory"),
+                                        PropertyScope.NONE
+                                )
+                                .build()
+                )
+                .requiredTextParameter(
+                        Labels.from(
+                                DESCRIPTION,
+                                "description of trajectory",
+                                "Add a description for the trajectory")
+                )
+                .requiredIntegerParameter(
+                        Labels.from(
+                                SUBPOINTS,
+                                "number of allowed subpoints",
+                                "Number og allowed subpoints of the trajector"),
+                        2, 10, 1
+                )
+                .outputStrategy(OutputStrategies.append(
+                        EpProperties.stringEp(
+                                Labels.from(
+                                        "trajectory_wkt",
+                                        "trajectory_wkt",
+                                        "trajectory wkt (lineString) of a point stream"),
+                                WKT,
+                                SO.Text),
+                        EpProperties.stringEp(
+                                Labels.from(
+                                        "trajectory_description",
+                                        "trajectory_description",
+                                        "description of trajectory"),
+                                DESCRIPTION,
+                                SO.Text))
+                )
+
+                .supportedFormats(SupportedFormats.jsonFormat())
+                .supportedProtocols(SupportedProtocols.kafka())
+                .build();
+    }
+
+
+    @Override
+    public ConfiguredEventProcessor<CreateTrajectoryFromPointsParameter> onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) {
+
+
+        String wkt = extractor.mappingPropertyValue(WKT);
+        String epsg_value = extractor.mappingPropertyValue(EPSG);
+        String m = extractor.mappingPropertyValue(M);
+
+        String description = extractor.singleValueParameter(DESCRIPTION, String.class);
+        Integer subpoints = extractor.singleValueParameter(SUBPOINTS, Integer.class);
+
+
+        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg_value, description, subpoints, m);
+
+        return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
+    }
+}
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
new file mode 100755
index 0000000..0397ac5
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsParameter.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory;
+
+import org.apache.streampipes.model.graph.DataProcessorInvocation;
+import org.apache.streampipes.wrapper.params.binding.EventProcessorBindingParams;
+
+public class CreateTrajectoryFromPointsParameter extends EventProcessorBindingParams {
+
+    private String epsg;
+    private String wkt;
+    private String description;
+    private Integer subpoints;
+    private String m;
+
+
+    public CreateTrajectoryFromPointsParameter(DataProcessorInvocation graph, String wkt, String epsg, String description, Integer subpoints, String m) {
+        super(graph);
+        this.wkt = wkt;
+        this.epsg = epsg;
+        this.description = description;
+        this.subpoints = subpoints;
+        this.m = m;
+    }
+
+    public String getEpsg() {
+        return epsg;
+    }
+
+    public String getWkt() {
+        return wkt;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Integer getSubpoints() {
+        return subpoints;
+    }
+
+    public String getM() {
+        return m;
+    }
+}


[incubator-streampipes-extensions] 09/17: extended Geometry helper with WKT Reader

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 156b8ca9a6fb9f441a0660a33dc5935ec15c1fa0
Author: micklich <fl...@disy.net>
AuthorDate: Tue Apr 28 17:24:42 2020 +0200

    extended Geometry helper with WKT Reader
    
    
    Revert "extended Geometry helper with WKT Reader"
    
    This reverts commit e4cb162fef10504d67c83cc8340f93615d316d81.
    
    added WKT reader, trajectory class and documentation
    
    This reverts commit 953c1b65c30249fe10e7d8caae713892daa4e16f.
---
 .../geo/jvm/jts/helper/SpGeometryBuilder.java      |  40 +++++++-
 .../geo/jvm/jts/helper/SpTrajectoryBuilder.java    | 107 +++++++++++++++++++++
 .../documentation.md                               |  77 +++++++++++++++
 .../icon.png                                       | Bin 0 -> 9399 bytes
 .../strings.en                                     |   6 ++
 5 files changed, 227 insertions(+), 3 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
index 274796c..e6e183a 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
@@ -19,6 +19,8 @@
 package org.apache.streampipes.processors.geo.jvm.jts.helper;
 
 import org.locationtech.jts.geom.*;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTReader;
 
 public class SpGeometryBuilder {
 
@@ -31,9 +33,9 @@ public class SpGeometryBuilder {
   /**
    * Creates a JTS point geometry from Longitude and Latitude values
    *
-   * @param lng  Longitude value in the range -180 <Longitude > 180
-   * @param lat  Latitude value in the range -90 <LATITUDE > 90
-   * @param epsg EPSG Code for projection onfo
+   * @param lng Longitude value in the range -180 <Longitude > 180
+   * @param lat Latitude value in the range -90 <LATITUDE > 90
+   * @param epsg EPSG Code for projection info
    * @return a JTS Point Geometry Object with lat lng values. An empty point geometry is created if Latitude or Longitude values are out of range
    * or has null values.
    */
@@ -61,7 +63,39 @@ public class SpGeometryBuilder {
     return point;
   }
 
+
+  /**
+   * creates a Geometry from a wkt_string. string has to be valid and is not be checked. If invalid, an empty point
+   * geom is returned. method calls getPrecision method and creates a jts geometry factory and a WKT-parser object.
+   * from the wktString the
+   *
+   * @param wktString wkt text
+   * @param epsg EPSG Code for projection info
+   * @return Geometry geom: a JTS Geometry Object depending on the WKT input. An empty point geometry is created if Latitude or Longitude values are out of range
+   *    * or has null values
+   */
+  public static Geometry createSPGeom(String wktString, Integer epsg) {
+
+    Geometry geom;
+    PrecisionModel prec = getPrecisionModel(epsg);
+
+    GeometryFactory geomFactory = new GeometryFactory(prec, epsg);
+    WKTReader wktReader = new WKTReader(geomFactory);
+
+    try {
+      geom = wktReader.read(wktString);
+    } catch (ParseException e) {
+      // if wktString is invalid, an empty point geometry will be created as returnedGeom
+      geom = geomFactory.createPoint();
+    }
+
+    return geom;
+  }
+
+
+
   /**
+   *
    * @param checkedvalue Any Value
    * @param min          Min value to check
    * @param max          max value to check
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
new file mode 100644
index 0000000..4c9cc0d
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.helper;
+
+
+import org.locationtech.jts.geom.*;
+
+public class SpTrajectoryBuilder {
+
+    private int numberSubPoints;
+    private String description;
+    private CoordinateList coordinateList;
+
+    /**
+     * Constructor of SpTrajectory
+     * @param numberSubPoints Integer number of allowed subpoints of the trajectory
+     * @param description Text Description of the single Trajectory
+     */
+    public SpTrajectoryBuilder(int numberSubPoints, String description) {
+        this.numberSubPoints = numberSubPoints;
+        this.description = description;
+        this.coordinateList = new CoordinateList();
+    }
+
+
+    /**
+     * getter method for description text
+     * @return
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Adds a Point to the trajectory object and also handle removement depending on the
+     * number of choosen Subpoints
+     * @param point Point geometry
+     * @param m stores an extra integer to the subpoint of a trajectory
+     */
+    public void addPointToTrajectory(Point point, Integer m) {
+        coordinateList.add(createSingleTrajectoryCoordinate(point, m));
+        if (coordinateList.size() > numberSubPoints) {
+            removeOldestPoint();
+        }
+    }
+
+
+    /**
+     * returns a JTS LineString geometry from the trajectory object. LineString only stores the point geometry without M value.
+     *  The lineString is oriented to the trajectory direction. This means: the newest point is always the last point and has the
+     *  highest subpoint index. The First point is the oldest point with the lowest index [0]
+     * @param factory a Geometry factory for creating the lineString with the same precision and CRS and should be
+     *                the factory of the input point geometry
+     * @return JTS LineString JTS LineString
+     */
+    public LineString returnAsLineString(GeometryFactory factory){
+        LineString geom;
+        if ( coordinateList.size() > 1) {
+            //only linestring if more than 2 points.
+            // reverse output of linestring. so last added point is first
+            geom = factory.createLineString(coordinateList.toCoordinateArray());
+        } else {
+            geom = factory.createLineString();
+        }
+
+        return geom;
+    }
+
+    /**
+     * removes the oldest point (Index 0) from the CoordinateList object.
+     */
+    private void removeOldestPoint(){
+        coordinateList.remove(0);
+    }
+
+    /**
+     * Creates an Coordinate object with X, Y and M Value to be stored later directly in the trajectory object. Should be used
+     * always used if adding a subpoint to the trajectory list
+     * @param geom Point geometry, which coordinates will be added to the trajectory list
+     * @param m Integer M value, which will be used to store as extra parameter  in the trajectory list
+     * @return CoordinateXYM coordinate object
+     */
+    private CoordinateXYM createSingleTrajectoryCoordinate(Point geom, Integer m){
+        CoordinateXYM coordinate =new CoordinateXYM((geom.getX()), geom.getY(), m);
+        return coordinate;
+    }
+
+
+}
+
+
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/documentation.md b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/documentation.md
new file mode 100644
index 0000000..1fbec38
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/documentation.md
@@ -0,0 +1,77 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+
+## Trajectory from JTS Point
+
+<p align="center">
+    <img src="icon.png" width="150px;" class="pe-image-documentation"/>
+</p>
+
+***
+
+## Description
+
+This processor creates a JTS LineString geometry from  JTS Points events, represent a trajectory. A trajectory is defined  as the path that a moving object follows through space as a function of time. Each sub-point of this LineString represents a single event. The latest sub-point represents the latest geo-event. For each Point event it is also possible to store an additional m-value representing for example actually speed, distance, duration or direction of this event. A trajectory con [...]
+***
+
+## Required input
+
+*  WKT String of a JTS Point Geometry
+*  Integer value representing EPSG code
+*  Number value for M-value
+
+
+***
+
+## Configuration
+
+Creates a JTS Geometry LineString from a JTS Point Geometries events representing a trajectory.
+
+
+### 1st parameter
+Point WKT String
+
+### 2nd parameter
+EPSG code value
+
+### 3rd parameter
+M-value for each sub-point of the trajectory
+
+### 4rd parameter
+String for a description text for the trajectory
+
+### 5rd parameter
+Number of allowed sub-points
+
+***
+
+## Output
+
+Adds a LineString geometry in the Well Known Text to the event, representing a trajectory. Also the description text is added to the event stream. The first existing event creates an empty LineString.
+
+### Example
+Creating a LineString with a threshold of 2 allowed sub-points:
+
+* First Event:
+  * Point(8.12 41.23) --> LineString <empty>
+* Second Event:
+  * Point(8.56 41.25) --> LineString(8.12 41.23, 8.56 41.25)
+* Second Event:
+  * Point(8.84 40.98) --> LineString(8.56 41.25, 8.84 40.98)
+
+M-value is not represented in the LineString but will be stored for internal use!
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/icon.png b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/icon.png
new file mode 100644
index 0000000..7389006
Binary files /dev/null and b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/icon.png differ
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
new file mode 100644
index 0000000..a0dcba4
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
@@ -0,0 +1,6 @@
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.title=Static Google Maps Geocoder
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.description=GTrajectory from JTS point events
+appends these coordinates to every input event.
+
+place.title=Place
+place.description=Trajectory from single point events


[incubator-streampipes-extensions] 06/17: rewrite from labels.from to label.withID

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 8baaf58e0337ad504bc3478ce338118a1b23669f
Author: micklich <fl...@disy.net>
AuthorDate: Tue May 12 01:50:52 2020 +0200

    rewrite from labels.from to label.withID
---
 .../trajectory/CreateTrajectoryFromPoints.java     |  27 +++--
 .../CreateTrajectoryFromPointsController.java      | 129 +++++++++------------
 .../strings.en                                     |  24 +++-
 3 files changed, 95 insertions(+), 85 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
index 3ad78d9..26a695e 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPoints.java
@@ -32,16 +32,21 @@ import org.locationtech.jts.geom.Point;
 public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajectoryFromPointsParameter> {
 
     private static Logger LOG;
-    private CreateTrajectoryFromPointsParameter params;
-    SpTrajectoryBuilder trajectory;
 
+    private SpTrajectoryBuilder trajectory;
+
+    private String geom_wkt;
+    private String epsg_code;
+    private String m_value;
 
 
     @Override
     public void onInvocation(CreateTrajectoryFromPointsParameter params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) {
 
         LOG = params.getGraph().getLogger(CreateTrajectoryFromPointsParameter.class);
-        this.params = params;
+        this.geom_wkt =  params.getWkt();
+        this.epsg_code = params.getEpsg();
+        this.m_value = params.getM();
 
         trajectory = new SpTrajectoryBuilder(params.getSubpoints(), params.getDescription());
     }
@@ -49,18 +54,22 @@ public class CreateTrajectoryFromPoints implements EventProcessor<CreateTrajecto
     @Override
     public void onEvent(Event in, SpOutputCollector out) {
 
-        String wkt = in.getFieldBySelector(params.getWkt()).getAsPrimitive().getAsString();
-        Integer epsg = in.getFieldBySelector(params.getEpsg()).getAsPrimitive().getAsInt();
-        Integer m = in.getFieldBySelector(params.getM()).getAsPrimitive().getAsInt();
+        // extract values
+        String wkt = in.getFieldBySelector(geom_wkt).getAsPrimitive().getAsString();
+        Integer epsg = in.getFieldBySelector(epsg_code).getAsPrimitive().getAsInt();
+        Integer m = in.getFieldBySelector(m_value).getAsPrimitive().getAsInt();
 
+        //create JTS geometry
         Point eventGeom =  (Point) SpGeometryBuilder.createSPGeom(wkt,epsg);
 
-        //creates single trajectory
+        //adds point and m value to trajectory object
         trajectory.addPointToTrajectory(eventGeom, m);
+        // returns JTS LineString
         LineString geom = trajectory.returnAsLineString(eventGeom.getFactory());
 
-        in.addField(CreateTrajectoryFromPointsController.WKT, geom.toString());
-        in.addField(CreateTrajectoryFromPointsController.DESCRIPTION, trajectory.getDescription());
+        // adds to stream
+        in.addField("wkt-trajectory", geom.toString());
+        in.addField("description", trajectory.getDescription());
         out.collect(in);
 
     }
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index 654a907..a94140c 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -35,78 +35,65 @@ public class CreateTrajectoryFromPointsController extends  StandaloneEventProces
 
 
 
-    public final static String WKT = "trajectory_wkt";
-    public final static String EPSG = "EPSG";
-    public final static String M = "M-Value";
-    public final static String DESCRIPTION = "description";
-    public final static String SUBPOINTS = "subpoints";
 
+    public final static String POINT_KEY = "point-key";
+    public final static String EPSG_KEY = "epsg-key";
+    public final static String M_KEY = "m-key";
+    public final static String DESCRIPTION_KEY = "description-key";
+    public final static String SUBPOINTS_KEY = "subpoints-key";
+
+    public final static String WKT = "trajectory_wkt";
     public final static String EPA_NAME = "Create Single Trajectory";
 
 
     @Override
     public DataProcessorDescription declareModel() {
-        return ProcessingElementBuilder
-                .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory",
-                        EPA_NAME,
-                        "Creates a trajectory from Points")
-                .category(DataProcessorType.GEO)
-                .withAssets(Assets.DOCUMENTATION, Assets.ICON)
-                .requiredStream(
-                        StreamRequirementsBuilder
-                                .create()
-                                .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.domainPropertyReq("http://www.opengis.net/spec/geosparql/1.0#wktLiteral"),
-                                        Labels.from(WKT,
-                                                "Geometry WKT",
-                                                "WKT of the requested Geometry"),
-                                        PropertyScope.NONE
-                                )
-                                .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.domainPropertyReq("http://streampipes.org/epsg"),
-                                        Labels.from(EPSG, "EPSG Field", "EPSG Code for SRID"),
-                                        PropertyScope.NONE
-                                )
-                                .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.numberReq(),
-                                        Labels.from(M, "M Value", "Choose a value add to trajectory"),
-                                        PropertyScope.NONE
-                                )
-                                .build()
-                )
-                .requiredTextParameter(
-                        Labels.from(
-                                DESCRIPTION,
-                                "description of trajectory",
-                                "Add a description for the trajectory")
-                )
-                .requiredIntegerParameter(
-                        Labels.from(
-                                SUBPOINTS,
-                                "number of allowed subpoints",
-                                "Number og allowed subpoints of the trajector"),
-                        2, 10, 1
-                )
-                .outputStrategy(OutputStrategies.append(
-                        EpProperties.stringEp(
-                                Labels.from(
-                                        "trajectory_wkt",
-                                        "trajectory_wkt",
-                                        "trajectory wkt (lineString) of a point stream"),
-                                WKT,
-                                SO.Text),
-                        EpProperties.stringEp(
-                                Labels.from(
-                                        "trajectory_description",
-                                        "trajectory_description",
-                                        "description of trajectory"),
-                                DESCRIPTION,
-                                SO.Text))
-                )
-
-                .supportedFormats(SupportedFormats.jsonFormat())
-                .supportedProtocols(SupportedProtocols.kafka())
-                .build();
+      return ProcessingElementBuilder
+          .create("org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory")
+          .category(DataProcessorType.GEO)
+          .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+          .withLocales(Locales.EN)
+          .requiredStream(
+              StreamRequirementsBuilder
+                  .create()
+                  .requiredPropertyWithUnaryMapping(
+                      EpRequirements.domainPropertyReq("http://www.opengis.net/ont/geosparql#Geometry"),
+                      Labels.withId(POINT_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                  )
+                  .requiredPropertyWithUnaryMapping(
+                      EpRequirements.domainPropertyReq("http://data.ign.fr/def/ignf#CartesianCS"),
+                      Labels.withId(EPSG_KEY), PropertyScope.MEASUREMENT_PROPERTY
+                  )
+                  .requiredPropertyWithUnaryMapping(
+                      EpRequirements.numberReq(),
+                      Labels.withId(M_KEY),  PropertyScope.MEASUREMENT_PROPERTY
+                  )
+                  .build()
+          )
+          .requiredTextParameter(
+              Labels.withId(DESCRIPTION_KEY)
+          )
+          .requiredIntegerParameter(
+              Labels.withId(SUBPOINTS_KEY),
+              2, 30, 1
+          )
+
+          .outputStrategy(OutputStrategies.append(
+              EpProperties.numberEp(
+                  Labels.withId(M_KEY),
+                  "m-value",
+                  SO.Number
+              ),
+              EpProperties.numberEp(
+                  Labels.withId(WKT),
+                  "trajectory-wkt",
+                  "http://www.opengis.net/ont/geosparql#Geometry")
+              )
+          )
+
+          .supportedFormats(SupportedFormats.jsonFormat())
+          .supportedProtocols(SupportedProtocols.kafka())
+          .build();
     }
 
 
@@ -115,14 +102,14 @@ public class CreateTrajectoryFromPointsController extends  StandaloneEventProces
 
 
         String wkt = extractor.mappingPropertyValue(WKT);
-        String epsg_value = extractor.mappingPropertyValue(EPSG);
-        String m = extractor.mappingPropertyValue(M);
+        String epsg = extractor.mappingPropertyValue(EPSG_KEY);
+        String m = extractor.mappingPropertyValue(M_KEY);
 
-        String description = extractor.singleValueParameter(DESCRIPTION, String.class);
-        Integer subpoints = extractor.singleValueParameter(SUBPOINTS, Integer.class);
+        String description = extractor.singleValueParameter(DESCRIPTION_KEY, String.class);
+        Integer subpoints = extractor.singleValueParameter(SUBPOINTS_KEY, Integer.class);
 
 
-        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg_value, description, subpoints, m);
+        CreateTrajectoryFromPointsParameter params = new CreateTrajectoryFromPointsParameter(graph, wkt, epsg, description, subpoints, m);
 
         return new ConfiguredEventProcessor<>(params, CreateTrajectoryFromPoints::new);
     }
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
index a0dcba4..f38fef7 100644
--- a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
@@ -1,6 +1,20 @@
-org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.title=Static Google Maps Geocoder
-org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.description=GTrajectory from JTS point events
-appends these coordinates to every input event.
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.title=Single Trajectory Creator
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.description=Creates a trajectory from JTS point events
 
-place.title=Place
-place.description=Trajectory from single point events
+point-key.title=JTS Point Event
+point-key.description=Single Point Event which will be added to the trajectory
+
+point-key.title=JTS Point Event
+point-key.description=Single Point Event which will be added to the trajectory
+
+epsg-key.title=CRS of Input Point
+epsg-key.description=EPSG-Code of input point
+
+m-key.title=measurement value
+m-key.description=Measurement value which will be stored with each point event
+
+description-key.title=description text of trajectory
+description-key.description=A description text for the trajectory
+
+subpoints-key.title=number of allowed sub-points
+subpoints-key.description=amount of allowed sub-points, creating the trajectory


[incubator-streampipes-extensions] 02/17: extended Geometry helper with WKT Reader

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit f40542f8348bc1559ba296f72737e0c954a02b0f
Author: micklich <fl...@disy.net>
AuthorDate: Tue Apr 28 17:24:42 2020 +0200

    extended Geometry helper with WKT Reader
    
    
    Revert "extended Geometry helper with WKT Reader"
    
    This reverts commit e4cb162fef10504d67c83cc8340f93615d316d81.
    
    added WKT reader, trajectory class and documentation
    
    This reverts commit 953c1b65c30249fe10e7d8caae713892daa4e16f.
---
 .../geo/jvm/jts/helper/SpGeometryBuilder.java      |  35 ++++++-
 .../geo/jvm/jts/helper/SpTrajectoryBuilder.java    | 107 +++++++++++++++++++++
 .../documentation.md                               |  77 +++++++++++++++
 .../icon.png                                       | Bin 0 -> 9399 bytes
 .../strings.en                                     |   6 ++
 5 files changed, 224 insertions(+), 1 deletion(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
index c72635a..136db98 100644
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpGeometryBuilder.java
@@ -19,6 +19,8 @@
 package org.apache.streampipes.processors.geo.jvm.jts.helper;
 
 import org.locationtech.jts.geom.*;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTReader;
 
 public class SpGeometryBuilder {
 
@@ -32,7 +34,7 @@ public class SpGeometryBuilder {
    *
    * @param lng Longitude value in the range -180 <Longitude > 180
    * @param lat Latitude value in the range -90 <LATITUDE > 90
-   * @param epsg EPSG Code for projection onfo
+   * @param epsg EPSG Code for projection info
    * @return a JTS Point Geometry Object with lat lng values. An empty point geometry is created if Latitude or Longitude values are out of range
    * or has null values.
    */
@@ -60,6 +62,37 @@ public class SpGeometryBuilder {
     return point;
   }
 
+
+  /**
+   * creates a Geometry from a wkt_string. string has to be valid and is not be checked. If invalid, an empty point
+   * geom is returned. method calls getPrecision method and creates a jts geometry factory and a WKT-parser object.
+   * from the wktString the
+   *
+   * @param wktString wkt text
+   * @param epsg EPSG Code for projection info
+   * @return Geometry geom: a JTS Geometry Object depending on the WKT input. An empty point geometry is created if Latitude or Longitude values are out of range
+   *    * or has null values
+   */
+  public static Geometry createSPGeom(String wktString, Integer epsg) {
+
+    Geometry geom;
+    PrecisionModel prec = getPrecisionModel(epsg);
+
+    GeometryFactory geomFactory = new GeometryFactory(prec, epsg);
+    WKTReader wktReader = new WKTReader(geomFactory);
+
+    try {
+      geom = wktReader.read(wktString);
+    } catch (ParseException e) {
+      // if wktString is invalid, an empty point geometry will be created as returnedGeom
+      geom = geomFactory.createPoint();
+    }
+
+    return geom;
+  }
+
+
+
   /**
    *
    * @param checkedvalue Any Value
diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
new file mode 100644
index 0000000..4c9cc0d
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.processors.geo.jvm.jts.helper;
+
+
+import org.locationtech.jts.geom.*;
+
+public class SpTrajectoryBuilder {
+
+    private int numberSubPoints;
+    private String description;
+    private CoordinateList coordinateList;
+
+    /**
+     * Constructor of SpTrajectory
+     * @param numberSubPoints Integer number of allowed subpoints of the trajectory
+     * @param description Text Description of the single Trajectory
+     */
+    public SpTrajectoryBuilder(int numberSubPoints, String description) {
+        this.numberSubPoints = numberSubPoints;
+        this.description = description;
+        this.coordinateList = new CoordinateList();
+    }
+
+
+    /**
+     * getter method for description text
+     * @return
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Adds a Point to the trajectory object and also handle removement depending on the
+     * number of choosen Subpoints
+     * @param point Point geometry
+     * @param m stores an extra integer to the subpoint of a trajectory
+     */
+    public void addPointToTrajectory(Point point, Integer m) {
+        coordinateList.add(createSingleTrajectoryCoordinate(point, m));
+        if (coordinateList.size() > numberSubPoints) {
+            removeOldestPoint();
+        }
+    }
+
+
+    /**
+     * returns a JTS LineString geometry from the trajectory object. LineString only stores the point geometry without M value.
+     *  The lineString is oriented to the trajectory direction. This means: the newest point is always the last point and has the
+     *  highest subpoint index. The First point is the oldest point with the lowest index [0]
+     * @param factory a Geometry factory for creating the lineString with the same precision and CRS and should be
+     *                the factory of the input point geometry
+     * @return JTS LineString JTS LineString
+     */
+    public LineString returnAsLineString(GeometryFactory factory){
+        LineString geom;
+        if ( coordinateList.size() > 1) {
+            //only linestring if more than 2 points.
+            // reverse output of linestring. so last added point is first
+            geom = factory.createLineString(coordinateList.toCoordinateArray());
+        } else {
+            geom = factory.createLineString();
+        }
+
+        return geom;
+    }
+
+    /**
+     * removes the oldest point (Index 0) from the CoordinateList object.
+     */
+    private void removeOldestPoint(){
+        coordinateList.remove(0);
+    }
+
+    /**
+     * Creates an Coordinate object with X, Y and M Value to be stored later directly in the trajectory object. Should be used
+     * always used if adding a subpoint to the trajectory list
+     * @param geom Point geometry, which coordinates will be added to the trajectory list
+     * @param m Integer M value, which will be used to store as extra parameter  in the trajectory list
+     * @return CoordinateXYM coordinate object
+     */
+    private CoordinateXYM createSingleTrajectoryCoordinate(Point geom, Integer m){
+        CoordinateXYM coordinate =new CoordinateXYM((geom.getX()), geom.getY(), m);
+        return coordinate;
+    }
+
+
+}
+
+
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/documentation.md b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/documentation.md
new file mode 100644
index 0000000..1fbec38
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/documentation.md
@@ -0,0 +1,77 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+
+## Trajectory from JTS Point
+
+<p align="center">
+    <img src="icon.png" width="150px;" class="pe-image-documentation"/>
+</p>
+
+***
+
+## Description
+
+This processor creates a JTS LineString geometry from  JTS Points events, represent a trajectory. A trajectory is defined  as the path that a moving object follows through space as a function of time. Each sub-point of this LineString represents a single event. The latest sub-point represents the latest geo-event. For each Point event it is also possible to store an additional m-value representing for example actually speed, distance, duration or direction of this event. A trajectory con [...]
+***
+
+## Required input
+
+*  WKT String of a JTS Point Geometry
+*  Integer value representing EPSG code
+*  Number value for M-value
+
+
+***
+
+## Configuration
+
+Creates a JTS Geometry LineString from a JTS Point Geometries events representing a trajectory.
+
+
+### 1st parameter
+Point WKT String
+
+### 2nd parameter
+EPSG code value
+
+### 3rd parameter
+M-value for each sub-point of the trajectory
+
+### 4rd parameter
+String for a description text for the trajectory
+
+### 5rd parameter
+Number of allowed sub-points
+
+***
+
+## Output
+
+Adds a LineString geometry in the Well Known Text to the event, representing a trajectory. Also the description text is added to the event stream. The first existing event creates an empty LineString.
+
+### Example
+Creating a LineString with a threshold of 2 allowed sub-points:
+
+* First Event:
+  * Point(8.12 41.23) --> LineString <empty>
+* Second Event:
+  * Point(8.56 41.25) --> LineString(8.12 41.23, 8.56 41.25)
+* Second Event:
+  * Point(8.84 40.98) --> LineString(8.56 41.25, 8.84 40.98)
+
+M-value is not represented in the LineString but will be stored for internal use!
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/icon.png b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/icon.png
new file mode 100644
index 0000000..7389006
Binary files /dev/null and b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/icon.png differ
diff --git a/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
new file mode 100644
index 0000000..a0dcba4
--- /dev/null
+++ b/streampipes-processors-geo-jvm/src/main/resources/org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory/strings.en
@@ -0,0 +1,6 @@
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.title=Static Google Maps Geocoder
+org.apache.streampipes.processors.geo.jvm.jts.processor.trajectory.description=GTrajectory from JTS point events
+appends these coordinates to every input event.
+
+place.title=Place
+place.description=Trajectory from single point events


[incubator-streampipes-extensions] 12/17: ontologie

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

micklich pushed a commit to branch feature/trajectory
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 6de2600f29f6421e5a1fd2d2c78c2af582f41416
Author: micklich <fl...@disy.net>
AuthorDate: Mon May 11 16:34:59 2020 +0200

    ontologie
---
 .../processor/trajectory/CreateTrajectoryFromPointsController.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
index 490007f..654a907 100755
--- a/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
+++ b/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/processor/trajectory/CreateTrajectoryFromPointsController.java
@@ -56,14 +56,14 @@ public class CreateTrajectoryFromPointsController extends  StandaloneEventProces
                         StreamRequirementsBuilder
                                 .create()
                                 .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.stringReq(),
+                                        EpRequirements.domainPropertyReq("http://www.opengis.net/spec/geosparql/1.0#wktLiteral"),
                                         Labels.from(WKT,
                                                 "Geometry WKT",
                                                 "WKT of the requested Geometry"),
                                         PropertyScope.NONE
                                 )
                                 .requiredPropertyWithUnaryMapping(
-                                        EpRequirements.numberReq(),
+                                        EpRequirements.domainPropertyReq("http://streampipes.org/epsg"),
                                         Labels.from(EPSG, "EPSG Field", "EPSG Code for SRID"),
                                         PropertyScope.NONE
                                 )