-
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
introduce Coord/Point trait #901
Comments
Is the std. |
The demo integration in A/B Street is very nice, I'd love to see this go forward! I do want to raise one possible design consideration. It's not relevant for What if the trait implementer wants to control the scalar values in the point more tightly? Specifically, something like rounding an This might be a niche/weird use case not worth considering, but still wanted to bring it up |
Yeah that would be tricky. In practice is this precision model something that you maintain through all your intermediate calculations? IIRC it was only used in order to have a smaller serialization of game state. So would it be reasonable to only truncate the precision then during serialization? I think conceptually what you have there is no longer really an Another option would be to to formalize those semantics with your own e.g.
|
The chain of reasoning was:
Thinking back more, another reason to round is to avoid epsilon comparisons everywhere. Due to floating point error, two operations on a line-string might return a distance along of it of 1.2 and 1.200000000001. I want If we just did this rounding when we serialize, then the two workflows in 2) would still differ. As soon as we create some geometry object, we need to round. The rounding right now happens inside of The I don't want to distract from this PR anymore. The example integration would need some tweaking, but I like it. If anyone has prior experience or opinions about how to deal with |
@dabreegster Is this round-trip rounding issue present when you use serde with |
Ah, seemingly not! This feature (for JSON output -- bincode is fine already) might not've been around when I last dug into this. I might consider trying this + baking in epsilon checks to |
We should probably have a look at enabling that feature in |
I hadn't seen this 🙂. This does raise a question of whether geometry traits should offer mutable methods |
One way to dip our toe into #838 would be a coord/point trait.
I've done a little POC here: https://github.com/georust/geo/tree/mkirk/affine-coord-trait
I did this as a means of integrating the new
AffineOps
into ABStreet here: https://github.com/a-b-street/abstreet/compare/master...michaelkirk:abstreet:mkirk/apply-affine?expand=1#diff-b2aff24a689eccbe772abd984783d3a508924c1e7d197cee9ba8cede6a36ee89R124Disclaimer: I don't know that @dabreegster would actually wants to use this integration in ABStreet, I was just looking for a real-world application to test-bed it in.
One reason to use a Coord/Point trait as a starting point for trait-based geoms in geo is that there are already places internally that could immediately benefit, even if this crate never goes whole hog on trait-based geometries.
For example, there's a bunch of places in our API's where it's not clear wether we should pass in a Point or a Coordinate. Using a trait that encompasses both would clean that up, while also allowing people to pass in their own point type.
(maybe ultimately we should resurrect #15, but that could be pretty disruptive)
The text was updated successfully, but these errors were encountered: