Skip to content

Fix bug filtering collinear points on vertical lines#81155

Merged
iverase merged 6 commits into
elastic:masterfrom
iverase:verticalLines
Dec 2, 2021
Merged

Fix bug filtering collinear points on vertical lines#81155
iverase merged 6 commits into
elastic:masterfrom
iverase:verticalLines

Conversation

@iverase

@iverase iverase commented Nov 30, 2021

Copy link
Copy Markdown
Contributor

In #59501 we added a process to remove collinear points that exist in vertical lines for polygons as they were making the polygon decomposition logic to fail. Unfortunately this logic introduced a bug while filtering the points that is fixed here.

fixes #81076

@iverase iverase added >bug :Analytics/Geo Indexing, search aggregations of geo points and shapes v8.0.0 v7.16.1 v8.1.0 labels Nov 30, 2021
@iverase iverase requested a review from imotov November 30, 2021 14:24
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Nov 30, 2021
@elasticmachine

Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@imotov imotov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@iverase, ping me when you have a chance. I think I am missing something here.

}
if (linearRing.getLon(i - 1) == linearRing.getLon(i + 1)
&& linearRing.getLat(i - 1) > linearRing.getLat(i) != linearRing.getLat(i + 1) > linearRing.getLat(i)) {
// coplanar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am a bit confused about terminology and the logic here. We have only 2 coordinates, so theoretically all our points are coplanar. Do you mean collinear here? Based on this logic we only remove points if we go down and then up within the same longitude. What's the reason for not removing colinear points in between? Basically, in the example below: POLYGON ((0 0, 0 10, 10 10, 10 5, 10 -10, 10 0, 0 0)) the current logic removes point B, but keep point A intact.

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

doh! Yes, I meant collinear points

@iverase iverase Dec 1, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had a look and the current logic that what I expect that is to remove point A:

original: "POLYGON ((0 0, 0 10, 10 10, 10 5, 10 -10, 10 0, 0 0))"

image

processed: "POLYGON ((10 0, 10 -10, 10 10, 0 10, 0 0, 10 0))"

image

@iverase iverase changed the title Fix bug filtering coplanar points on vertical lines Fix bug filtering collinear points on vertical lines Dec 1, 2021

@imotov imotov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Please add comments around this check so future me will not get confused again :)

@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

💚 Backport successful

Status Branch Result
8.0
7.16

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 Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.16.0 v8.0.0-rc1 v8.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geotile_grid aggregation on geo_shape produces incorrect results for polygons in certain corner cases

6 participants