Search in sources :

Example 1 with GeoCompositePolygon

use of org.apache.lucene.spatial3d.geom.GeoCompositePolygon in project lucene-solr by apache.

the class Geo3DUtil method fromPolygon.

/**
    * Convert a set of Polygon objects into a GeoPolygon.
    * @param polygons are the Polygon objects.
    * @return the GeoPolygon.
    */
static GeoPolygon fromPolygon(final Polygon... polygons) {
    //System.err.println("Creating polygon...");
    if (polygons.length < 1) {
        throw new IllegalArgumentException("need at least one polygon");
    }
    final GeoPolygon shape;
    if (polygons.length == 1) {
        final GeoPolygon component = fromPolygon(polygons[0]);
        if (component == null) {
            // Polygon is degenerate
            shape = new GeoCompositePolygon();
        } else {
            shape = component;
        }
    } else {
        final GeoCompositePolygon poly = new GeoCompositePolygon();
        for (final Polygon p : polygons) {
            final GeoPolygon component = fromPolygon(p);
            if (component != null) {
                poly.addShape(component);
            }
        }
        shape = poly;
    }
    return shape;
//System.err.println("...done");
}
Also used : GeoCompositePolygon(org.apache.lucene.spatial3d.geom.GeoCompositePolygon) GeoPolygon(org.apache.lucene.spatial3d.geom.GeoPolygon) Polygon(org.apache.lucene.geo.Polygon) GeoPolygon(org.apache.lucene.spatial3d.geom.GeoPolygon) GeoCompositePolygon(org.apache.lucene.spatial3d.geom.GeoCompositePolygon)

Aggregations

Polygon (org.apache.lucene.geo.Polygon)1 GeoCompositePolygon (org.apache.lucene.spatial3d.geom.GeoCompositePolygon)1 GeoPolygon (org.apache.lucene.spatial3d.geom.GeoPolygon)1