I have two polygons, one inside another, and one draw it on the map there is a line connecting vertices of outside and inside polygon. I am trying to draw it like multipolygon using
Polygon[] polygons = null;
List<Polygon> PolygonList = new ArrayList<Polygon>();
polygons = new Polygon[PolygonList.size()];
PolygonList.toArray(polygons);
MultiPolygon multiPolygon = null;
multiPolygon = geometryFactory.createMultiPolygon(polygons);
Original coordinates stored in PolygonList and then converted in polygon array are,
[POLYGON ((6420562.64 4963523.59, 6420559.63 4963527.13, 6420551.28 4963536.4, 6420545.66 4963542.93, 6420539.47 4963549.81, 6420549.2 4963566.43, 6420557.44 4963581.87, 6420547.09 4963592.12, 6420546.75 4963592.47, 6420538.87 4963604.54, 6420542.3 4963606.54, 6420554.08 4963592.16, 6420569.13 4963585.65, 6420581.56 4963580.36, 6420579.2 4963571.27, 6420577.81 4963568, 6420576.04 4963565.49, 6420573.62 4963563.02, 6420569.94 4963560.08, 6420564.25 4963556.37, 6420556.16 4963551.2, 6420552.46 4963548.07, 6420551.29 4963549.4, 6420549.14 4963547.81, 6420552.7 4963543.31, 6420554.96 4963544.66, 6420559.37 4963535.02, 6420556.44 4963532.82, 6420560.19 4963527.58, 6420563.24 4963529.58, 6420564.47 4963526.17, 6420562.64 4963523.59)), POLYGON ((6420560.94 4963584.49, 6420567.53 4963579.99, 6420563.58 4963574.11, 6420557.04 4963578.61, 6420560.94 4963584.49))]
but when I get coordinates from created multipolygon all coordinates are mixed,
[(6420562.64, 4963523.59, NaN), (6420559.63, 4963527.13, NaN), (6420551.28, 4963536.4, NaN), (6420545.66, 4963542.93, NaN), (6420539.47, 4963549.81, NaN), (6420549.2, 4963566.43, NaN), (6420557.44, 4963581.87, NaN), (6420547.09, 4963592.12, NaN), (6420546.75, 4963592.47, NaN), (6420538.87, 4963604.54, NaN), (6420542.3, 4963606.54, NaN), (6420554.08, 4963592.16, NaN), (6420569.13, 4963585.65, NaN), (6420581.56, 4963580.36, NaN), (6420579.2, 4963571.27, NaN), (6420577.81, 4963568.0, NaN), (6420576.04, 4963565.49, NaN), (6420573.62, 4963563.02, NaN), (6420569.94, 4963560.08, NaN), (6420564.25, 4963556.37, NaN), (6420556.16, 4963551.2, NaN), (6420552.46, 4963548.07, NaN), (6420551.29, 4963549.4, NaN), (6420549.14, 4963547.81, NaN), (6420552.7, 4963543.31, NaN), (6420554.96, 4963544.66, NaN), (6420559.37, 4963535.02, NaN), (6420556.44, 4963532.82, NaN), (6420560.19, 4963527.58, NaN), (6420563.24, 4963529.58, NaN), (6420564.47, 4963526.17, NaN), (6420562.64, 4963523.59, NaN)]
and the drawn polygon look like this enter image description here (image is rotated) Is there any way to use multipolygon or need to use a linear ring and define polygon with holes in it.