Skip to content

Geo: Do not normalize the longitude with value -180 for Lucene shapes #37299

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

Merged
merged 3 commits into from
Jan 11, 2019

Conversation

iverase
Copy link
Contributor

@iverase iverase commented Jan 10, 2019

Lucene based shapes should not normalize the longitude value -180 to 180.

Closes #37297

@iverase iverase requested a review from imotov January 10, 2019 12:43
@iverase iverase added >bug :Analytics/Geo Indexing, search aggregations of geo points and shapes v7.0.0 v6.6.1 labels Jan 10, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

@iverase iverase self-assigned this Jan 10, 2019
@iverase iverase changed the title Do not normalize the longitude with value -180 for Lucene shapes [Geo]: Do not normalize the longitude with value -180 for Lucene shapes Jan 10, 2019
@@ -357,7 +357,7 @@ protected static Polygon polygonS4J(GeometryFactory factory, Coordinate[][] poly
double[] x = new double[shell.length];
double[] y = new double[shell.length];
for (int i = 0; i < shell.length; ++i) {
x[i] = normalizeLon(shell[i].x);
x[i] = Math.abs(shell[i].x) > 180 ? normalizeLon(shell[i].x) : shell[i].x;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify why this is done only here and not in toPolygonLucene() and in LineStringBuilder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not an expert in JTS, but I guess the implementation understand that -180/+180 are the same point and it creates the right polygon. Lucene implementation, and in particular the tesselator implementation does not understand that and it won't create the right polygon. It will join the points without crossing the dateline.

I don't think it is a bug in Lucene's implementation but a feature and we need to adapt accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed it with @iverase and he clarified this. Thanks! I think it would be nice to add a javadoc comment here to explain why this is not needed for holes and in toPolygonLucene() to explain why it is not needed there.

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -357,7 +357,7 @@ protected static Polygon polygonS4J(GeometryFactory factory, Coordinate[][] poly
double[] x = new double[shell.length];
double[] y = new double[shell.length];
for (int i = 0; i < shell.length; ++i) {
x[i] = normalizeLon(shell[i].x);
x[i] = Math.abs(shell[i].x) > 180 ? normalizeLon(shell[i].x) : shell[i].x;
Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed it with @iverase and he clarified this. Thanks! I think it would be nice to add a javadoc comment here to explain why this is not needed for holes and in toPolygonLucene() to explain why it is not needed there.

@iverase iverase added the v6.7.0 label Jan 11, 2019
@iverase iverase changed the title [Geo]: Do not normalize the longitude with value -180 for Lucene shapes Geo: Do not normalize the longitude with value -180 for Lucene shapes Jan 11, 2019
@iverase iverase merged commit 0a50821 into elastic:master Jan 11, 2019
iverase added a commit that referenced this pull request Jan 11, 2019
…#37299)

Lucene based shapes should not normalize the longitude value -180 to 180.
iverase added a commit that referenced this pull request Jan 11, 2019
…#37299)

Lucene based shapes should not normalize the longitude value -180 to 180.
@iverase iverase deleted the datelineBug branch January 11, 2019 08:41
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 v6.6.1 v6.7.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants