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

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

Merged
merged 3 commits into from Jan 11, 2019

Conversation

Projects
None yet
4 participants
@iverase
Copy link
Contributor

commented Jan 10, 2019

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

Closes #37297

@elasticmachine

This comment has been minimized.

Copy link

commented Jan 10, 2019

@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;

This comment has been minimized.

Copy link
@imotov

imotov Jan 10, 2019

Member

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

This comment has been minimized.

Copy link
@iverase

iverase Jan 10, 2019

Author Contributor

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.

This comment has been minimized.

Copy link
@imotov

imotov Jan 10, 2019

Member

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.

@imotov

imotov approved these changes Jan 10, 2019

Copy link
Member

left a comment

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;

This comment has been minimized.

Copy link
@imotov

imotov Jan 10, 2019

Member

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

7 checks passed

CLA Commit author is a member of Elasticsearch
Details
elasticsearch-ci-1 Build finished.
Details
elasticsearch-ci-2 Build finished.
Details
elasticsearch-ci/default-distro Build finished.
Details
elasticsearch-ci/docbldesx Build finished.
Details
elasticsearch-ci/oss-distro-docs Build finished.
Details
elasticsearch-ci/packaging-sample Build finished.
Details

iverase added a commit that referenced this pull request Jan 11, 2019

Geo: Do not normalize the longitude with value -180 for Lucene shapes (
…#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

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

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

@iverase iverase deleted the iverase:datelineBug branch Jan 11, 2019

@colings86 colings86 added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.