forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vector tiles: order hits by geometry size by default (elastic#75621)
_mvt end point gives priority to geometries with larger area
- Loading branch information
Showing
13 changed files
with
197 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
...rtile/feature/SphericalMercatorUtils.java → ...ch/common/geo/SphericalMercatorUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
server/src/test/java/org/elasticsearch/common/geo/SphericalMercatorUtilTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.common.geo; | ||
|
||
import org.elasticsearch.geo.GeometryTestUtils; | ||
import org.elasticsearch.geometry.Rectangle; | ||
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoTileUtils; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.hamcrest.Matchers; | ||
|
||
import static org.elasticsearch.common.geo.SphericalMercatorUtils.MERCATOR_BOUNDS; | ||
import static org.elasticsearch.common.geo.SphericalMercatorUtils.lonToSphericalMercator; | ||
import static org.elasticsearch.common.geo.SphericalMercatorUtils.latToSphericalMercator; | ||
import static org.elasticsearch.common.geo.SphericalMercatorUtils.recToSphericalMercator; | ||
|
||
public class SphericalMercatorUtilTests extends ESTestCase { | ||
|
||
public void testLon() { | ||
assertThat(lonToSphericalMercator(180.0), Matchers.equalTo(MERCATOR_BOUNDS)); | ||
assertThat(lonToSphericalMercator(-180.0), Matchers.equalTo(-MERCATOR_BOUNDS)); | ||
assertThat(lonToSphericalMercator(0.0), Matchers.equalTo(0.0)); | ||
final double lon = lonToSphericalMercator(GeometryTestUtils.randomLon()); | ||
assertThat(lon, Matchers.greaterThanOrEqualTo(-MERCATOR_BOUNDS)); | ||
assertThat(lon, Matchers.lessThanOrEqualTo(MERCATOR_BOUNDS)); | ||
} | ||
|
||
public void testLat() { | ||
assertThat(latToSphericalMercator(GeoTileUtils.LATITUDE_MASK), Matchers.closeTo(MERCATOR_BOUNDS, 1e-7)); | ||
assertThat(latToSphericalMercator(-GeoTileUtils.LATITUDE_MASK), Matchers.closeTo(-MERCATOR_BOUNDS, 1e-7)); | ||
assertThat(latToSphericalMercator(0.0), Matchers.closeTo(0, 1e-7)); | ||
final double lat = latToSphericalMercator(randomValueOtherThanMany( | ||
l -> l >= GeoTileUtils.LATITUDE_MASK || l <= -GeoTileUtils.LATITUDE_MASK, | ||
GeometryTestUtils::randomLat | ||
)); | ||
assertThat(lat, Matchers.greaterThanOrEqualTo(-MERCATOR_BOUNDS)); | ||
assertThat(lat, Matchers.lessThanOrEqualTo(MERCATOR_BOUNDS)); | ||
} | ||
|
||
public void testRectangle() { | ||
Rectangle rect = GeometryTestUtils.randomRectangle(); | ||
Rectangle mercatorRect = recToSphericalMercator(rect); | ||
assertThat(mercatorRect.getMinX(), Matchers.equalTo(lonToSphericalMercator(rect.getMinX()))); | ||
assertThat(mercatorRect.getMaxX(), Matchers.equalTo(lonToSphericalMercator(rect.getMaxX()))); | ||
assertThat(mercatorRect.getMinY(), Matchers.equalTo(latToSphericalMercator(rect.getMinY()))); | ||
assertThat(mercatorRect.getMaxY(), Matchers.equalTo(latToSphericalMercator(rect.getMaxY()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.