Convert a list of {@link PolygonOptions} to a {@link MultiPolygon}

@param multiPolygonOptions multi polygon options
@param hasZ                has z flag
@param hasM                has m flag
@return multi polygon
494154
public MultiPolygon toMultiPolygonFromOptions(
            MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) {

        MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM);

        for (PolygonOptions mapPolygon : multiPolygonOptions
                .getPolygonOptions()) {
            Polygon polygon = toPolygon(mapPolygon);
            multiPolygon.addPolygon(polygon);
        }

        return multiPolygon;
    }
164333
function(array) {
            var polys = [];
            var p = null;
            for(var i=0, len=array.length; i<len; ++i) {
                try {
                    p = this.parseCoords["polygon"].apply(this, [array[i]]);
                } catch(err) {
                    throw err;
                }
                polys.push(p);
            }
            return new OpenLayers.Geometry.MultiPolygon(polys);
        }
16989
function polygonToPSLG(loops, options) {
  if(!Array.isArray(loops)) {
    throw new Error('poly-to-pslg: Error, invalid polygon')
  }
  if(loops.length === 0) {
    return {
      points: [],
      edges:  []
    }
  }

  options = options || {}

  var nested = true
  if('nested' in options) {
    nested = !!options.nested
  } else if(loops[0].length === 2 && typeof loops[0][0] === 'number') {
    //Hack:  If use doesn't pass in a loop, then try to guess if it is nested
    nested = false
  }
  if(!nested) {
    loops = [loops]
  }

  //First we just unroll all the points in the dumb/obvious way
  var points = []
  var edges = []
  for(var i=0; i<loops.length; ++i) {
    var loop = loops[i]
    var offset = points.length
    for(var j=0; j<loop.length; ++j) {
      points.push(loop[j])
      edges.push([ offset+j, offset+(j+1)%loop.length ])
    }
  }

  //Then we run snap rounding to clean up self intersections and duplicate verts
  var clean = 'clean' in options ? true : !!options.clean
  if(clean) {
    cleanPSLG(points, edges)
  }

  //Finally, we return the resulting PSLG
  return {
    points: points,
    edges:  edges
  }
}
76470
public static boolean isPointOnMultiPolyline(LatLng point, MultiPolylineOptions multiPolyline, boolean geodesic, double tolerance) {
        boolean near = false;
        for (PolylineOptions polyline : multiPolyline.getPolylineOptions()) {
            near = isPointOnPolyline(point, polyline, geodesic, tolerance);
            if (near) {
                break;
            }
        }
        return near;
    }
849981
public  org.osmdroid.views.overlay.Polygon toCurvePolygon(CurvePolygon curvePolygon) {

        org.osmdroid.views.overlay.Polygon polygonOptions = new org.osmdroid.views.overlay.Polygon();
        List<GeoPoint> pts = new ArrayList<>();
        List<Curve> rings = curvePolygon.getRings();
        List<List<GeoPoint>> holes = new ArrayList<>();
        if (!rings.isEmpty()) {

            Double z = null;

            // Add the polygon points
            Curve curve = rings.get(0);
            if (curve instanceof CompoundCurve) {
                CompoundCurve compoundCurve = (CompoundCurve) curve;
                for (LineString lineString : compoundCurve.getLineStrings()) {
                    for (Point point : lineString.getPoints()) {
                        GeoPoint latLng = toLatLng(point);
                        pts.add(latLng);

                    }
                }
            } else if (curve instanceof LineString) {
                LineString lineString = (LineString) curve;
                for (Point point : lineString.getPoints()) {
                    GeoPoint latLng = toLatLng(point);
                    pts.add(latLng);

                }
            } else {
                throw new GeoPackageException("Unsupported Curve Type: "
                    + curve.getClass().getSimpleName());
            }


            // Add the holes
            for (int i = 1; i < rings.size(); i++) {
                Curve hole = rings.get(i);
                List<GeoPoint> holeLatLngs = new ArrayList<GeoPoint>();
                if (hole instanceof CompoundCurve) {
                    CompoundCurve holeCompoundCurve = (CompoundCurve) hole;
                    for (LineString holeLineString : holeCompoundCurve.getLineStrings()) {
                        for (Point point : holeLineString.getPoints()) {
                            GeoPoint latLng = toLatLng(point);
                            holeLatLngs.add(latLng);

                        }
                    }
                } else if (hole instanceof LineString) {
                    LineString holeLineString = (LineString) hole;
                    for (Point point : holeLineString.getPoints()) {
                        GeoPoint latLng = toLatLng(point);
                        holeLatLngs.add(latLng);
                        if (point.hasZ()) {
                            z = (z == null) ? point.getZ() : Math.max(z,
                                point.getZ());
                        }
                    }
                } else {
                    throw new GeoPackageException("Unsupported Curve Hole Type: "
                        + hole.getClass().getSimpleName());
                }
                holes.add(holeLatLngs);

            }

        }
        polygonOptions.setHoles(holes);
        polygonOptions.setPoints(pts);

        return polygonOptions;
    }
