public static void toGeojsonMultiPolygon ( MultiPolygon multiPolygon , StringBuilder sb ) { sb . append ( "{\"type\":\"MultiPolygon\",\"coordinates\":[" ) ; for ( int i = 0 ; i < multiPolygon . getNumGeometries ( ) ; i ++ ) { Polygon p = ( Polygon ) multiPolygon . getGeometryN ( i ) ; sb . append ( "[" ) ; //Process exterior ring toGeojsonCoordinates ( p . getExteriorRing ( ) . getCoordinates ( ) , sb ) ; //Process interior rings for ( int j = 0 ; j < p . getNumInteriorRing ( ) ; j ++ ) { sb . append ( "," ) ; toGeojsonCoordinates ( p . getInteriorRingN ( j ) . getCoordinates ( ) , sb ) ; } sb . append ( "]" ) ; if ( i < multiPolygon . getNumGeometries ( ) - 1 ) { sb . append ( "," ) ; } } sb . append ( "]}" ) ; }
Coordinates of a MultiPolygon are an array of Polygon coordinate arrays .