-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Add sedona-geo-traits-ext to sedona-db #194
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 9 commits into
apache:main
from
Kontinuation:split-pr4-add-geo-traits-ext
Oct 9, 2025
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d6ca4af
Add sedona-geo-traits-ext as a standalone crate
Kontinuation 0c1b89c
Add comments for public APIs
Kontinuation fdf324c
Fix Cargo.toml
Kontinuation 18eba58
Remove Cargo.lock
Kontinuation 7cbc5d7
Fix typo
Kontinuation a8a4645
Fix problems spotted by Copilot
Kontinuation 0b59c90
test(sedona-geo-traits-ext): add WKB extension trait tests
Kontinuation e5b3971
Update rust/sedona-geo-traits-ext/README.md
Kontinuation 8155ca1
Tune tests and forward more functions for geo_types::Geometry
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,41 @@ | ||
| # 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-traits-ext" | ||
| 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-traits extended for implementing generic algorithms" | ||
| readme = "README.md" | ||
| edition = "2021" | ||
|
|
||
| [workspace] | ||
|
|
||
| [dependencies] | ||
| geo-traits = "0.3.0" | ||
| geo-types = "0.7.17" | ||
| num-traits = { version = "0.2", default-features = false, features = ["libm"] } | ||
| wkb = "0.9.1" | ||
| byteorder = "1" | ||
|
|
||
| [dev-dependencies] | ||
| wkt = "0.14.0" | ||
|
|
||
| [patch.crates-io] | ||
| wkb = { git = "https://github.com/georust/wkb.git", rev = "130eb0c2b343bc9299aeafba6d34c2a6e53f3b6a" } |
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,37 @@ | ||
| <!-- 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. --> | ||
|
|
||
| # Geo-Traits Extended | ||
|
|
||
| This crate extends the `geo-traits` crate with additional traits and | ||
| implementations. The goal is to provide a set of traits that are useful for | ||
| implementing algorithms in `geo-generic-alg` crate. Most of the methods are | ||
| inspired by the `geo-types` crate, but are implemented as traits for the | ||
| `geo-traits` types. Some methods returns concrete types defined in `geo-types`, | ||
| these methods are only for computing tiny, intermediate results during | ||
| algorithm execution. By adding methods in `geo-types` to `geo-traits-ext`, | ||
| we can port algorithms in `geo` crate for concrete `geo-types` types to generic | ||
| `geo-traits-ext` types more easily. | ||
|
|
||
| `geo-traits-ext` traits also has an associated `Tag` type to workaround the | ||
| single orphan rule in Rust. For instance, we cannot write blanket `AreaTrait` | ||
| implementations for both `LineStringTrait` and `PolygonTrait` because we | ||
| cannot show that there would be no type implementing both `LineStringTrait` and | ||
| `PolygonTrait`. By adding an associated `Tag` type, we can write blanket | ||
| implementations for `AreaTrait<LineStringTag>` and `AreaTrait<PolygonTag>`, since | ||
| `AreaTrait<LineStringTag>` and `AreaTrait<PolygonTag>` are different types. | ||
| Please refer to the source code of `geo-generic-alg` for more details. | ||
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,69 @@ | ||
| // 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. | ||
| //! Extend CoordTrait traits for the `geo-traits` crate | ||
|
|
||
| use geo_traits::{CoordTrait, UnimplementedCoord}; | ||
| use geo_types::{Coord, CoordNum}; | ||
|
|
||
| use crate::{CoordTag, GeoTraitExtWithTypeTag}; | ||
|
|
||
| /// Extension methods that bridge [`CoordTrait`] with concrete `geo-types` helpers. | ||
| pub trait CoordTraitExt: CoordTrait + GeoTraitExtWithTypeTag<Tag = CoordTag> | ||
| where | ||
| <Self as CoordTrait>::T: CoordNum, | ||
| { | ||
| #[inline] | ||
| /// Converts this coordinate into the concrete [`geo_types::Coord`]. | ||
| fn geo_coord(&self) -> Coord<Self::T> { | ||
| Coord { | ||
| x: self.x(), | ||
| y: self.y(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<T> CoordTraitExt for Coord<T> | ||
| where | ||
| T: CoordNum, | ||
| { | ||
| fn geo_coord(&self) -> Coord<T> { | ||
| *self | ||
| } | ||
| } | ||
|
|
||
| impl<T: CoordNum> GeoTraitExtWithTypeTag for Coord<T> { | ||
| type Tag = CoordTag; | ||
| } | ||
|
|
||
| impl<T> CoordTraitExt for &Coord<T> | ||
| where | ||
| T: CoordNum, | ||
| { | ||
| fn geo_coord(&self) -> Coord<T> { | ||
| **self | ||
| } | ||
| } | ||
|
|
||
| impl<T: CoordNum> GeoTraitExtWithTypeTag for &Coord<T> { | ||
| type Tag = CoordTag; | ||
| } | ||
|
|
||
| impl<T> CoordTraitExt for UnimplementedCoord<T> where T: CoordNum {} | ||
|
|
||
| impl<T: CoordNum> GeoTraitExtWithTypeTag for UnimplementedCoord<T> { | ||
| type Tag = CoordTag; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.