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 2022/11/23 22:53:21 UTC
[streampipes] 13/16: styleguide and change input value for method addPoint
This is an automated email from the ASF dual-hosted git repository.
micklich pushed a commit to branch STREAMPIPES-642
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit d22ab8680e8c09f019d7f8529aee43b080cb6586
Author: micklich <mi...@apache.org>
AuthorDate: Wed Nov 23 23:40:25 2022 +0100
styleguide and change input value for method addPoint
---
.../geo/jvm/jts/helper/SpTrajectoryBuilder.java | 44 +++++++++++++---------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
index 7f6b48b3e..dff143021 100644
--- a/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
+++ b/streampipes-extensions/streampipes-processors-geo-jvm/src/main/java/org/apache/streampipes/processors/geo/jvm/jts/helper/SpTrajectoryBuilder.java
@@ -18,18 +18,23 @@
package org.apache.streampipes.processors.geo.jvm.jts.helper;
-import org.locationtech.jts.geom.*;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.CoordinateList;
+import org.locationtech.jts.geom.CoordinateXYM;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.Point;
public class SpTrajectoryBuilder {
-
private int numberSubPoints;
private String description;
private CoordinateList coordinateList;
/**
* Constructor of SpTrajectory
+ *
* @param numberSubPoints Integer number of allowed sub-points of the trajectory
- * @param description Text Description of the single Trajectory
+ * @param description Text Description of the single Trajectory
*/
public SpTrajectoryBuilder(int numberSubPoints, String description) {
this.numberSubPoints = numberSubPoints;
@@ -38,20 +43,23 @@ public class SpTrajectoryBuilder {
}
- /**
+ /**
* getter method for description text
+ *
* @return description text
*/
public String getDescription() {
return description;
}
+
/**
* 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}
+ * @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) {
+ public void addPointToTrajectory(Point point, Double m) {
coordinateList.add(createSingleTrajectoryCoordinate(point, m));
if (coordinateList.size() > numberSubPoints) {
removeOldestPoint();
@@ -61,45 +69,45 @@ public class SpTrajectoryBuilder {
/**
* 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]
+ * 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){
+ public LineString returnAsLineString(GeometryFactory factory) {
LineString geom;
- if ( coordinateList.size() > 1) {
+ 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(){
+ 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
+ * Creates a 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
+ * @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);
+ private Coordinate createSingleTrajectoryCoordinate(Point geom, Double m) {
+ CoordinateXYM coordinate = new CoordinateXYM((geom.getX()), geom.getY(), m);
return coordinate;
}
-
-
}