This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-db.git
The following commit(s) were added to refs/heads/main by this push:
new adde6c3 Use spatial predicates defined by TG when tg feature is
enabled (#26)
adde6c3 is described below
commit adde6c3f907c41fbfa5d485f88d370ad5b86c864
Author: Kristin Cowalcijk <[email protected]>
AuthorDate: Sat Sep 6 01:08:13 2025 +0800
Use spatial predicates defined by TG when tg feature is enabled (#26)
* Use spatial predicates defined by TG when tg feature is enabled
* Mark the failing test using xfail instead of skip
---
python/sedonadb/tests/functions/test_predicates.py | 34 ++++++++++++++++++----
rust/sedona-common/src/option.rs | 2 +-
rust/sedona/src/context.rs | 3 ++
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/python/sedonadb/tests/functions/test_predicates.py
b/python/sedonadb/tests/functions/test_predicates.py
index fafe9f5..91d9ddb 100644
--- a/python/sedonadb/tests/functions/test_predicates.py
+++ b/python/sedonadb/tests/functions/test_predicates.py
@@ -312,11 +312,6 @@ def test_st_touches(eng, geom1, geom2, expected):
"MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((0 0, 1 0, 1 1, 0 1,
0 0)))",
True,
),
- (
- "POINT (0 0)",
- "GEOMETRYCOLLECTION (POINT (0 0), LINESTRING (0 0, 1 1), POLYGON
((0 0, 1 0, 1 1, 0 1, 0 0)))",
- False,
- ),
# Identical geometries are not considered within each other
("POINT (0 0)", "POINT (0 0)", True),
(
@@ -333,3 +328,32 @@ def test_st_within(eng, geom1, geom2, expected):
f"SELECT ST_Within({geom_or_null(geom1)}, {geom_or_null(geom2)})",
expected,
)
+
+
[email protected](reason="https://github.com/tidwall/tg/issues/20")
[email protected]("eng", [SedonaDB, PostGIS])
[email protected](
+ ("geom1", "geom2", "expected"),
+ [
+ # These cases demonstrates the weirdness of ST_Contains:
+ # Both POINT(0 0) and GEOMETRYCOLLECTION (POINT (0 0)) contains POINT
(0 0),
+ # but GEOMETRYCOLLECTION (POINT (0 0), LINESTRING (0 0, 1 1)) does not
contain POINT (0 0).
+ # See
https://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html
+ (
+ "POINT (0 0)",
+ "GEOMETRYCOLLECTION (POINT (0 0), LINESTRING (0 0, 1 1))",
+ False,
+ ),
+ (
+ "POINT (0 0)",
+ "GEOMETRYCOLLECTION (POINT (0 0), LINESTRING (0 0, 1 1), POLYGON
((0 0, 1 0, 1 1, 0 1, 0 0)))",
+ False,
+ ),
+ ],
+)
+def test_st_within_skipped(eng, geom1, geom2, expected):
+ eng = eng.create_or_skip()
+ eng.assert_query_result(
+ f"SELECT ST_Within({geom_or_null(geom1)}, {geom_or_null(geom2)})",
+ expected,
+ )
diff --git a/rust/sedona-common/src/option.rs b/rust/sedona-common/src/option.rs
index 90d9ab0..a788ba5 100644
--- a/rust/sedona-common/src/option.rs
+++ b/rust/sedona-common/src/option.rs
@@ -53,7 +53,7 @@ config_namespace! {
pub enable: bool, default = true
/// Spatial library to use for spatial join
- pub spatial_library: SpatialLibrary, default = SpatialLibrary::Geo
+ pub spatial_library: SpatialLibrary, default = SpatialLibrary::Tg
/// Options for configuring the GEOS spatial library
pub geos: GeosOptions, default = GeosOptions::default()
diff --git a/rust/sedona/src/context.rs b/rust/sedona/src/context.rs
index 9779854..68b87bb 100644
--- a/rust/sedona/src/context.rs
+++ b/rust/sedona/src/context.rs
@@ -138,6 +138,9 @@ impl SedonaContext {
#[cfg(feature = "geo")]
out.register_scalar_kernels(sedona_geo::register::scalar_kernels().into_iter())?;
+ #[cfg(feature = "tg")]
+
out.register_scalar_kernels(sedona_tg::register::scalar_kernels().into_iter())?;
+
// Register geo aggregate kernels if built with geo support
#[cfg(feature = "geo")]
out.register_aggregate_kernels(sedona_geo::register::aggregate_kernels().into_iter())?;