01:
02: /*
03: * The JTS Topology Suite is a collection of Java classes that
04: * implement the fundamental operations required to validate a given
05: * geo-spatial data set to a known topological specification.
06: *
07: * Copyright (C) 2001 Vivid Solutions
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2.1 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: *
23: * For more information, contact:
24: *
25: * Vivid Solutions
26: * Suite #1A
27: * 2328 Government Street
28: * Victoria BC V8T 5G5
29: * Canada
30: *
31: * (250)385-6040
32: * www.vividsolutions.com
33: */
34: package com.vividsolutions.jts.operation;
35:
36: import java.io.PrintStream;
37: import java.util.*;
38: import com.vividsolutions.jts.util.*;
39: import com.vividsolutions.jts.algorithm.*;
40: import com.vividsolutions.jts.geom.*;
41: import com.vividsolutions.jts.geomgraph.GeometryGraph;
42:
43: /**
44: * The base class for operations that require {@link GeometryGraph}s.
45: *
46: * @version 1.7
47: */
48: public class GeometryGraphOperation {
49: protected final CGAlgorithms cga = new CGAlgorithms();
50: protected final LineIntersector li = new RobustLineIntersector();
51: protected PrecisionModel resultPrecisionModel;
52:
53: /**
54: * The operation args into an array so they can be accessed by index
55: */
56: protected GeometryGraph[] arg; // the arg(s) of the operation
57:
58: public GeometryGraphOperation(Geometry g0, Geometry g1) {
59: this (g0, g1, BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE
60: // BoundaryNodeRule.ENDPOINT_BOUNDARY_RULE
61: );
62: }
63:
64: public GeometryGraphOperation(Geometry g0, Geometry g1,
65: BoundaryNodeRule boundaryNodeRule) {
66: // use the most precise model for the result
67: if (g0.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0)
68: setComputationPrecision(g0.getPrecisionModel());
69: else
70: setComputationPrecision(g1.getPrecisionModel());
71:
72: arg = new GeometryGraph[2];
73: arg[0] = new GeometryGraph(0, g0, boundaryNodeRule);
74: arg[1] = new GeometryGraph(1, g1, boundaryNodeRule);
75: }
76:
77: public GeometryGraphOperation(Geometry g0) {
78: setComputationPrecision(g0.getPrecisionModel());
79:
80: arg = new GeometryGraph[1];
81: arg[0] = new GeometryGraph(0, g0);
82: ;
83: }
84:
85: public Geometry getArgGeometry(int i) {
86: return arg[i].getGeometry();
87: }
88:
89: protected void setComputationPrecision(PrecisionModel pm) {
90: resultPrecisionModel = pm;
91: li.setPrecisionModel(resultPrecisionModel);
92: }
93: }
|