-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Implement weighted geo_shape centroid support #50297
Implement weighted geo_shape centroid support #50297
Conversation
Pinging @elastic/es-analytics-geo (:Analytics/Geo) |
I think the lat/lon values for the centroid need to be normalise to be in bounds. What I am wondering now is that we need to handle the dateline. I think the current calculation does not consider the dateline so two polygons at each side of the dateline might give a strange centroid? On the other hand this has been always like that even for points so it might be just a feature. |
3a4a9f4
to
58b2243
Compare
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.
Thanks Tal! I think the only issue at the moment is how we calculate weights for Polygons as we accept polygons with different orientations so we need to be careful there.
server/src/main/java/org/elasticsearch/common/geo/CentroidCalculator.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidAggregator.java
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/common/geo/CentroidCalculatorTests.java
Show resolved
Hide resolved
…hapetype-centroid
…hapetype-centroid
Heyo, I've updated to be agnostic to orientation with the help of Math.abs |
assertEquals(5.5, calculator.getY(), DELTA); | ||
} | ||
|
||
public void testRoundingErrorAndNormalization() { |
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 one issue I am not entirely sure how to best support. Due to how the centroid is calculated, it can happen that the longitude or latitude values are invalid and must be normalized.
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.
I think this is ok. Normalization only happens when writing the centroid into the doc value.
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.
lgtm.
I am not sure about having to read the weight when reading the extent but I don't have a good suggestion. For the time being this looks good as I think we will have a last iteration to decide the final format of the doc value.
agreed. I will highlight this in our next review |
This PR implements proper centroid calculations of geometries according to the definition defined in #49887. To compute things correctly, an additional variable encoded long representing the total weight for the centroid of the geometry in a tree. This weight is always positive. Some tests are fixed, as they did not have valid geometries. closes #49887.
This PR implements proper centroid calculations of geometries according to the
definition defined in #49887. To compute things correctly, an additional variable
encoded long representing the total weight for the centroid of the geometry in
a tree. This weight is always positive. Some tests are fixed, as they did not
have valid geometries.
closes #49887.