-
Notifications
You must be signed in to change notification settings - Fork 202
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
more legible geo-types debug output (WKT-ish) #1302
base: main
Are you sure you want to change the base?
Conversation
429674b
to
9688830
Compare
FIXES #564 Note: Most of the output is valid WKT, but not all of it is. For example, there is no RECT or TRIANGLE type in standard WKT. And there are certain invalid representations you can make in geo that are not valid WKT, but for a debug output format we still need to print *something* e.g. a polygon with interiors but no exterior: `POLYGON(EMPTY,(1 2,2 4))`
9688830
to
135b570
Compare
#[cfg(feature = "std")] | ||
#[cfg(test)] | ||
mod tests { | ||
use super::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are pretty comprehensive, and the best place to see what's what.
|
||
let rect = Rect::new((3, 4), (1, 2)); | ||
// output is always (min, max) | ||
assert_eq!("RECT(1 2,3 4)", format!("{rect:?}")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example of output that's not actually WKT, but I think it's still intuitive.
I think "don't let the perfect be the enemy of the good" is the right approach here w/r/t/ validity. If it's easy to get 95 % of debug output straight into TestBuilder (etc), and the other 5 % requires some light search and replace, that's still a huge improvement. |
CHANGES.md
if knowledge of this change could be valuable to users.FIXES #564
I've wanted this for a long time! Inevitably for any project using geo I end up pulling in some other crate to produce debug output (usually wkt). The writing portion of wkt is pretty short (parsing is a little trickier) which is why I opted to copy the logic rather than relying on the wkt crate or something.
Note: Most of the output is valid WKT, but not all of it is.
For example, there is no RECT or TRIANGLE type in standard WKT.
And there are certain invalid representations you can make in geo that
are not valid WKT, e.g. a polygon with interiors but no exterior. I'm not sure if it's valid WKT, but we need to print something meaningful, in this case:
POLYGON(EMPTY,(1 2,2 4))
.