-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix buffer element erosion for negative distance and remove overlay d…
…eps (#1119)
- Loading branch information
Showing
6 changed files
with
451 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
modules/core/src/main/java/org/locationtech/jts/operation/buffer/BufferNodeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2016 Vivid Solutions. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
package org.locationtech.jts.operation.buffer; | ||
|
||
/** | ||
* @version 1.7 | ||
*/ | ||
import org.locationtech.jts.geom.Coordinate; | ||
import org.locationtech.jts.geomgraph.DirectedEdgeStar; | ||
import org.locationtech.jts.geomgraph.Node; | ||
import org.locationtech.jts.geomgraph.NodeFactory; | ||
import org.locationtech.jts.geomgraph.PlanarGraph; | ||
|
||
/** | ||
* Creates nodes for use in the {@link PlanarGraph}s constructed during | ||
* buffer operations. | ||
* | ||
* @version 1.7 | ||
*/ | ||
class BufferNodeFactory | ||
extends NodeFactory | ||
{ | ||
public Node createNode(Coordinate coord) | ||
{ | ||
return new Node(coord, new DirectedEdgeStar()); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
modules/core/src/main/java/org/locationtech/jts/operation/buffer/MaximalEdgeRing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) 2016 Vivid Solutions. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
package org.locationtech.jts.operation.buffer; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.locationtech.jts.geom.GeometryFactory; | ||
import org.locationtech.jts.geomgraph.DirectedEdge; | ||
import org.locationtech.jts.geomgraph.DirectedEdgeStar; | ||
import org.locationtech.jts.geomgraph.EdgeRing; | ||
import org.locationtech.jts.geomgraph.Node; | ||
|
||
/** | ||
* A ring of {@link DirectedEdge}s which may contain nodes of degree > 2. | ||
* A <tt>MaximalEdgeRing</tt> may represent two different spatial entities: | ||
* <ul> | ||
* <li>a single polygon possibly containing inversions (if the ring is oriented CW) | ||
* <li>a single hole possibly containing exversions (if the ring is oriented CCW) | ||
* </ul> | ||
* If the MaximalEdgeRing represents a polygon, | ||
* the interior of the polygon is strongly connected. | ||
* <p> | ||
* These are the form of rings used to define polygons under some spatial data models. | ||
* However, under the OGC SFS model, {@link MinimalEdgeRing}s are required. | ||
* A MaximalEdgeRing can be converted to a list of MinimalEdgeRings using the | ||
* {@link #buildMinimalRings() } method. | ||
* | ||
* @version 1.7 | ||
* @see org.locationtech.jts.operation.buffer.MinimalEdgeRing | ||
*/ | ||
class MaximalEdgeRing | ||
extends EdgeRing | ||
{ | ||
|
||
public MaximalEdgeRing(DirectedEdge start, GeometryFactory geometryFactory) { | ||
super(start, geometryFactory); | ||
} | ||
|
||
public DirectedEdge getNext(DirectedEdge de) | ||
{ | ||
return de.getNext(); | ||
} | ||
public void setEdgeRing(DirectedEdge de, EdgeRing er) | ||
{ | ||
de.setEdgeRing(er); | ||
} | ||
|
||
/** | ||
* For all nodes in this EdgeRing, | ||
* link the DirectedEdges at the node to form minimalEdgeRings | ||
*/ | ||
public void linkDirectedEdgesForMinimalEdgeRings() | ||
{ | ||
DirectedEdge de = startDe; | ||
do { | ||
Node node = de.getNode(); | ||
((DirectedEdgeStar) node.getEdges()).linkMinimalDirectedEdges(this); | ||
de = de.getNext(); | ||
} while (de != startDe); | ||
} | ||
|
||
public List buildMinimalRings() | ||
{ | ||
List minEdgeRings = new ArrayList(); | ||
DirectedEdge de = startDe; | ||
do { | ||
if (de.getMinEdgeRing() == null) { | ||
EdgeRing minEr = new MinimalEdgeRing(de, geometryFactory); | ||
minEdgeRings.add(minEr); | ||
} | ||
de = de.getNext(); | ||
} while (de != startDe); | ||
return minEdgeRings; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
modules/core/src/main/java/org/locationtech/jts/operation/buffer/MinimalEdgeRing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2016 Vivid Solutions. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
package org.locationtech.jts.operation.buffer; | ||
|
||
import org.locationtech.jts.geom.GeometryFactory; | ||
import org.locationtech.jts.geomgraph.DirectedEdge; | ||
import org.locationtech.jts.geomgraph.Edge; | ||
import org.locationtech.jts.geomgraph.EdgeRing; | ||
|
||
/** | ||
* A ring of {@link Edge}s with the property that no node | ||
* has degree greater than 2. These are the form of rings required | ||
* to represent polygons under the OGC SFS spatial data model. | ||
* | ||
* @version 1.7 | ||
* @see org.locationtech.jts.operation.buffer.MaximalEdgeRing | ||
*/ | ||
class MinimalEdgeRing | ||
extends EdgeRing | ||
{ | ||
|
||
public MinimalEdgeRing(DirectedEdge start, GeometryFactory geometryFactory) { | ||
super(start, geometryFactory); | ||
} | ||
|
||
public DirectedEdge getNext(DirectedEdge de) | ||
{ | ||
return de.getNextMin(); | ||
} | ||
public void setEdgeRing(DirectedEdge de, EdgeRing er) | ||
{ | ||
de.setMinEdgeRing(er); | ||
} | ||
|
||
} |
Oops, something went wrong.