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,291 @@
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/GraphComponent.js
9
+ */
10
+
11
+
12
+
13
+ /**
14
+ * @param {Coordinate[]}
15
+ * pts
16
+ * @param {Label}
17
+ * label
18
+ * @augments jsts.geomgraph.GraphComponent
19
+ * @constructor
20
+ */
21
+ jsts.geomgraph.Edge = function(pts, label) {
22
+ this.pts = pts;
23
+ this.label = label;
24
+ this.eiList = new jsts.geomgraph.EdgeIntersectionList(this);
25
+ this.depth = new jsts.geomgraph.Depth();
26
+ };
27
+
28
+ jsts.geomgraph.Edge.prototype = new jsts.geomgraph.GraphComponent();
29
+ jsts.geomgraph.Edge.constructor = jsts.geomgraph.Edge;
30
+
31
+ /**
32
+ * Updates an IM from the label for an edge. Handles edges from both L and A
33
+ * geometries.
34
+ */
35
+ jsts.geomgraph.Edge.updateIM = function(label, im) {
36
+ im.setAtLeastIfValid(label.getLocation(0, jsts.geomgraph.Position.ON), label
37
+ .getLocation(1, jsts.geomgraph.Position.ON), 1);
38
+ if (label.isArea()) {
39
+ im.setAtLeastIfValid(label.getLocation(0, jsts.geomgraph.Position.LEFT),
40
+ label.getLocation(1, jsts.geomgraph.Position.LEFT), 2);
41
+ im.setAtLeastIfValid(label.getLocation(0, jsts.geomgraph.Position.RIGHT),
42
+ label.getLocation(1, jsts.geomgraph.Position.RIGHT), 2);
43
+ }
44
+ };
45
+
46
+
47
+ /**
48
+ * @private
49
+ */
50
+ jsts.geomgraph.Edge.prototype.pts = null;
51
+
52
+
53
+ /**
54
+ * @private
55
+ */
56
+ jsts.geomgraph.Edge.prototype.env = null;
57
+
58
+
59
+ /**
60
+ * @private
61
+ */
62
+ jsts.geomgraph.Edge.prototype.name = null;
63
+
64
+
65
+ /**
66
+ * @type {MonotoneChainEdge}
67
+ * @private
68
+ */
69
+ jsts.geomgraph.Edge.prototype.mce = null;
70
+
71
+
72
+ /**
73
+ * @private
74
+ */
75
+ jsts.geomgraph.Edge.prototype._isIsolated = true;
76
+
77
+
78
+ /**
79
+ * @type {Depth}
80
+ * @private
81
+ */
82
+ jsts.geomgraph.Edge.prototype.depth = null;
83
+
84
+
85
+ /**
86
+ * // the change in area depth from the R to L side of this edge
87
+ */
88
+ jsts.geomgraph.Edge.prototype.depthDelta = 0;
89
+
90
+
91
+ /**
92
+ * @type {jsts.geomgraph.EdgeIntersectionList}
93
+ * @private
94
+ */
95
+ jsts.geomgraph.Edge.prototype.eiList = null;
96
+
97
+
98
+ /**
99
+ * @return {int}
100
+ */
101
+ jsts.geomgraph.Edge.prototype.getNumPoints = function() {
102
+ return this.pts.length;
103
+ };
104
+
105
+
106
+ jsts.geomgraph.Edge.prototype.getEnvelope = function() {
107
+ // compute envelope lazily
108
+ if (this.env === null) {
109
+ this.env = new jsts.geom.Envelope();
110
+ for (var i = 0; i < this.pts.length; i++) {
111
+ this.env.expandToInclude(pts[i]);
112
+ }
113
+ }
114
+ return env;
115
+ };
116
+
117
+ jsts.geomgraph.Edge.prototype.getDepth = function() {
118
+ return this.depth;
119
+ };
120
+
121
+ /**
122
+ * The depthDelta is the change in depth as an edge is crossed from R to L
123
+ *
124
+ * @return the change in depth as the edge is crossed from R to L.
125
+ */
126
+ jsts.geomgraph.Edge.prototype.getDepthDelta = function() {
127
+ return this.depthDelta;
128
+ };
129
+ jsts.geomgraph.Edge.prototype.setDepthDelta = function(depthDelta) {
130
+ this.depthDelta = depthDelta;
131
+ };
132
+
133
+ /**
134
+ * @return {Coordinate[]}
135
+ */
136
+ jsts.geomgraph.Edge.prototype.getCoordinates = function() {
137
+ return this.pts;
138
+ };
139
+
140
+
141
+ /**
142
+ * @param {int}
143
+ * i
144
+ * @return {Coordinate}
145
+ */
146
+ jsts.geomgraph.Edge.prototype.getCoordinate = function(i) {
147
+ if (i === undefined) {
148
+ if (this.pts.length > 0) {
149
+ return this.pts[0];
150
+ } else {
151
+ return null;
152
+ }
153
+ }
154
+
155
+ return this.pts[i];
156
+ };
157
+
158
+
159
+ /**
160
+ * @return {boolean}
161
+ */
162
+ jsts.geomgraph.Edge.prototype.isClosed = function() {
163
+ return this.pts[0].equals(this.pts[this.pts.length - 1]);
164
+ };
165
+
166
+
167
+ jsts.geomgraph.Edge.prototype.setIsolated = function(isIsolated) {
168
+ this._isIsolated = isIsolated;
169
+ };
170
+ jsts.geomgraph.Edge.prototype.isIsolated = function() {
171
+ return this._isIsolated;
172
+ };
173
+
174
+
175
+ /**
176
+ * Adds EdgeIntersections for one or both intersections found for a segment of
177
+ * an edge to the edge intersection list.
178
+ *
179
+ * @param {LineIntersector}
180
+ * li
181
+ * @param {int}
182
+ * segmentIndex
183
+ * @param {int}
184
+ * geomIndex
185
+ */
186
+ jsts.geomgraph.Edge.prototype.addIntersections = function(li, segmentIndex,
187
+ geomIndex) {
188
+ for (var i = 0; i < li.getIntersectionNum(); i++) {
189
+ this.addIntersection(li, segmentIndex, geomIndex, i);
190
+ }
191
+ };
192
+
193
+
194
+ /**
195
+ * Add an EdgeIntersection for intersection intIndex. An intersection that falls
196
+ * exactly on a vertex of the edge is normalized to use the higher of the two
197
+ * possible segmentIndexes
198
+ *
199
+ * @param {LineIntersector}
200
+ * li
201
+ * @param {int}
202
+ * segmentIndex
203
+ * @param {int}
204
+ * geomIndex
205
+ * @param {int}
206
+ * intIndex
207
+ */
208
+ jsts.geomgraph.Edge.prototype.addIntersection = function(li, segmentIndex,
209
+ geomIndex, intIndex) {
210
+ var intPt = new jsts.geom.Coordinate(li.getIntersection(intIndex));
211
+ var normalizedSegmentIndex = segmentIndex;
212
+ var dist = li.getEdgeDistance(geomIndex, intIndex);
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
+ normalizedSegmentIndex = nextSegIndex;
222
+ dist = 0.0;
223
+ }
224
+ }
225
+ /**
226
+ * Add the intersection point to edge intersection list.
227
+ */
228
+ var ei = this.eiList.add(intPt, normalizedSegmentIndex, dist);
229
+ };
230
+
231
+
232
+ /**
233
+ * @return {int}
234
+ */
235
+ jsts.geomgraph.Edge.prototype.getMaximumSegmentIndex = function() {
236
+ return this.pts.length - 1;
237
+ };
238
+
239
+ jsts.geomgraph.Edge.prototype.getEdgeIntersectionList = function() {
240
+ return this.eiList;
241
+ };
242
+
243
+ jsts.geomgraph.Edge.prototype.isClosed = function()
244
+ {
245
+ return this.pts[0].equals(this.pts[this.pts.length - 1]);
246
+ };
247
+ /**
248
+ * An Edge is collapsed if it is an Area edge and it consists of
249
+ * two segments which are equal and opposite (eg a zero-width V).
250
+ */
251
+ jsts.geomgraph.Edge.prototype.isCollapsed = function()
252
+ {
253
+ if (! this.label.isArea()) return false;
254
+ if (this.pts.length != 3) return false;
255
+ if (this.pts[0].equals(this.pts[2])) return true;
256
+ return false;
257
+ };
258
+ jsts.geomgraph.Edge.prototype.getCollapsedEdge = function()
259
+ {
260
+ var newPts = [];
261
+ newPts[0] = this.pts[0];
262
+ newPts[1] = this.pts[1];
263
+ var newe = new jsts.geomgraph.Edge(newPts, jsts.geomgraph.Label.toLineLabel(this.label));
264
+ return newe;
265
+ };
266
+
267
+
268
+ /**
269
+ * Update the IM with the contribution for this component. A component only
270
+ * contributes if it has a labelling for both parent geometries
271
+ */
272
+ jsts.geomgraph.Edge.prototype.computeIM = function(im) {
273
+ jsts.geomgraph.Edge.updateIM(this.label, im);
274
+ };
275
+
276
+ /**
277
+ * @return true if the coordinate sequences of the Edges are identical.
278
+ */
279
+ jsts.geomgraph.Edge.prototype.isPointwiseEqual = function(e)
280
+ {
281
+ if (this.pts.length != e.pts.length) return false;
282
+
283
+ for (var i = 0; i < this.pts.length; i++) {
284
+ if (! this.pts[i].equals2D(e.pts[i])) {
285
+ return false;
286
+ }
287
+ }
288
+ return true;
289
+ };
290
+
291
+ // TODO: port rest..
@@ -0,0 +1,188 @@
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/util/Assert.js
11
+ */
12
+
13
+ var Assert = jsts.util.Assert;
14
+
15
+ /**
16
+ * Models the end of an edge incident on a node. EdgeEnds have a direction
17
+ * determined by the direction of the ray from the initial point to the next
18
+ * point. EdgeEnds are comparable under the ordering "a has a greater angle
19
+ * with the x-axis than b". This ordering is used to sort EdgeEnds around a
20
+ * node.
21
+ *
22
+ * @param {Edge}
23
+ * edge
24
+ * @param {Coordinate}
25
+ * p0
26
+ * @param {Coordinate}
27
+ * p1
28
+ * @param {Label}
29
+ * label
30
+ * @constructor
31
+ */
32
+ jsts.geomgraph.EdgeEnd = function(edge, p0, p1, label) {
33
+ this.edge = edge;
34
+ if (p0 && p1) {
35
+ this.init(p0, p1);
36
+ }
37
+ if (label) {
38
+ this.label = label || null;
39
+ }
40
+ };
41
+
42
+ /**
43
+ * the parent edge of this edge end
44
+ *
45
+ * @type {Edge}
46
+ * @protected
47
+ */
48
+ jsts.geomgraph.EdgeEnd.prototype.edge = null;
49
+
50
+
51
+ /**
52
+ * @type {Label}
53
+ * @protected
54
+ */
55
+ jsts.geomgraph.EdgeEnd.prototype.label = null;
56
+
57
+
58
+ /**
59
+ * the node this edge end originates at
60
+ *
61
+ * @type {Node}
62
+ * @private
63
+ */
64
+ jsts.geomgraph.EdgeEnd.prototype.node = null;
65
+
66
+
67
+ /**
68
+ * points of initial line segment
69
+ *
70
+ * @type {Coordinate}
71
+ * @private
72
+ */
73
+ jsts.geomgraph.EdgeEnd.prototype.p0 = null;
74
+ jsts.geomgraph.EdgeEnd.prototype.p1 = null;
75
+
76
+
77
+ /**
78
+ * the direction vector for this edge from its starting point
79
+ *
80
+ * @type {double}
81
+ * @private
82
+ */
83
+ jsts.geomgraph.EdgeEnd.prototype.dx = null;
84
+ jsts.geomgraph.EdgeEnd.prototype.dy = null;
85
+
86
+
87
+ /**
88
+ * @type {int}
89
+ * @private
90
+ */
91
+ jsts.geomgraph.EdgeEnd.prototype.quadrant = null;
92
+
93
+
94
+ /**
95
+ * @param {Coordinate}
96
+ * p0
97
+ * @param {Coordinate}
98
+ * p1
99
+ * @protected
100
+ */
101
+ jsts.geomgraph.EdgeEnd.prototype.init = function(p0, p1) {
102
+ this.p0 = p0;
103
+ this.p1 = p1;
104
+ this.dx = p1.x - p0.x;
105
+ this.dy = p1.y - p0.y;
106
+ this.quadrant = jsts.geomgraph.Quadrant.quadrant(this.dx, this.dy);
107
+ Assert.isTrue(!(this.dx === 0 && this.dy === 0),
108
+ 'EdgeEnd with identical endpoints found');
109
+ };
110
+
111
+ jsts.geomgraph.EdgeEnd.prototype.getEdge = function() {
112
+ return this.edge;
113
+ };
114
+
115
+ jsts.geomgraph.EdgeEnd.prototype.getLabel = function() {
116
+ return this.label;
117
+ };
118
+
119
+ jsts.geomgraph.EdgeEnd.prototype.getCoordinate = function() {
120
+ return this.p0;
121
+ };
122
+
123
+ jsts.geomgraph.EdgeEnd.prototype.getDirectedCoordinate = function() {
124
+ return this.p1;
125
+ };
126
+
127
+ jsts.geomgraph.EdgeEnd.prototype.getQuadrant = function() {
128
+ return this.quadrant;
129
+ };
130
+
131
+ jsts.geomgraph.EdgeEnd.prototype.getDx = function() {
132
+ return this.dx;
133
+ };
134
+
135
+ jsts.geomgraph.EdgeEnd.prototype.getDy = function() {
136
+ return this.dy;
137
+ };
138
+
139
+
140
+ jsts.geomgraph.EdgeEnd.prototype.setNode = function(node) {
141
+ this.node = node;
142
+ };
143
+
144
+ jsts.geomgraph.EdgeEnd.prototype.getNode = function() {
145
+ return this.node;
146
+ };
147
+
148
+ jsts.geomgraph.EdgeEnd.prototype.compareTo = function(e) {
149
+ return this.compareDirection(e);
150
+ };
151
+
152
+
153
+ /**
154
+ * Implements the total order relation:
155
+ * <p>
156
+ * a has a greater angle with the positive x-axis than b
157
+ * <p>
158
+ * Using the obvious algorithm of simply computing the angle is not robust,
159
+ * since the angle calculation is obviously susceptible to roundoff. A robust
160
+ * algorithm is: - first compare the quadrant. If the quadrants are different,
161
+ * it it trivial to determine which vector is "greater". - if the vectors lie
162
+ * in the same quadrant, the computeOrientation function can be used to decide
163
+ * the relative orientation of the vectors.
164
+ *
165
+ * @param {EdgeEnd}
166
+ * e
167
+ * @return {number}
168
+ */
169
+ jsts.geomgraph.EdgeEnd.prototype.compareDirection = function(e) {
170
+ if (this.dx === e.dx && this.dy === e.dy)
171
+ return 0;
172
+ // if the rays are in different quadrants, determining the ordering is
173
+ // trivial
174
+ if (this.quadrant > e.quadrant)
175
+ return 1;
176
+ if (this.quadrant < e.quadrant)
177
+ return -1;
178
+ // vectors are in the same quadrant - check relative orientation of
179
+ // direction vectors
180
+ // this is > e if it is CCW of e
181
+ return jsts.algorithm.CGAlgorithms.computeOrientation(e.p0, e.p1, this.p1);
182
+ };
183
+
184
+ jsts.geomgraph.EdgeEnd.prototype.computeLabel = function(boundaryNodeRule) {
185
+ // subclasses should override this if they are using labels
186
+ };
187
+
188
+ })();