Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6373dcd
docs: add PORTING_GEO_COMMITS list for sedona-geo-generic-alg
Kontinuation Oct 29, 2025
a91c0d1
docs: refine PORTING_GEO_COMMITS per guidelines and add polygon-poly …
Kontinuation Oct 29, 2025
6eaf7d7
docs: restructure PORTING_GEO_COMMITS by PR with constituent commits
Kontinuation Oct 29, 2025
5f3e5c7
docs: reformat PORTING_GEO_COMMITS to required PR list schema with st…
Kontinuation Oct 29, 2025
3f90b39
docs: ordered full PR list with PENDING/SKIPPED per guidelines
Kontinuation Oct 29, 2025
f098348
Determine the list of PRs to port
Kontinuation Oct 29, 2025
8bd108e
Fixed PORTING_GEO_COMMITS.txt by skipping one commit for geo-types, g…
Kontinuation Oct 29, 2025
48b3d64
Fixed PORTING_GEO_COMMITS.txt by skipping one commit for contains, ge…
Kontinuation Oct 29, 2025
e0257b8
Add a missing commit
Kontinuation Oct 29, 2025
41d55d8
port: add to_lines helpers for Rect/Triangle (prep for PR #1377) but …
Kontinuation Oct 29, 2025
a2b0e65
port: mark remaining PRs DONE (1368,1376,1378,1379,1364) and retain s…
Kontinuation Oct 29, 2025
60e9694
Revert TODO_GEO_COMMITS.txt
Kontinuation Oct 29, 2025
0d35bcc
Port PR #1368: Rect corner rename
Kontinuation Oct 29, 2025
8f00f66
Port https://github.com/georust/geo/pull/1376, we only need to add co…
Kontinuation Oct 30, 2025
325306f
Ported https://github.com/georust/geo/pull/1377: Faster Intersection …
Kontinuation Oct 30, 2025
641fe69
Port https://github.com/georust/geo/pull/1378
Kontinuation Sep 30, 2025
48f8e76
Add more benches
Kontinuation Sep 30, 2025
d2e04f1
Port https://github.com/georust/geo/pull/1379: LineString/MultiLineSt…
Kontinuation Oct 30, 2025
904b2eb
Ported https://github.com/georust/geo/pull/1364: Apply constructor a…
Kontinuation Oct 30, 2025
2ec5cd3
Remove PORTING_GEO_COMMITS.txt and TODO_GEO_COMMITS.txt
Kontinuation Oct 30, 2025
008de62
Fix comments
Kontinuation Oct 31, 2025
7b86708
Fix clippy warnings
Kontinuation Oct 31, 2025
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
9 changes: 2 additions & 7 deletions c/sedona-tg/src/tg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,19 @@ use crate::{error::TgError, tg_bindgen::*};
///
/// These index types are used to inform the internal index used in geometries
/// to accelerate repeated operations.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Default)]
pub enum IndexType {
/// Do not build an index
Unindexed,
/// Use the statically set default
#[default]
Default,
/// Use natural indexing
Natural,
/// Use y-stripes indexing
YStripes,
}

impl Default for IndexType {
fn default() -> Self {
Self::Default
}
}

impl IndexType {
fn to_tg(self) -> tg_index {
match self {
Expand Down
135 changes: 135 additions & 0 deletions rust/sedona-geo-generic-alg/benches/intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.
use criterion::{criterion_group, criterion_main, Criterion};
use geo::Triangle;
use geo_traits::to_geo::ToGeoGeometry;
use geo_types::Geometry;
use sedona_geo_generic_alg::MultiPolygon;
Expand Down Expand Up @@ -49,6 +50,26 @@ fn multi_polygon_intersection(c: &mut Criterion) {
});
});

c.bench_function("MultiPolygon intersects 2", |bencher| {
bencher.iter(|| {
let mut intersects = 0;
let mut non_intersects = 0;

for a in &plot_geoms {
for b in &zone_geoms {
if criterion::black_box(a.intersects(b)) {
intersects += 1;
} else {
non_intersects += 1;
}
}
}

assert_eq!(intersects, 974);
assert_eq!(non_intersects, 27782);
});
});

c.bench_function("MultiPolygon intersects geo", |bencher| {
bencher.iter(|| {
let mut intersects = 0;
Expand All @@ -68,6 +89,26 @@ fn multi_polygon_intersection(c: &mut Criterion) {
assert_eq!(non_intersects, 27782);
});
});

c.bench_function("MultiPolygon intersects geo 2", |bencher| {
bencher.iter(|| {
let mut intersects = 0;
let mut non_intersects = 0;

for a in &plot_geoms {
for b in &zone_geoms {
if criterion::black_box(geo::Intersects::intersects(a, b)) {
intersects += 1;
} else {
non_intersects += 1;
}
}
}

assert_eq!(intersects, 974);
assert_eq!(non_intersects, 27782);
});
});
}

fn multi_polygon_intersection_wkb(c: &mut Criterion) {
Expand Down Expand Up @@ -395,6 +436,97 @@ fn point_triangle_intersection(c: &mut Criterion) {
});
}

