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,198 @@
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
+ /**
8
+ *@requires jsts/noding/SegmentIntersector.js
9
+ */
10
+
11
+ /**
12
+ * Computes the intersections between two line segments in {@link SegmentString}s
13
+ * and adds them to each string. The {@link SegmentIntersector} is passed to a
14
+ * {@link Noder}. The {@link addIntersections} method is called whenever the
15
+ * {@link Noder} detects that two SegmentStrings <i>might</i> intersect. This
16
+ * class is an example of the <i>Strategy</i> pattern.
17
+ *
18
+ * @constructor
19
+ */
20
+ jsts.noding.IntersectionAdder = function(li) {
21
+ this.li = li;
22
+ };
23
+
24
+ jsts.noding.IntersectionAdder.prototype = new jsts.noding.SegmentIntersector();
25
+ jsts.noding.IntersectionAdder.constructor = jsts.noding.IntersectionAdder;
26
+
27
+
28
+ jsts.noding.IntersectionAdder.isAdjacentSegments = function(i1, i2) {
29
+ return Math.abs(i1 - i2) === 1;
30
+ };
31
+
32
+ /**
33
+ * These variables keep track of what types of intersections were found during
34
+ * ALL edges that have been intersected.
35
+ */
36
+ /**
37
+ * @type {boolean}
38
+ * @private
39
+ */
40
+ jsts.noding.IntersectionAdder.prototype._hasIntersection = false;
41
+ /**
42
+ * @type {boolean}
43
+ * @private
44
+ */
45
+ jsts.noding.IntersectionAdder.prototype.hasProper = false;
46
+ /**
47
+ * @type {boolean}
48
+ * @private
49
+ */
50
+ jsts.noding.IntersectionAdder.prototype.hasProperInterior = false;
51
+ /**
52
+ * @type {boolean}
53
+ * @private
54
+ */
55
+ jsts.noding.IntersectionAdder.prototype.hasInterior = false;
56
+
57
+ // the proper intersection point found
58
+
59
+ /**
60
+ * @type {Coordinate}
61
+ * @private
62
+ */
63
+ jsts.noding.IntersectionAdder.prototype.properIntersectionPoint = null;
64
+
65
+ /**
66
+ * @type {LineIntersector}
67
+ * @private
68
+ */
69
+ jsts.noding.IntersectionAdder.prototype.li = null;
70
+ /**
71
+ * @type {boolean}
72
+ * @private
73
+ */
74
+ jsts.noding.IntersectionAdder.prototype.isSelfIntersection = null;
75
+
76
+ jsts.noding.IntersectionAdder.prototype.numIntersections = 0;
77
+ jsts.noding.IntersectionAdder.prototype.numInteriorIntersections = 0;
78
+ jsts.noding.IntersectionAdder.prototype.numProperIntersections = 0;
79
+
80
+ // testing only
81
+ jsts.noding.IntersectionAdder.prototype.numTests = 0;
82
+
83
+
84
+ jsts.noding.IntersectionAdder.prototype.getLineIntersector = function() {
85
+ return this.li;
86
+ };
87
+
88
+ /**
89
+ * @return the proper intersection point, or <code>null</code> if none was
90
+ * found.
91
+ */
92
+ jsts.noding.IntersectionAdder.prototype.getProperIntersectionPoint = function() {
93
+ return this.properIntersectionPoint;
94
+ };
95
+
96
+ jsts.noding.IntersectionAdder.prototype.hasIntersection = function() {
97
+ return this._hasIntersection;
98
+ };
99
+ /**
100
+ * A proper intersection is an intersection which is interior to at least two
101
+ * line segments. Note that a proper intersection is not necessarily in the
102
+ * interior of the entire Geometry, since another edge may have an endpoint
103
+ * equal to the intersection, which according to SFS semantics can result in the
104
+ * point being on the Boundary of the Geometry.
105
+ */
106
+ jsts.noding.IntersectionAdder.prototype.hasProperIntersection = function() {
107
+ return this.hasProper;
108
+ };
109
+ /**
110
+ * A proper interior intersection is a proper intersection which is <b>not</b>
111
+ * contained in the set of boundary nodes set for this SegmentIntersector.
112
+ */
113
+ jsts.noding.IntersectionAdder.prototype.hasProperInteriorIntersection = function() {
114
+ return this.hasProperInterior;
115
+ };
116
+ /**
117
+ * An interior intersection is an intersection which is in the interior of some
118
+ * segment.
119
+ */
120
+ jsts.noding.IntersectionAdder.prototype.hasInteriorIntersection = function() {
121
+ return this.hasInterior;
122
+ };
123
+
124
+ /**
125
+ * A trivial intersection is an apparent self-intersection which in fact is
126
+ * simply the point shared by adjacent line segments. Note that closed edges
127
+ * require a special check for the point shared by the beginning and end
128
+ * segments.
129
+ *
130
+ * @private
131
+ */
132
+ jsts.noding.IntersectionAdder.prototype.isTrivialIntersection = function(e0,
133
+ segIndex0, e1, segIndex1) {
134
+ if (e0 == e1) {
135
+ if (this.li.getIntersectionNum() == 1) {
136
+ if (jsts.noding.IntersectionAdder
137
+ .isAdjacentSegments(segIndex0, segIndex1))
138
+ return true;
139
+ if (e0.isClosed()) {
140
+ var maxSegIndex = e0.size() - 1;
141
+ if ((segIndex0 === 0 && segIndex1 === maxSegIndex) ||
142
+ (segIndex1 === 0 && segIndex0 === maxSegIndex)) {
143
+ return true;
144
+ }
145
+ }
146
+ }
147
+ }
148
+ return false;
149
+ };
150
+
151
+ /**
152
+ * This method is called by clients of the {@link SegmentIntersector} class to
153
+ * process intersections for two segments of the {@link SegmentString}s being
154
+ * intersected. Note that some clients (such as {@link MonotoneChain}s) may
155
+ * optimize away this call for segment pairs which they have determined do not
156
+ * intersect (e.g. by an disjoint envelope test).
157
+ */
158
+ jsts.noding.IntersectionAdder.prototype.processIntersections = function(e0,
159
+ segIndex0, e1, segIndex1) {
160
+ if (e0 === e1 && segIndex0 === segIndex1)
161
+ return;
162
+ this.numTests++;
163
+ var p00 = e0.getCoordinates()[segIndex0];
164
+ var p01 = e0.getCoordinates()[segIndex0 + 1];
165
+ var p10 = e1.getCoordinates()[segIndex1];
166
+ var p11 = e1.getCoordinates()[segIndex1 + 1];
167
+
168
+ this.li.computeIntersection(p00, p01, p10, p11);
169
+ if (this.li.hasIntersection()) {
170
+ this.numIntersections++;
171
+ if (this.li.isInteriorIntersection()) {
172
+ this.numInteriorIntersections++;
173
+ this.hasInterior = true;
174
+ }
175
+ // if the segments are adjacent they have at least one trivial intersection,
176
+ // the shared endpoint. Don't bother adding it if it is the
177
+ // only intersection.
178
+ if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
179
+ this._hasIntersection = true;
180
+ e0.addIntersections(this.li, segIndex0, 0);
181
+ e1.addIntersections(this.li, segIndex1, 1);
182
+ if (this.li.isProper()) {
183
+ this.numProperIntersections++;
184
+ this.hasProper = true;
185
+ this.hasProperInterior = true;
186
+ }
187
+ }
188
+ }
189
+ };
190
+
191
+ /**
192
+ * Always process all intersections
193
+ *
194
+ * @return false always.
195
+ */
196
+ jsts.noding.IntersectionAdder.prototype.isDone = function() {
197
+ return false;
198
+ };
@@ -0,0 +1,79 @@
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
+ /**
8
+ * Port source:
9
+ * /jts/jts/java/src/com/vividsolutions/jts/noding/IntersectionFinderAdder.java
10
+ * Revision: 108
11
+ */
12
+
13
+ /**
14
+ * Finds proper and interior intersections in a set of SegmentStrings,
15
+ * and adds them as nodes.
16
+ */
17
+
18
+ /**
19
+ * Creates an intersection finder which finds all proper intersections
20
+ *
21
+ * @param li
22
+ * the LineIntersector to use.
23
+ */
24
+ jsts.noding.IntersectionFinderAdder = function(li) {
25
+ this.li = li;
26
+ this.interiorIntersections = new javascript.util.ArrayList();
27
+ };
28
+
29
+ jsts.noding.IntersectionFinderAdder.prototype = new jsts.noding.SegmentIntersector();
30
+ jsts.noding.IntersectionFinderAdder.constructor = jsts.noding.IntersectionFinderAdder;
31
+
32
+
33
+ jsts.noding.IntersectionFinderAdder.prototype.li = null;
34
+ jsts.noding.IntersectionFinderAdder.prototype.interiorIntersections = null;
35
+
36
+
37
+ jsts.noding.IntersectionFinderAdder.prototype.getInteriorIntersections = function() {
38
+ return this.interiorIntersections;
39
+ };
40
+
41
+ /**
42
+ * This method is called by clients of the {@link SegmentIntersector} class to
43
+ * process intersections for two segments of the {@link SegmentString}s being
44
+ * intersected. Note that some clients (such as {@link MonotoneChain}s) may
45
+ * optimize away this call for segment pairs which they have determined do not
46
+ * intersect (e.g. by an disjoint envelope test).
47
+ */
48
+ jsts.noding.IntersectionFinderAdder.prototype.processIntersections = function(
49
+ e0, segIndex0, e1, segIndex1) {
50
+ // don't bother intersecting a segment with itself
51
+ if (e0 === e1 && segIndex0 === segIndex1)
52
+ return;
53
+
54
+ var p00 = e0.getCoordinates()[segIndex0];
55
+ var p01 = e0.getCoordinates()[segIndex0 + 1];
56
+ var p10 = e1.getCoordinates()[segIndex1];
57
+ var p11 = e1.getCoordinates()[segIndex1 + 1];
58
+
59
+ this.li.computeIntersection(p00, p01, p10, p11);
60
+
61
+ if (this.li.hasIntersection()) {
62
+ if (this.li.isInteriorIntersection()) {
63
+ for (var intIndex = 0; intIndex < this.li.getIntersectionNum(); intIndex++) {
64
+ this.interiorIntersections.add(this.li.getIntersection(intIndex));
65
+ }
66
+ e0.addIntersections(this.li, segIndex0, 0);
67
+ e1.addIntersections(this.li, segIndex1, 1);
68
+ }
69
+ }
70
+ };
71
+
72
+ /**
73
+ * Always process all intersections
74
+ *
75
+ * @return false always.
76
+ */
77
+ jsts.noding.IntersectionFinderAdder.prototype.isDone = function() {
78
+ return false;
79
+ };
@@ -0,0 +1,147 @@
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/noding/SinglePassNoder.js
11
+ * @requires jsts/index/strtree/STRtree.js
12
+ * @requires jsts/noding/NodedSegmentString.js
13
+ * @requires jsts/index/chain/MonotoneChainBuilder.js
14
+ * @requires jsts/index/chain/MonotoneChainOverlapAction.js
15
+ */
16
+
17
+ var MonotoneChainOverlapAction = jsts.index.chain.MonotoneChainOverlapAction;
18
+ var SinglePassNoder = jsts.noding.SinglePassNoder;
19
+ var STRtree = jsts.index.strtree.STRtree;
20
+ var NodedSegmentString = jsts.noding.NodedSegmentString;
21
+ var MonotoneChainBuilder = jsts.index.chain.MonotoneChainBuilder;
22
+
23
+ /**
24
+ * @constructor
25
+ * @private
26
+ */
27
+ var SegmentOverlapAction = function(si) {
28
+ this.si = si;
29
+
30
+ };
31
+ SegmentOverlapAction.prototype = new MonotoneChainOverlapAction();
32
+ SegmentOverlapAction.constructor = SegmentOverlapAction;
33
+
34
+ /**
35
+ * @type {SegmentIntersector}
36
+ * @private
37
+ */
38
+ SegmentOverlapAction.prototype.si = null;
39
+
40
+ SegmentOverlapAction.prototype.overlap = function(mc1, start1, mc2, start2) {
41
+ var ss1 = mc1.getContext();
42
+ var ss2 = mc2.getContext();
43
+ this.si.processIntersections(ss1, start1, ss2, start2);
44
+ };
45
+
46
+ /**
47
+ * @constructor
48
+ */
49
+ jsts.noding.MCIndexNoder = function() {
50
+ this.monoChains = [];
51
+ this.index = new STRtree();
52
+ };
53
+
54
+ jsts.noding.MCIndexNoder.prototype = new SinglePassNoder();
55
+ jsts.noding.MCIndexNoder.constructor = jsts.noding.MCIndexNoder;
56
+
57
+ /**
58
+ * @type {Array}
59
+ * @private
60
+ */
61
+ jsts.noding.MCIndexNoder.prototype.monoChains = null;
62
+ /**
63
+ * @type {SpatialIndex}
64
+ * @private
65
+ */
66
+ jsts.noding.MCIndexNoder.prototype.index = null;
67
+ /**
68
+ * @type {number}
69
+ * @private
70
+ */
71
+ jsts.noding.MCIndexNoder.prototype.idCounter = 0;
72
+
73
+ /**
74
+ * @type {Array}
75
+ * @private
76
+ */
77
+ jsts.noding.MCIndexNoder.prototype.nodedSegStrings = null;
78
+ /**
79
+ * statistics
80
+ *
81
+ * @type {number}
82
+ * @private
83
+ */
84
+ jsts.noding.MCIndexNoder.prototype.nOverlaps = 0;
85
+
86
+
87
+ jsts.noding.MCIndexNoder.prototype.getMonotoneChains = function() {
88
+ return this.monoChains;
89
+ };
90
+
91
+ jsts.noding.MCIndexNoder.prototype.getIndex = function() {
92
+ return this.index;
93
+ };
94
+
95
+ jsts.noding.MCIndexNoder.prototype.getNodedSubstrings = function() {
96
+ return NodedSegmentString.getNodedSubstrings(this.nodedSegStrings);
97
+ };
98
+
99
+ jsts.noding.MCIndexNoder.prototype.computeNodes = function(inputSegStrings) {
100
+ this.nodedSegStrings = inputSegStrings;
101
+ for (var i = inputSegStrings.iterator(); i.hasNext(); ) {
102
+ this.add(i.next());
103
+ }
104
+ this.intersectChains();
105
+ };
106
+
107
+ /**
108
+ * @private
109
+ */
110
+ jsts.noding.MCIndexNoder.prototype.intersectChains = function() {
111
+ var overlapAction = new SegmentOverlapAction(this.segInt);
112
+
113
+ for (var i = 0; i < this.monoChains.length; i++) {
114
+ var queryChain = this.monoChains[i];
115
+ var overlapChains = this.index.query(queryChain.getEnvelope());
116
+ for (var j = 0; j < overlapChains.length; j++) {
117
+ var testChain = overlapChains[j];
118
+ /**
119
+ * following test makes sure we only compare each pair of chains once
120
+ * and that we don't compare a chain to itself
121
+ */
122
+ if (testChain.getId() > queryChain.getId()) {
123
+ queryChain.computeOverlaps(testChain, overlapAction);
124
+ this.nOverlaps++;
125
+ }
126
+ // short-circuit if possible
127
+ if (this.segInt.isDone())
128
+ return;
129
+ }
130
+ }
131
+ };
132
+
133
+ /**
134
+ * @private
135
+ */
136
+ jsts.noding.MCIndexNoder.prototype.add = function(segStr) {
137
+ var segChains = MonotoneChainBuilder.getChains(segStr.getCoordinates(),
138
+ segStr);
139
+ for (var i = 0; i < segChains.length; i++) {
140
+ var mc = segChains[i];
141
+ mc.setId(this.idCounter++);
142
+ this.index.insert(mc.getEnvelope(), mc);
143
+ this.monoChains.push(mc);
144
+ }
145
+ };
146
+
147
+ })();
@@ -0,0 +1,35 @@
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
+ /**
8
+ * @requires jsts/noding/SegmentString.js
9
+ */
10
+
11
+
12
+
13
+ /**
14
+ * An interface for classes which support adding nodes to a segment string.
15
+ *
16
+ * @interface
17
+ */
18
+ jsts.noding.NodableSegmentString = function() {
19
+
20
+ };
21
+
22
+
23
+ jsts.noding.NodableSegmentString.prototype = new jsts.noding.SegmentString();
24
+
25
+
26
+ /**
27
+ * Adds an intersection node for a given point and segment to this segment
28
+ * string.
29
+ *
30
+ * @param {Coordinate}
31
+ * intPt the location of the intersection.
32
+ * @param {number}
33
+ * segmentIndex the index of the segment containing the intersection.
34
+ */
35
+ jsts.noding.NodableSegmentString.prototype.addIntersection = jsts.abstractFunc;