-
Notifications
You must be signed in to change notification settings - Fork 199
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
Implement 3D and Measure support for geo-types only #797
Closed
Commits on Apr 21, 2022
-
Implement 3D and Measure support for geo-types only
This PR includes georust#772 and georust#812 --- This PR focuses on `geo-types` only. This is a part of georust#742. This PR changes the underlying geo-type data structures to support 3D data and measurement values (M and Z values). The PR attempts to cause relatively minor disruptions to the existing users (see breaking changes below). My knowledge of the actual geo algorithms is limited, so please ping me for any specific algo change. ## geo-types restructuring All geo type structs have been renamed from `Foo<T>(...)` to `Foo<T, Z=NoValue, M=NoValue>(...)`, and several type aliases were added: ```rust // old pub struct LineString<T: CoordNum>(pub Vec<Coordinate<T>>); // new pub struct LineString<T: CoordNum, Z: ZCoord=NoValue, M: Measure=NoValue>(pub Vec<Coordinate<T, Z, M>>); pub type LineStringM<T, M=T> = LineString<T, NoValue, M>; pub type LineString3D<T> = LineString<T, T, NoValue>; pub type LineString3DM<T, M=T> = LineString<T, T, M>; ``` ## NoValue magic `NoValue` is an empty struct that behaves just like a number. It supports all math and comparison operations. This means that a `Z` or `M` value can be manipulated without checking if it is actually there. This code works for Z and M being either a number or a NoValue: ```rust pub struct NoValue; impl<T: CoordNum, Z: ZCoord, M: Measure> Sub for Coordinate<T, Z, M> { type Output = Self; fn sub(self, rhs: Self) -> Self { coord! { x: self.x - rhs.x, y: self.y - rhs.y, z: self.z - rhs.z, m: self.m - rhs.m, } } } ``` ## Variant algorithm implementations Function implementations can keep just the original 2D `<T>` variant, or add support for 3D `<Z>` and/or the Measure `<M>`. The above example works for all combinations of objects. This function only works for 2D objects with and without the Measure. ```rust impl<T: CoordNum, M: Measure> Line<T, NoValue, M> { /// Calculate the slope (Δy/Δx). pub fn slope(&self) -> T { self.dy() / self.dx() } } ``` ## Breaking changes * It is no longer possible to create Coordinate with just `x` and `y` values using implicit tuple constructor. Use `coord!` instead.
Configuration menu - View commit details
-
Copy full SHA for d16ca12 - Browse repository at this point
Copy the full SHA d16ca12View commit details -
Removed custom Measure and ZCoord traits
This simplifies the design a bit, by using the same `CoordNum` everywhere. `NoValue` can now be used anywhere, making it possible to define `Coordinate<NoValue>` -- an empty value.
Configuration menu - View commit details
-
Copy full SHA for db989f6 - Browse repository at this point
Copy the full SHA db989f6View commit details
Commits on Apr 22, 2022
-
Configuration menu - View commit details
-
Copy full SHA for fc998b3 - Browse repository at this point
Copy the full SHA fc998b3View commit details -
Configuration menu - View commit details
-
Copy full SHA for ec62c59 - Browse repository at this point
Copy the full SHA ec62c59View commit details -
Configuration menu - View commit details
-
Copy full SHA for 193fc31 - Browse repository at this point
Copy the full SHA 193fc31View commit details
Commits on May 6, 2022
-
Configuration menu - View commit details
-
Copy full SHA for c7832a7 - Browse repository at this point
Copy the full SHA c7832a7View commit details -
Configuration menu - View commit details
-
Copy full SHA for b064892 - Browse repository at this point
Copy the full SHA b064892View commit details
Commits on Jun 8, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 01fc095 - Browse repository at this point
Copy the full SHA 01fc095View commit details
Commits on Jun 22, 2022
-
Apply suggestions from code review
Co-authored-by: Corey Farwell <coreyf@rwell.org>
Configuration menu - View commit details
-
Copy full SHA for 0ea63b5 - Browse repository at this point
Copy the full SHA 0ea63b5View commit details
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.