Convert a {@link Polygon} to a {@link PolygonOptions}

@param polygon polygon
@return polygon options
323748
public PolygonOptions toPolygon(Polygon polygon) {

        PolygonOptions polygonOptions = new PolygonOptions();

        List<LineString> rings = polygon.getRings();

        if (!rings.isEmpty()) {

            Double z = null;

            // Add the polygon points
            LineString polygonLineString = rings.get(0);

            // Try to simplify the number of points in the polygon ring
            List<Point> points = simplifyPoints(polygonLineString.getPoints());

            for (Point point : points) {
                LatLng latLng = toLatLng(point);
                polygonOptions.add(latLng);
                if (point.hasZ()) {
                    z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
                }
            }

            // Add the holes
            for (int i = 1; i < rings.size(); i++) {
                LineString hole = rings.get(i);

                // Try to simplify the number of points in the polygon hole
                List<Point> holePoints = simplifyPoints(hole.getPoints());

                List<LatLng> holeLatLngs = new ArrayList<LatLng>();
                for (Point point : holePoints) {
                    LatLng latLng = toLatLng(point);
                    holeLatLngs.add(latLng);
                    if (point.hasZ()) {
                        z = (z == null) ? point.getZ() : Math.max(z,
                                point.getZ());
                    }
                }
                polygonOptions.addHole(holeLatLngs);
            }

            if (polygon.hasZ() && z != null) {
                polygonOptions.zIndex(z.floatValue());
            }
        }

        return polygonOptions;
    }
745098
public Envelope convertEnvelopeFromWgsToEnu( Envelope envelopeWgs ) {
        Polygon polygonEnu = GeometryUtilities.createPolygonFromEnvelope(envelopeWgs);
        convertGeometryFromWgsToEnu(polygonEnu);
        Envelope envelopeEnu = polygonEnu.getEnvelopeInternal();
        return envelopeEnu;
    }
462211
public Polygon copy() {
		float[] copyPoints = new float[points.length];
		System.arraycopy(points, 0, copyPoints, 0, copyPoints.length);
		
		return new Polygon(copyPoints);
	}
970659
public static Geometry removePoint(Geometry geometry, Polygon polygon) throws SQLException {
        if(geometry == null){
            return null;
        }
        GeometryEditor localGeometryEditor = new GeometryEditor();
        PolygonDeleteVertexOperation localBoxDeleteVertexOperation = new PolygonDeleteVertexOperation(geometry.getFactory(), new PreparedPolygon(polygon));
        Geometry localGeometry = localGeometryEditor.edit(geometry, localBoxDeleteVertexOperation);
        if (localGeometry.isEmpty()) {
            return null;
        }
        return localGeometry;            
    }
1036149
function polygonize (str, properties) {
  var coordinates = str.split(' ').map(function (pairStr) {
    return pairStr.split(',').reverse().map(Number);
  });

  return polygon([coordinates], properties);
}
1187003
public Polygon toPolygon(com.google.android.gms.maps.model.Polygon polygon,
                             boolean hasZ, boolean hasM) {
        return toPolygon(polygon.getPoints(), polygon.getHoles(), hasZ, hasM);
    }
158185
public static Polygon createPolygonFromBounds( double minX, double minY, double maxX, double maxY ) {
        Coordinate[] c = new Coordinate[]{new Coordinate(minX, minY), new Coordinate(minX, maxY), new Coordinate(maxX, maxY),
                new Coordinate(maxX, minY), new Coordinate(minX, minY)};
        return gf().createPolygon(c);
    }
1317372
function Polygon(options) {

    var self = this;
    this.manager = options.manager;
    this.paper = options.paper;

    if (options.id) {
        this._id = options.id;
    } else {
        this._id = this.manager.getRandomId();
    }
    this._points = options.points;

    this._strokeColor = options.strokeColor;
    this._strokeWidth = options.strokeWidth || 2;
    this._selected = false;
    this._zoomFraction = 1;
    if (options.zoom) {
        this._zoomFraction = options.zoom / 100;
    }
    this.handle_wh = 6;

    this.element = this.paper.path("");
    this.element.attr({'fill-opacity': 0.01,
                        'fill': '#fff',
                        'cursor': 'pointer'});

    if (this.manager.canEdit) {
        // Drag handling of element
        this.element.drag(
            function(dx, dy) {
                if (self._zoomFraction === 0) {
                    return;     // just in case
                }
                // DRAG, update location and redraw
                dx = dx / self._zoomFraction;
                dy = dy / self._zoomFraction;

                var offsetX = dx - this.prevX;
                var offsetY = dy - this.prevY;
                this.prevX = dx;
                this.prevY = dy;

                // Manager handles move and redraw
                self.manager.moveSelectedShapes(offsetX, offsetY, true);
            },
            function() {
                self._handleMousedown();
                this.prevX = 0;
                this.prevY = 0;
                return false;
            },
            function() {
                // STOP
                // notify manager if rectangle has moved
                if (this.prevX !== 0 || this.prevY !== 0) {
                    self.manager.notifySelectedShapesChanged();
                }
                return false;
            }
        );
    }

    // create handles...
    this.createHandles();
    // and draw the Polygon
    this.drawShape();
}
1080639
function() {
        var geometry = this.polygon && this.polygon.geometry;
        if(geometry && this.multi) {
            geometry = new OpenLayers.Geometry.MultiPolygon([geometry]);
        }
        return geometry;
    }
