code: public static LineString removeDuplicateCoordinates(LineString linestring, double tolerance) throws SQLException {
          Coordinate[] coords = CoordinateUtils.removeRepeatedCoordinates(linestring.getCoordinates(), tolerance, false);
          if(coords.length<2){  
              throw new SQLException("Not enough coordinates to build a new LineString.\n Please adjust the tolerance");
          }
          return FACTORY.createLineString(coords);
      }
docs: Removes duplicated coordinates within a LineString.
  
  @param linestring
  @param tolerance to delete the coordinates
  @return
  @throws java.sql.SQLException