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,235 @@
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: /jts/jts/java/src/com/vividsolutions/jts/noding/NodedSegmentString.java
9
+ * Revision: 478
10
+ */
11
+
12
+ /**
13
+ * @requires jsts/noding/NodableSegmentString.js
14
+ */
15
+
16
+ /**
17
+ * Represents a list of contiguous line segments, and supports noding the
18
+ * segments. The line segments are represented by an array of {@link Coordinate}s.
19
+ * Intended to optimize the noding of contiguous segments by reducing the number
20
+ * of allocated objects. SegmentStrings can carry a context object, which is
21
+ * useful for preserving topological or parentage information. All noded
22
+ * substrings are initialized with the same context object.
23
+ *
24
+ * Creates a new segment string from a list of vertices.
25
+ *
26
+ * @param pts
27
+ * the vertices of the segment string.
28
+ * @param data
29
+ * the user-defined data of this segment string (may be null).
30
+ *
31
+ * @constructor
32
+ */
33
+ jsts.noding.NodedSegmentString = function(pts, data) {
34
+ this.nodeList = new jsts.noding.SegmentNodeList(this);
35
+
36
+ this.pts = pts;
37
+ this.data = data;
38
+ };
39
+ jsts.noding.NodedSegmentString.prototype = new jsts.noding.NodableSegmentString();
40
+ jsts.noding.NodedSegmentString.constructor = jsts.noding.NodedSegmentString;
41
+
42
+
43
+ /**
44
+ * Gets the {@link SegmentString}s which result from splitting this string at node points.
45
+ *
46
+ * @param {javascript.util.Collection}
47
+ * segStrings a Collection of NodedSegmentStrings.
48
+ * @param {javascript.util.Collection} resultEdgelist
49
+ * a List which will collect the NodedSegmentStrings representing the
50
+ * substrings.
51
+ * @return {Array} a Collection of NodedSegmentStrings representing the
52
+ * substrings.
53
+ */
54
+ jsts.noding.NodedSegmentString.getNodedSubstrings = function(segStrings) {
55
+ if (arguments.length === 2) {
56
+ jsts.noding.NodedSegmentString.getNodedSubstrings2.apply(this, arguments);
57
+ return;
58
+ }
59
+
60
+ var resultEdgelist = new javascript.util.ArrayList();
61
+ jsts.noding.NodedSegmentString.getNodedSubstrings2(segStrings, resultEdgelist);
62
+ return resultEdgelist;
63
+ };
64
+
65
+
66
+ /**
67
+ * Adds the noded {@link SegmentString}s which result from splitting this string at node points.
68
+ *
69
+ * @param {javascript.util.Collection} segStrings
70
+ * a Collection of NodedSegmentStrings.
71
+ * @param {javascript.util.Collection} resultEdgelist
72
+ * a List which will collect the NodedSegmentStrings representing the
73
+ * substrings.
74
+ */
75
+ jsts.noding.NodedSegmentString.getNodedSubstrings2 = function(segStrings,
76
+ resultEdgelist) {
77
+ for (var i = segStrings.iterator(); i.hasNext(); ) {
78
+ var ss = i.next();
79
+ ss.getNodeList().addSplitEdges(resultEdgelist);
80
+ }
81
+ };
82
+
83
+
84
+ /**
85
+ * @type {jsts.noding.SegmentNodeList}
86
+ * @private
87
+ */
88
+ jsts.noding.NodedSegmentString.prototype.nodeList = null;
89
+
90
+
91
+ /**
92
+ * @type {Array.<jsts.geom.Coordinate>}
93
+ * @private
94
+ */
95
+ jsts.noding.NodedSegmentString.prototype.pts = null;
96
+
97
+
98
+ /**
99
+ * @type {Object}
100
+ * @private
101
+ */
102
+ jsts.noding.NodedSegmentString.prototype.data = null;
103
+
104
+
105
+ jsts.noding.NodedSegmentString.prototype.getData = function() {
106
+ return this.data;
107
+ };
108
+ jsts.noding.NodedSegmentString.prototype.setData = function(data) {
109
+ this.data = data;
110
+ };
111
+ jsts.noding.NodedSegmentString.prototype.getNodeList = function() {
112
+ return this.nodeList;
113
+ };
114
+ jsts.noding.NodedSegmentString.prototype.size = function() {
115
+ return this.pts.length;
116
+ };
117
+ jsts.noding.NodedSegmentString.prototype.getCoordinate = function(i) {
118
+ return this.pts[i];
119
+ };
120
+ jsts.noding.NodedSegmentString.prototype.getCoordinates = function() {
121
+ return this.pts;
122
+ };
123
+
124
+ jsts.noding.NodedSegmentString.prototype.isClosed = function() {
125
+ return this.pts[0].equals(this.pts[this.pts.length - 1]);
126
+ };
127
+
128
+
129
+ /**
130
+ * Gets the octant of the segment starting at vertex <code>index</code>.
131
+ *
132
+ * @param index
133
+ * the index of the vertex starting the segment. Must not be the last
134
+ * index in the vertex list.
135
+ * @return the octant of the segment at the vertex.
136
+ */
137
+ jsts.noding.NodedSegmentString.prototype.getSegmentOctant = function(index) {
138
+ if (index === this.pts.length - 1)
139
+ return -1;
140
+ return this.safeOctant(this.getCoordinate(index), this.getCoordinate(index + 1));
141
+ };
142
+
143
+
144
+ /**
145
+ * @private
146
+ */
147
+ jsts.noding.NodedSegmentString.prototype.safeOctant = function(p0, p1) {
148
+ if (p0.equals2D(p1))
149
+ return 0;
150
+ return jsts.noding.Octant.octant(p0, p1);
151
+ };
152
+
153
+
154
+ /**
155
+ * Adds EdgeIntersections for one or both intersections found for a segment of
156
+ * an edge to the edge intersection list.
157
+ */
158
+ jsts.noding.NodedSegmentString.prototype.addIntersections = function(li,
159
+ segmentIndex, geomIndex) {
160
+ for (var i = 0; i < li.getIntersectionNum(); i++) {
161
+ this.addIntersection(li, segmentIndex, geomIndex, i);
162
+ }
163
+ };
164
+
165
+
166
+ /**
167
+ * Add an SegmentNode for intersection intIndex. An intersection that falls
168
+ * exactly on a vertex of the SegmentString is normalized to use the higher of
169
+ * the two possible segmentIndexes
170
+ */
171
+ jsts.noding.NodedSegmentString.prototype.addIntersection = function(li,
172
+ segmentIndex, geomIndex, intIndex) {
173
+
174
+ if (li instanceof jsts.geom.Coordinate) {
175
+ this.addIntersection2.apply(this, arguments);
176
+ return;
177
+ }
178
+
179
+ var intPt = new jsts.geom.Coordinate(li.getIntersection(intIndex));
180
+ this.addIntersection2(intPt, segmentIndex);
181
+ };
182
+
183
+
184
+ /**
185
+ * Adds an intersection node for a given point and segment to this segment
186
+ * string.
187
+ *
188
+ * @param {jsts.geom.Coordinate} intPt
189
+ * the location of the intersection.
190
+ * @param segmentIndex
191
+ * the index of the segment containing the intersection.
192
+ */
193
+ jsts.noding.NodedSegmentString.prototype.addIntersection2 = function(intPt,
194
+ segmentIndex) {
195
+ this.addIntersectionNode(intPt, segmentIndex);
196
+ };
197
+
198
+
199
+ /**
200
+ * Adds an intersection node for a given point and segment to this segment
201
+ * string. If an intersection already exists for this exact location, the
202
+ * existing node will be returned.
203
+ *
204
+ * @param {jsts.geom.Coordinate} intPt
205
+ * the location of the intersection.
206
+ * @param segmentIndex
207
+ * the index of the segment containing the intersection.
208
+ * @return {SegmentNode} the intersection node for the point.
209
+ */
210
+ jsts.noding.NodedSegmentString.prototype.addIntersectionNode = function(intPt,
211
+ segmentIndex) {
212
+ var normalizedSegmentIndex = segmentIndex;
213
+ // normalize the intersection point location
214
+ var nextSegIndex = normalizedSegmentIndex + 1;
215
+ if (nextSegIndex < this.pts.length) {
216
+ var nextPt = this.pts[nextSegIndex];
217
+
218
+ // Normalize segment index if intPt falls on vertex
219
+ // The check for point equality is 2D only - Z values are ignored
220
+ if (intPt.equals2D(nextPt)) {
221
+ // Debug.println("normalized distance");
222
+ normalizedSegmentIndex = nextSegIndex;
223
+ }
224
+ }
225
+ /**
226
+ * Add the intersection point to edge intersection list.
227
+ */
228
+ var ei = this.nodeList.add(intPt, normalizedSegmentIndex);
229
+ return ei;
230
+ };
231
+
232
+ jsts.noding.NodedSegmentString.prototype.toString = function() {
233
+ var geometryFactory = new jsts.geom.GeometryFactory();
234
+ return new jsts.io.WKTWriter().write(geometryFactory.createLineString(this.pts));
235
+ };
@@ -0,0 +1,41 @@
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
+ * Computes all intersections between segments in a set of
11
+ * {@link SegmentString}s. Intersections found are represented as
12
+ * {@link SegmentNode}s and added to the {@link SegmentString}s in which
13
+ * they occur. As a final step in the noding a new set of segment strings
14
+ * split at the nodes may be returned.
15
+ *
16
+ * @interface
17
+ */
18
+ jsts.noding.Noder = function() {
19
+
20
+ };
21
+
22
+
23
+ /**
24
+ * Computes the noding for a collection of {@link SegmentString}s. Some
25
+ * Noders may add all these nodes to the input SegmentStrings; others may only
26
+ * add some or none at all.
27
+ *
28
+ * @param {Array}
29
+ * segStrings a collection of {@link SegmentString}s to node.
30
+ */
31
+ jsts.noding.Noder.prototype.computeNodes = jsts.abstractFunc;
32
+
33
+ /**
34
+ * Returns a {@link Collection} of fully noded {@link SegmentString}s. The
35
+ * SegmentStrings have the same context as their parent.
36
+ *
37
+ * @return {Array} a Collection of SegmentStrings.
38
+ */
39
+ jsts.noding.Noder.prototype.getNodedSubstrings = jsts.abstractFunc;
40
+
41
+ })();
@@ -0,0 +1,5 @@
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
+ */
@@ -0,0 +1,84 @@
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
+ * Methods for computing and working with octants of the Cartesian plane
11
+ * Octants are numbered as follows:
12
+ * <pre>
13
+ * \2|1/
14
+ * 3 \|/ 0
15
+ * ---+--
16
+ * 4 /|\ 7
17
+ * /5|6\
18
+ * <pre>
19
+ * If line segments lie along a coordinate axis, the octant is the lower of the two
20
+ * possible values.
21
+ *
22
+ * @constructor
23
+ */
24
+ jsts.noding.Octant = function() {
25
+ throw jsts.error.AbstractMethodInvocationError();
26
+ };
27
+
28
+
29
+ /**
30
+ * Returns the octant of a directed line segment (specified as x and y
31
+ * displacements, which cannot both be 0).
32
+ */
33
+ jsts.noding.Octant.octant = function(dx, dy) {
34
+ if (dx instanceof jsts.geom.Coordinate) {
35
+ return jsts.noding.Octant.octant2.apply(this, arguments);
36
+ }
37
+
38
+ if (dx === 0.0 && dy === 0.0)
39
+ throw new jsts.error.IllegalArgumentError('Cannot compute the octant for point ( ' + dx + ', ' + dy + ' )');
40
+
41
+ var adx = Math.abs(dx);
42
+ var ady = Math.abs(dy);
43
+
44
+ if (dx >= 0) {
45
+ if (dy >= 0) {
46
+ if (adx >= ady)
47
+ return 0;
48
+ else
49
+ return 1;
50
+ }
51
+ else { // dy < 0
52
+ if (adx >= ady)
53
+ return 7;
54
+ else
55
+ return 6;
56
+ }
57
+ }
58
+ else { // dx < 0
59
+ if (dy >= 0) {
60
+ if (adx >= ady)
61
+ return 3;
62
+ else
63
+ return 2;
64
+ }
65
+ else { // dy < 0
66
+ if (adx >= ady)
67
+ return 4;
68
+ else
69
+ return 5;
70
+ }
71
+ }
72
+ };
73
+
74
+
75
+ /**
76
+ * Returns the octant of a directed line segment from p0 to p1.
77
+ */
78
+ jsts.noding.Octant.octant2 = function(p0, p1) {
79
+ var dx = p1.x - p0.x;
80
+ var dy = p1.y - p0.y;
81
+ if (dx === 0.0 && dy === 0.0)
82
+ throw new jsts.error.IllegalArgumentError('Cannot compute the octant for two identical points ' + p0);
83
+ return jsts.noding.Octant.octant(dx, dy);
84
+ };
@@ -0,0 +1,94 @@
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
+ * Allows comparing {@link Coordinate} arrays in an orientation-independent way.
10
+ *
11
+ * Creates a new {@link OrientedCoordinateArray} for the given
12
+ * {@link Coordinate} array.
13
+ *
14
+ * @param pts
15
+ * the coordinates to orient.
16
+ */
17
+ jsts.noding.OrientedCoordinateArray = function(pts) {
18
+ this.pts = pts;
19
+ this._orientation = jsts.noding.OrientedCoordinateArray.orientation(pts);
20
+ };
21
+
22
+
23
+ /**
24
+ * @type {Array.<Coordinate>}
25
+ * @private
26
+ */
27
+ jsts.noding.OrientedCoordinateArray.prototype.pts = null;
28
+
29
+
30
+ /**
31
+ * @type {boolean}
32
+ * @private
33
+ */
34
+ jsts.noding.OrientedCoordinateArray.prototype._orientation = undefined;
35
+
36
+
37
+ /**
38
+ * Computes the canonical orientation for a coordinate array.
39
+ *
40
+ * @param {Array.
41
+ * <Coordinate>} pts the array to test.
42
+ * @return <code>true</code> if the points are oriented forwards.
43
+ * @return <code>false</code if the points are oriented in reverse.
44
+ * @private
45
+ */
46
+ jsts.noding.OrientedCoordinateArray.orientation = function(pts) {
47
+ return jsts.geom.CoordinateArrays.increasingDirection(pts) === 1;
48
+ };
49
+
50
+ /**
51
+ * Compares two {@link OrientedCoordinateArray}s for their relative order
52
+ *
53
+ * @return -1 this one is smaller.
54
+ * @return 0 the two objects are equal.
55
+ * @return 1 this one is greater.
56
+ */
57
+
58
+ jsts.noding.OrientedCoordinateArray.prototype.compareTo = function(o1) {
59
+ var oca = o1;
60
+ var comp = jsts.noding.OrientedCoordinateArray.compareOriented(this.pts,
61
+ this._orientation, oca.pts, oca._orientation);
62
+ return comp;
63
+ };
64
+
65
+
66
+ /**
67
+ * @private
68
+ */
69
+ jsts.noding.OrientedCoordinateArray.compareOriented = function(pts1,
70
+ orientation1, pts2, orientation2) {
71
+ var dir1 = orientation1 ? 1 : -1;
72
+ var dir2 = orientation2 ? 1 : -1;
73
+ var limit1 = orientation1 ? pts1.length : -1;
74
+ var limit2 = orientation2 ? pts2.length : -1;
75
+
76
+ var i1 = orientation1 ? 0 : pts1.length - 1;
77
+ var i2 = orientation2 ? 0 : pts2.length - 1;
78
+ var comp = 0;
79
+ while (true) {
80
+ var compPt = pts1[i1].compareTo(pts2[i2]);
81
+ if (compPt !== 0)
82
+ return compPt;
83
+ i1 += dir1;
84
+ i2 += dir2;
85
+ var done1 = i1 === limit1;
86
+ var done2 = i2 === limit2;
87
+ if (done1 && !done2)
88
+ return -1;
89
+ if (!done1 && done2)
90
+ return 1;
91
+ if (done1 && done2)
92
+ return 0;
93
+ }
94
+ };