-
Notifications
You must be signed in to change notification settings - Fork 200
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
point types #5
Comments
How about make our pub struct Coordinate {
pub x: f64,
pub y: f64,
pub z: Option<f64>,
pub m: Option<f64>
} And also operators like distance are 2d by default. If any operation involves z, it must declare this nature on name like |
I think initially just having two coordinates (x, y) should be be an okay starting point, and if we want to expand we can do that in the future. Though, if we do think having more than two coordinates is important right now, I like @sunng87 's suggestion |
We can use traits and generics to write code that handles several coordinate types. It's more efficient than |
I'm looking into picking back up launchbadge/sqlx#166 for a personal project of mine, however I require 3D points, otherwise there's no point in my doing any of this. This seems like the place to start with this since I will really be needing the features of With that said, I'm quite confident that I can generalize the code in Moving into the "4D" case, at least 4D in the nomenclature of the WKT/WKB I feel like we're outside this crate's notion of a Let me know if I'm going in the wrong direction here, and how I should proceed if you can. EDIT: I should also add a question about how |
Wow! A very old issue! My guess is that the majority of the work due here will be plotting forward a course that keeps things optimal for the vast majority of users who are not doing anything with 3D/4D points. Are you familiar with how other geometry libraries deal with 3d/4d, like geos/JTS? We don't have to copy them, but it's a good jumping off point for discussion at least. One aside, you mentioned postgis, but it seems like launchbadge/sqlx#166 is talking about postgres's built in geometric types, which, as I understand it, are not the same as the geometry types in postgis. |
/cc @pka the geozero author, who is likely to have better perspective on this than me. |
The geozero API does support converting points with XYZM + t/tm dimensions, but has currently only complete 3D/4D implementations for FlatGeobuf, WKB and WKT. To read 3D points from SQLx an implementation of |
I would also like to upvote for the support for 3D points. I was using Shapely a lot for my projects, which is basically a Python wrapper of GEOS. AFAIK, shapely treat the z-value just as an associate attribute to be carried around without participating in the algorithms. Quoted from its docs:
I personally like the proposal of
as proposed at the very beginning. Just having the slot for saving z value will already makes a huge difference, allowing other crates to take advantages of this API. Furthermore, if we can support some basic operation on the z-value (just using interpolation between coordinates) will be an even huge improvement. (This is not supported by GEOS, but we can make our rust version better than them right 😄 ) |
I tried to hack a multi-dimensional geo types, first using traits, but later switched to constant generics as they seemed far easier and less surprising. WIP implementation. Coordinates are stored with three generics -- struct Coordinate<T: CoordNum, M: Metadata, const D: usize> {
coord: [T; D],
meta: M,
} Fixed length types (point, line, box, triangle) are stored with another param struct SizedMultipoint<T: CoordNum, M: Metadata, const D: usize, const P: usize> {
coords: [Coordinate<T, M, D>; P],
} Variable-length types use vectors: struct Multipoint<T: CoordNum, M: Metadata, const D: usize> {
coords: Vec<Coordinate<T, M, D>>,
} The actual types would become: type Point<T, M, const D: usize> = SizedMultipoint<T, M, D, 1>;
type Point2D<T> = Point<T, (), 2>;
type Point2DM<T,M> = Point<T, M, 2>;
type Point3D<T> = Point<T, (), 3>;
type Point3DM<T, M> = Point<T, M, 3>;
type Line<T, M, const D: usize> = SizedMultipoint<T, M, D, 2>;
type Line2D<T> = Line<T, (), 2>;
type Line2DM<T, M> = Line<T, M, 2>;
type Line3D<T> = Line<T, (), 3>;
type Line3DM<T, M> = Line<T, M, 3>;
type Triangle<T, M, const D: usize> = SizedMultipoint<T, M, D, 3>;
type Triangle2D<T> = Triangle<T, (), 2>;
type Triangle2DM<T, M> = Triangle<T, M, 2>;
type Triangle3D<T> = Triangle<T, (), 3>;
type Triangle3DM<T, M> = Triangle<T, M, 3>; |
Very rough draft implementation of this is being done in https://github.com/georust/geo/pull/742/files |
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
plus some other methods to help migrate from direct field access. This is intended to be a non-breaking change for now, to give people an upgrade window. In an upcoming *breaking* release of geo-types we'll drop pub field access altogether. This is in pursuit of adding support for 3D/4D geometries. We'll leverage generics in a way that is intended to avoid runtime cost for our mostly 2D user base. See #5 for more. This commit includes a bunch of new methods that correspond to the deprecated field access. See geo-types/CHANGES.md for a summary. `#[inline]` hints were added to maintain performance (it's actually improved in some places!) geo was updated to address all the deprecations.
how do we want to handle the difference between x,y, x,y,z, x,y,z,w (someone could conceivably want a 4th digit for something like time). Possibilities
The text was updated successfully, but these errors were encountered: