jsts-rails 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +8 -8
  2. data/lib/jsts-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/javascript.util.js +33 -1
  4. data/vendor/assets/javascripts/jsts-original.js +164 -1573
  5. data/vendor/assets/javascripts/jsts.js +197 -0
  6. data/vendor/assets/javascripts/jsts/algorithm/Angle.js +387 -0
  7. data/vendor/assets/javascripts/jsts/algorithm/BoundaryNodeRule.js +67 -0
  8. data/vendor/assets/javascripts/jsts/algorithm/CGAlgorithms.js +596 -0
  9. data/vendor/assets/javascripts/jsts/algorithm/CentralEndpointIntersector.js +118 -0
  10. data/vendor/assets/javascripts/jsts/algorithm/CentroidArea.js +225 -0
  11. data/vendor/assets/javascripts/jsts/algorithm/CentroidLine.js +85 -0
  12. data/vendor/assets/javascripts/jsts/algorithm/CentroidPoint.js +77 -0
  13. data/vendor/assets/javascripts/jsts/algorithm/ConvexHull.js +409 -0
  14. data/vendor/assets/javascripts/jsts/algorithm/HCoordinate.js +234 -0
  15. data/vendor/assets/javascripts/jsts/algorithm/LineIntersector.js +502 -0
  16. data/vendor/assets/javascripts/jsts/algorithm/MCPointInRing.js +124 -0
  17. data/vendor/assets/javascripts/jsts/algorithm/PointLocator.js +247 -0
  18. data/vendor/assets/javascripts/jsts/algorithm/RayCrossingCounter.js +215 -0
  19. data/vendor/assets/javascripts/jsts/algorithm/RobustDeterminant.js +353 -0
  20. data/vendor/assets/javascripts/jsts/algorithm/RobustLineIntersector.js +477 -0
  21. data/vendor/assets/javascripts/jsts/algorithm/distance/DiscreteHausdorffDistance.js +228 -0
  22. data/vendor/assets/javascripts/jsts/algorithm/distance/DistanceToPoint.js +68 -0
  23. data/vendor/assets/javascripts/jsts/algorithm/distance/PointPairDistance.js +104 -0
  24. data/vendor/assets/javascripts/jsts/algorithm/locate/PointOnGeometryLocator.js +7 -0
  25. data/vendor/assets/javascripts/jsts/algorithm/locate/SimplePointInAreaLocator.js +102 -0
  26. data/vendor/assets/javascripts/jsts/geom/Coordinate.js +158 -0
  27. data/vendor/assets/javascripts/jsts/geom/CoordinateArrays.js +148 -0
  28. data/vendor/assets/javascripts/jsts/geom/CoordinateFilter.js +29 -0
  29. data/vendor/assets/javascripts/jsts/geom/CoordinateList.js +157 -0
  30. data/vendor/assets/javascripts/jsts/geom/CoordinateSequenceFilter.js +63 -0
  31. data/vendor/assets/javascripts/jsts/geom/Dimension.js +137 -0
  32. data/vendor/assets/javascripts/jsts/geom/Envelope.js +833 -0
  33. data/vendor/assets/javascripts/jsts/geom/Geometry.js +1535 -0
  34. data/vendor/assets/javascripts/jsts/geom/GeometryCollection.js +230 -0
  35. data/vendor/assets/javascripts/jsts/geom/GeometryComponentFilter.js +36 -0
  36. data/vendor/assets/javascripts/jsts/geom/GeometryFactory.js +263 -0
  37. data/vendor/assets/javascripts/jsts/geom/GeometryFilter.js +29 -0
  38. data/vendor/assets/javascripts/jsts/geom/IntersectionMatrix.js +650 -0
  39. data/vendor/assets/javascripts/jsts/geom/LineSegment.js +275 -0
  40. data/vendor/assets/javascripts/jsts/geom/LineString.js +299 -0
  41. data/vendor/assets/javascripts/jsts/geom/LinearRing.js +69 -0
  42. data/vendor/assets/javascripts/jsts/geom/Location.js +83 -0
  43. data/vendor/assets/javascripts/jsts/geom/MultiLineString.js +47 -0
  44. data/vendor/assets/javascripts/jsts/geom/MultiPoint.js +64 -0
  45. data/vendor/assets/javascripts/jsts/geom/MultiPolygon.js +64 -0
  46. data/vendor/assets/javascripts/jsts/geom/Point.js +197 -0
  47. data/vendor/assets/javascripts/jsts/geom/Polygon.js +263 -0
  48. data/vendor/assets/javascripts/jsts/geom/PrecisionModel.js +187 -0
  49. data/vendor/assets/javascripts/jsts/geom/Triangle.js +313 -0
  50. data/vendor/assets/javascripts/jsts/geom/util/GeometryCombiner.js +143 -0
  51. data/vendor/assets/javascripts/jsts/geom/util/GeometryExtracter.js +76 -0
  52. data/vendor/assets/javascripts/jsts/geom/util/GeometryTransformer.js +295 -0
  53. data/vendor/assets/javascripts/jsts/geom/util/LinearComponentExtracter.js +207 -0
  54. data/vendor/assets/javascripts/jsts/geom/util/PointExtracter.js +67 -0
  55. data/vendor/assets/javascripts/jsts/geom/util/PolygonExtracter.js +71 -0
  56. data/vendor/assets/javascripts/jsts/geomgraph/Depth.js +145 -0
  57. data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdge.js +270 -0
  58. data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdgeStar.js +388 -0
  59. data/vendor/assets/javascripts/jsts/geomgraph/Edge.js +291 -0
  60. data/vendor/assets/javascripts/jsts/geomgraph/EdgeEnd.js +188 -0
  61. data/vendor/assets/javascripts/jsts/geomgraph/EdgeEndStar.js +322 -0
  62. data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersection.js +122 -0
  63. data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersectionList.js +146 -0
  64. data/vendor/assets/javascripts/jsts/geomgraph/EdgeList.js +111 -0
  65. data/vendor/assets/javascripts/jsts/geomgraph/EdgeNodingValidator.js +76 -0
  66. data/vendor/assets/javascripts/jsts/geomgraph/EdgeRing.js +230 -0
  67. data/vendor/assets/javascripts/jsts/geomgraph/GeometryGraph.js +469 -0
  68. data/vendor/assets/javascripts/jsts/geomgraph/GraphComponent.js +181 -0
  69. data/vendor/assets/javascripts/jsts/geomgraph/Label.js +316 -0
  70. data/vendor/assets/javascripts/jsts/geomgraph/Node.js +105 -0
  71. data/vendor/assets/javascripts/jsts/geomgraph/NodeFactory.js +22 -0
  72. data/vendor/assets/javascripts/jsts/geomgraph/NodeMap.js +128 -0
  73. data/vendor/assets/javascripts/jsts/geomgraph/PlanarGraph.js +214 -0
  74. data/vendor/assets/javascripts/jsts/geomgraph/Position.js +63 -0
  75. data/vendor/assets/javascripts/jsts/geomgraph/Quadrant.js +143 -0
  76. data/vendor/assets/javascripts/jsts/geomgraph/TopologyLocation.js +251 -0
  77. data/vendor/assets/javascripts/jsts/geomgraph/index/EdgeSetIntersector.js +47 -0
  78. data/vendor/assets/javascripts/jsts/geomgraph/index/SegmentIntersector.js +298 -0
  79. data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleEdgeSetIntersector.js +107 -0
  80. data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleMCSweepLineIntersector.js +29 -0
  81. data/vendor/assets/javascripts/jsts/index/ArrayListVisitor.js +37 -0
  82. data/vendor/assets/javascripts/jsts/index/DoubleBits.js +132 -0
  83. data/vendor/assets/javascripts/jsts/index/IntervalSize.js +55 -0
  84. data/vendor/assets/javascripts/jsts/index/ItemVisitor.js +23 -0
  85. data/vendor/assets/javascripts/jsts/index/SpatialIndex.js +67 -0
  86. data/vendor/assets/javascripts/jsts/index/bintree/Bintree.js +224 -0
  87. data/vendor/assets/javascripts/jsts/index/bintree/Interval.js +160 -0
  88. data/vendor/assets/javascripts/jsts/index/bintree/Key.js +110 -0
  89. data/vendor/assets/javascripts/jsts/index/bintree/Node.js +204 -0
  90. data/vendor/assets/javascripts/jsts/index/bintree/NodeBase.js +220 -0
  91. data/vendor/assets/javascripts/jsts/index/bintree/Root.js +113 -0
  92. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChain.js +244 -0
  93. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainBuilder.js +106 -0
  94. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainOverlapAction.js +56 -0
  95. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainSelectAction.js +44 -0
  96. data/vendor/assets/javascripts/jsts/index/kdtree/KdNode.js +171 -0
  97. data/vendor/assets/javascripts/jsts/index/kdtree/KdTree.js +218 -0
  98. data/vendor/assets/javascripts/jsts/index/quadtree/Key.js +134 -0
  99. data/vendor/assets/javascripts/jsts/index/quadtree/Node.js +220 -0
  100. data/vendor/assets/javascripts/jsts/index/quadtree/NodeBase.js +330 -0
  101. data/vendor/assets/javascripts/jsts/index/quadtree/Quadtree.js +228 -0
  102. data/vendor/assets/javascripts/jsts/index/quadtree/Root.js +105 -0
  103. data/vendor/assets/javascripts/jsts/index/strtree/AbstractNode.js +107 -0
  104. data/vendor/assets/javascripts/jsts/index/strtree/AbstractSTRtree.js +594 -0
  105. data/vendor/assets/javascripts/jsts/index/strtree/Boundable.js +37 -0
  106. data/vendor/assets/javascripts/jsts/index/strtree/BoundablePair.js +0 -0
  107. data/vendor/assets/javascripts/jsts/index/strtree/Interval.js +94 -0
  108. data/vendor/assets/javascripts/jsts/index/strtree/ItemBoundable.js +60 -0
  109. data/vendor/assets/javascripts/jsts/index/strtree/SIRtree.js +122 -0
  110. data/vendor/assets/javascripts/jsts/index/strtree/STRtree.js +450 -0
  111. data/vendor/assets/javascripts/jsts/io/GeoJSONParser.js +471 -0
  112. data/vendor/assets/javascripts/jsts/io/GeoJSONReader.js +58 -0
  113. data/vendor/assets/javascripts/jsts/io/GeoJSONWriter.js +38 -0
  114. data/vendor/assets/javascripts/jsts/io/OpenLayersParser.js +245 -0
  115. data/vendor/assets/javascripts/jsts/io/WKTParser.js +421 -0
  116. data/vendor/assets/javascripts/jsts/io/WKTReader.js +68 -0
  117. data/vendor/assets/javascripts/jsts/io/WKTWriter.js +61 -0
  118. data/vendor/assets/javascripts/jsts/noding/BasicSegmentString.js +87 -0
  119. data/vendor/assets/javascripts/jsts/noding/FastNodingValidator.js +127 -0
  120. data/vendor/assets/javascripts/jsts/noding/InteriorIntersectionFinder.js +171 -0
  121. data/vendor/assets/javascripts/jsts/noding/IntersectionAdder.js +198 -0
  122. data/vendor/assets/javascripts/jsts/noding/IntersectionFinderAdder.js +79 -0
  123. data/vendor/assets/javascripts/jsts/noding/MCIndexNoder.js +147 -0
  124. data/vendor/assets/javascripts/jsts/noding/NodableSegmentString.js +35 -0
  125. data/vendor/assets/javascripts/jsts/noding/NodedSegmentString.js +235 -0
  126. data/vendor/assets/javascripts/jsts/noding/Noder.js +41 -0
  127. data/vendor/assets/javascripts/jsts/noding/NodingValidator.js +5 -0
  128. data/vendor/assets/javascripts/jsts/noding/Octant.js +84 -0
  129. data/vendor/assets/javascripts/jsts/noding/OrientedCoordinateArray.js +94 -0
  130. data/vendor/assets/javascripts/jsts/noding/ScaledNoder.js +105 -0
  131. data/vendor/assets/javascripts/jsts/noding/SegmentIntersector.js +45 -0
  132. data/vendor/assets/javascripts/jsts/noding/SegmentNode.js +70 -0
  133. data/vendor/assets/javascripts/jsts/noding/SegmentNodeList.js +262 -0
  134. data/vendor/assets/javascripts/jsts/noding/SegmentPointComparator.js +78 -0
  135. data/vendor/assets/javascripts/jsts/noding/SegmentString.js +61 -0
  136. data/vendor/assets/javascripts/jsts/noding/SinglePassNoder.js +51 -0
  137. data/vendor/assets/javascripts/jsts/noding/snapround/HotPixel.js +271 -0
  138. data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexPointSnapper.js +96 -0
  139. data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexSnapRounder.js +147 -0
  140. data/vendor/assets/javascripts/jsts/operation/BoundaryOp.js +166 -0
  141. data/vendor/assets/javascripts/jsts/operation/GeometryGraphOperation.js +90 -0
  142. data/vendor/assets/javascripts/jsts/operation/IsSimpleOp.js +293 -0
  143. data/vendor/assets/javascripts/jsts/operation/buffer/BufferBuilder.js +317 -0
  144. data/vendor/assets/javascripts/jsts/operation/buffer/BufferInputLineSimplifier.js +294 -0
  145. data/vendor/assets/javascripts/jsts/operation/buffer/BufferOp.js +340 -0
  146. data/vendor/assets/javascripts/jsts/operation/buffer/BufferParameters.js +328 -0
  147. data/vendor/assets/javascripts/jsts/operation/buffer/BufferSubgraph.js +296 -0
  148. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveBuilder.js +369 -0
  149. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveSetBuilder.js +301 -0
  150. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentGenerator.js +777 -0
  151. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentString.js +109 -0
  152. data/vendor/assets/javascripts/jsts/operation/buffer/RightmostEdgeFinder.js +164 -0
  153. data/vendor/assets/javascripts/jsts/operation/buffer/SubgraphDepthLocater.js +220 -0
  154. data/vendor/assets/javascripts/jsts/operation/distance/ConnectedElementLocationFilter.js +67 -0
  155. data/vendor/assets/javascripts/jsts/operation/distance/DistanceOp.js +506 -0
  156. data/vendor/assets/javascripts/jsts/operation/distance/GeometryLocation.js +102 -0
  157. data/vendor/assets/javascripts/jsts/operation/overlay/LineBuilder.js +194 -0
  158. data/vendor/assets/javascripts/jsts/operation/overlay/MaximalEdgeRing.js +72 -0
  159. data/vendor/assets/javascripts/jsts/operation/overlay/MinimalEdgeRing.js +33 -0
  160. data/vendor/assets/javascripts/jsts/operation/overlay/OverlayNodeFactory.js +26 -0
  161. data/vendor/assets/javascripts/jsts/operation/overlay/OverlayOp.js +584 -0
  162. data/vendor/assets/javascripts/jsts/operation/overlay/PointBuilder.js +103 -0
  163. data/vendor/assets/javascripts/jsts/operation/overlay/PolygonBuilder.js +282 -0
  164. data/vendor/assets/javascripts/jsts/operation/overlay/snap/GeometrySnapper.js +228 -0
  165. data/vendor/assets/javascripts/jsts/operation/overlay/snap/LineStringSnapper.js +228 -0
  166. data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapIfNeededOverlayOp.js +85 -0
  167. data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapOverlayOp.js +134 -0
  168. data/vendor/assets/javascripts/jsts/operation/polygonize/EdgeRing.js +259 -0
  169. data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeDirectedEdge.js +94 -0
  170. data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeEdge.js +31 -0
  171. data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeGraph.js +507 -0
  172. data/vendor/assets/javascripts/jsts/operation/polygonize/Polygonizer.js +259 -0
  173. data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBuilder.js +140 -0
  174. data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundle.js +183 -0
  175. data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundleStar.js +48 -0
  176. data/vendor/assets/javascripts/jsts/operation/relate/RelateComputer.js +444 -0
  177. data/vendor/assets/javascripts/jsts/operation/relate/RelateNode.js +46 -0
  178. data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeFactory.js +25 -0
  179. data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeGraph.js +118 -0
  180. data/vendor/assets/javascripts/jsts/operation/relate/RelateOp.js +75 -0
  181. data/vendor/assets/javascripts/jsts/operation/union/CascadedPolygonUnion.js +319 -0
  182. data/vendor/assets/javascripts/jsts/operation/union/PointGeometryUnion.js +118 -0
  183. data/vendor/assets/javascripts/jsts/operation/union/UnaryUnionOp.js +244 -0
  184. data/vendor/assets/javascripts/jsts/operation/union/UnionInteracting.js +156 -0
  185. data/vendor/assets/javascripts/jsts/operation/valid/ConnectedInteriorTester.js +259 -0
  186. data/vendor/assets/javascripts/jsts/operation/valid/ConsistentAreaTester.js +127 -0
  187. data/vendor/assets/javascripts/jsts/operation/valid/IndexedNestedRingTester.js +89 -0
  188. data/vendor/assets/javascripts/jsts/operation/valid/IsValidOp.js +619 -0
  189. data/vendor/assets/javascripts/jsts/operation/valid/TopologyValidationError.js +199 -0
  190. data/vendor/assets/javascripts/jsts/planargraph/DirectedEdge.js +232 -0
  191. data/vendor/assets/javascripts/jsts/planargraph/DirectedEdgeStar.js +168 -0
  192. data/vendor/assets/javascripts/jsts/planargraph/Edge.js +124 -0
  193. data/vendor/assets/javascripts/jsts/planargraph/GraphComponent.js +182 -0
  194. data/vendor/assets/javascripts/jsts/planargraph/Node.js +127 -0
  195. data/vendor/assets/javascripts/jsts/planargraph/NodeMap.js +76 -0
  196. data/vendor/assets/javascripts/jsts/planargraph/PlanarGraph.js +246 -0
  197. data/vendor/assets/javascripts/jsts/simplify/LineSegmentIndex.js +101 -0
  198. data/vendor/assets/javascripts/jsts/triangulate/DelaunayTriangulationBuilder.js +224 -0
  199. data/vendor/assets/javascripts/jsts/triangulate/IncrementalDelaunayTriangulator.js +111 -0
  200. data/vendor/assets/javascripts/jsts/triangulate/VoronoiDiagramBuilder.js +172 -0
  201. data/vendor/assets/javascripts/jsts/triangulate/quadedge/LastFoundQuadEdgeLocator.js +52 -0
  202. data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdge.js +437 -0
  203. data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdgeSubdivision.js +1064 -0
  204. data/vendor/assets/javascripts/jsts/triangulate/quadedge/TrianglePredicate.js +350 -0
  205. data/vendor/assets/javascripts/jsts/triangulate/quadedge/Vertex.js +496 -0
  206. data/vendor/assets/javascripts/jsts/util/Assert.js +80 -0
  207. data/vendor/assets/javascripts/jsts/util/AssertionFailedException.js +23 -0
  208. data/vendor/assets/javascripts/jsts/util/UniqueCoordinateArrayFilter.js +52 -0
  209. metadata +204 -1
@@ -0,0 +1,48 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+
3
+ /**
4
+ * @requires jsts/geomgraph/EdgeEndStar.js
5
+ */
6
+
7
+
8
+
9
+ /**
10
+ * An ordered list of {@link EdgeEndBundle}s around a {@link RelateNode}.
11
+ * They are maintained in CCW order (starting with the positive x-axis) around the node
12
+ * for efficient lookup and topology building.
13
+ *
14
+ * @constructor
15
+ */
16
+ jsts.operation.relate.EdgeEndBundleStar = function() {
17
+ jsts.geomgraph.EdgeEndStar.apply(this, arguments);
18
+ };
19
+
20
+ jsts.operation.relate.EdgeEndBundleStar.prototype = new jsts.geomgraph.EdgeEndStar();
21
+
22
+
23
+ /**
24
+ * Insert a EdgeEnd in order in the list. If there is an existing EdgeStubBundle
25
+ * which is parallel, the EdgeEnd is added to the bundle. Otherwise, a new
26
+ * EdgeEndBundle is created to contain the EdgeEnd. <br>
27
+ */
28
+ jsts.operation.relate.EdgeEndBundleStar.prototype.insert = function(e) {
29
+ var eb = this.edgeMap.get(e);
30
+ if (eb === null) {
31
+ eb = new jsts.operation.relate.EdgeEndBundle(e);
32
+ this.insertEdgeEnd(e, eb);
33
+ }
34
+ else {
35
+ eb.insert(e);
36
+ }
37
+ };
38
+
39
+
40
+ /**
41
+ * Update the IM with the contribution for the EdgeStubs around the node.
42
+ */
43
+ jsts.operation.relate.EdgeEndBundleStar.prototype.updateIM = function(im) {
44
+ for (var it = this.iterator(); it.hasNext(); ) {
45
+ var esb = it.next();
46
+ esb.updateIM(im);
47
+ }
48
+ };
@@ -0,0 +1,444 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ (function() {
8
+
9
+ /**
10
+ * @requires jsts/geom/Location.js
11
+ * @requires jsts/util/Assert.js
12
+ */
13
+
14
+ var Location = jsts.geom.Location;
15
+ var Assert = jsts.util.Assert;
16
+ var ArrayList = javascript.util.ArrayList;
17
+
18
+
19
+ /**
20
+ * Computes the topological relationship between two Geometries.
21
+ * <p>
22
+ * RelateComputer does not need to build a complete graph structure to compute
23
+ * the IntersectionMatrix. The relationship between the geometries can be
24
+ * computed by simply examining the labelling of edges incident on each node.
25
+ * <p>
26
+ * RelateComputer does not currently support arbitrary GeometryCollections.
27
+ * This is because GeometryCollections can contain overlapping Polygons. In
28
+ * order to correct compute relate on overlapping Polygons, they would first
29
+ * need to be noded and merged (if not explicitly, at least implicitly).
30
+ *
31
+ * @constructor
32
+ */
33
+ jsts.operation.relate.RelateComputer = function(arg) {
34
+ this.li = new jsts.algorithm.RobustLineIntersector();
35
+ this.ptLocator = new jsts.algorithm.PointLocator();
36
+ this.nodes = new jsts.geomgraph.NodeMap(
37
+ new jsts.operation.relate.RelateNodeFactory());
38
+ this.isolatedEdges = new ArrayList();
39
+
40
+ this.arg = arg;
41
+ };
42
+
43
+
44
+ /**
45
+ * @type {LineIntersector}
46
+ * @private
47
+ */
48
+ jsts.operation.relate.RelateComputer.prototype.li = null;
49
+
50
+
51
+ /**
52
+ * @type {PointLocator}
53
+ * @private
54
+ */
55
+ jsts.operation.relate.RelateComputer.prototype.ptLocator = null;
56
+
57
+
58
+ /**
59
+ * the arg(s) of the operation
60
+ *
61
+ * @type {GeometryGraph[]}
62
+ * @private
63
+ */
64
+ jsts.operation.relate.RelateComputer.prototype.arg = null;
65
+
66
+
67
+ /**
68
+ * @type {NodeMap}
69
+ * @private
70
+ */
71
+ jsts.operation.relate.RelateComputer.prototype.nodes = null;
72
+
73
+
74
+ /**
75
+ * this intersection matrix will hold the results compute for the relate
76
+ *
77
+ * @type {IntersectionMatrix}
78
+ * @private
79
+ */
80
+ jsts.operation.relate.RelateComputer.prototype.im = null;
81
+
82
+
83
+ /**
84
+ * @type {javascript.util.ArrayList}
85
+ * @private
86
+ */
87
+ jsts.operation.relate.RelateComputer.prototype.isolatedEdges = null;
88
+
89
+
90
+ /**
91
+ * the intersection point found (if any)
92
+ *
93
+ * @type {Coordinate}
94
+ * @private
95
+ */
96
+ jsts.operation.relate.RelateComputer.prototype.invalidPoint = null;
97
+
98
+
99
+ jsts.operation.relate.RelateComputer.prototype.computeIM = function() {
100
+ var im = new jsts.geom.IntersectionMatrix();
101
+ // since Geometries are finite and embedded in a 2-D space, the EE element
102
+ // must always be 2
103
+ im.set(Location.EXTERIOR, Location.EXTERIOR, 2);
104
+
105
+ // if the Geometries don't overlap there is nothing to do
106
+ if (!this.arg[0].getGeometry().getEnvelopeInternal().intersects(
107
+ this.arg[1].getGeometry().getEnvelopeInternal())) {
108
+ this.computeDisjointIM(im);
109
+ return im;
110
+ }
111
+ this.arg[0].computeSelfNodes(this.li, false);
112
+ this.arg[1].computeSelfNodes(this.li, false);
113
+
114
+ // compute intersections between edges of the two input geometries
115
+ var intersector = this.arg[0].computeEdgeIntersections(this.arg[1],
116
+ this.li, false);
117
+ // System.out.println("computeIM: # segment intersection tests: " +
118
+ // intersector.numTests);
119
+ this.computeIntersectionNodes(0);
120
+ this.computeIntersectionNodes(1);
121
+ /**
122
+ * Copy the labelling for the nodes in the parent Geometries. These override
123
+ * any labels determined by intersections between the geometries.
124
+ */
125
+ this.copyNodesAndLabels(0);
126
+ this.copyNodesAndLabels(1);
127
+
128
+ // complete the labelling for any nodes which only have a label for a single
129
+ // geometry
130
+ this.labelIsolatedNodes();
131
+
132
+ // If a proper intersection was found, we can set a lower bound on the IM.
133
+ this.computeProperIntersectionIM(intersector, im);
134
+
135
+ /**
136
+ * Now process improper intersections (eg where one or other of the
137
+ * geometries has a vertex at the intersection point) We need to compute the
138
+ * edge graph at all nodes to determine the IM.
139
+ */
140
+
141
+ // build EdgeEnds for all intersections
142
+ var eeBuilder = new jsts.operation.relate.EdgeEndBuilder();
143
+ var ee0 = eeBuilder.computeEdgeEnds(this.arg[0].getEdgeIterator());
144
+ this.insertEdgeEnds(ee0);
145
+ var ee1 = eeBuilder.computeEdgeEnds(this.arg[1].getEdgeIterator());
146
+ this.insertEdgeEnds(ee1);
147
+
148
+ this.labelNodeEdges();
149
+
150
+ /**
151
+ * Compute the labeling for isolated components <br>
152
+ * Isolated components are components that do not touch any other components
153
+ * in the graph. They can be identified by the fact that they will contain
154
+ * labels containing ONLY a single element, the one for their parent
155
+ * geometry. We only need to check components contained in the input graphs,
156
+ * since isolated components will not have been replaced by new components
157
+ * formed by intersections.
158
+ */
159
+ this.labelIsolatedEdges(0, 1);
160
+ this.labelIsolatedEdges(1, 0);
161
+
162
+ // update the IM from all components
163
+ this.updateIM(im);
164
+ return im;
165
+ };
166
+
167
+
168
+ /**
169
+ * @private
170
+ */
171
+ jsts.operation.relate.RelateComputer.prototype.insertEdgeEnds = function(ee) {
172
+ for (var i = ee.iterator(); i.hasNext();) {
173
+ var e = i.next();
174
+ this.nodes.add(e);
175
+ }
176
+ };
177
+
178
+
179
+ /**
180
+ * @param {jsts.geom.IntersectionMatrix}
181
+ * im
182
+ * @private
183
+ */
184
+ jsts.operation.relate.RelateComputer.prototype.computeProperIntersectionIM = function(
185
+ intersector, im) {
186
+ // If a proper intersection is found, we can set a lower bound on the IM.
187
+ var dimA = this.arg[0].getGeometry().getDimension();
188
+ var dimB = this.arg[1].getGeometry().getDimension();
189
+ var hasProper = intersector.hasProperIntersection();
190
+ var hasProperInterior = intersector.hasProperInteriorIntersection();
191
+
192
+ // For Geometry's of dim 0 there can never be proper intersections.
193
+
194
+ /**
195
+ * If edge segments of Areas properly intersect, the areas must properly
196
+ * overlap.
197
+ */
198
+ if (dimA === 2 && dimB === 2) {
199
+ if (hasProper)
200
+ im.setAtLeast('212101212');
201
+ }
202
+ /**
203
+ * If an Line segment properly intersects an edge segment of an Area, it
204
+ * follows that the Interior of the Line intersects the Boundary of the
205
+ * Area. If the intersection is a proper <i>interior</i> intersection, then
206
+ * there is an Interior-Interior intersection too. Note that it does not
207
+ * follow that the Interior of the Line intersects the Exterior of the Area,
208
+ * since there may be another Area component which contains the rest of the
209
+ * Line.
210
+ */
211
+ else if (dimA === 2 && dimB === 1) {
212
+ if (hasProper)
213
+ im.setAtLeast('FFF0FFFF2');
214
+ if (hasProperInterior)
215
+ im.setAtLeast('1FFFFF1FF');
216
+ } else if (dimA === 1 && dimB === 2) {
217
+ if (hasProper)
218
+ im.setAtLeast('F0FFFFFF2');
219
+ if (hasProperInterior)
220
+ im.setAtLeast('1F1FFFFFF');
221
+ }
222
+ /* If edges of LineStrings properly intersect *in an interior point*, all
223
+ we can deduce is that
224
+ the interiors intersect. (We can NOT deduce that the exteriors intersect,
225
+ since some other segments in the geometries might cover the points in the
226
+ neighbourhood of the intersection.)
227
+ It is important that the point be known to be an interior point of
228
+ both Geometries, since it is possible in a self-intersecting geometry to
229
+ have a proper intersection on one segment that is also a boundary point of another segment.
230
+ */
231
+ else if (dimA === 1 && dimB === 1) {
232
+ if (hasProperInterior)
233
+ im.setAtLeast('0FFFFFFFF');
234
+ }
235
+ };
236
+
237
+
238
+ /**
239
+ * Copy all nodes from an arg geometry into this graph. The node label in the
240
+ * arg geometry overrides any previously computed label for that argIndex.
241
+ * (E.g. a node may be an intersection node with a computed label of BOUNDARY,
242
+ * but in the original arg Geometry it is actually in the interior due to the
243
+ * Boundary Determination Rule)
244
+ *
245
+ * @private
246
+ */
247
+ jsts.operation.relate.RelateComputer.prototype.copyNodesAndLabels = function(
248
+ argIndex) {
249
+ for (var i = this.arg[argIndex].getNodeIterator(); i.hasNext();) {
250
+ var graphNode = i.next();
251
+ var newNode = this.nodes.addNode(graphNode.getCoordinate());
252
+ newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
253
+ }
254
+ };
255
+
256
+
257
+ /**
258
+ * Insert nodes for all intersections on the edges of a Geometry. Label the
259
+ * created nodes the same as the edge label if they do not already have a
260
+ * label. This allows nodes created by either self-intersections or mutual
261
+ * intersections to be labelled. Endpoint nodes will already be labelled from
262
+ * when they were inserted.
263
+ *
264
+ * @private
265
+ */
266
+ jsts.operation.relate.RelateComputer.prototype.computeIntersectionNodes = function(
267
+ argIndex) {
268
+ for (var i = this.arg[argIndex].getEdgeIterator(); i.hasNext();) {
269
+ var e = i.next();
270
+ var eLoc = e.getLabel().getLocation(argIndex);
271
+ for (var eiIt = e.getEdgeIntersectionList().iterator(); eiIt.hasNext();) {
272
+ var ei = eiIt.next();
273
+ var n = this.nodes.addNode(ei.coord);
274
+ if (eLoc === Location.BOUNDARY)
275
+ n.setLabelBoundary(argIndex);
276
+ else {
277
+ if (n.getLabel().isNull(argIndex))
278
+ n.setLabel(argIndex, Location.INTERIOR);
279
+ }
280
+ }
281
+ }
282
+ };
283
+
284
+
285
+ /**
286
+ * For all intersections on the edges of a Geometry, label the corresponding
287
+ * node IF it doesn't already have a label. This allows nodes created by
288
+ * either self-intersections or mutual intersections to be labelled. Endpoint
289
+ * nodes will already be labelled from when they were inserted.
290
+ *
291
+ * @private
292
+ */
293
+ jsts.operation.relate.RelateComputer.prototype.labelIntersectionNodes = function(
294
+ argIndex) {
295
+ for (var i = this.arg[argIndex].getEdgeIterator(); i.hasNext();) {
296
+ var e = i.next();
297
+ var eLoc = e.getLabel().getLocation(argIndex);
298
+ for (var eiIt = e.getEdgeIntersectionList().iterator(); eiIt.hasNext();) {
299
+ var ei = eiIt.next();
300
+ var n = this.nodes.find(ei.coord);
301
+ if (n.getLabel().isNull(argIndex)) {
302
+ if (eLoc === Location.BOUNDARY)
303
+ n.setLabelBoundary(argIndex);
304
+ else
305
+ n.setLabel(argIndex, Location.INTERIOR);
306
+ }
307
+ }
308
+ }
309
+ };
310
+
311
+
312
+ /**
313
+ * If the Geometries are disjoint, we need to enter their dimension and
314
+ * boundary dimension in the Ext rows in the IM
315
+ *
316
+ * @private
317
+ */
318
+ jsts.operation.relate.RelateComputer.prototype.computeDisjointIM = function(
319
+ im) {
320
+ var ga = this.arg[0].getGeometry();
321
+ if (!ga.isEmpty()) {
322
+ im.set(Location.INTERIOR, Location.EXTERIOR, ga.getDimension());
323
+ im.set(Location.BOUNDARY, Location.EXTERIOR, ga.getBoundaryDimension());
324
+ }
325
+ var gb = this.arg[1].getGeometry();
326
+ if (!gb.isEmpty()) {
327
+ im.set(Location.EXTERIOR, Location.INTERIOR, gb.getDimension());
328
+ im.set(Location.EXTERIOR, Location.BOUNDARY, gb.getBoundaryDimension());
329
+ }
330
+ };
331
+
332
+
333
+ /**
334
+ * @private
335
+ */
336
+ jsts.operation.relate.RelateComputer.prototype.labelNodeEdges = function() {
337
+ for (var ni = this.nodes.iterator(); ni.hasNext();) {
338
+ var node = ni.next();
339
+ node.getEdges().computeLabelling(this.arg);
340
+ }
341
+ };
342
+
343
+
344
+ /**
345
+ * update the IM with the sum of the IMs for each component
346
+ *
347
+ * @private
348
+ */
349
+ jsts.operation.relate.RelateComputer.prototype.updateIM = function(im) {
350
+ for (var ei = this.isolatedEdges.iterator(); ei.hasNext();) {
351
+ var e = ei.next();
352
+ e.updateIM(im);
353
+ }
354
+ for (var ni = this.nodes.iterator(); ni.hasNext();) {
355
+ var node = ni.next();
356
+ node.updateIM(im);
357
+ node.updateIMFromEdges(im);
358
+ }
359
+ };
360
+
361
+
362
+ /**
363
+ * Processes isolated edges by computing their labelling and adding them to
364
+ * the isolated edges list. Isolated edges are guaranteed not to touch the
365
+ * boundary of the target (since if they did, they would have caused an
366
+ * intersection to be computed and hence would not be isolated)
367
+ *
368
+ * @private
369
+ */
370
+ jsts.operation.relate.RelateComputer.prototype.labelIsolatedEdges = function(
371
+ thisIndex, targetIndex) {
372
+ for (var ei = this.arg[thisIndex].getEdgeIterator(); ei.hasNext();) {
373
+ var e = ei.next();
374
+ if (e.isIsolated()) {
375
+ this.labelIsolatedEdge(e, targetIndex, this.arg[targetIndex]
376
+ .getGeometry());
377
+ this.isolatedEdges.add(e);
378
+ }
379
+ }
380
+ };
381
+
382
+
383
+ /**
384
+ * Label an isolated edge of a graph with its relationship to the target
385
+ * geometry. If the target has dim 2 or 1, the edge can either be in the
386
+ * interior or the exterior. If the target has dim 0, the edge must be in the
387
+ * exterior
388
+ *
389
+ * @private
390
+ */
391
+ jsts.operation.relate.RelateComputer.prototype.labelIsolatedEdge = function(
392
+ e, targetIndex, target) {
393
+ // this won't work for GeometryCollections with both dim 2 and 1 geoms
394
+ if (target.getDimension() > 0) {
395
+ // since edge is not in boundary, may not need the full generality of
396
+ // PointLocator?
397
+ // Possibly should use ptInArea locator instead? We probably know here
398
+ // that the edge does not touch the bdy of the target Geometry
399
+ var loc = this.ptLocator.locate(e.getCoordinate(), target);
400
+ e.getLabel().setAllLocations(targetIndex, loc);
401
+ } else {
402
+ e.getLabel().setAllLocations(targetIndex, Location.EXTERIOR);
403
+ }
404
+ };
405
+
406
+
407
+ /**
408
+ * Isolated nodes are nodes whose labels are incomplete (e.g. the location for
409
+ * one Geometry is null). This is the case because nodes in one graph which
410
+ * don't intersect nodes in the other are not completely labelled by the
411
+ * initial process of adding nodes to the nodeList. To complete the labelling
412
+ * we need to check for nodes that lie in the interior of edges, and in the
413
+ * interior of areas.
414
+ *
415
+ * @private
416
+ */
417
+ jsts.operation.relate.RelateComputer.prototype.labelIsolatedNodes = function() {
418
+ for (var ni = this.nodes.iterator(); ni.hasNext();) {
419
+ var n = ni.next();
420
+ var label = n.getLabel();
421
+ // isolated nodes should always have at least one geometry in their label
422
+ Assert
423
+ .isTrue(label.getGeometryCount() > 0, 'node with empty label found');
424
+ if (n.isIsolated()) {
425
+ if (label.isNull(0))
426
+ this.labelIsolatedNode(n, 0);
427
+ else
428
+ this.labelIsolatedNode(n, 1);
429
+ }
430
+ }
431
+ };
432
+
433
+
434
+ /**
435
+ * Label an isolated node with its relationship to the target geometry.
436
+ */
437
+ jsts.operation.relate.RelateComputer.prototype.labelIsolatedNode = function(
438
+ n, targetIndex) {
439
+ var loc = this.ptLocator.locate(n.getCoordinate(), this.arg[targetIndex]
440
+ .getGeometry());
441
+ n.getLabel().setAllLocations(targetIndex, loc);
442
+ };
443
+
444
+ })();