Skip to content

Commit f3a7bc9

Browse files
committed
Migrated geo-traits-ext and geo-generic-alg
1 parent a93b322 commit f3a7bc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+21376
-113
lines changed

Cargo.lock

Lines changed: 135 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ members = [
2222
"c/sedona-s2geography",
2323
"c/sedona-tg",
2424
"r/sedonadb/src/rust",
25+
"rust/geo-traits-ext",
26+
"rust/geo-generic-alg",
27+
"rust/geo-test-fixtures",
2528
"rust/sedona-adbc",
2629
"rust/sedona-expr",
2730
"rust/sedona-functions",
@@ -54,7 +57,7 @@ rust-version = "1.82"
5457
[workspace.dependencies]
5558
approx = "0.5"
5659
abi_stable = "0.11.3"
57-
adbc_core = { git = "https://github.com/apache/arrow-adbc", rev = "1ba248290cd299c4969b679463bcd54c217cf2e4" }
60+
adbc_core = "0.20.0"
5861
lru = "0.12"
5962
arrow = { version = "55.1.0", features = ["prettyprint", "ffi", "chrono-tz"] }
6063
arrow-array = { version = "55.1.0" }
@@ -81,22 +84,20 @@ env_logger = "0.11"
8184
futures = { version = "0.3" }
8285
object_store = { version = "0.12.0", default-features = false }
8386
float_next_after = "1"
87+
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
8488
mimalloc = { version = "0.1", default-features = false }
8589
libmimalloc-sys = { version = "0.1", default-features = false }
8690

8791
geos = { version = "10.0.0", features = ["geo"] }
8892

89-
# Use our own fork of georust/geo, which implements generic computational geometry algorithms for geo-traits
90-
geo-generic-alg = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-generic-alg" }
91-
geo-types = "0.7.16"
92-
geo-traits = "0.2.0"
93-
geo-traits-ext = "0.1.0"
94-
geo = { version = "0.30.0" }
93+
geo-types = "0.7.17"
94+
geo-traits = "0.3.0"
95+
geo = "0.31.0"
9596

9697
geo-index = { version = "0.3.1" }
9798

98-
wkb = { version = "0.8.0", features = ["geos"] }
99-
wkt = "0.13.0"
99+
wkb = { version = "0.9.0" }
100+
wkt = "0.14.0"
100101

101102
parking_lot = "0.12"
102103
parquet = { version = "55.1.0", default-features = false, features = [
@@ -127,9 +128,5 @@ datafusion-ffi = { git = "https://github.com/paleolimbot/datafusion.git", branch
127128
datafusion-physical-expr = { git = "https://github.com/paleolimbot/datafusion.git", branch = "local-49-with-patch", package = "datafusion-physical-expr" }
128129
datafusion-physical-plan = { git = "https://github.com/paleolimbot/datafusion.git", branch = "local-49-with-patch", package = "datafusion-physical-plan" }
129130

130-
geo-types = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-types" }
131-
geo-traits = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-traits" }
132-
geo-traits-ext = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-traits-ext" }
133-
geo-index = { git = "https://github.com/wherobots/geo-index.git", branch = "main" }
134-
wkb = { git = "https://github.com/wherobots/wkb.git", branch = "generic-alg" }
135-
wkt = { git = "https://github.com/wherobots/wkt.git", branch = "generic-alg" }
131+
# geo-index = { git = "https://github.com/Kontinuation/geo-index.git", branch = "geo-0.31.0" }
132+
geo-index = { path = "/Users/bopeng/workspace/github/geo-index" }

c/sedona-geos/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ sedona-expr = { path = "../../rust/sedona-expr" }
4242
sedona-functions = { path = "../../rust/sedona-functions" }
4343
sedona-geometry = { path = "../../rust/sedona-geometry" }
4444
sedona-schema = { path = "../../rust/sedona-schema" }
45-
wkb = { workspace = true, features = ["geos"] }
45+
wkb = { workspace = true }
4646

4747
[[bench]]
4848
harness = false

rust/geo-generic-alg/Cargo.toml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
[package]
18+
name = "geo-generic-alg"
19+
version.workspace = true
20+
homepage.workspace = true
21+
repository.workspace = true
22+
description.workspace = true
23+
readme.workspace = true
24+
edition.workspace = true
25+
rust-version.workspace = true
26+
27+
[features]
28+
default = ["multithreading"]
29+
use-serde = ["serde", "geo-types/serde"]
30+
multithreading = ["i_overlay/allow_multithreading", "geo-types/multithreading"]
31+
32+
[dependencies]
33+
float_next_after = { workspace = true }
34+
geo-traits = { workspace = true }
35+
geo-types = { workspace = true, features = ["approx", "use-rstar_0_12"] }
36+
geo-traits-ext = { path = "../geo-traits-ext" }
37+
log = "0.4.11"
38+
num-traits = { workspace = true }
39+
robust = "1.1.0"
40+
rstar = "0.12.0"
41+
serde = { workspace = true, features = ["derive"], optional = true }
42+
i_overlay = { version = "4.0.0, < 4.1.0", default-features = false }
43+
44+
[dev-dependencies]
45+
geo-test-fixtures = { path = "../geo-test-fixtures" }
46+
approx = { workspace = true }
47+
criterion = { workspace = true }
48+
pretty_env_logger = "0.4"
49+
rand = { workspace = true }
50+
rand_distr = "0.4.3"
51+
geo = { workspace = true }
52+
wkt = { workspace = true }
53+
54+
# For writing WKB geometry for benchmarks
55+
geos = { workspace = true, features = ["geo"] }
56+
57+
[[bench]]
58+
name = "area"
59+
harness = false
60+
61+
[[bench]]
62+
name = "intersection"
63+
harness = false
64+
65+
[[bench]]
66+
name = "centroid"
67+
harness = false
68+
69+
[[bench]]
70+
name = "length"
71+
harness = false
72+
73+
[[bench]]
74+
name = "distance"
75+
harness = false
76+
77+
[[bench]]
78+
name = "perimeter"
79+
harness = false

rust/geo-generic-alg/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generic Algorithms for Geo-Traits
2+
3+
This crate provides the same algorithms as the `geo` crate, but applies traits
4+
defined in `geo-traits` instead of concrete geometry types defined in
5+
`geo-types`.
6+
7+
We are still in the early stage of migrating the algorithms, and the crate is
8+
not ready for production use yet.
9+
10+
## Status
11+
12+
- [ ] Area calculation
13+
- [ ] Centroid calculation
14+
- [ ] Convex hull calculation
15+
- [ ] Relationships (contains, within, etc)
16+
- [ ] Simplification
17+
- [ ] Buffer
18+
- [ ] Distance
19+
- [ ] Intersection
20+
- [ ] Union
21+
- [ ] Difference
22+
- [ ] Symmetric difference
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use criterion::{criterion_group, criterion_main, Criterion};
2+
use geo_generic_alg::Area;
3+
use geo_generic_alg::Polygon;
4+
use geo_traits::to_geo::ToGeoGeometry;
5+
6+
#[path = "utils/wkb.rs"]
7+
mod wkb;
8+
9+
fn criterion_benchmark(c: &mut Criterion) {
10+
c.bench_function("area_f32", |bencher| {
11+
let norway = geo_test_fixtures::norway_main::<f32>();
12+
let polygon = Polygon::new(norway, vec![]);
13+
14+
bencher.iter(|| {
15+
criterion::black_box(criterion::black_box(&polygon).signed_area());
16+
});
17+
});
18+
19+
c.bench_function("area", |bencher| {
20+
let norway = geo_test_fixtures::norway_main::<f64>();
21+
let polygon = Polygon::new(norway, vec![]);
22+
23+
bencher.iter(|| {
24+
criterion::black_box(criterion::black_box(&polygon).signed_area());
25+
});
26+
});
27+
28+
c.bench_function("area_wkb", |bencher| {
29+
let norway = geo_test_fixtures::norway_main::<f64>();
30+
let polygon = Polygon::new(norway, vec![]);
31+
let wkb_bytes = wkb::geo_to_wkb(&polygon);
32+
33+
bencher.iter(|| {
34+
let wkb_geom = geo_generic_tests::wkb::reader::read_wkb(&wkb_bytes).unwrap();
35+
criterion::black_box(wkb_geom.signed_area());
36+
});
37+
});
38+
39+
c.bench_function("area_wkb_convert", |bencher| {
40+
let norway = geo_test_fixtures::norway_main::<f64>();
41+
let polygon = Polygon::new(norway, vec![]);
42+
let wkb_bytes = wkb::geo_to_wkb(&polygon);
43+
44+
bencher.iter(|| {
45+
let wkb_geom = geo_generic_tests::wkb::reader::read_wkb(&wkb_bytes).unwrap();
46+
let geom = wkb_geom.to_geometry();
47+
criterion::black_box(geom.signed_area());
48+
});
49+
});
50+
}
51+
52+
criterion_group!(benches, criterion_benchmark);
53+
criterion_main!(benches);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use criterion::{criterion_group, criterion_main, Criterion};
2+
use geo_generic_alg::Centroid;
3+
use geo_generic_alg::Polygon;
4+
use geo_traits::to_geo::ToGeoGeometry;
5+
6+
#[path = "utils/wkb.rs"]
7+
mod wkb;
8+
9+
fn criterion_benchmark(c: &mut Criterion) {
10+
c.bench_function("centroid_f32", |bencher| {
11+
let norway = geo_test_fixtures::norway_main::<f32>();
12+
let polygon = Polygon::new(norway, vec![]);
13+
14+
bencher.iter(|| {
15+
criterion::black_box(criterion::black_box(&polygon).centroid());
16+
});
17+
});
18+
19+
c.bench_function("centroid", |bencher| {
20+
let norway = geo_test_fixtures::norway_main::<f64>();
21+
let polygon = Polygon::new(norway, vec![]);
22+
23+
bencher.iter(|| {
24+
criterion::black_box(criterion::black_box(&polygon).centroid());
25+
});
26+
});
27+
28+
c.bench_function("centroid_wkb", |bencher| {
29+
let norway = geo_test_fixtures::norway_main::<f64>();
30+
let polygon = Polygon::new(norway, vec![]);
31+
let wkb_bytes = wkb::geo_to_wkb(&polygon);
32+
33+
bencher.iter(|| {
34+
let wkb_geom = geo_generic_tests::wkb::reader::read_wkb(&wkb_bytes).unwrap();
35+
criterion::black_box(wkb_geom.centroid());
36+
});
37+
});
38+
39+
c.bench_function("centroid_wkb_convert", |bencher| {
40+
let norway = geo_test_fixtures::norway_main::<f64>();
41+
let polygon = Polygon::new(norway, vec![]);
42+
let wkb_bytes = wkb::geo_to_wkb(&polygon);
43+
44+
bencher.iter(|| {
45+
let wkb_geom = geo_generic_tests::wkb::reader::read_wkb(&wkb_bytes).unwrap();
46+
let geom = wkb_geom.to_geometry();
47+
criterion::black_box(geom.centroid());
48+
});
49+
});
50+
}
51+
52+
criterion_group!(benches, criterion_benchmark);
53+
criterion_main!(benches);

0 commit comments

Comments
 (0)