|
@@ -31,33 +31,40 @@ import java.util.List;
|
|
|
|
|
|
public class FeatureFactoryTests extends ESTestCase {
|
|
public class FeatureFactoryTests extends ESTestCase {
|
|
|
|
|
|
- @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/75325")
|
|
|
|
public void testPoint() {
|
|
public void testPoint() {
|
|
- int z = randomIntBetween(1, 10);
|
|
|
|
|
|
+ int z = randomIntBetween(3, 10);
|
|
int x = randomIntBetween(0, (1 << z) - 1);
|
|
int x = randomIntBetween(0, (1 << z) - 1);
|
|
int y = randomIntBetween(0, (1 << z) - 1);
|
|
int y = randomIntBetween(0, (1 << z) - 1);
|
|
int extent = randomIntBetween(1 << 8, 1 << 14);
|
|
int extent = randomIntBetween(1 << 8, 1 << 14);
|
|
FeatureFactory builder = new FeatureFactory(z, x, y, extent);
|
|
FeatureFactory builder = new FeatureFactory(z, x, y, extent);
|
|
Rectangle rectangle = GeoTileUtils.toBoundingBox(x, y, z);
|
|
Rectangle rectangle = GeoTileUtils.toBoundingBox(x, y, z);
|
|
{
|
|
{
|
|
- double lat = randomValueOtherThanMany((l) -> rectangle.getMinY() > l || rectangle.getMaxY() < l, GeoTestUtil::nextLatitude);
|
|
|
|
- double lon = randomValueOtherThanMany((l) -> rectangle.getMinX() > l || rectangle.getMaxX() < l, GeoTestUtil::nextLongitude);
|
|
|
|
|
|
+ double lat = randomValueOtherThanMany((l) -> rectangle.getMinY() >= l || rectangle.getMaxY() <= l, GeoTestUtil::nextLatitude);
|
|
|
|
+ double lon = randomValueOtherThanMany((l) -> rectangle.getMinX() >= l || rectangle.getMaxX() <= l, GeoTestUtil::nextLongitude);
|
|
List<VectorTile.Tile.Feature> features = builder.getFeatures(new Point(lon, lat), new UserDataIgnoreConverter());
|
|
List<VectorTile.Tile.Feature> features = builder.getFeatures(new Point(lon, lat), new UserDataIgnoreConverter());
|
|
assertThat(features.size(), Matchers.equalTo(1));
|
|
assertThat(features.size(), Matchers.equalTo(1));
|
|
VectorTile.Tile.Feature feature = features.get(0);
|
|
VectorTile.Tile.Feature feature = features.get(0);
|
|
assertThat(feature.getType(), Matchers.equalTo(VectorTile.Tile.GeomType.POINT));
|
|
assertThat(feature.getType(), Matchers.equalTo(VectorTile.Tile.GeomType.POINT));
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- double lat = randomValueOtherThanMany((l) -> rectangle.getMinY() <= l && rectangle.getMaxY() >= l, GeoTestUtil::nextLatitude);
|
|
|
|
- double lon = randomValueOtherThanMany((l) -> rectangle.getMinX() <= l && rectangle.getMaxX() >= l, GeoTestUtil::nextLongitude);
|
|
|
|
|
|
+ int xNew = randomValueOtherThanMany(v -> Math.abs(v - x) < 2, () -> randomIntBetween(0, (1 << z) - 1));
|
|
|
|
+ int yNew = randomValueOtherThanMany(v -> Math.abs(v - y) < 2, () -> randomIntBetween(0, (1 << z) - 1));
|
|
|
|
+ Rectangle rectangleNew = GeoTileUtils.toBoundingBox(xNew, yNew, z);
|
|
|
|
+ double lat = randomValueOtherThanMany(
|
|
|
|
+ (l) -> rectangleNew.getMinY() >= l || rectangleNew.getMaxY() <= l,
|
|
|
|
+ GeoTestUtil::nextLatitude
|
|
|
|
+ );
|
|
|
|
+ double lon = randomValueOtherThanMany(
|
|
|
|
+ (l) -> rectangleNew.getMinX() >= l || rectangleNew.getMaxX() <= l,
|
|
|
|
+ GeoTestUtil::nextLongitude
|
|
|
|
+ );
|
|
List<VectorTile.Tile.Feature> features = builder.getFeatures(new Point(lon, lat), new UserDataIgnoreConverter());
|
|
List<VectorTile.Tile.Feature> features = builder.getFeatures(new Point(lon, lat), new UserDataIgnoreConverter());
|
|
assertThat(features.size(), Matchers.equalTo(0));
|
|
assertThat(features.size(), Matchers.equalTo(0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/75325")
|
|
|
|
public void testMultiPoint() {
|
|
public void testMultiPoint() {
|
|
- int z = randomIntBetween(1, 10);
|
|
|
|
|
|
+ int z = randomIntBetween(3, 10);
|
|
int x = randomIntBetween(0, (1 << z) - 1);
|
|
int x = randomIntBetween(0, (1 << z) - 1);
|
|
int y = randomIntBetween(0, (1 << z) - 1);
|
|
int y = randomIntBetween(0, (1 << z) - 1);
|
|
int extent = randomIntBetween(1 << 8, 1 << 14);
|
|
int extent = randomIntBetween(1 << 8, 1 << 14);
|
|
@@ -66,8 +73,8 @@ public class FeatureFactoryTests extends ESTestCase {
|
|
int numPoints = randomIntBetween(2, 10);
|
|
int numPoints = randomIntBetween(2, 10);
|
|
{
|
|
{
|
|
List<Point> points = new ArrayList<>();
|
|
List<Point> points = new ArrayList<>();
|
|
- double lat = randomValueOtherThanMany((l) -> rectangle.getMinY() > l || rectangle.getMaxY() < l, GeoTestUtil::nextLatitude);
|
|
|
|
- double lon = randomValueOtherThanMany((l) -> rectangle.getMinX() > l || rectangle.getMaxX() < l, GeoTestUtil::nextLongitude);
|
|
|
|
|
|
+ double lat = randomValueOtherThanMany((l) -> rectangle.getMinY() >= l || rectangle.getMaxY() <= l, GeoTestUtil::nextLatitude);
|
|
|
|
+ double lon = randomValueOtherThanMany((l) -> rectangle.getMinX() >= l || rectangle.getMaxX() <= l, GeoTestUtil::nextLongitude);
|
|
points.add(new Point(lon, lat));
|
|
points.add(new Point(lon, lat));
|
|
for (int i = 0; i < numPoints - 1; i++) {
|
|
for (int i = 0; i < numPoints - 1; i++) {
|
|
points.add(new Point(GeoTestUtil.nextLongitude(), GeoTestUtil.nextLatitude()));
|
|
points.add(new Point(GeoTestUtil.nextLongitude(), GeoTestUtil.nextLatitude()));
|
|
@@ -78,14 +85,17 @@ public class FeatureFactoryTests extends ESTestCase {
|
|
assertThat(feature.getType(), Matchers.equalTo(VectorTile.Tile.GeomType.POINT));
|
|
assertThat(feature.getType(), Matchers.equalTo(VectorTile.Tile.GeomType.POINT));
|
|
}
|
|
}
|
|
{
|
|
{
|
|
|
|
+ int xNew = randomValueOtherThanMany(v -> Math.abs(v - x) < 2, () -> randomIntBetween(0, (1 << z) - 1));
|
|
|
|
+ int yNew = randomValueOtherThanMany(v -> Math.abs(v - y) < 2, () -> randomIntBetween(0, (1 << z) - 1));
|
|
|
|
+ Rectangle rectangleNew = GeoTileUtils.toBoundingBox(xNew, yNew, z);
|
|
List<Point> points = new ArrayList<>();
|
|
List<Point> points = new ArrayList<>();
|
|
for (int i = 0; i < numPoints; i++) {
|
|
for (int i = 0; i < numPoints; i++) {
|
|
double lat = randomValueOtherThanMany(
|
|
double lat = randomValueOtherThanMany(
|
|
- (l) -> rectangle.getMinY() <= l && rectangle.getMaxY() >= l,
|
|
|
|
|
|
+ (l) -> rectangleNew.getMinY() >= l || rectangleNew.getMaxY() <= l,
|
|
GeoTestUtil::nextLatitude
|
|
GeoTestUtil::nextLatitude
|
|
);
|
|
);
|
|
double lon = randomValueOtherThanMany(
|
|
double lon = randomValueOtherThanMany(
|
|
- (l) -> rectangle.getMinX() <= l && rectangle.getMaxX() >= l,
|
|
|
|
|
|
+ (l) -> rectangleNew.getMinX() >= l || rectangleNew.getMaxX() <= l,
|
|
GeoTestUtil::nextLongitude
|
|
GeoTestUtil::nextLongitude
|
|
);
|
|
);
|
|
points.add(new Point(lon, lat));
|
|
points.add(new Point(lon, lat));
|