fn linestring_polygon_intersection(c: &mut Criterion) {
use geo::{coord, line_string, LineString, Polygon, Rect};
c.bench_function("LineString above Polygon", |bencher| {
let ls = line_string![
coord! {x:0., y:1.},
coord! {x:5., y:6.},
coord! {x:10., y:1.}
];
let poly = Polygon::new(
line_string![
coord! {x:0., y:0.},
coord! {x:5., y:4.},
coord! {x:10., y:0.}
],
vec![],
);

bencher.iter(|| {
assert!(!criterion::black_box(&ls).intersects(criterion::black_box(&poly)));
});
});
c.bench_function("LineString above Triangle", |bencher| {
let ls = line_string![
coord! {x:0., y:1.},
coord! {x:5., y:6.},
coord! {x:10., y:1.}
];
let poly = Triangle::new(
coord! {x:0., y:0.},
coord! {x:5., y:4.},
coord! {x:10., y:0.},
);

bencher.iter(|| {
assert!(!criterion::black_box(&ls).intersects(criterion::black_box(&poly)));
});
});
c.bench_function("LineString around Rectangle", |bencher| {
let ls = line_string![
coord! {x:-1., y:-1.},
coord! {x:-1., y:11.},
coord! {x:11., y:11.}
];
let poly = Rect::new(coord! {x:0., y:0.}, coord! {x:10., y:10.});

bencher.iter(|| {
assert!(!criterion::black_box(&ls).intersects(criterion::black_box(&poly)));
});
});

c.bench_function("long disjoint ", |bencher| {
let ls = LineString::from_iter((0..1000).map(|x| coord! {x:x as f64, y:x as f64}));
let ln = (0..1000).map(|x| coord! {x:x as f64, y:(x-1) as f64});
let k = vec![coord! {x:-5. ,y:-5. }].into_iter();
let ext = ln.chain(k);

let poly = Polygon::new(LineString::from_iter(ext), vec![]);

bencher.iter(|| {
assert!(!criterion::black_box(&ls).intersects(criterion::black_box(&poly)));
});
});

c.bench_function("ls within poly ", |bencher| {
let ls = line_string![
coord! {x:1., y:1.},
coord! {x:5., y:6.},
coord! {x:9., y:1.}
];

let poly: Polygon = Rect::new(coord! {x:0., y:0.}, coord! {x:10., y:10.}).into();

bencher.iter(|| {
assert!(criterion::black_box(&ls).intersects(criterion::black_box(&poly)));
});
});
c.bench_function("ls within rect ", |bencher| {
let ls = line_string![
coord! {x:1., y:1.},
coord! {x:5., y:6.},
coord! {x:9., y:1.}
];

let poly = Rect::new(coord! {x:0., y:0.}, coord! {x:10., y:10.});

bencher.iter(|| {
assert!(criterion::black_box(&ls).intersects(criterion::black_box(&poly)));
});
});
}

