-
Notifications
You must be signed in to change notification settings - Fork 25
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
Reconsider design of core structures #32
Comments
The above change does not correspond to the wtk specification correctly as the Dimension is not sufficient to specify the allowed types. For example for points we can have:
Both the Z and M version are dimension 3. Instead I think want there to be 4 fundamental coord types. Basically any use of Option for Z or M should be avoided.
So a line string would become:
|
@grivy Your proposed design looks good to me. What does the |
hmm.. Like money, coordinates should not be stored in floating points, as we want to be able to compare and we do not want to loose precision. In one project I have lat/lon in i64's (need to divide by (lat_i64 / 8192 / 60 / 60) to get the floating point value. And another project in a local Cartesian reference frame is in mm (y_i32 / 1000) to get float value. So while I think it is good to provide default structs it should also be possible to use the users' own Coordinate type for direct translation to WKT. So the user would have to implement the CoordZ trait and then implement the x(), y(), z() functions returning floats. Actually when writing to WKT (unlike WKB) there should not be any need to loss precision due to float representation. For example the y_i32 can be written to a string first, and then have the decimal point inserted later 654356 -> "654356" => "654.356". This would allow the user to prevent any loss in precision. Or is there a maximum to the number of decimals in the WKT standard? For this scenario I suppose the user would implement a trait for example CoordM and provide the functions: x_as_string(), y_as_string(), m_as_string() oh and x_from_string(), y_from_string(), m_from_string() Not sure yet what the implications are on LineString and user provided LineString structs. Maybe this library can provide some inspiration: |
What about not having a wkt-specific internal representation and instead having And of course impls for every type in Although I'm not sure how parsing would look like in this scenario |
You might also be interested in https://github.com/georust/geozero Which allows things like:
|
I looked at it when I was trying to find options but by reading the readme I didn't get the idea of how it would help in my case. But you're right, it might be helpful |
I'm still kind of getting the hang of GeoZero myself, but I think the idea is that you can implement:
and then you can serialize your type to any of the supported output formats (wkt, geojson, gdal, etc.) |
Right now, it's possible to model this with the current design:
...which translates to something like:
...which doesn't make any sense since the first item has two dimensions but the second item has three dimensions.
We can change the core structures to a different design to enforce all items having the same dimensions:
(Keep in mind, this design is not final and is just a rought draft)
playpen
The text was updated successfully, but these errors were encountered: