Skip to content
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

Store dimensionality in parsed WKT objects #125

Open
kylebarron opened this issue Oct 30, 2024 · 0 comments
Open

Store dimensionality in parsed WKT objects #125

kylebarron opened this issue Oct 30, 2024 · 0 comments

Comments

@kylebarron
Copy link
Member

WKT strings can store a dimensionality even while being EMPTY. E.g. these are valid:

POINT EMPTY
POINT Z EMPTY
POINT M EMPTY
POINT ZM EMPTY

Currently, the parsed representation does not store this. It only stores a coordinate or a sequence of coordinates, depending on the type:

pub struct LineString<T: WktNum>(pub Vec<Coord<T>>);

I think it would be a worthwhile change to also store the dimensionality as part of the geometry. E.g.:

pub struct LineString<T: WktNum> {
    coords: Vec<Coord<T>>,
    dim: Dimension,
}

This would be nice for two reasons:

  1. It would solve the empty geometry problem by storing the dimension even when there are no coordinates.
  2. It would make it easier to implement the dim method for each geometry trait, because it wouldn't have to recurse into the first coordinate.

Unfortunately, this would be a breaking change because the .0 element of the geometry types is public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant