code: public static Coordinate[] removeDuplicatedCoordinates(Coordinate[] coords, boolean closeRing) {
          LinkedHashSet<Coordinate> finalCoords = new LinkedHashSet<Coordinate>();
          Coordinate prevCoord = coords[0];
          finalCoords.add(prevCoord);
          Coordinate firstCoord = prevCoord;
          int nbCoords = coords.length;
          for (int i = 1; i < nbCoords; i++) {
              Coordinate currentCoord = coords[i];
              if (currentCoord.equals2D(prevCoord)) {
                  continue;
              }
              finalCoords.add(currentCoord);
              prevCoord = currentCoord;
          }
          if (closeRing) {
              Coordinate[] coordsFinal = finalCoords.toArray(new Coordinate[0]);
              Coordinate[] closedCoords = Arrays.copyOf(coordsFinal, coordsFinal.length + 1);
              closedCoords[closedCoords.length-1] = firstCoord;
              return closedCoords;
          }
          return finalCoords.toArray(new Coordinate[0]);
  
      }
docs: Remove dupliacted coordinates
  Note : This method doesn't preserve the topology of geometry
  
  @param coords the input coordinates
  @param closeRing is true the first coordinate is added at the end to close the array
  @return