@Test public void testAddAfterEnd() { Segment s = new Segment(0, 0, 0, 1, true); s.addAfterEnd(0, 2); assertEquals(2, s.getNumCoordinates()); assertEquals(0, s.xStart, 0d); assertEquals(0, s.yStart, 0d); assertEquals(0, s.xEnd, 0d); assertEquals(2, s.yEnd, 0d); }
private void addAfterEnd(double x, double y, boolean touch) { if (simplify && sameSlope(dxEnd, dyEnd, x - xEnd, y - yEnd)) { ordinates[idxLast - 2] = x; ordinates[idxLast - 1] = y; } else { if (idxLast >= ordinates.length - 1) { int extra = ordinates.length / 2; double[] newOrdinates = new double[ordinates.length + extra]; System.arraycopy(ordinates, 0, newOrdinates, 0, ordinates.length); this.ordinates = newOrdinates; assert isConsistent(); } ordinates[idxLast++] = x; ordinates[idxLast++] = y; if (simplify) { dxEnd = x - xEnd; dyEnd = y - yEnd; } } xEnd = x; yEnd = y; if (touch) { touched = true; } }
Segment { private void addAfterEnd(double x, double y, boolean touch) { if (simplify && sameSlope(dxEnd, dyEnd, x - xEnd, y - yEnd)) { ordinates[idxLast - 2] = x; ordinates[idxLast - 1] = y; } else { if (idxLast >= ordinates.length - 1) { int extra = ordinates.length / 2; double[] newOrdinates = new double[ordinates.length + extra]; System.arraycopy(ordinates, 0, newOrdinates, 0, ordinates.length); this.ordinates = newOrdinates; assert isConsistent(); } ordinates[idxLast++] = x; ordinates[idxLast++] = y; if (simplify) { dxEnd = x - xEnd; dyEnd = y - yEnd; } } xEnd = x; yEnd = y; if (touch) { touched = true; } } }
Segment { private void addAfterEnd(double x, double y, boolean touch) { if (simplify && sameSlope(dxEnd, dyEnd, x - xEnd, y - yEnd)) { ordinates[idxLast - 2] = x; ordinates[idxLast - 1] = y; } else { if (idxLast >= ordinates.length - 1) { int extra = ordinates.length / 2; double[] newOrdinates = new double[ordinates.length + extra]; System.arraycopy(ordinates, 0, newOrdinates, 0, ordinates.length); this.ordinates = newOrdinates; assert isConsistent(); } ordinates[idxLast++] = x; ordinates[idxLast++] = y; if (simplify) { dxEnd = x - xEnd; dyEnd = y - yEnd; } } xEnd = x; yEnd = y; if (touch) { touched = true; } } Segment();  Segment(double x1, double y1, double x2, double y2, int initialSize, boolean simplify);   Segment(double x1, double y1, double x2, double y2, boolean simplify); }
Segment { private void addAfterEnd(double x, double y, boolean touch) { if (simplify && sameSlope(dxEnd, dyEnd, x - xEnd, y - yEnd)) { ordinates[idxLast - 2] = x; ordinates[idxLast - 1] = y; } else { if (idxLast >= ordinates.length - 1) { int extra = ordinates.length / 2; double[] newOrdinates = new double[ordinates.length + extra]; System.arraycopy(ordinates, 0, newOrdinates, 0, ordinates.length); this.ordinates = newOrdinates; assert isConsistent(); } ordinates[idxLast++] = x; ordinates[idxLast++] = y; if (simplify) { dxEnd = x - xEnd; dyEnd = y - yEnd; } } xEnd = x; yEnd = y; if (touch) { touched = true; } } Segment();  Segment(double x1, double y1, double x2, double y2, int initialSize, boolean simplify);   Segment(double x1, double y1, double x2, double y2, boolean simplify); void setXY(double x1, double y1, double x2, double y2); void addAfterEnd(double x, double y); void addBeforeStart(double x, double y); LineString toLineString(); void merge(Segment other, MergePoint mergePoint); @Override String toString(); }
Segment { private void addAfterEnd(double x, double y, boolean touch) { if (simplify && sameSlope(dxEnd, dyEnd, x - xEnd, y - yEnd)) { ordinates[idxLast - 2] = x; ordinates[idxLast - 1] = y; } else { if (idxLast >= ordinates.length - 1) { int extra = ordinates.length / 2; double[] newOrdinates = new double[ordinates.length + extra]; System.arraycopy(ordinates, 0, newOrdinates, 0, ordinates.length); this.ordinates = newOrdinates; assert isConsistent(); } ordinates[idxLast++] = x; ordinates[idxLast++] = y; if (simplify) { dxEnd = x - xEnd; dyEnd = y - yEnd; } } xEnd = x; yEnd = y; if (touch) { touched = true; } } Segment();  Segment(double x1, double y1, double x2, double y2, int initialSize, boolean simplify);   Segment(double x1, double y1, double x2, double y2, boolean simplify); void setXY(double x1, double y1, double x2, double y2); void addAfterEnd(double x, double y); void addBeforeStart(double x, double y); LineString toLineString(); void merge(Segment other, MergePoint mergePoint); @Override String toString();  }