-
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
Changes from 4 commits
4c8e453
be06dde
9ce0614
8383741
5fa879f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # 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] | ||
|
|
||
| [features] | ||
| default = ["multithreading"] | ||
| use-serde = ["serde", "geo-types/serde"] | ||
| multithreading = ["i_overlay/allow_multithreading", "geo-types/multithreading"] | ||
|
||
|
|
||
| [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" | ||
| serde = { version = "1", features = ["derive"], optional = true } | ||
| 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 | ||
| 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`. |
| 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); |
| 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); |
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!