public static void toGeojsonGeometryCollection(GeometryCollection geometryCollection, StringBuilder sb) {
        sb.append("{\"type\":\"GeometryCollection\",\"geometries\":[");
        for (int i = 0; i < geometryCollection.getNumGeometries(); i++) {
            Geometry geom = geometryCollection.getGeometryN(i);
            if (geom instanceof Point) {
                toGeojsonPoint((Point) geom, sb);
            } else if (geom instanceof LineString) {
                toGeojsonLineString((LineString) geom, sb);
            } else if (geom instanceof Polygon) {
                toGeojsonPolygon((Polygon) geom, sb);
            }
            if (i < geometryCollection.getNumGeometries() - 1) {
                sb.append(",");
            }
        }
        sb.append("]}");
    }
public static void toGeojsonGeometryCollection ( GeometryCollection geometryCollection , StringBuilder sb ) { sb . append ( "{\"type\":\"GeometryCollection\",\"geometries\":[" ) ; for ( int i = 0 ; i < geometryCollection . getNumGeometries ( ) ; i ++ ) { Geometry geom = geometryCollection . getGeometryN ( i ) ; if ( geom instanceof Point ) { toGeojsonPoint ( ( Point ) geom , sb ) ; } else if ( geom instanceof LineString ) { toGeojsonLineString ( ( LineString ) geom , sb ) ; } else if ( geom instanceof Polygon ) { toGeojsonPolygon ( ( Polygon ) geom , sb ) ; } if ( i < geometryCollection . getNumGeometries ( ) - 1 ) { sb . append ( "," ) ; } } sb . append ( "]}" ) ; }
A GeoJSON object with type "GeometryCollection" is a geometry object
which represents a collection of geometry objects.

A geometry collection must have a member with the name "geometries". The
value corresponding to "geometries"is an array. Each element in this
array is a GeoJSON geometry object.

Syntax:

{ "type": "GeometryCollection", "geometries": [ { "type": "Point",
"coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [
[101.0, 0.0], [102.0, 1.0] ] } ] }

@param geometryCollection
@param sb