| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
package org.locationtech.jts.operation; |
| 15 |
|
| 16 |
import org.locationtech.jts.algorithm.BoundaryNodeRule; |
| 17 |
import org.locationtech.jts.algorithm.LineIntersector; |
| 18 |
import org.locationtech.jts.algorithm.RobustLineIntersector; |
| 19 |
import org.locationtech.jts.geom.Geometry; |
| 20 |
import org.locationtech.jts.geom.PrecisionModel; |
| 21 |
import org.locationtech.jts.geomgraph.GeometryGraph; |
| 22 |
|
| 23 |
/** |
| 24 |
* The base class for operations that require {@link GeometryGraph}s. |
| 25 |
* |
| 26 |
* @version 1.7 |
| 27 |
*/ |
| 28 |
public class GeometryGraphOperation |
| 29 |
{ |
| 30 |
protected final LineIntersector li = new RobustLineIntersector(); |
| 31 |
protected PrecisionModel resultPrecisionModel; |
| 32 |
|
| 33 |
/** |
| 34 |
* The operation args into an array so they can be accessed by index |
| 35 |
*/ |
| 36 |
protected GeometryGraph[] arg; |
| 37 |
|
| 38 |
public GeometryGraphOperation(Geometry g0, Geometry g1) |
| 39 |
{ |
| 40 |
this(g0, g1, |
| 41 |
BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE |
| 42 |
|
| 43 |
); |
| 44 |
} |
| 45 |
|
| 46 |
public GeometryGraphOperation(Geometry g0, Geometry g1, BoundaryNodeRule boundaryNodeRule) |
| 47 |
{ |
| 48 |
|
| 49 |
if (g0.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0) |
| 50 |
setComputationPrecision(g0.getPrecisionModel()); |
| 51 |
else |
| 52 |
setComputationPrecision(g1.getPrecisionModel()); |
| 53 |
|
| 54 |
arg = new GeometryGraph[2]; |
| 55 |
arg[0] = new GeometryGraph(0, g0, boundaryNodeRule); |
| 56 |
arg[1] = new GeometryGraph(1, g1, boundaryNodeRule); |
| 57 |
} |
| 58 |
|
| 59 |
public GeometryGraphOperation(Geometry g0) { |
| 60 |
setComputationPrecision(g0.getPrecisionModel()); |
| 61 |
|
| 62 |
arg = new GeometryGraph[1]; |
| 63 |
arg[0] = new GeometryGraph(0, g0);; |
| 64 |
} |
| 65 |
|
| 66 |
public Geometry getArgGeometry(int i) { return arg[i].getGeometry(); } |
| 67 |
|
| 68 |
protected void setComputationPrecision(PrecisionModel pm) |
| 69 |
{ |
| 70 |
resultPrecisionModel = pm; |
| 71 |
li.setPrecisionModel(resultPrecisionModel); |
| 72 |
} |
| 73 |
} |
| 74 |
|