Search in sources :

Example 1 with GeoTestUtil

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));
}
Also used : GeoTestUtil(org.apache.lucene.geo.GeoTestUtil) ArrayList(java.util.ArrayList) Polygon(org.opensearch.geometry.Polygon) MultiPolygon(org.opensearch.geometry.MultiPolygon) LinearRing(org.opensearch.geometry.LinearRing) Point(org.opensearch.geometry.Point) MultiPoint(org.opensearch.geometry.MultiPoint)

Aggregations

ArrayList (java.util.ArrayList)1 GeoTestUtil (org.apache.lucene.geo.GeoTestUtil)1 LinearRing (org.opensearch.geometry.LinearRing)1 MultiPoint (org.opensearch.geometry.MultiPoint)1 MultiPolygon (org.opensearch.geometry.MultiPolygon)1 Point (org.opensearch.geometry.Point)1 Polygon (org.opensearch.geometry.Polygon)1