This repository was archived by the owner on Feb 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Support complex polygons for geofences #7
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,12 @@ | |
| "url": "git@github.com:uber/in-n-out.git" | ||
| }, | ||
| "author": "Alain Rodriguez <eagle5command@gmail.com>", | ||
| "contributors": [ | ||
| "Aiden Scandella <sc@ndella.com>" | ||
| ], | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add yourself to the contributor list |
||
| "version": "0.0.8", | ||
|
|
||
| "version": "0.0.7", | ||
|
|
||
| "scripts": { | ||
| "test": "./test/tests.sh" | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What happens when the point is on the boundary of the hole ? Also totally unrelated, but the polygons that are constructed using gps coordinates might not work correctly over a large surface area because the polygon is not curved along the surface of the earth.
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.
Well, I don't think we're too concerned about that sort of boundary condition? Conceivably they'd flutter between the two sides on each ping based on the GPS error. As for what the code will actually do, being on the boundary means you're "in" that boundary, so it'd probably put them in the hole.
As for point 2, when ops creates their polygons they're looking at such a lat/lon projection in the first place and they're probably transcribing legal boundary areas directly in that same projection with Google Maps (or city bounds maps, etc) so it should still be accurate (because someone else did the projection work for them).
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.
Interesting thoughts @dfellis, yes I didn't think about that, google maps uses kind of mercator projection. Also I went and had a peek in point-in-polygon library (didn't look at the code carefully though) which uses ray tracing and should work on complex polygons as well directly ( if we give a set of x-y coordinates for the polygon) but this way its simpler.
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.
This is a performance issue. The magic behind in-n-out is the cached griding for each geofence ring, resulting in only needing to do an O(N) ray trace check in the worse case of intersecting tiles and O(1) otherwise. We need to compute a cached grid for each hole ring and use that instead for the hole checks.
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.
Did you actually read my implementation?
You're looking at the 'x' block, which only applies if the point lies on the boundary.
Trust me, I understand the point of the library, and for points that are clearly within the inner ring(s) at the given resolution, we short-circuit:
https://github.com/uber/in-n-out/pull/7/files#diff-068591b5cb8abf665e6104587d821d57R139