-
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
Correctness issues with Contains #513
Comments
@michaelkirk Please go ahead! I suggest that we turn this into a tracking issue for completing both the
Some of these (especially in the case of
We could check off (or add comments on what is done / left) as and when we ensure correctness of specific pairs of geometries. Please let me know if you wish to discuss any specific combination. |
Sounds good! |
Seems like JTS's approach (and thus probably GOES/PostGIS/GDAL's) is to actually generate an explicit dimensional matrix to compare to the DE-9IM definition for the general case, with some short-circuit optimizations where possible. Sounds like a lot of work, but maybe the way to go. I'm going to do some more research.
calculate intersection matrix: |
After looking into more, I think we should explicitly calculate an explicit DE-9IM style intersection matrix. As well as fixing contains, this would give us default implementations for all the other DE-9IM relations "for free". you can see the JTS implementation: It's ~1k lines of code/comments by itself:
And of course it depends on lots of other things, maybe most notably JTS's own
Line count is admittedly a crude metric, I didn't strip out comments and we can probably make some simplifying assumptions, e.g. maybe we can skip having pluggable As well as getting a wider array of (theoretically correct) implementations for some of the relation booleans, JTS (et al) also use the geomgraph stuff as a dependency of building buffers and some other operations, so it might pay some future dividends. What do you think @georust/core - is there interest in merging several-thousand lines to do explicit DE-9IM calculations? |
Yes very much so – I think having a full DE-9IM implementation is incredibly valuable for geo as a project. It's not an insurmountable amount of work, but as you say, it's not a 200-line PR, either. Let's create a tracking issue and discuss ideas for what concretely needs to be done, and who is available/interested in helping? |
I'm in favour of adding the functionality to compute the full matrix. Also agree with @urschrei in creating a tracking issue, and incrementally adding this functionality. That said, we should still aim to keep the existing traits as efficient as we can (but also fully correct ofc), and not compute the whole matrix before answering the Intersects or Contains traits. May be provide traits for each entry of the matrix, and for calculating boundary of a geometry. Then the current traits can use those, but exit early if it is not needed to compute all the entries. How about working on a couple of RFCs to brainstorm the design of the traits / planning the implementation? On a related note, could we enable GitHub pages on a gh-pages branch for this repo? The long list of check boxes above could be nicely made into a table, but GitHub doesn't like css (for security reasons) in it's markdown. I also would also like to see / add some proofs of correctness of our implementations which we can maintain there as pandoc documents (it has excellent math support via LaTeX in it's markdown). |
Great idea. I've also enabled "projects" for this repo – may be useful.
Yep.
💓 |
I've put together a basic table for the |
639: Introduce the geomgraph module for DE-9IM Relate trait r=michaelkirk a=michaelkirk - [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md). - [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. --- Fixes #513, #515 (I'm sorry it's so large) ~~I'm going to leave it as a draft (edit: 🤦 I failed to actually open the PR as a draft) while I wait to merge #636 and #638 and then do some rebasing, but I don't anticipate doing other large changes before review.~~ *update: ready for review!* Here's some of the earlier work in pursuit of this: #514 #516 #523 #524 #538 #552 #561 #611 #628 #629 #636 Primarily, this introduces the geomgraph module for a DE-9IM `Relate` trait. geomgraph implements a topology graph largely inspired by JTS's module of the same name: https://github.com/locationtech/jts/tree/jts-1.18.1/modules/core/src/main/java/org/locationtech/jts/geomgraph You can see some of the reference code if you omit the "REMOVE JTS COMMENTS" commit. In some places the implementation is quite close to the JTS source. The overall "flow" is pretty similar to that of JTS, but in the small, there were some divergences. It's not easy (or desirable) to literally translate a Java codebase making heavy use of inheritance and pointers to rust. Additionally, I chose to take advantage of `Option` and rust's enums with associated data to make some case analysis more explicit. There is a corresponding PR in our [jts-test-runner](georust/jts-test-runner#6) crate which includes the bulk of the tests for the new Relate trait. ## Algorithm Overview This functionality is accessed on geometries, via the `Relate` trait, e.g. `line.relate(point)` which returns a DE-9IM [`IntersectionMatrix`](https://en.wikipedia.org/wiki/DE-9IM#Matrix_model). The `Relate` trait is driven by the `RelateOperation`. The `RelateOperation` builds a `GeometryGraph` for each of the two geometries being related. A `GeometryGraph` is a systematic way to organize the "interesting" parts of a geometry's structure - e.g. where its vertices, lines, and areas lie relative to one another. Once the `RelateOperation` has built the two `GeometryGraph`s, it uses them to efficiently compare the two Geometries's structures, outputting the `IntesectionMatrix`. Co-authored-by: Michael Kirk <[email protected]> Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
639: Introduce the geomgraph module for DE-9IM Relate trait r=frewsxcv,rmanoka a=michaelkirk - [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md). - [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. --- Fixes #513, #515 (I'm sorry it's so large) ~~I'm going to leave it as a draft (edit: 🤦 I failed to actually open the PR as a draft) while I wait to merge #636 and #638 and then do some rebasing, but I don't anticipate doing other large changes before review.~~ *update: ready for review!* Here's some of the earlier work in pursuit of this: #514 #516 #523 #524 #538 #552 #561 #611 #628 #629 #636 Primarily, this introduces the geomgraph module for a DE-9IM `Relate` trait. geomgraph implements a topology graph largely inspired by JTS's module of the same name: https://github.com/locationtech/jts/tree/jts-1.18.1/modules/core/src/main/java/org/locationtech/jts/geomgraph You can see some of the reference code if you omit the "REMOVE JTS COMMENTS" commit. In some places the implementation is quite close to the JTS source. The overall "flow" is pretty similar to that of JTS, but in the small, there were some divergences. It's not easy (or desirable) to literally translate a Java codebase making heavy use of inheritance and pointers to rust. Additionally, I chose to take advantage of `Option` and rust's enums with associated data to make some case analysis more explicit. There is a corresponding PR in our [jts-test-runner](georust/jts-test-runner#6) crate which includes the bulk of the tests for the new Relate trait. ## Algorithm Overview This functionality is accessed on geometries, via the `Relate` trait, e.g. `line.relate(point)` which returns a DE-9IM [`IntersectionMatrix`](https://en.wikipedia.org/wiki/DE-9IM#Matrix_model). The `Relate` trait is driven by the `RelateOperation`. The `RelateOperation` builds a `GeometryGraph` for each of the two geometries being related. A `GeometryGraph` is a systematic way to organize the "interesting" parts of a geometry's structure - e.g. where its vertices, lines, and areas lie relative to one another. Once the `RelateOperation` has built the two `GeometryGraph`s, it uses them to efficiently compare the two Geometries's structures, outputting the `IntesectionMatrix`. Co-authored-by: Michael Kirk <[email protected]> Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
This was fixed via the |
There are some correctness issues with our Contains implementation - discussed in #511
We should fix them.
I can find time to fix these this week, unless @rmanoka was already planning to do the work (I'm happy either way, so long as it gets fixed).
The text was updated successfully, but these errors were encountered: