use of org.apache.lucene.geo.GeoTestUtil in project OpenSearch by opensearch-project.
the class GeometryTestUtils method randomPolygon.
public static Polygon randomPolygon(boolean hasAlt) {
org.apache.lucene.geo.Polygon lucenePolygon = randomValueOtherThanMany(p -> area(p) == 0, GeoTestUtil::nextPolygon);
if (lucenePolygon.numHoles() > 0) {
org.apache.lucene.geo.Polygon[] luceneHoles = lucenePolygon.getHoles();
List<LinearRing> holes = new ArrayList<>();
for (int i = 0; i < lucenePolygon.numHoles(); i++) {
org.apache.lucene.geo.Polygon poly = luceneHoles[i];
holes.add(linearRing(poly.getPolyLons(), poly.getPolyLats(), hasAlt));
}
return new Polygon(linearRing(lucenePolygon.getPolyLons(), lucenePolygon.getPolyLats(), hasAlt), holes);
}
return new Polygon(linearRing(lucenePolygon.getPolyLons(), lucenePolygon.getPolyLats(), hasAlt));
}
Aggregations