-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Add sedona-geo-generic-alg to sedona-db #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Kontinuation
merged 5 commits into
apache:main
from
Kontinuation:split-pr5-add-geo-generic-alg
Oct 9, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4c8e453
Add sedona-geo-traits-ext to sedona-db
Kontinuation be06dde
Remove unused algorithms
Kontinuation 9ce0614
Remove Cargo.lock
Kontinuation 8383741
docs: add upstream source attribution for geo::algorithm::area and up…
Kontinuation 5fa879f
Remove unused feature flags in sedona-geo-generic-alg
Kontinuation File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| [package] | ||
| name = "sedona-geo-generic-alg" | ||
| version = "0.2.0" | ||
| authors = ["Apache Sedona <[email protected]>"] | ||
| license = "Apache-2.0" | ||
| homepage = "https://github.com/apache/sedona-db" | ||
| repository = "https://github.com/apache/sedona-db" | ||
| description = "geo algorithms refactored to work with sedona-geo-traits-ext" | ||
| readme = "README.md" | ||
| edition = "2021" | ||
|
|
||
| [workspace] | ||
|
|
||
| [dependencies] | ||
| float_next_after = "1" | ||
| geo-traits = { version = "0.3.0" } | ||
| geo-types = { version = "0.7.17", features = ["approx", "use-rstar_0_12"] } | ||
| sedona-geo-traits-ext = { path = "../sedona-geo-traits-ext" } | ||
| log = "0.4.11" | ||
| num-traits = { version = "0.2", default-features = false, features = ["libm"] } | ||
| robust = "1.1.0" | ||
| rstar = "0.12.0" | ||
| i_overlay = { version = "4.0.0, < 4.1.0", default-features = false } | ||
|
|
||
| [dev-dependencies] | ||
| approx = "0.5" | ||
| criterion = { version = "0.5", features = ["html_reports"] } | ||
| pretty_env_logger = "0.4" | ||
| rand = "0.8" | ||
| rand_distr = "0.4.3" | ||
| geo = "0.31.0" | ||
| wkb = "0.9.1" | ||
| wkt = "0.14.0" | ||
|
|
||
| [patch.crates-io] | ||
| wkb = { git = "https://github.com/georust/wkb.git", rev = "130eb0c2b343bc9299aeafba6d34c2a6e53f3b6a" } | ||
|
|
||
| [[bench]] | ||
| name = "area" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "intersection" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "centroid" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "length" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "distance" | ||
| harness = false | ||
|
|
||
| [[bench]] | ||
| name = "perimeter" | ||
| harness = false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <!-- Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. --> | ||
|
|
||
| # Generic Algorithms for Geo-Traits | ||
|
|
||
| This crate contains algorithms ported from the [`geo` crate](https://github.com/georust/geo), | ||
| but works with traits defined in `geo-traits-ext` instead of concrete geometry types defined in | ||
| `geo-types`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| use criterion::{criterion_group, criterion_main, Criterion}; | ||
| use geo_traits::to_geo::ToGeoGeometry; | ||
| use sedona_geo_generic_alg::Area; | ||
| use sedona_geo_generic_alg::Polygon; | ||
|
|
||
| #[path = "utils/wkb_util.rs"] | ||
| mod wkb_util; | ||
|
|
||
| fn criterion_benchmark(c: &mut Criterion) { | ||
| c.bench_function("area_generic_f32", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f32>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(criterion::black_box(&polygon).signed_area()); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("area_generic", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(criterion::black_box(&polygon).signed_area()); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("area_geo_f32", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f32>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(geo::Area::signed_area(criterion::black_box(&polygon))); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("area_geo", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(geo::Area::signed_area(criterion::black_box(&polygon))); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("area_wkb", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
| let wkb_bytes = wkb_util::geo_to_wkb(polygon); | ||
|
|
||
| bencher.iter(|| { | ||
| let wkb_geom = wkb::reader::read_wkb(&wkb_bytes).unwrap(); | ||
| criterion::black_box(wkb_geom.signed_area()); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("area_wkb_convert", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
| let wkb_bytes = wkb_util::geo_to_wkb(polygon); | ||
|
|
||
| bencher.iter(|| { | ||
| let wkb_geom = wkb::reader::read_wkb(&wkb_bytes).unwrap(); | ||
| let geom = wkb_geom.to_geometry(); | ||
| criterion::black_box(geom.signed_area()); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| criterion_group!(benches, criterion_benchmark); | ||
| criterion_main!(benches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| use criterion::{criterion_group, criterion_main, Criterion}; | ||
| use geo_traits::to_geo::ToGeoGeometry; | ||
| use sedona_geo_generic_alg::Centroid; | ||
| use sedona_geo_generic_alg::Polygon; | ||
|
|
||
| #[path = "utils/wkb_util.rs"] | ||
| mod wkb_util; | ||
|
|
||
| fn criterion_benchmark(c: &mut Criterion) { | ||
| c.bench_function("centroid_generic_f32", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f32>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(criterion::black_box(&polygon).centroid()); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("centroid_generic", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(criterion::black_box(&polygon).centroid()); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("centroid_geo_f32", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f32>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(geo::Centroid::centroid(criterion::black_box(&polygon))); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("centroid_geo", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
|
|
||
| bencher.iter(|| { | ||
| criterion::black_box(geo::Centroid::centroid(criterion::black_box(&polygon))); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("centroid_wkb", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
| let wkb_bytes = wkb_util::geo_to_wkb(polygon); | ||
|
|
||
| bencher.iter(|| { | ||
| let wkb_geom = wkb::reader::read_wkb(&wkb_bytes).unwrap(); | ||
| criterion::black_box(wkb_geom.centroid()); | ||
| }); | ||
| }); | ||
|
|
||
| c.bench_function("centroid_wkb_convert", |bencher| { | ||
| let norway = sedona_testing::fixtures::norway_main::<f64>(); | ||
| let polygon = Polygon::new(norway, vec![]); | ||
| let wkb_bytes = wkb_util::geo_to_wkb(polygon); | ||
|
|
||
| bencher.iter(|| { | ||
| let wkb_geom = wkb::reader::read_wkb(&wkb_bytes).unwrap(); | ||
| let geom = wkb_geom.to_geometry(); | ||
| criterion::black_box(geom.centroid()); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| criterion_group!(benches, criterion_benchmark); | ||
| criterion_main!(benches); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can probably use
{ workspace = true}to avoid keeping them up to date?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Currently sedona-geo-generic-alg is in its standalone workspace, not in the workspace of sedona-db. Adding it to the workspace of sedona-db will result in the most terrible dependency conflict. We'll add it to sedona-db's workspace and update this to inherit from workspace in the final step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it!