859617
public List<List<List<Double>>> getCoordinates() {
		List<List<List<Double>>> polygon = new ArrayList<List<List<Double>>>();
		for (LineString lineString : coordinates) {
			polygon.add(lineString.getCoordinates());
		}
		return polygon;
	}
665894
public static Polygon create(org.locationtech.jts.geom.Polygon polygon) {
        double[] lats = new double[polygon.getNumPoints()];
        double[] lons = new double[polygon.getNumPoints()];
        for (int i = 0; i < polygon.getNumPoints(); i++) {
            lats[i] = polygon.getCoordinates()[i].y;
            lons[i] = polygon.getCoordinates()[i].x;
        }
        return new Polygon(lats, lons);
    }
832767
public static Polygon lines2Polygon( boolean checkValid, LineString... lines ) {
        List<Coordinate> coordinatesList = new ArrayList<Coordinate>();

        List<LineString> linesList = new ArrayList<LineString>();
        for( LineString tmpLine : lines ) {
            linesList.add(tmpLine);
        }

        LineString currentLine = linesList.get(0);
        linesList.remove(0);
        while( linesList.size() > 0 ) {
            Coordinate[] coordinates = currentLine.getCoordinates();
            List<Coordinate> tmpList = Arrays.asList(coordinates);
            coordinatesList.addAll(tmpList);

            Point thePoint = currentLine.getEndPoint();

            double minDistance = Double.MAX_VALUE;
            LineString minDistanceLine = null;
            boolean needFlip = false;
            for( LineString tmpLine : linesList ) {
                Point tmpStartPoint = tmpLine.getStartPoint();
                double distance = thePoint.distance(tmpStartPoint);
                if (distance < minDistance) {
                    minDistance = distance;
                    minDistanceLine = tmpLine;
                    needFlip = false;
                }

                Point tmpEndPoint = tmpLine.getEndPoint();
                distance = thePoint.distance(tmpEndPoint);
                if (distance < minDistance) {
                    minDistance = distance;
                    minDistanceLine = tmpLine;
                    needFlip = true;
                }
            }

            linesList.remove(minDistanceLine);

            if (needFlip) {
                minDistanceLine = (LineString) minDistanceLine.reverse();
            }

            currentLine = minDistanceLine;

        }
        // add last
        Coordinate[] coordinates = currentLine.getCoordinates();
        List<Coordinate> tmpList = Arrays.asList(coordinates);
        coordinatesList.addAll(tmpList);

        coordinatesList.add(coordinatesList.get(0));
        LinearRing linearRing = gf().createLinearRing(coordinatesList.toArray(new Coordinate[0]));
        Polygon polygon = gf().createPolygon(linearRing, null);

        if (checkValid) {
            if (!polygon.isValid()) {
                return null;
            }
        }
        return polygon;
    }
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;
    }
1011822
public function polygon(string $polygon)
    {
        if (\in_array($polygon, $this->polygon, true)) {
            $this->query['polygon_' . $polygon] = '1';

            return $this;
        }

        throw new InvalidParameterException('This polygon format is not supported');
    }
129467
public static Geometry drapeMultiPolygon(MultiPolygon polygons, Geometry triangles, STRtree sTRtree) {
        GeometryFactory factory = polygons.getFactory();         
        //Split the triangles in lines to perform all intersections
        Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true);
        int nbPolygons = polygons.getNumGeometries();
        Polygon[] polygonsDiff = new Polygon[nbPolygons];
        for (int i = 0; i < nbPolygons; i++) {
            polygonsDiff[i] = processPolygon((Polygon) polygons.getGeometryN(i), triangleLines, factory);
        }
        Geometry diffExt = factory.createMultiPolygon(polygonsDiff);
        CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree);
        diffExt.apply(drapeFilter);
        return diffExt;
    }
1312301
function(node) {
            var nodeList = this.getElementsByTagNameNS(node, this.gmlns,
                                                       "Polygon");
            var components = [];
            if(nodeList.length > 0) {
                var polygon;
                for(var i=0; i<nodeList.length; ++i) {
                    polygon = this.parseGeometry.polygon.apply(this,
                                                               [nodeList[i]]);
                    if(polygon) {
                        components.push(polygon);
                    }
                }
            }
            return new OpenLayers.Geometry.MultiPolygon(components);
        }
1210548
public Polygon createPolygon(Bbox bbox) {
		Coordinate tl = new Coordinate(bbox.getX(), bbox.getY());
		Coordinate tr = new Coordinate(bbox.getX() + bbox.getWidth(), bbox.getY());
		Coordinate br = new Coordinate(bbox.getX() + bbox.getWidth(), bbox.getY() + bbox.getHeight());
		Coordinate bl = new Coordinate(bbox.getX(), bbox.getY() + bbox.getHeight());
		return new Polygon(srid, precision, new LinearRing(srid, precision, new Coordinate[] { tl, tr, br, bl, tl }),
				null);
	}