CoordinateSequences.reverse(revSeq); return revSeq;
/** * Reverses a LineString according to the z value. The z of the first point * must be lower than the z of the end point. * * @param lineString * @return */ private static LineString reverse3D(LineString lineString, String order) { CoordinateSequence seq = lineString.getCoordinateSequence(); double startZ = seq.getCoordinate(0).z; double endZ = seq.getCoordinate(seq.size() - 1).z; if (order.equalsIgnoreCase("desc")) { if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ < endZ) { CoordinateSequences.reverse(seq); return FACTORY.createLineString(seq); } } else if (order.equalsIgnoreCase("asc")) { if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ > endZ) { CoordinateSequences.reverse(seq); return FACTORY.createLineString(seq); } } else { throw new IllegalArgumentException("Supported order values are asc or desc."); } return lineString; }
public Geometry reverse() { CoordinateSequence seq = points.copy(); CoordinateSequences.reverse(seq); LinearRing rev = getFactory().createLinearRing(seq); return rev; } }
/** * Creates a {@link LineString} whose coordinates are in the reverse * order of this objects * * @return a {@link LineString} with coordinates in the reverse order */ public Geometry reverse() { CoordinateSequence seq = points.copy(); CoordinateSequences.reverse(seq); LineString revLine = getFactory().createLineString(seq); return revLine; }
private void normalize(LinearRing ring, boolean clockwise) { if (ring.isEmpty()) { return; } CoordinateSequence seq = ring.getCoordinateSequence(); int minCoordinateIndex = CoordinateSequences.minCoordinateIndex(seq, 0, seq.size()-2); CoordinateSequences.scroll(seq, minCoordinateIndex, true); if (Orientation.isCCW(seq) == clockwise) CoordinateSequences.reverse(seq); }
private static void doTestReverse(CoordinateSequenceFactory factory, int dimension) { // arrange CoordinateSequence sequence = createSequenceFromOrdinates(factory, dimension); CoordinateSequence reversed = sequence.copy(); // act CoordinateSequences.reverse(reversed); // assert for (int i = 0; i < sequence.size(); i++) checkCoordinateAt(sequence, i, reversed, sequence.size() - i - 1, dimension); }
/** * Normalizes a LineString. A normalized linestring * has the first point which is not equal to it's reflected point * less than the reflected point. */ public void normalize() { for (int i = 0; i < points.size() / 2; i++) { int j = points.size() - 1 - i; // skip equal points on both ends if (!points.getCoordinate(i).equals(points.getCoordinate(j))) { if (points.getCoordinate(i).compareTo(points.getCoordinate(j)) > 0) { CoordinateSequence copy = points.copy(); CoordinateSequences.reverse(copy); points = copy; } return; } } }