code: public static @Nonnull JsonArray lineStringToPolygon(@Nonnull double[][] lineString) {
          JsonArray jsonJLineString = toJsonJLineString(lineString);
          if (lineString[0][0] != lineString[lineString.length - 1][0] || lineString[0][1] != lineString[lineString.length - 1][1]) {
              // add last coordinate to close the polygon
              jsonJLineString.add(array(lineString[0][0], lineString[0][1]));
          }
          JsonArray result = array();
          result.add(jsonJLineString);
          return result;
      }
docs: Takes a two dimensional linestring and creates a three dimensional polygon from it. Also closes the polygon if needed.
  @param lineString 2d array of doubles
  @return JsonArray with the 3d polygon