Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion c/sedona-geos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ mod st_minimumclearance_line;
mod st_normalize;
mod st_nrings;
mod st_numinteriorrings;
mod st_numpoints;
mod st_perimeter;
mod st_polygonize;
mod st_polygonize_agg;
Expand Down
1 change: 0 additions & 1 deletion c/sedona-geos/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub fn scalar_kernels() -> Vec<(&'static str, Vec<ScalarKernelRef>)> {
"st_normalize" => crate::st_normalize::st_normalize_impl,
"st_nrings" => crate::st_nrings::st_nrings_impl,
"st_numinteriorrings" => crate::st_numinteriorrings::st_num_interior_rings_impl,
"st_numpoints" => crate::st_numpoints::st_num_points_impl,
"st_overlaps" => crate::binary_predicates::st_overlaps_impl,
"st_perimeter" => crate::st_perimeter::st_perimeter_impl,
"st_polygonize" => crate::st_polygonize::st_polygonize_impl,
Expand Down
146 changes: 0 additions & 146 deletions c/sedona-geos/src/st_numpoints.rs

This file was deleted.

2 changes: 2 additions & 0 deletions docs/reference/sql/st_npoints.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ kernels:

Returns the total number of coordinate points in the geometry, counting all vertices across all components.

Aliases: `ST_NumPoints`.

## Examples

```sql
Expand Down
40 changes: 8 additions & 32 deletions python/sedonadb/tests/functions/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2605,6 +2605,7 @@ def test_st_pointm(eng, x, y, m, expected):
],
)
def test_st_points(eng, geometry, expected, expected_n):
is_postgis = eng is PostGIS
eng = eng.create_or_skip()
eng.assert_query_result(
f"SELECT ST_Points({geom_or_null(geometry)})",
Expand All @@ -2614,6 +2615,13 @@ def test_st_points(eng, geometry, expected, expected_n):
f"SELECT ST_NPoints({geom_or_null(geometry)})",
expected_n,
)
if not is_postgis:
# ST_NumPoints is an alias for ST_NPoints in SedonaDB.
# PostGIS still treats ST_NumPoints as LineString-only despite documentation.
eng.assert_query_result(
f"SELECT ST_NumPoints({geom_or_null(geometry)})",
expected_n,
)


@pytest.mark.parametrize("eng", [SedonaDB, PostGIS])
Expand Down Expand Up @@ -3767,38 +3775,6 @@ def test_st_numinteriorrings_basic(eng, geom, expected):
)


@pytest.mark.parametrize("eng", [SedonaDB, PostGIS])
@pytest.mark.parametrize(
("geom", "expected"),
[
(None, None),
("POINT EMPTY", None),
("LINESTRING EMPTY", 0),
("POLYGON EMPTY", None),
("MULTIPOINT EMPTY", None),
("MULTILINESTRING EMPTY", None),
("MULTIPOLYGON EMPTY", None),
("GEOMETRYCOLLECTION EMPTY", None),
("POINT (1 2)", None),
("LINESTRING (0 0, 1 1, 2 2)", 3),
("LINESTRING (0 0, 1 1, 0 0)", 3),
("LINESTRING Z (0 0 0, 1 1 1, 2 2 2, 3 3 3)", 4),
("LINESTRING M (0 0 0, 1 1 1, 2 2 2, 3 3 3)", 4),
("LINESTRING ZM (0 0 0 2, 1 1 1 4)", 2),
("POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))", None),
("MULTILINESTRING ((0 0, 0 1, 1 1, 0 0),(0 0, 1 1))", None),
("GEOMETRYCOLLECTION (LINESTRING (0 0, 0 1, 1 1, 0 0))", None),
("POLYGON ((0 0,6 0,6 6,0 6,0 0),(2 2,4 2,4 4,2 4,2 2))", None),
],
)
def test_st_numpoints(eng, geom, expected):
eng = eng.create_or_skip()
eng.assert_query_result(
f"SELECT ST_NumPoints({geom_or_null(geom)})",
expected,
)


@pytest.mark.parametrize("eng", [SedonaDB, PostGIS])
@pytest.mark.parametrize(
("geom", "expected"),
Expand Down
20 changes: 10 additions & 10 deletions python/sedonadb/tests/geography/test_geog_mechanical_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,28 +638,28 @@ def test_st_numinteriorrings(eng, geog, expected):
("geog", "expected"),
[
pytest.param(None, None, id="null"),
pytest.param("POINT EMPTY", None, id="point_empty"),
pytest.param("POINT EMPTY", 0, id="point_empty"),
pytest.param("LINESTRING EMPTY", 0, id="linestring_empty"),
pytest.param("POLYGON EMPTY", None, id="polygon_empty"),
pytest.param("MULTIPOINT EMPTY", None, id="multipoint_empty"),
pytest.param("MULTILINESTRING EMPTY", None, id="multilinestring_empty"),
pytest.param("MULTIPOLYGON EMPTY", None, id="multipolygon_empty"),
pytest.param("GEOMETRYCOLLECTION EMPTY", None, id="geometrycollection_empty"),
pytest.param("POINT (1 2)", None, id="point"),
pytest.param("POLYGON EMPTY", 0, id="polygon_empty"),
pytest.param("MULTIPOINT EMPTY", 0, id="multipoint_empty"),
pytest.param("MULTILINESTRING EMPTY", 0, id="multilinestring_empty"),
pytest.param("MULTIPOLYGON EMPTY", 0, id="multipolygon_empty"),
pytest.param("GEOMETRYCOLLECTION EMPTY", 0, id="geometrycollection_empty"),
pytest.param("POINT (1 2)", 1, id="point"),
pytest.param("LINESTRING (0 0, 1 1, 2 2)", 3, id="linestring"),
pytest.param("LINESTRING (0 0, 1 1, 0 0)", 3, id="linestring_closed"),
pytest.param("LINESTRING Z (0 0 0, 1 1 1, 2 2 2, 3 3 3)", 4, id="linestring_z"),
pytest.param("LINESTRING M (0 0 0, 1 1 1, 2 2 2, 3 3 3)", 4, id="linestring_m"),
pytest.param("LINESTRING ZM (0 0 0 2, 1 1 1 4)", 2, id="linestring_zm"),
pytest.param("POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))", None, id="polygon"),
pytest.param("POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))", 5, id="polygon"),
pytest.param(
"MULTILINESTRING ((0 0, 0 1, 1 1, 0 0),(0 0, 1 1))",
None,
6,
id="multilinestring",
),
pytest.param(
"GEOMETRYCOLLECTION (LINESTRING (0 0, 0 1, 1 1, 0 0))",
None,
4,
id="geometrycollection",
),
],
Expand Down
7 changes: 7 additions & 0 deletions rust/sedona-functions/src/st_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub fn st_npoints_udf() -> SedonaScalarUDF {
ItemCrsKernel::wrap_impl(vec![Arc::new(STNPoints)]),
Volatility::Immutable,
)
.with_aliases(vec!["st_numpoints".to_string()])
}

#[derive(Debug)]
Expand Down Expand Up @@ -296,6 +297,12 @@ mod tests {
assert!(st_npoints_udf.documentation().is_none());
}

#[test]
fn npoints_aliases() {
let udf: ScalarUDF = st_npoints_udf().into();
assert!(udf.aliases().contains(&"st_numpoints".to_string()));
}

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_GEOGRAPHY)] sedona_type: SedonaType) {
use arrow_array::UInt64Array;
Expand Down
Loading