criterion_group! {
name = bench_multi_polygons;
config = Criterion::default().sample_size(10);
Expand Down Expand Up @@ -444,12 +576,15 @@ criterion_group! {
targets = point_polygon_intersection_wkb_conv
}

criterion_group! { bench_linestring_poly,linestring_polygon_intersection}

criterion_main!(
bench_multi_polygons,
bench_multi_polygons_wkb,
bench_multi_polygons_wkb_aligned,
bench_multi_polygons_wkb_conv,
bench_rects,
bench_linestring_poly,
bench_point_rect,
bench_point_triangle,
bench_point_polygon,
Expand Down
8 changes: 4 additions & 4 deletions rust/sedona-geo-generic-alg/src/algorithm/centroid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Generic Centroid algorithm
//!
//! Ported (and contains copied code) from `geo::algorithm::centroid`:
//! <https://github.com/georust/geo/blob/5d667f844716a3d0a17aa60bc0a58528cb5808c3/geo/src/algorithm/centroid.rs>.
//! <https://github.com/georust/geo/blob/f2326a3dd1fa9ff39d3e65618eb7ca2bacad2c0c/geo/src/algorithm/centroid.rs>.
//! Original code is dual-licensed under Apache-2.0 or MIT; used here under Apache-2.0.
use core::borrow::Borrow;
use std::cmp::Ordering;
Expand Down Expand Up @@ -870,7 +870,7 @@ mod test {
// Tests: Centroid of MultiLineString
#[test]
fn empty_multilinestring_test() {
let mls: MultiLineString = MultiLineString::new(vec![]);
let mls: MultiLineString = MultiLineString::empty();
let centroid = mls.centroid();
assert!(centroid.is_none());
}
Expand Down Expand Up @@ -1049,7 +1049,7 @@ mod test {
fn empty_interior_polygon_test() {
let poly = Polygon::new(
LineString::from(vec![p(0., 0.), p(0., 1.), p(1., 1.), p(1., 0.), p(0., 0.)]),
vec![LineString::new(vec![])],
vec![LineString::empty()],
);
assert_eq!(poly.centroid(), Some(p(0.5, 0.5)));
}
Expand All @@ -1072,7 +1072,7 @@ mod test {
// Tests: Centroid of MultiPolygon
#[test]
fn empty_multipolygon_polygon_test() {
assert!(MultiPolygon::<f64>::new(Vec::new()).centroid().is_none());
assert!(MultiPolygon::<f64>::empty().centroid().is_none());
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Generic Coordinate Position algorithm
//!
//! Ported (and contains copied code) from `geo::algorithm::coordinate_position`:
//! <https://github.com/georust/geo/blob/5d667f844716a3d0a17aa60bc0a58528cb5808c3/geo/src/algorithm/coordinate_position.rs>.
//! <https://github.com/georust/geo/blob/f2326a3dd1fa9ff39d3e65618eb7ca2bacad2c0c/geo/src/algorithm/coordinate_position.rs>.
//! Original code is dual-licensed under Apache-2.0 or MIT; used here under Apache-2.0.
use core::borrow::Borrow;
use std::cmp::Ordering;
Expand Down Expand Up @@ -589,7 +589,7 @@ mod test {

#[test]
fn test_empty_poly() {
let square_poly: Polygon<f64> = Polygon::new(LineString::new(vec![]), vec![]);
let square_poly: Polygon<f64> = Polygon::empty();
assert_eq!(
square_poly.coordinate_position(&Coord::zero()),
CoordPos::Outside
Expand Down
8 changes: 4 additions & 4 deletions rust/sedona-geo-generic-alg/src/algorithm/dimensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Generic Dimensions (HasDimensions) algorithm
//!
//! Ported (and contains copied code) from `geo::algorithm::dimensions`:
//! <https://github.com/georust/geo/blob/5d667f844716a3d0a17aa60bc0a58528cb5808c3/geo/src/algorithm/dimensions.rs>.
//! <https://github.com/georust/geo/blob/f2326a3dd1fa9ff39d3e65618eb7ca2bacad2c0c/geo/src/algorithm/dimensions.rs>.
//! Original code is dual-licensed under Apache-2.0 or MIT; used here under Apache-2.0.
use core::borrow::Borrow;
use sedona_geo_traits_ext::*;
Expand Down Expand Up @@ -73,7 +73,7 @@ pub trait HasDimensions {
/// ]);
/// assert!(!line_string.is_empty());
///
/// let empty_line_string: LineString = LineString::new(vec![]);
/// let empty_line_string: LineString = LineString::empty();
/// assert!(empty_line_string.is_empty());
///
/// let point = Point::new(0.0, 0.0);
Expand Down Expand Up @@ -112,7 +112,7 @@ pub trait HasDimensions {
/// assert_eq!(Dimensions::ZeroDimensional, point.dimensions());
///
/// // An `Empty` dimensionality is distinct from, and less than, being 0-dimensional
/// let empty_collection = GeometryCollection::<f32>::new_from(vec![]);
/// let empty_collection = GeometryCollection::<f32>::empty();
/// assert_eq!(Dimensions::Empty, empty_collection.dimensions());
/// assert!(empty_collection.dimensions() < point.dimensions());
/// ```
Expand Down Expand Up @@ -147,7 +147,7 @@ pub trait HasDimensions {
/// let geometry_collection = GeometryCollection::new_from(vec![degenerate_line_rect.into(), degenerate_point_rect.into()]);
/// assert_eq!(Dimensions::ZeroDimensional, geometry_collection.boundary_dimensions());
///
/// let geometry_collection = GeometryCollection::<f32>::new_from(vec![]);
/// let geometry_collection = GeometryCollection::<f32>::empty();
/// assert_eq!(Dimensions::Empty, geometry_collection.boundary_dimensions());
/// ```
fn boundary_dimensions(&self) -> Dimensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Intersects implementations for Geometry and GeometryCollection (generic)
//!
//! Ported (and contains copied code) from `geo::algorithm::intersects::collections`:
//! <https://github.com/georust/geo/blob/5d667f844716a3d0a17aa60bc0a58528cb5808c3/geo/src/algorithm/intersects/collections.rs>.
//! <https://github.com/georust/geo/blob/f2326a3dd1fa9ff39d3e65618eb7ca2bacad2c0c/geo/src/algorithm/intersects/collections.rs>.
//! Original code is dual-licensed under Apache-2.0 or MIT; used here under Apache-2.0.
use core::borrow::Borrow;
use sedona_geo_traits_ext::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Intersects implementations for Coord and Point (generic)
//!
//! Ported (and contains copied code) from `geo::algorithm::intersects::coordinate`:
//! <https://github.com/georust/geo/blob/5d667f844716a3d0a17aa60bc0a58528cb5808c3/geo/src/algorithm/intersects/coordinate.rs>.
//! <https://github.com/georust/geo/blob/f2326a3dd1fa9ff39d3e65618eb7ca2bacad2c0c/geo/src/algorithm/intersects/coordinate.rs>.
//! Original code is dual-licensed under Apache-2.0 or MIT; used here under Apache-2.0.
use sedona_geo_traits_ext::{CoordTag, CoordTraitExt, PointTag, PointTraitExt};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Intersects implementations for Line (generic)
//!
//! Ported (and contains copied code) from `geo::algorithm::intersects::line`:
//! <https://github.com/georust/geo/blob/5d667f844716a3d0a17aa60bc0a58528cb5808c3/geo/src/algorithm/intersects/line.rs>.
//! <https://github.com/georust/geo/blob/f2326a3dd1fa9ff39d3e65618eb7ca2bacad2c0c/geo/src/algorithm/intersects/line.rs>.
//! Original code is dual-licensed under Apache-2.0 or MIT; used here under Apache-2.0.
use sedona_geo_traits_ext::*;

Expand Down
Loading
Loading