@Test public void testReverseRing() { Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 1), new Coordinate(0, 2), new Coordinate(0, 0) }; LinearRing before = geomFactory.createLinearRing(coordinates); assertEquals(before.getCoordinateN(0), coordinates[0]); assertEquals(before.getCoordinateN(1), coordinates[1]); assertEquals(before.getCoordinateN(2), coordinates[2]); assertEquals(before.getCoordinateN(3), coordinates[3]); LinearRing after = JTSUtilities.reverseRing(before); assertTrue( after.equalsTopo(before.reverse()) ); assertEquals(after.getCoordinateN(0), coordinates[3]); assertEquals(after.getCoordinateN(1), coordinates[2]); assertEquals(after.getCoordinateN(2), coordinates[1]); assertEquals(after.getCoordinateN(3), coordinates[0]); }
public static final LinearRing reverseRing(LinearRing lr) { GeometryFactory gf = lr.getFactory(); CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); CoordinateSequence csOrig = lr.getCoordinateSequence(); int numPoints = csOrig.size(); int dimensions = csOrig.getDimension(); CoordinateSequence csNew = csf.create(numPoints, dimensions); for (int i = 0; i < numPoints; i++) { for (int j = 0; j < dimensions; j++) { csNew.setOrdinate(numPoints-1-i, j, csOrig.getOrdinate(i, j)); } } return gf.createLinearRing(csNew); }
JTSUtilities { public static final LinearRing reverseRing(LinearRing lr) { GeometryFactory gf = lr.getFactory(); CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); CoordinateSequence csOrig = lr.getCoordinateSequence(); int numPoints = csOrig.size(); int dimensions = csOrig.getDimension(); CoordinateSequence csNew = csf.create(numPoints, dimensions); for (int i = 0; i < numPoints; i++) { for (int j = 0; j < dimensions; j++) { csNew.setOrdinate(numPoints-1-i, j, csOrig.getOrdinate(i, j)); } } return gf.createLinearRing(csNew); } }
JTSUtilities { public static final LinearRing reverseRing(LinearRing lr) { GeometryFactory gf = lr.getFactory(); CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); CoordinateSequence csOrig = lr.getCoordinateSequence(); int numPoints = csOrig.size(); int dimensions = csOrig.getDimension(); CoordinateSequence csNew = csf.create(numPoints, dimensions); for (int i = 0; i < numPoints; i++) { for (int j = 0; j < dimensions; j++) { csNew.setOrdinate(numPoints-1-i, j, csOrig.getOrdinate(i, j)); } } return gf.createLinearRing(csNew); } private  JTSUtilities(); }
JTSUtilities { public static final LinearRing reverseRing(LinearRing lr) { GeometryFactory gf = lr.getFactory(); CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); CoordinateSequence csOrig = lr.getCoordinateSequence(); int numPoints = csOrig.size(); int dimensions = csOrig.getDimension(); CoordinateSequence csNew = csf.create(numPoints, dimensions); for (int i = 0; i < numPoints; i++) { for (int j = 0; j < dimensions; j++) { csNew.setOrdinate(numPoints-1-i, j, csOrig.getOrdinate(i, j)); } } return gf.createLinearRing(csNew); } private  JTSUtilities(); static final double[] zMinMax(final Coordinate[] cs); static final void zMinMax(final CoordinateSequence cs, double[] target); static final ShapeType findBestGeometryType(Geometry geom); static final Class findBestGeometryClass(ShapeType type); static final LinearRing reverseRing(LinearRing lr); static final Polygon makeGoodShapePolygon(Polygon p); static final MultiPolygon makeGoodShapeMultiPolygon(MultiPolygon mp); static final int guessCoorinateDims(final Coordinate[] cs); static Geometry convertToCollection(Geometry geom, ShapeType type); static final ShapeType getShapeType(Geometry geom,
            int shapeFileDimentions); static final ShapeType getShapeType(Class featureClass); static final ShapeType getShapeType(GeometryDescriptor gd); }
JTSUtilities { public static final LinearRing reverseRing(LinearRing lr) { GeometryFactory gf = lr.getFactory(); CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); CoordinateSequence csOrig = lr.getCoordinateSequence(); int numPoints = csOrig.size(); int dimensions = csOrig.getDimension(); CoordinateSequence csNew = csf.create(numPoints, dimensions); for (int i = 0; i < numPoints; i++) { for (int j = 0; j < dimensions; j++) { csNew.setOrdinate(numPoints-1-i, j, csOrig.getOrdinate(i, j)); } } return gf.createLinearRing(csNew); } private  JTSUtilities(); static final double[] zMinMax(final Coordinate[] cs); static final void zMinMax(final CoordinateSequence cs, double[] target); static final ShapeType findBestGeometryType(Geometry geom); static final Class findBestGeometryClass(ShapeType type); static final LinearRing reverseRing(LinearRing lr); static final Polygon makeGoodShapePolygon(Polygon p); static final MultiPolygon makeGoodShapeMultiPolygon(MultiPolygon mp); static final int guessCoorinateDims(final Coordinate[] cs); static Geometry convertToCollection(Geometry geom, ShapeType type); static final ShapeType getShapeType(Geometry geom,
            int shapeFileDimentions); static final ShapeType getShapeType(Class featureClass); static final ShapeType getShapeType(GeometryDescriptor gd);  }