Skip to content
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

Throw helpful exception for Polygons with holes outside of shell #9105

Closed
wants to merge 0 commits into from

Conversation

nknize
Copy link
Contributor

@nknize nknize commented Dec 30, 2014

A recent situation occured in #9071 where a MultiPolygon coordinate array was accidentally defined as a single polygon with multiple holes. Since the intent was a MultiPolygon, the holes of the unintended Polygon fell outside the outer shell. This exposed a bug in the contains logic inside BasePolygonBuilder. An ArrayIndexOutOfBoundsException was being thrown instead of a more useful ElasticsearchParseException( "hole is not within polygon" ). This pull request fixes the bug and adds additional unit tests for verifying proper MultiPolygon type parsing.

closes #9071

@nknize nknize added :Analytics/Geo Indexing, search aggregations of geo points and shapes v2.0.0-beta1 v1.5.0 v1.4.3 >bug review labels Dec 30, 2014
// don't waste time calling a binary search
final int pos;
if (intersections == 0 ||
(pos = Arrays.binarySearch(edges, 0, intersections, current, INTERSECTION_ORDER)) >= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: it would be nice for the second clause to be aligned vertically with the clause above

@rjernst
Copy link
Member

rjernst commented Dec 31, 2014

LGTM, I left one minor comment.

@nknize nknize force-pushed the fix/9071 branch 2 times, most recently from fa7dfa6 to b21024b Compare January 2, 2015 14:20
@nknize
Copy link
Contributor Author

nknize commented Jan 2, 2015

merged in b21024b

@nknize nknize closed this Jan 2, 2015
@nknize nknize deleted the fix/9071 branch January 2, 2015 14:24
@clintongormley clintongormley changed the title [GEO] Throw helpful exception for Polygons with holes outside of shell Geo: Throw helpful exception for Polygons with holes outside of shell Feb 10, 2015
@clintongormley clintongormley changed the title Geo: Throw helpful exception for Polygons with holes outside of shell Throw helpful exception for Polygons with holes outside of shell Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug v1.4.3 v1.5.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Geo: MultiPolygon areas trigger ArrayIndexOutOfBoundsException -1
3 participants