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,47 @@
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
+
9
+ /**
10
+ * @constructor
11
+ */
12
+ jsts.geomgraph.index.EdgeSetIntersector = function() {
13
+
14
+ };
15
+
16
+
17
+ /**
18
+ * Computes all self-intersections between edges in a set of edges, allowing
19
+ * client to choose whether self-intersections are computed.
20
+ *
21
+ * @param {javascript.util.List}
22
+ * edges a list of edges to test for intersections.
23
+ * @param {SegmentIntersector}
24
+ * si the SegmentIntersector to use.
25
+ * @param {boolean}
26
+ * testAllSegments true if self-intersections are to be tested as well.
27
+ */
28
+ jsts.geomgraph.index.EdgeSetIntersector.prototype.computeIntersections = function(
29
+ edges, si, testAllSegments) {
30
+ throw new jsts.error.AbstractMethodInvocationError();
31
+ };
32
+
33
+
34
+ /**
35
+ * Computes all mutual intersections between two sets of edges.
36
+ *
37
+ * @param {javascript.util.List}
38
+ * edges0 a list of edges to test for intersections.
39
+ * @param {javascript.util.List}
40
+ * edges1 a list of edges to test for intersections.
41
+ * @param {SegmentIntersector}
42
+ * si the SegmentIntersector to use.
43
+ */
44
+ jsts.geomgraph.index.EdgeSetIntersector.prototype.computeIntersections2 = function(
45
+ edges0, edges1, si) {
46
+ throw new jsts.error.AbstractMethodInvocationError();
47
+ };
@@ -0,0 +1,298 @@
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
+ var ArrayList = javascript.util.ArrayList;
10
+
11
+ /**
12
+ * Computes the intersection of line segments, and adds the intersection to
13
+ * the edges containing the segments.
14
+ *
15
+ * @param {LineIntersector}
16
+ * li
17
+ * @param {boolean}
18
+ * includeProper
19
+ * @param {boolean}
20
+ * recordIsolated
21
+ * @constructor
22
+ */
23
+ jsts.geomgraph.index.SegmentIntersector = function(li, includeProper, recordIsolated) {
24
+ this.li = li;
25
+ this.includeProper = includeProper;
26
+ this.recordIsolated = recordIsolated;
27
+ };
28
+
29
+
30
+ /**
31
+ * @param {number}
32
+ * i1
33
+ * @param {number}
34
+ * i2
35
+ * @return {boolean}
36
+ */
37
+ jsts.geomgraph.index.SegmentIntersector.isAdjacentSegments = function(i1, i2) {
38
+ return Math.abs(i1 - i2) === 1;
39
+ };
40
+
41
+
42
+ /**
43
+ * @type {boolean}
44
+ * @private
45
+ */
46
+ jsts.geomgraph.index.SegmentIntersector.prototype._hasIntersection = false;
47
+
48
+
49
+ /**
50
+ * @type {boolean}
51
+ * @private
52
+ */
53
+ jsts.geomgraph.index.SegmentIntersector.prototype.hasProper = false;
54
+
55
+
56
+ /**
57
+ * @type {boolean}
58
+ * @private
59
+ */
60
+ jsts.geomgraph.index.SegmentIntersector.prototype.hasProperInterior = false;
61
+
62
+
63
+ /**
64
+ * the proper intersection point found
65
+ *
66
+ * @type {Coordinate}
67
+ * @private
68
+ */
69
+ jsts.geomgraph.index.SegmentIntersector.prototype.properIntersectionPoint = null;
70
+
71
+
72
+ /**
73
+ * @type {LineIntersector}
74
+ * @private
75
+ */
76
+ jsts.geomgraph.index.SegmentIntersector.prototype.li = null;
77
+
78
+
79
+ /**
80
+ * @type {boolean}
81
+ * @private
82
+ */
83
+ jsts.geomgraph.index.SegmentIntersector.prototype.includeProper = null;
84
+
85
+
86
+ /**
87
+ * @type {boolean}
88
+ * @private
89
+ */
90
+ jsts.geomgraph.index.SegmentIntersector.prototype.recordIsolated = null;
91
+
92
+
93
+ /**
94
+ * @type {boolean}
95
+ * @private
96
+ */
97
+ jsts.geomgraph.index.SegmentIntersector.prototype.isSelfIntersection = null;
98
+
99
+
100
+ /**
101
+ * @type {number}
102
+ * @private
103
+ */
104
+ jsts.geomgraph.index.SegmentIntersector.prototype.numIntersections = 0;
105
+
106
+
107
+ /**
108
+ * testing only
109
+ *
110
+ * @type {number}
111
+ */
112
+ jsts.geomgraph.index.SegmentIntersector.prototype.numTests = 0;
113
+
114
+
115
+ /**
116
+ * @type {Array.<javascript.util.Collection>}
117
+ * @private
118
+ */
119
+ jsts.geomgraph.index.SegmentIntersector.prototype.bdyNodes = null;
120
+
121
+
122
+ /**
123
+ * @param {javascript.util.Collection}
124
+ * bdyNodes0
125
+ * @param {javascript.util.Collection}
126
+ * bdyNodes1
127
+ */
128
+ jsts.geomgraph.index.SegmentIntersector.prototype.setBoundaryNodes = function(bdyNodes0, bdyNodes1) {
129
+ this.bdyNodes = [];
130
+ this.bdyNodes[0] = bdyNodes0;
131
+ this.bdyNodes[1] = bdyNodes1;
132
+ };
133
+
134
+
135
+ /**
136
+ * @return {Coordinate} the proper intersection point, or <code>null</code>
137
+ * if none was found.
138
+ */
139
+ jsts.geomgraph.index.SegmentIntersector.prototype.getProperIntersectionPoint = function() {
140
+ return this.properIntersectionPoint;
141
+ };
142
+
143
+
144
+ /**
145
+ * @return {boolean}
146
+ */
147
+ jsts.geomgraph.index.SegmentIntersector.prototype.hasIntersection = function() {
148
+ return this._hasIntersection;
149
+ };
150
+
151
+
152
+ /**
153
+ * A proper intersection is an intersection which is interior to at least two
154
+ * line segments. Note that a proper intersection is not necessarily in the
155
+ * interior of the entire Geometry, since another edge may have an endpoint
156
+ * equal to the intersection, which according to SFS semantics can result in
157
+ * the point being on the Boundary of the Geometry.
158
+ *
159
+ * @return {boolean}
160
+ */
161
+ jsts.geomgraph.index.SegmentIntersector.prototype.hasProperIntersection = function() {
162
+ return this.hasProper;
163
+ };
164
+
165
+
166
+ /**
167
+ * A proper interior intersection is a proper intersection which is <b>not</b>
168
+ * contained in the set of boundary nodes set for this jsts.geomgraph.index.SegmentIntersector.
169
+ *
170
+ * @return {boolean}
171
+ */
172
+ jsts.geomgraph.index.SegmentIntersector.prototype.hasProperInteriorIntersection = function() {
173
+ return this.hasProperInterior;
174
+ };
175
+
176
+
177
+ /**
178
+ * A trivial intersection is an apparent self-intersection which in fact is
179
+ * simply the point shared by adjacent line segments. Note that closed edges
180
+ * require a special check for the point shared by the beginning and end
181
+ * segments.
182
+ *
183
+ * @param {Edge}
184
+ * e0
185
+ * @param {int}
186
+ * segIndex0
187
+ * @param {Edge}
188
+ * e1
189
+ * @param {int}
190
+ * segIndex1
191
+ * @return {boolean}
192
+ */
193
+ jsts.geomgraph.index.SegmentIntersector.prototype.isTrivialIntersection = function(e0, segIndex0,
194
+ e1, segIndex1) {
195
+ if (e0 === e1) {
196
+ if (this.li.getIntersectionNum() === 1) {
197
+ if (jsts.geomgraph.index.SegmentIntersector.isAdjacentSegments(segIndex0, segIndex1))
198
+ return true;
199
+ if (e0.isClosed()) {
200
+ var maxSegIndex = e0.getNumPoints() - 1;
201
+ if ((segIndex0 === 0 && segIndex1 === maxSegIndex) ||
202
+ (segIndex1 === 0 && segIndex0 === maxSegIndex)) {
203
+ return true;
204
+ }
205
+ }
206
+ }
207
+ }
208
+ return false;
209
+ };
210
+
211
+
212
+ /**
213
+ * This method is called by clients of the EdgeIntersector class to test for
214
+ * and add intersections for two segments of the edges being intersected. Note
215
+ * that clients (such as MonotoneChainEdges) may choose not to intersect
216
+ * certain pairs of segments for efficiency reasons.
217
+ *
218
+ * @param {Edge}
219
+ * e0
220
+ * @param {int}
221
+ * segIndex0
222
+ * @param {Edge}
223
+ * e1
224
+ * @param {int}
225
+ * segIndex1
226
+ */
227
+ jsts.geomgraph.index.SegmentIntersector.prototype.addIntersections = function(e0, segIndex0, e1,
228
+ segIndex1) {
229
+ if (e0 === e1 && segIndex0 === segIndex1)
230
+ return;
231
+ this.numTests++;
232
+ var p00 = e0.getCoordinates()[segIndex0];
233
+ var p01 = e0.getCoordinates()[segIndex0 + 1];
234
+ var p10 = e1.getCoordinates()[segIndex1];
235
+ var p11 = e1.getCoordinates()[segIndex1 + 1];
236
+
237
+ this.li.computeIntersection(p00, p01, p10, p11);
238
+ /**
239
+ * Always record any non-proper intersections. If includeProper is true,
240
+ * record any proper intersections as well.
241
+ */
242
+ if (this.li.hasIntersection()) {
243
+ if (this.recordIsolated) {
244
+ e0.setIsolated(false);
245
+ e1.setIsolated(false);
246
+ }
247
+ this.numIntersections++;
248
+ // if the segments are adjacent they have at least one trivial
249
+ // intersection,
250
+ // the shared endpoint. Don't bother adding it if it is the
251
+ // only intersection.
252
+ if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
253
+ this._hasIntersection = true;
254
+ if (this.includeProper || !this.li.isProper()) {
255
+ e0.addIntersections(this.li, segIndex0, 0);
256
+ e1.addIntersections(this.li, segIndex1, 1);
257
+ }
258
+ if (this.li.isProper()) {
259
+ this.properIntersectionPoint = this.li.getIntersection(0).clone();
260
+ this.hasProper = true;
261
+ if (!this.isBoundaryPoint(this.li, this.bdyNodes))
262
+ this.hasProperInterior = true;
263
+ }
264
+ }
265
+ }
266
+ };
267
+
268
+
269
+ /**
270
+ * @param {LineIntersector}
271
+ * li
272
+ * @param {Array.<javascript.util.Collection>|javascript.util.Collection}
273
+ * bdyNodes
274
+ * @return {boolean}
275
+ * @private
276
+ */
277
+ jsts.geomgraph.index.SegmentIntersector.prototype.isBoundaryPoint = function(li, bdyNodes) {
278
+ if (bdyNodes === null)
279
+ return false;
280
+
281
+ if (bdyNodes instanceof Array) {
282
+ if (this.isBoundaryPoint(li, bdyNodes[0]))
283
+ return true;
284
+ if (this.isBoundaryPoint(li, bdyNodes[1]))
285
+ return true;
286
+ return false;
287
+ } else {
288
+ for (var i = bdyNodes.iterator(); i.hasNext();) {
289
+ var node = i.next();
290
+ var pt = node.getCoordinate();
291
+ if (li.isIntersection(pt))
292
+ return true;
293
+ }
294
+ return false;
295
+ }
296
+ };
297
+
298
+ })();
@@ -0,0 +1,107 @@
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/geomgraph/index/EdgeSetIntersector.js
9
+ */
10
+
11
+
12
+
13
+ /**
14
+ * Finds all intersections in one or two sets of edges, using the
15
+ * straightforward method of comparing all segments. This algorithm is too slow
16
+ * for production use, but is useful for testing purposes.
17
+ *
18
+ * @constructor
19
+ */
20
+ jsts.geomgraph.index.SimpleEdgeSetIntersector = function() {
21
+
22
+ };
23
+
24
+ jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype = new jsts.geomgraph.index.EdgeSetIntersector();
25
+
26
+
27
+ /**
28
+ * statistics information
29
+ *
30
+ * @type {int}
31
+ */
32
+ jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.nOverlaps = 0;
33
+
34
+
35
+ /**
36
+ * @param {javascript.util.List}
37
+ * edges
38
+ * @param {SegmentIntersector}
39
+ * si
40
+ * @param {boolean}
41
+ * testAllSegments
42
+ */
43
+ jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.computeIntersections = function(
44
+ edges, si, testAllSegments) {
45
+
46
+ if (si instanceof javascript.util.List) {
47
+ this.computeIntersections2.apply(this, arguments);
48
+ return;
49
+ }
50
+
51
+ this.nOverlaps = 0;
52
+
53
+ for (var i0 = edges.iterator(); i0.hasNext(); ) {
54
+ var edge0 = i0.next();
55
+ for (var i1 = edges.iterator(); i1.hasNext(); ) {
56
+ var edge1 = i1.next();
57
+ if (testAllSegments || edge0 != edge1)
58
+ this.computeIntersects(edge0, edge1, si);
59
+ }
60
+ }
61
+ };
62
+
63
+
64
+ /**
65
+ * @param {javascript.util.List}
66
+ * edges0
67
+ * @param {javascript.util.List}
68
+ * edges1
69
+ * @param {SegmentIntersector}
70
+ * si
71
+ */
72
+ jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.computeIntersections2 = function(
73
+ edges0, edges1, si) {
74
+ this.nOverlaps = 0;
75
+
76
+ for (var i0 = edges0.iterator(); i0.hasNext(); ) {
77
+ var edge0 = i0.next();
78
+ for (var i1 = edges1.iterator(); i1.hasNext(); ) {
79
+ var edge1 = i1.next();
80
+ this.computeIntersects(edge0, edge1, si);
81
+ }
82
+ }
83
+ };
84
+
85
+
86
+ /**
87
+ * Performs a brute-force comparison of every segment in each Edge. This has n^2
88
+ * performance, and is about 100 times slower than using monotone chains.
89
+ *
90
+ * @param {Edge}
91
+ * e0
92
+ * @param {Edge}
93
+ * e1
94
+ * @param {SegmentIntersector}
95
+ * si
96
+ */
97
+ jsts.geomgraph.index.SimpleEdgeSetIntersector.prototype.computeIntersects = function(
98
+ e0, e1, si) {
99
+ var pts0 = e0.getCoordinates();
100
+ var pts1 = e1.getCoordinates();
101
+ var i0, i1;
102
+ for (i0 = 0; i0 < pts0.length - 1; i0++) {
103
+ for (i1 = 0; i1 < pts1.length - 1; i1++) {
104
+ si.addIntersections(e0, i0, e1, i1);
105
+ }
106
+ }
107
+ };