Vector tiles: order hits by geometry size by default (#75621) #75748
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Vector tiles can only display polygons and lines that are big enough for the precision of the tile. This might create strange results where the hits layer of a vector tile contains no data even though the query have hits. In order to provide expected results we are ordering the hits result by geometry size so we always render polygon and lines which are big enough on respect to the tile precision.
The first issue is to define how to compute the geometry size. This size needs to computed in respect to the spherical mercator projection as it introduces distortion. In this approach we use the diagonal size of the geometry bounding in the spherical mercator projection as ordering value.
In order to perform this, we introduce the following changes:
Introduce two new methods in our ScriptDocValue geometry interface:
** getMercatorWidth(): width of the geometry in the spherical mercator projection.
** getMercatorHeight(): Height of the geometry in the spherical mercator projection.
Move SphericalMercatorUtil to server under common/geo.
Then if there is no ordering provided by the user when calling the _mvt API and the size of the request > 0, then we add a order by using a script that computes the diagonal of the geometry square. This is used to order the results.
Note: We have consider to use filtering but this would affect the results on the aggregation.
backport #75621