public Geometry reverse() { CoordinateSequence seq = (CoordinateSequence) points.clone(); 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 = (CoordinateSequence) points.clone(); CoordinateSequences.reverse(seq); LineString revLine = getFactory().createLineString(seq); return revLine; }
/** * 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 = (CoordinateSequence) points.clone(); CoordinateSequences.reverse(seq); LineString revLine = getFactory().createLineString(seq); return revLine; }
/** * 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; }
/** * 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 = (CoordinateSequence) points.clone(); CoordinateSequences.reverse(seq); LinearRing rev = getFactory().createLinearRing(seq); return rev; } }
/** * 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 */ public static LineString reverse3D(LineString lineString) { CoordinateSequence seq = lineString.getCoordinateSequence(); double startZ = seq.getCoordinate(0).z; double endZ = seq.getCoordinate(seq.size() - 1).z; if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ < endZ) { CoordinateSequences.reverse(seq); return FACTORY.createLineString(seq); } return lineString; }
/** * 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) { CoordinateSequences.reverse(points); } return; } } }