public static LineString removeRepeatedPoints(final LineString points) {
   final int axisCount = points.getAxisCount();
   final List<Double> coordinates = new ArrayList<>();
   double x = points.getX(0);
   double y = points.getY(0);
   coordinates.add(x);
   coordinates.add(y);
   for (int axisIndex = 2; axisIndex < axisCount; axisIndex++) {
     coordinates.add(points.getCoordinate(0, axisIndex));
   }
   for (int i = 0; i < points.getVertexCount(); i++) {
     final double x1 = points.getX(i);
     final double y1 = points.getY(i);
     if (x != x1 || y != y1) {
       coordinates.add(x1);
       coordinates.add(y1);
       for (int axisIndex = 2; axisIndex < axisCount; axisIndex++) {
         coordinates.add(points.getCoordinate(i, axisIndex));
       }
       x = x1;
       y = y1;
     }
   }
   return new LineStringDouble(axisCount, coordinates);
 }
 public static void setCoordinates(
     final double[] coordinates,
     final int axisCount,
     final int i,
     final LineString line,
     final int j) {
   for (int axisIndex = 0; axisIndex < axisCount; axisIndex++) {
     final double value = line.getCoordinate(j, axisIndex);
     coordinates[i * axisCount + axisIndex] = value;
   }
 }
 public static int appendReverse(
     final int axisCount,
     final LineString source,
     final int sourceStartIndex,
     final double[] targetCoordinates,
     final int targetStartIndex,
     final int vertexCount) {
   int coordIndex = targetStartIndex;
   final int sourceVertexCount = source.getVertexCount();
   double previousX;
   double previousY;
   if (targetStartIndex == 0) {
     previousX = Double.NaN;
     previousY = Double.NaN;
   } else {
     previousX = targetCoordinates[(targetStartIndex - 1) * axisCount];
     previousY = targetCoordinates[(targetStartIndex - 1) * axisCount + 1];
   }
   int coordinateIndex = coordIndex * axisCount;
   int sourceIndex = sourceVertexCount - 1 - sourceStartIndex;
   for (int i = 0; i < vertexCount; i++) {
     final double x = source.getX(sourceIndex);
     final double y = source.getY(sourceIndex);
     if (x != previousX || y != previousY) {
       targetCoordinates[coordinateIndex++] = x;
       targetCoordinates[coordinateIndex++] = y;
       for (int axisIndex = 2; axisIndex < axisCount; axisIndex++) {
         final double coordinate = source.getCoordinate(sourceIndex, axisIndex);
         targetCoordinates[coordinateIndex++] = coordinate;
       }
       coordIndex++;
     }
     sourceIndex--;
     previousX = x;
     previousY = y;
   }
   return coordIndex;
 }
 @Override
 public double getCoordinate(final int vertexIndex, final int axisIndex) {
   final LineString line = getLine();
   return line.getCoordinate(vertexIndex, axisIndex);
 }