public boolean isEmpty() { return shell.isEmpty(); }
/** * Tests whether this ring is closed. * Empty rings are closed by definition. * * @return true if this ring is closed */ public boolean isClosed() { if (isEmpty()) { // empty LinearRings are closed by definition return true; } return super.isClosed(); }
/** * Constructs a <code>Polygon</code> with the given exterior boundary and * interior boundaries. * *@param shell the outer boundary of the new <code>Polygon</code>, * or <code>null</code> or an empty <code>LinearRing</code> if the empty * geometry is to be created. *@param holes the inner boundaries of the new <code>Polygon</code> * , or <code>null</code> or empty <code>LinearRing</code>s if the empty * geometry is to be created. */ public Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory) { super(factory); if (shell == null) { shell = getFactory().createLinearRing((CoordinateSequence)null); } if (holes == null) { holes = new LinearRing[]{}; } if (hasNullElements(holes)) { throw new IllegalArgumentException("holes must not contain null elements"); } if (shell.isEmpty() && hasNonEmptyElements(holes)) { throw new IllegalArgumentException("shell is empty but holes are not"); } this.shell = shell; this.holes = holes; }
private void validateConstruction() { if (!isEmpty() && ! super.isClosed()) { throw new IllegalArgumentException("Points of LinearRing do not form a closed linestring"); } if (getCoordinateSequence().size() >= 1 && getCoordinateSequence().size() < MINIMUM_VALID_SIZE) { throw new IllegalArgumentException("Invalid number of points in LinearRing (found " + getCoordinateSequence().size() + " - must be 0 or >= 4)"); } }
private Polygon editPolygon(Polygon polygon, GeometryEditorOperation operation) { Polygon newPolygon = (Polygon) operation.edit(polygon, factory); // create one if needed if (newPolygon == null) newPolygon = factory.createPolygon((CoordinateSequence) null); if (newPolygon.isEmpty()) { //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino] return newPolygon; } LinearRing shell = (LinearRing) edit(newPolygon.getExteriorRing(), operation); if (shell == null || shell.isEmpty()) { //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino] return factory.createPolygon(null, null); } ArrayList holes = new ArrayList(); for (int i = 0; i < newPolygon.getNumInteriorRing(); i++) { LinearRing hole = (LinearRing) edit(newPolygon.getInteriorRingN(i), operation); if (hole == null || hole.isEmpty()) { continue; } holes.add(hole); } return factory.createPolygon(shell, (LinearRing[]) holes.toArray(new LinearRing[] { })); }
private void normalize(LinearRing ring, boolean clockwise) { if (ring.isEmpty()) { return; } Coordinate[] uniqueCoordinates = new Coordinate[ring.getCoordinates().length - 1]; System.arraycopy(ring.getCoordinates(), 0, uniqueCoordinates, 0, uniqueCoordinates.length); Coordinate minCoordinate = CoordinateArrays.minCoordinate(ring.getCoordinates()); CoordinateArrays.scroll(uniqueCoordinates, minCoordinate); System.arraycopy(uniqueCoordinates, 0, ring.getCoordinates(), 0, uniqueCoordinates.length); ring.getCoordinates()[uniqueCoordinates.length] = uniqueCoordinates[0]; if (CGAlgorithms.isCCW(ring.getCoordinates()) == clockwise) { CoordinateArrays.reverse(ring.getCoordinates()); } }
if (lr.isEmpty()) return;
public boolean isEmpty() { return shell.isEmpty(); }
/** * Tests whether this ring is closed. * Empty rings are closed by definition. * * @return true if this ring is closed */ public boolean isClosed() { if (isEmpty()) { // empty LinearRings are closed by definition return true; } return super.isClosed(); }
/** * Clips a polygon using the Liang-Barsky helper routine. Does not generate, in general, * valid polygons (but still does generate polygons good enough for rendering) * @param polygon * @return */ private Geometry clipPolygon(Polygon polygon) { final GeometryFactory gf = polygon.getFactory(); LinearRing exterior = (LinearRing) polygon.getExteriorRing(); LinearRing shell = polygonClip(exterior); if(shell == null || shell.isEmpty()) { return null; } List<LinearRing> holes = new ArrayList<LinearRing>(); for (int i = 0; i < polygon.getNumInteriorRing(); i++) { LinearRing hole = (LinearRing) polygon.getInteriorRingN(i); hole = polygonClip(hole); if(hole != null && !hole.isEmpty()) { holes.add(hole); } } return gf.createPolygon(shell, (LinearRing[]) holes.toArray(new LinearRing[holes.size()])); }
/** * Constructs a <code>Polygon</code> with the given exterior boundary and * interior boundaries. * *@param shell the outer boundary of the new <code>Polygon</code>, * or <code>null</code> or an empty <code>LinearRing</code> if the empty * geometry is to be created. *@param holes the inner boundaries of the new <code>Polygon</code> * , or <code>null</code> or empty <code>LinearRing</code>s if the empty * geometry is to be created. */ public Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory) { super(factory); if (shell == null) { shell = getFactory().createLinearRing((CoordinateSequence)null); } if (holes == null) { holes = new LinearRing[]{}; } if (hasNullElements(holes)) { throw new IllegalArgumentException("holes must not contain null elements"); } if (shell.isEmpty() && hasNonEmptyElements(holes)) { throw new IllegalArgumentException("shell is empty but holes are not"); } this.shell = shell; this.holes = holes; }
private void validateConstruction() { if (!isEmpty() && ! super.isClosed()) { throw new IllegalArgumentException("Points of LinearRing do not form a closed linestring"); } if (getCoordinateSequence().size() >= 1 && getCoordinateSequence().size() < MINIMUM_VALID_SIZE) { throw new IllegalArgumentException("Invalid number of points in LinearRing (found " + getCoordinateSequence().size() + " - must be 0 or >= 4)"); } }
private Polygon editPolygon(Polygon polygon, GeometryEditorOperation operation) { Polygon newPolygon = (Polygon) operation.edit(polygon, factory); // create one if needed if (newPolygon == null) newPolygon = factory.createPolygon((CoordinateSequence) null); if (newPolygon.isEmpty()) { //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino] return newPolygon; } LinearRing shell = (LinearRing) edit(newPolygon.getExteriorRing(), operation); if (shell == null || shell.isEmpty()) { //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino] return factory.createPolygon(null, null); } ArrayList holes = new ArrayList(); for (int i = 0; i < newPolygon.getNumInteriorRing(); i++) { LinearRing hole = (LinearRing) edit(newPolygon.getInteriorRingN(i), operation); if (hole == null || hole.isEmpty()) { continue; } holes.add(hole); } return factory.createPolygon(shell, (LinearRing[]) holes.toArray(new LinearRing[] { })); }
private void normalize(LinearRing ring, boolean clockwise) { if (ring.isEmpty()) { return; } Coordinate[] uniqueCoordinates = new Coordinate[ring.getCoordinates().length - 1]; System.arraycopy(ring.getCoordinates(), 0, uniqueCoordinates, 0, uniqueCoordinates.length); Coordinate minCoordinate = CoordinateArrays.minCoordinate(ring.getCoordinates()); CoordinateArrays.scroll(uniqueCoordinates, minCoordinate); System.arraycopy(uniqueCoordinates, 0, ring.getCoordinates(), 0, uniqueCoordinates.length); ring.getCoordinates()[uniqueCoordinates.length] = uniqueCoordinates[0]; if (CGAlgorithms.isCCW(ring.getCoordinates()) == clockwise) { CoordinateArrays.reverse(ring.getCoordinates()); } }
if (lr.isEmpty()) return;