Skip to content

Conversation

iverase
Copy link
Contributor

@iverase iverase commented May 9, 2022

The current library we use to encode mvt geometries into vector tiles features handle incorrectly the orientation of the polygons. The main branch of the project contains a fix to the issue but it has not been released.

This PR forks the method we use in JTSAdapter to generate the vector tile feature containing the fix for polygon orientation.

fixes #86560

@iverase iverase added >bug :Analytics/Geo Indexing, search aggregations of geo points and shapes v8.3.0 v8.2.1 v7.17.4 labels May 9, 2022
@iverase iverase requested a review from craigtaverner May 9, 2022 09:07
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label May 9, 2022
@elasticmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

Hi @iverase, I've updated the changelog YAML for you.

Copy link
Contributor

@craigtaverner craigtaverner left a comment

Choose a reason for hiding this comment

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

I think it looks good to me, but I also feel like I do not know enough of the inner workings of the MVT encoding to completely follow everything.

// Check CCW Winding (must be positive area in original coordinate system, MVT is positive-y-down,
// so inequality is flipped)
// See: https://docs.mapbox.com/vector-tiles/specification/#winding-order
if (exteriorArea > 0d) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I presume this is the change

Copy link
Contributor Author

@iverase iverase May 9, 2022

Choose a reason for hiding this comment

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

yes, that is the orientation for the outer ring

// Check CW Winding (must be negative area in original coordinate system, MVT is positive-y-down,
// so inequality is flipped)
// See: https://docs.mapbox.com/vector-tiles/specification/#winding-order
if (interiorArea < 0d) {
Copy link
Contributor

Choose a reason for hiding this comment

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

And another one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, that is the orientation for inner rings (holes)

assertThat(feature.getGeometryCount(), equalTo(22));
{
// outer ring
double[] xs = new double[5];
Copy link
Contributor

Choose a reason for hiding this comment

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

Understanding these tests requires inner knowledge of the MVT tile encoding, which I do not (yet) have.

@iverase iverase merged commit 6efa188 into elastic:master May 17, 2022
@iverase iverase deleted the fixMVTPolOrientation branch May 17, 2022 13:53
iverase added a commit to iverase/elasticsearch that referenced this pull request May 17, 2022
This commit forks the method we use in JTSAdapter to generate the vector tile feature containing the right logic
for polygon orientation.
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.2
7.17 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 86555

iverase added a commit to iverase/elasticsearch that referenced this pull request May 17, 2022
This commit forks the method we use in JTSAdapter to generate the vector tile feature containing the right logic
for polygon orientation.
# Conflicts:
#	x-pack/plugin/vector-tile/src/test/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactoryTests.java
elasticsearchmachine pushed a commit that referenced this pull request May 17, 2022
This commit forks the method we use in JTSAdapter to generate the vector tile feature containing the right logic
for polygon orientation.
elasticsearchmachine pushed a commit that referenced this pull request May 17, 2022
* Fix mvt polygon orientation (#86555)

This commit forks the method we use in JTSAdapter to generate the vector tile feature containing the right logic
for polygon orientation.
# Conflicts:
#	x-pack/plugin/vector-tile/src/test/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactoryTests.java

* compile error
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.17.4 v8.2.1 v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Foreground extrusions missing with vector tile returned by the vector tile search API
4 participants