private LinearRing[] getHoles(int n, double originX, double originY, double width) { List holeList = new ArrayList(); addHoles(n, originX, originY, width, holeList ); return GeometryFactory.toLinearRingArray(holeList); }
seqIndex++; LinearRing[] holeArray = GeometryFactory.toLinearRingArray(holes); polys.add(geometryFactory.createPolygon(shell, holeArray));
private LinearRing[] getHoles(int n, double originX, double originY, double width) { List holeList = new ArrayList(); addHoles(n, originX, originY, width, holeList ); return GeometryFactory.toLinearRingArray(holeList); }
seqIndex++; LinearRing[] holeArray = GeometryFactory.toLinearRingArray(holes); polys.add(geometryFactory.createPolygon(shell, holeArray));
Polygon polygon = geometryFactory.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); polygons.add(polygon); Polygon polygon = geometryFactory.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); polygons.add(polygon);
Polygon polygon = geometryFactory.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); polygons.add(polygon); Polygon polygon = geometryFactory.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); polygons.add(polygon);
private Geometry removeSmallHoles(Polygon polygon, double areaTolerance) { GeometryFactory factory = polygon.getFactory(); LineString exteriorRing = polygon.getExteriorRing(); // check interior rings List<LinearRing> interiorRingList = new ArrayList<LinearRing>(); for (int index = 0; index < polygon.getNumInteriorRing(); index++) { LineString interiorRing = polygon.getInteriorRingN(index); if (interiorRing.isRing()) { if (Math.abs(interiorRing.getArea()) >= areaTolerance) { interiorRingList.add((LinearRing) interiorRing); } } } LinearRing[] holes = null; if (interiorRingList.size() > 0) { holes = GeometryFactory.toLinearRingArray(interiorRingList); } Geometry finalGeom = factory.createPolygon((LinearRing) exteriorRing, holes); finalGeom.setUserData(polygon.getUserData()); return finalGeom; } }
/** * Removes duplicated coordinates within a Polygon. * @param poly * @return */ public static Polygon removeDuplicateCoordinates(Polygon poly) { Coordinate[] shellCoords = CoordinateArrays.removeRepeatedPoints(poly.getExteriorRing().getCoordinates()); LinearRing shell = FACTORY.createLinearRing(shellCoords); ArrayList<LinearRing> holes = new ArrayList<LinearRing>(); for (int i = 0; i < poly.getNumInteriorRing(); i++) { Coordinate[] holeCoords = CoordinateArrays.removeRepeatedPoints(poly.getInteriorRingN(i).getCoordinates()); holes.add(FACTORY.createLinearRing(holeCoords)); } return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); }
/** * Removes duplicated coordinates within a Polygon. * * @param polygon the input polygon * @param tolerance to delete the coordinates * @return * @throws java.sql.SQLException */ public static Polygon removeDuplicateCoordinates(Polygon polygon, double tolerance) throws SQLException { Coordinate[] shellCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getExteriorRing().getCoordinates(),tolerance,true); LinearRing shell = FACTORY.createLinearRing(shellCoords); ArrayList<LinearRing> holes = new ArrayList<LinearRing>(); for (int i = 0; i < polygon.getNumInteriorRing(); i++) { Coordinate[] holeCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getInteriorRingN(i).getCoordinates(), tolerance, true); if (holeCoords.length < 4) { throw new SQLException("Not enough coordinates to build a new LinearRing.\n Please adjust the tolerance"); } holes.add(FACTORY.createLinearRing(holeCoords)); } return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); }
/** * Removes duplicated coordinates within a Polygon. * * @param polygon the input polygon * @param tolerance to delete the coordinates * @return * @throws java.sql.SQLException */ public static Polygon removeDuplicateCoordinates(Polygon polygon, double tolerance) throws SQLException { Coordinate[] shellCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getExteriorRing().getCoordinates(),tolerance,true); LinearRing shell = FACTORY.createLinearRing(shellCoords); ArrayList<LinearRing> holes = new ArrayList<LinearRing>(); for (int i = 0; i < polygon.getNumInteriorRing(); i++) { Coordinate[] holeCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getInteriorRingN(i).getCoordinates(), tolerance, true); if (holeCoords.length < 4) { throw new SQLException("Not enough coordinates to build a new LinearRing.\n Please adjust the tolerance"); } holes.add(FACTORY.createLinearRing(holeCoords)); } return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); }
/** * Removes duplicated coordinates within a Polygon. * * @param poly * @return */ public static Polygon removeCoordinates(Polygon poly) { Coordinate[] shellCoords = CoordinateUtils.removeDuplicatedCoordinates(poly.getExteriorRing().getCoordinates(),true); LinearRing shell = FACTORY.createLinearRing(shellCoords); ArrayList<LinearRing> holes = new ArrayList<LinearRing>(); for (int i = 0; i < poly.getNumInteriorRing(); i++) { Coordinate[] holeCoords = CoordinateUtils.removeDuplicatedCoordinates(poly.getInteriorRingN(i).getCoordinates(),true); holes.add(FACTORY.createLinearRing(holeCoords)); } return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); }
/** * Removes duplicated coordinates within a Polygon. * * @param poly * @return */ public static Polygon removeCoordinates(Polygon poly) { Coordinate[] shellCoords = CoordinateUtils.removeDuplicatedCoordinates(poly.getExteriorRing().getCoordinates(),true); LinearRing shell = FACTORY.createLinearRing(shellCoords); ArrayList<LinearRing> holes = new ArrayList<LinearRing>(); for (int i = 0; i < poly.getNumInteriorRing(); i++) { Coordinate[] holeCoords = CoordinateUtils.removeDuplicatedCoordinates(poly.getInteriorRingN(i).getCoordinates(),true); holes.add(FACTORY.createLinearRing(holeCoords)); } return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes)); }
GeometryFactory.toLinearRingArray(holeRings)); return poly;