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
commit c95884437103cee47258e67e34dcec72f6611b99 Author: jsorel <[email protected]> AuthorDate: Wed Dec 2 10:10:25 2026 +0100 feat(Geometry): add GeometryFactory.createDataPoints with a sample system --- .../main/org/apache/sis/geometries/GeometryFactory.java | 16 ++++++++++++++-- .../org/apache/sis/geometries/GeometryFactoryTest.java | 13 +++++++++++++ 2 files changed, 27 insertions(+), 2 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 59ca1cbe86..1d587f5e18 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 @@ -153,8 +153,20 @@ public final class GeometryFactory { } public DataPoints createDataPoints(CoordinateReferenceSystem crs, double ... positions) { - final Array array = NDArrays.of(crs, positions); - return createDataPoints(array); + return createDataPoints(SampleSystem.of(crs), positions); + } + + /** + * Creates data points in the coordinate reference system of the given sample system. + * Giving the sample system avoids looking it up from the coordinate reference system, + * which matters when many small data points are created. + * + * @param system sample system of the positions. + * @param positions coordinates of the positions, one position after the other. + * @return created data points. + */ + public DataPoints createDataPoints(SampleSystem system, double ... positions) { + return createDataPoints(NDArrays.of(system, positions)); } /** diff --git a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/GeometryFactoryTest.java b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/GeometryFactoryTest.java index 8c17095b11..77efc957ff 100644 --- a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/GeometryFactoryTest.java +++ b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/GeometryFactoryTest.java @@ -21,12 +21,14 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.apache.sis.geometries.curve.Circle; import org.apache.sis.geometries.surface.CurvePolygon; import org.apache.sis.geometries.surface.Polygon; +import org.apache.sis.maths.SampleSystem; import org.apache.sis.maths.Vector; // Test dependencies import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertSame; import org.junit.jupiter.api.Test; @@ -51,6 +53,17 @@ public class GeometryFactoryTest extends GeometryTest { assertArrayEquals(new double[] {bounds[2], bounds[3]}, envelope.getUpperCorner().getCoordinates(), CURVE_TOLERANCE); } + /** + * Data points created with a sample system are in the coordinate reference system of that sample system. + */ + @Test + public void testCreateDataPoints() { + final DataPoints points = F.createDataPoints(SampleSystem.of(CRS2), 1, 2, 3, 4); + assertSame(CRS2, points.getCoordinateReferenceSystem()); + assertEquals(2, points.size()); + assertArrayEquals(new double[] {1, 2, 3, 4}, points.getAttributeArray(DataPointsType.ATT_POSITION).toArrayDouble()); + } + /** * The quadrilateral turns counterclockwise from the first half axis toward the second one. */
