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

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new d07197bd1a feat(Geometry): add rhumb line
d07197bd1a is described below

commit d07197bd1ad573669cc78c7094b9bb3349f3815b
Author: jsorel <[email protected]>
AuthorDate: Mon Sep 7 11:19:26 2026 +0200

    feat(Geometry): add rhumb line
---
 .../org/apache/sis/geometries/GeometryFactory.java |  6 ++
 .../org/apache/sis/geometries/curve/Rhumb.java     | 66 ++++++++++++++++++++++
 .../shared/DefaultRhumb.java}                      | 40 +++++++++----
 3 files changed, 100 insertions(+), 12 deletions(-)

diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryFactory.java
 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryFactory.java
index 66343471a9..3423f52207 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryFactory.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/GeometryFactory.java
@@ -33,6 +33,7 @@ import org.apache.sis.geometries.curve.LineString;
 import org.apache.sis.geometries.curve.LinearRing;
 import org.apache.sis.geometries.curve.MultiCurve;
 import org.apache.sis.geometries.curve.MultiLineString;
+import org.apache.sis.geometries.curve.Rhumb;
 import org.apache.sis.geometries.internal.shared.ArrayDataPoints;
 import org.apache.sis.geometries.internal.shared.DefaultArcByBulge;
 import org.apache.sis.geometries.internal.shared.DefaultArcByCenterPoint;
@@ -57,6 +58,7 @@ import 
org.apache.sis.geometries.internal.shared.DefaultPolyhedron;
 import org.apache.sis.geometries.internal.shared.DefaultRawMultiPoint;
 import org.apache.sis.geometries.internal.shared.DefaultReversedCurve;
 import org.apache.sis.geometries.internal.shared.DefaultReversedSurface;
+import org.apache.sis.geometries.internal.shared.DefaultRhumb;
 import org.apache.sis.geometries.internal.shared.DefaultTriangle;
 import org.apache.sis.geometries.internal.shared.DefaultTriangulatedSurface;
 import org.apache.sis.geometries.point.MultiPoint;
@@ -128,6 +130,10 @@ public final class GeometryFactory extends 
org.apache.sis.geometry.wrapper.Geome
         return new DefaultGeodesic(sequence);
     }
 
+    public static Rhumb createRhumb(DataPoints sequence) {
+        return new DefaultRhumb(sequence);
+    }
+
     public static LinearRing createLinearRing(DataPoints sequence) {
         return new DefaultLinearRing(sequence);
     }
diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/curve/Rhumb.java
 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/curve/Rhumb.java
index e5cb5760a6..48c88dba86 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/curve/Rhumb.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/curve/Rhumb.java
@@ -16,20 +16,34 @@
  */
 package org.apache.sis.geometries.curve;
 
+import org.apache.sis.geometries.AttributesType;
 import org.apache.sis.geometries.Bearing;
 import org.apache.sis.geometries.Curve;
 import org.apache.sis.geometries.CurveInterpolation;
+import org.apache.sis.geometries.DataPoints;
+import org.apache.sis.geometries.Point;
+import org.apache.sis.geometries.internal.shared.AbstractGeometry;
+import org.apache.sis.maths.Array;
 import static org.opengis.annotation.Specification.ISO_19107;
 import org.opengis.annotation.UML;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 
 /**
+ * A curve on the ellipsoid following a constant bearing from one point to the 
next.
  *
  * @author Johann Sorel (Geomatys)
  */
 @UML(identifier="Rhumb", specification=ISO_19107) // section 7.5.1
 public interface Rhumb extends Curve {
 
+    public static final String TYPE = "RHUMB";
+
+    @Override
+    public default String getGeometryType() {
+        return TYPE;
+    }
+
     @UML(identifier="interpolation", specification=ISO_19107) // section 
7.5.2.1
     @Override
     public default CurveInterpolation getInterpolation() {
@@ -38,4 +52,56 @@ public interface Rhumb extends Curve {
 
     //TODO in the UML but not in the spec
     Bearing getBearing();
+
+    /**
+     * The number of Points in this Geodesic.
+     *
+     * @see OGC Simple Feature Access 1.2.1 - 6.1.7.2
+     * @return number of Points in this Geodesic.
+     */
+    default int getNumPoints() {
+        return getDataPoints().size();
+    }
+
+    /**
+     * Returns the specified Point N in this Rhumb.
+     *
+     * @see OGC Simple Feature Access 1.2.1 - 6.1.7.2
+     * @return the specified Point N in this Geodesic.
+     */
+    default Point getPointN(int n) {
+        return getDataPoints().getPoint(n);
+    }
+
+    /**
+     * @return null, a Rhumb has no control points
+     */
+    @Override
+    public default Array getControlPoints() {
+        return null;
+    }
+
+    @Override
+    default CoordinateReferenceSystem getCoordinateReferenceSystem() {
+        return getDataPoints().getCoordinateReferenceSystem();
+    }
+
+    @Override
+    default void setCoordinateReferenceSystem(CoordinateReferenceSystem cs) 
throws IllegalArgumentException {
+        getDataPoints().setCoordinateReferenceSystem(cs);
+    }
+
+    @Override
+    public default AttributesType getAttributesType() {
+        return getDataPoints().getAttributesType();
+    }
+
+    @Override
+    default String asText() {
+        final StringBuilder sb = new StringBuilder("RHUMB (");
+        final DataPoints points = getDataPoints();
+        AbstractGeometry.toText(sb, points);
+        sb.append(')');
+        return sb.toString();
+    }
 }
diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/curve/Rhumb.java
 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/internal/shared/DefaultRhumb.java
similarity index 54%
copy from 
incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/curve/Rhumb.java
copy to 
incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/internal/shared/DefaultRhumb.java
index e5cb5760a6..b99ef01489 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/curve/Rhumb.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/internal/shared/DefaultRhumb.java
@@ -14,28 +14,44 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.geometries.curve;
+package org.apache.sis.geometries.internal.shared;
 
 import org.apache.sis.geometries.Bearing;
-import org.apache.sis.geometries.Curve;
-import org.apache.sis.geometries.CurveInterpolation;
-import static org.opengis.annotation.Specification.ISO_19107;
-import org.opengis.annotation.UML;
+import org.apache.sis.geometries.DataPoints;
+import org.apache.sis.geometries.curve.Rhumb;
+import org.opengis.geometry.Envelope;
 
 
 /**
  *
  * @author Johann Sorel (Geomatys)
  */
-@UML(identifier="Rhumb", specification=ISO_19107) // section 7.5.1
-public interface Rhumb extends Curve {
+public class DefaultRhumb extends AbstractGeometry implements Rhumb {
+
+    private final DataPoints points;
+
+    public DefaultRhumb(DataPoints points) {
+        this.points = points;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return points.isEmpty();
+    }
+
+    @Override
+    public DataPoints getDataPoints() {
+        return points;
+    }
+
+    @Override
+    public Envelope getEnvelope() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
 
-    @UML(identifier="interpolation", specification=ISO_19107) // section 
7.5.2.1
     @Override
-    public default CurveInterpolation getInterpolation() {
-        return CurveInterpolation.RHUMB;
+    public Bearing getBearing() {
+        throw new UnsupportedOperationException("Not supported yet.");
     }
 
-    //TODO in the UML but not in the spec
-    Bearing getBearing();
 }

Reply via email to