1032155
private Collection<Geometry> unionAdjacentPolygons(Collection<Geometry> list) {
        UnaryUnionOp op = new UnaryUnionOp(list);
        Geometry result = op.union();
        if (result.getNumGeometries() < list.size()) {
            list.clear();
            for (int i = 0; i < result.getNumGeometries(); i++) {
                list.add(result.getGeometryN(i));
            }
        }
        return list;
    }
426409
public MultiPolygonOptions toPolygons(MultiPolygon multiPolygon) {

        MultiPolygonOptions polygons = new MultiPolygonOptions();

        for (Polygon polygon : multiPolygon.getPolygons()) {
            PolygonOptions polygonOptions = toPolygon(polygon);
            polygons.add(polygonOptions);
        }

        return polygons;
    }
800103
private static String multiPolygonCoordinatesFromWkt(String wkt) {
        wkt = removeBrackets(wkt,1);
        String polygonsWithPipeSeparator = wkt.replaceAll("\\s*\\)\\s*\\)\\s*,\\s*\\(\\s*\\(\\s*","))|((");
        String[] polygons = polygonsWithPipeSeparator.split("\\|");
        String[] polygonsCoordinates = new String[polygons.length];
        for (int i=0;i<polygons.length;i++){
            polygonsCoordinates[i] = polygonCoordinatesFromWkt(polygons[i]);
        }
        String coordinates = Joiner.on(",").join(polygonsCoordinates);
        return String.format("[%s]", coordinates);
    }
184496
public static Polygon convert(Polygon polygon, int dimension) {
        LinearRing shell = GeometryCoordinateDimension.convert(polygon.getExteriorRing(),dimension);
        int nbOfHoles = polygon.getNumInteriorRing();
        final LinearRing[] holes = new LinearRing[nbOfHoles];
        for (int i = 0; i < nbOfHoles; i++) {
            holes[i] = GeometryCoordinateDimension.convert(polygon.getInteriorRingN(i),dimension);
        }
        return gf.createPolygon(shell, holes);
    }
625275
public MultiPolygon toMultiPolygon(
            List<com.google.android.gms.maps.model.Polygon> polygonList,
            boolean hasZ, boolean hasM) {

        MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM);

        for (com.google.android.gms.maps.model.Polygon mapPolygon : polygonList) {
            Polygon polygon = toPolygon(mapPolygon);
            multiPolygon.addPolygon(polygon);
        }

        return multiPolygon;
    }
967910
public MultiPolygon toMultiPolygon(
            List<com.google.android.gms.maps.model.Polygon> polygonList) {
        return toMultiPolygon(polygonList, false, false);
    }
23500
private Polygon createPolygon(double[][][] coordinates, CrsId crsId) {
        LinearRing[] rings = new LinearRing[coordinates.length];
        for (int i = 0; i < coordinates.length; i++) {
            rings[i] = new LinearRing(createPointSequence(coordinates[i], crsId));
        }
        return new Polygon(rings);
    }
1020329
public Polygon toPolygon(List<LatLng> latLngs, List<List<LatLng>> holes) {
        return toPolygon(latLngs, holes, false, false);
    }
1082360
public static mil.nga.geopackage.map.geom.MultiPolygon addPolygonsToMap(
            GoogleMap map, MultiPolygonOptions polygons) {
        mil.nga.geopackage.map.geom.MultiPolygon multiPolygon = new mil.nga.geopackage.map.geom.MultiPolygon();
        for (PolygonOptions polygonOption : polygons.getPolygonOptions()) {
            if (polygons.getOptions() != null) {
                polygonOption.fillColor(polygons.getOptions().getFillColor());
                polygonOption.strokeColor(polygons.getOptions()
                        .getStrokeColor());
                polygonOption.geodesic(polygons.getOptions().isGeodesic());
                polygonOption.visible(polygons.getOptions().isVisible());
                polygonOption.zIndex(polygons.getOptions().getZIndex());
                polygonOption.strokeWidth(polygons.getOptions().getStrokeWidth());
            }
            com.google.android.gms.maps.model.Polygon polygon = addPolygonToMap(
                    map, polygonOption);
            multiPolygon.add(polygon);
        }
        return multiPolygon;
    }
1336918
public static boolean isPointOnMultiPolygon(LatLng point, MultiPolygonOptions multiPolygon, boolean geodesic, double tolerance) {
        boolean near = false;
        for (PolygonOptions polygon : multiPolygon.getPolygonOptions()) {
            near = isPointOnPolygon(point, polygon, geodesic, tolerance);
            if (near) {
                break;
            }
        }
        return near;
    }
901332
public static JCGLPolygonMode polygonModeFromGL(
    final int g)
  {
    switch (g) {
      case GL2GL3.GL_FILL:
        return JCGLPolygonMode.POLYGON_FILL;
      case GL2GL3.GL_LINE:
        return JCGLPolygonMode.POLYGON_LINES;
      case GL2GL3.GL_POINT:
        return JCGLPolygonMode.POLYGON_POINTS;
      default:
        throw new UnreachableCodeException();
    }
  }
459312
public static MultiPolygon of(Stream<Polygon> polygons) {
        return of(polygons.collect(Collectors.toList()));
    }