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

Support geo label position as runtime field #86154

Merged

Conversation

craigtaverner
Copy link
Contributor

@craigtaverner craigtaverner commented Apr 25, 2022

There is a need to provide sensibly calculated label positions for polygons and lines in Kibana maps (as requested in #86044). A very convenient way of satisfy this need is through a runtime field that the rest API can make use of when labels are requested. This has the advantage of providing painless access to the label position as well. This PR provides the runtime field.

@craigtaverner craigtaverner added >enhancement :Analytics/Geo Indexing, search aggregations of geo points and shapes v8.3.0 labels Apr 25, 2022
@elasticsearchmachine
Copy link
Collaborator

Hi @craigtaverner, I've created a changelog YAML for you.

@craigtaverner
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/part-2

@craigtaverner craigtaverner marked this pull request as ready for review April 29, 2022 09:54
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Apr 29, 2022
@craigtaverner craigtaverner requested a review from iverase April 29, 2022 09:54
@iverase iverase added the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label May 2, 2022
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label May 2, 2022
@sethmlarson sethmlarson added the Team:Clients Meta label for clients team label May 3, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/clients-team (Team:Clients)

We simplified this to always use the middle of the first tree geometry.
The use of the centroid can be done higher up in the stack.
For painless, this means in the user written script.
For the REST API we will add that logic on the server side.
Now that we no longer use the centroid for polygon labels, but the
middle of the first triangle.
This time without rounding error
And more tests, including testing intersects for all label positions.
Copy link
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

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

Just have a small comment about how we handle an error. Otherwise let's get CI green and it can be approved.

@craigtaverner craigtaverner force-pushed the label_position_runtime_field branch from 4ae19a0 to ccf30cf Compare May 9, 2022 10:14
The centroid is unlikely to be one of the points, so we choose a point
closest to the middle of the bounding box.
The changes to expose GeoShapeQueryable.toQuantizeLuceneGeometry to
external use also caused exception causes to be one level deeper.
This fix just brings the underlying message up one level to get
tests to pass.
While we could have also changed tests to assert on causes a level
deeper, this fix seems more backwards compatible, just in case anyone
else is relying on causes.
@craigtaverner craigtaverner force-pushed the label_position_runtime_field branch from ccf30cf to 74dc54b Compare May 9, 2022 12:54
@iverase iverase requested a review from stu-elastic May 9, 2022 13:19
Copy link
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

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

LGTM

Thank you Craig!

Copy link
Contributor

@stu-elastic stu-elastic left a comment

Choose a reason for hiding this comment

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

Scripting looks good.

@craigtaverner craigtaverner merged commit 36fd640 into elastic:master May 10, 2022
@craigtaverner craigtaverner deleted the label_position_runtime_field branch October 20, 2023 10:47
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 :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Clients Meta label for clients team Team:Core/Infra Meta label for core/infra team v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants