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,109 @@
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
+ * A dynamic list of the vertices in a constructed offset curve. Automatically
10
+ * removes adjacent vertices which are closer than a given tolerance.
11
+ * @constructor
12
+ */
13
+ jsts.operation.buffer.OffsetSegmentString = function() {
14
+ this.ptList = [];
15
+ };
16
+
17
+
18
+ /**
19
+ * @private
20
+ */
21
+ jsts.operation.buffer.OffsetSegmentString.prototype.ptList = null;
22
+
23
+
24
+ /**
25
+ * @private
26
+ */
27
+ jsts.operation.buffer.OffsetSegmentString.prototype.precisionModel = null;
28
+
29
+
30
+ /**
31
+ * The distance below which two adjacent points on the curve are considered to
32
+ * be coincident. This is chosen to be a small fraction of the offset distance.
33
+ *
34
+ * @private
35
+ */
36
+ jsts.operation.buffer.OffsetSegmentString.prototype.minimimVertexDistance = 0.0;
37
+
38
+
39
+ jsts.operation.buffer.OffsetSegmentString.prototype.setPrecisionModel = function(
40
+ precisionModel) {
41
+ this.precisionModel = precisionModel;
42
+ };
43
+
44
+ jsts.operation.buffer.OffsetSegmentString.prototype.setMinimumVertexDistance = function(
45
+ minimimVertexDistance) {
46
+ this.minimimVertexDistance = minimimVertexDistance;
47
+ };
48
+
49
+ jsts.operation.buffer.OffsetSegmentString.prototype.addPt = function(pt) {
50
+ var bufPt = new jsts.geom.Coordinate(pt);
51
+ this.precisionModel.makePrecise(bufPt);
52
+ // don't add duplicate (or near-duplicate) points
53
+ if (this.isRedundant(bufPt))
54
+ return;
55
+ this.ptList.push(bufPt);
56
+ };
57
+
58
+ jsts.operation.buffer.OffsetSegmentString.prototype.addPts = function(pt,
59
+ isForward) {
60
+ if (isForward) {
61
+ for (var i = 0; i < pt.length; i++) {
62
+ this.addPt(pt[i]);
63
+ }
64
+ } else {
65
+ for (var i = pt.length - 1; i >= 0; i--) {
66
+ this.addPt(pt[i]);
67
+ }
68
+ }
69
+ };
70
+
71
+
72
+ /**
73
+ * Tests whether the given point is redundant relative to the previous point in
74
+ * the list (up to tolerance).
75
+ *
76
+ * @param pt
77
+ * @return true if the point is redundant.
78
+ * @private
79
+ */
80
+ jsts.operation.buffer.OffsetSegmentString.prototype.isRedundant = function(pt) {
81
+ if (this.ptList.length < 1)
82
+ return false;
83
+ var lastPt = this.ptList[this.ptList.length - 1];
84
+ var ptDist = pt.distance(lastPt);
85
+ if (ptDist < this.minimimVertexDistance)
86
+ return true;
87
+ return false;
88
+ };
89
+
90
+ jsts.operation.buffer.OffsetSegmentString.prototype.closeRing = function() {
91
+ if (this.ptList.length < 1)
92
+ return;
93
+ var startPt = new jsts.geom.Coordinate(this.ptList[0]);
94
+ var lastPt = this.ptList[this.ptList.length - 1];
95
+ var last2Pt = null;
96
+ if (this.ptList.length >= 2)
97
+ last2Pt = this.ptList[this.ptList.length - 2];
98
+ if (startPt.equals(lastPt))
99
+ return;
100
+ this.ptList.push(startPt);
101
+ };
102
+
103
+ jsts.operation.buffer.OffsetSegmentString.prototype.reverse = function() {
104
+
105
+ };
106
+
107
+ jsts.operation.buffer.OffsetSegmentString.prototype.getCoordinates = function() {
108
+ return this.ptList;
109
+ };
@@ -0,0 +1,164 @@
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
+ * A RightmostEdgeFinder find the DirectedEdge in a list which has the highest
9
+ * coordinate, and which is oriented L to R at that point. (I.e. the right side
10
+ * is on the RHS of the edge.)
11
+ *
12
+ * @constructor
13
+ */
14
+ jsts.operation.buffer.RightmostEdgeFinder = function() {};
15
+ // private Coordinate extremeCoord;
16
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.minIndex = -1;
17
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.minCoord = null;
18
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.minDe = null;
19
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.orientedDe = null;
20
+
21
+
22
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.getEdge = function() {
23
+ return this.orientedDe;
24
+ };
25
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.getCoordinate = function() {
26
+ return this.minCoord;
27
+ };
28
+
29
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.findEdge = function(
30
+ dirEdgeList) {
31
+ /**
32
+ * Check all forward DirectedEdges only. This is still general, because each
33
+ * edge has a forward DirectedEdge.
34
+ */
35
+ for (var i = dirEdgeList.iterator(); i.hasNext();) {
36
+ var de = i.next();
37
+ if (!de.isForward())
38
+ continue;
39
+ this.checkForRightmostCoordinate(de);
40
+ }
41
+
42
+ /**
43
+ * If the rightmost point is a node, we need to identify which of the incident
44
+ * edges is rightmost.
45
+ */
46
+ jsts.util.Assert.isTrue(this.minIndex !== 0 ||
47
+ this.minCoord.equals(this.minDe.getCoordinate()),
48
+ 'inconsistency in rightmost processing');
49
+ if (this.minIndex === 0) {
50
+ this.findRightmostEdgeAtNode();
51
+ } else {
52
+ this.findRightmostEdgeAtVertex();
53
+ }
54
+ /**
55
+ * now check that the extreme side is the R side. If not, use the sym instead.
56
+ */
57
+ this.orientedDe = this.minDe;
58
+ var rightmostSide = this.getRightmostSide(this.minDe, this.minIndex);
59
+ if (rightmostSide == jsts.geomgraph.Position.LEFT) {
60
+ this.orientedDe = this.minDe.getSym();
61
+ }
62
+ };
63
+ /**
64
+ * @private
65
+ */
66
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.findRightmostEdgeAtNode = function() {
67
+ var node = this.minDe.getNode();
68
+ var star = node.getEdges();
69
+ this.minDe = star.getRightmostEdge();
70
+ // the DirectedEdge returned by the previous call is not
71
+ // necessarily in the forward direction. Use the sym edge if it isn't.
72
+ if (!this.minDe.isForward()) {
73
+ this.minDe = this.minDe.getSym();
74
+ this.minIndex = this.minDe.getEdge().getCoordinates().length - 1;
75
+ }
76
+ };
77
+ /**
78
+ * @private
79
+ */
80
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.findRightmostEdgeAtVertex = function() {
81
+ /**
82
+ * The rightmost point is an interior vertex, so it has a segment on either
83
+ * side of it. If these segments are both above or below the rightmost point,
84
+ * we need to determine their relative orientation to decide which is
85
+ * rightmost.
86
+ */
87
+ var pts = this.minDe.getEdge().getCoordinates();
88
+ jsts.util.Assert.isTrue(this.minIndex > 0 && this.minIndex < pts.length,
89
+ 'rightmost point expected to be interior vertex of edge');
90
+ var pPrev = pts[this.minIndex - 1];
91
+ var pNext = pts[this.minIndex + 1];
92
+ var orientation = jsts.algorithm.CGAlgorithms.computeOrientation(
93
+ this.minCoord, pNext, pPrev);
94
+ var usePrev = false;
95
+ // both segments are below min point
96
+ if (pPrev.y < this.minCoord.y && pNext.y < this.minCoord.y &&
97
+ orientation === jsts.algorithm.CGAlgorithms.COUNTERCLOCKWISE) {
98
+ usePrev = true;
99
+ } else if (pPrev.y > this.minCoord.y && pNext.y > this.minCoord.y &&
100
+ orientation === jsts.algorithm.CGAlgorithms.CLOCKWISE) {
101
+ usePrev = true;
102
+ }
103
+ // if both segments are on the same side, do nothing - either is safe
104
+ // to select as a rightmost segment
105
+ if (usePrev) {
106
+ this.minIndex = this.minIndex - 1;
107
+ }
108
+ };
109
+ /**
110
+ * @private
111
+ */
112
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.checkForRightmostCoordinate = function(
113
+ de) {
114
+ var coord = de.getEdge().getCoordinates();
115
+ for (var i = 0; i < coord.length - 1; i++) {
116
+ // only check vertices which are the start or end point of a non-horizontal
117
+ // segment
118
+ // <FIX> MD 19 Sep 03 - NO! we can test all vertices, since the rightmost
119
+ // must have a non-horiz segment adjacent to it
120
+ if (this.minCoord === null || coord[i].x > this.minCoord.x) {
121
+ this.minDe = de;
122
+ this.minIndex = i;
123
+ this.minCoord = coord[i];
124
+ }
125
+ // }
126
+ }
127
+ };
128
+ /**
129
+ * @private
130
+ */
131
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.getRightmostSide = function(
132
+ de, index) {
133
+ var side = this.getRightmostSideOfSegment(de, index);
134
+ if (side < 0)
135
+ side = this.getRightmostSideOfSegment(de, index - 1);
136
+ if (side < 0) {
137
+ // reaching here can indicate that segment is horizontal
138
+ // Assert.shouldNeverReachHere("problem with finding rightmost side of
139
+ // segment at " + de.getCoordinate());
140
+ // testing only
141
+ this.minCoord = null;
142
+ this.checkForRightmostCoordinate(de);
143
+ }
144
+ return side;
145
+ };
146
+
147
+ /**
148
+ * @private
149
+ */
150
+ jsts.operation.buffer.RightmostEdgeFinder.prototype.getRightmostSideOfSegment = function(
151
+ de, i) {
152
+ var e = de.getEdge();
153
+ var coord = e.getCoordinates();
154
+
155
+ if (i < 0 || i + 1 >= coord.length)
156
+ return -1;
157
+ if (coord[i].y == coord[i + 1].y)
158
+ return -1; // indicates edge is parallel to x-axis
159
+
160
+ var pos = jsts.geomgraph.Position.LEFT;
161
+ if (coord[i].y < coord[i + 1].y)
162
+ pos = jsts.geomgraph.Position.RIGHT;
163
+ return pos;
164
+ };
@@ -0,0 +1,220 @@
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
+ * Locates a subgraph inside a set of subgraphs, in order to determine the
9
+ * outside depth of the subgraph. The input subgraphs are assumed to have had
10
+ * depths already calculated for their edges.
11
+ *
12
+ * @constructor
13
+ */
14
+ jsts.operation.buffer.SubgraphDepthLocater = function(subgraphs) {
15
+ this.subgraphs = [];
16
+ this.seg = new jsts.geom.LineSegment();
17
+
18
+ this.subgraphs = subgraphs;
19
+ };
20
+
21
+ jsts.operation.buffer.SubgraphDepthLocater.prototype.subgraphs = null;
22
+ jsts.operation.buffer.SubgraphDepthLocater.prototype.seg = null;
23
+
24
+
25
+ jsts.operation.buffer.SubgraphDepthLocater.prototype.getDepth = function(p) {
26
+ var stabbedSegments = this.findStabbedSegments(p);
27
+ // if no segments on stabbing line subgraph must be outside all others.
28
+ if (stabbedSegments.length === 0)
29
+ return 0;
30
+ stabbedSegments.sort();
31
+ var ds = stabbedSegments[0];
32
+ return ds.leftDepth;
33
+ };
34
+
35
+ /**
36
+ * Finds all non-horizontal segments intersecting the stabbing line. The
37
+ * stabbing line is the ray to the right of stabbingRayLeftPt.
38
+ *
39
+ * @param stabbingRayLeftPt
40
+ * the left-hand origin of the stabbing line.
41
+ * @return a List of {@link DepthSegments} intersecting the stabbing line.
42
+ * @private
43
+ */
44
+ jsts.operation.buffer.SubgraphDepthLocater.prototype.findStabbedSegments = function(
45
+ stabbingRayLeftPt) {
46
+
47
+ if (arguments.length === 3) {
48
+ this.findStabbedSegments2.apply(this, arguments);
49
+ return;
50
+ }
51
+
52
+ var stabbedSegments = [];
53
+ for (var i = 0; i < this.subgraphs.length; i++) {
54
+ var bsg = this.subgraphs[i];
55
+
56
+ // optimization - don't bother checking subgraphs which the ray does not
57
+ // intersect
58
+ var env = bsg.getEnvelope();
59
+ if (stabbingRayLeftPt.y < env.getMinY() ||
60
+ stabbingRayLeftPt.y > env.getMaxY())
61
+ continue;
62
+
63
+ this.findStabbedSegments2(stabbingRayLeftPt, bsg.getDirectedEdges(),
64
+ stabbedSegments);
65
+ }
66
+ return stabbedSegments;
67
+ };
68
+
69
+ /**
70
+ * Finds all non-horizontal segments intersecting the stabbing line in the list
71
+ * of dirEdges. The stabbing line is the ray to the right of stabbingRayLeftPt.
72
+ *
73
+ * @param stabbingRayLeftPt
74
+ * the left-hand origin of the stabbing line.
75
+ * @param stabbedSegments
76
+ * the current list of {@link DepthSegments} intersecting the stabbing
77
+ * line.
78
+ * @private
79
+ */
80
+ jsts.operation.buffer.SubgraphDepthLocater.prototype.findStabbedSegments2 = function(
81
+ stabbingRayLeftPt, dirEdges, stabbedSegments) {
82
+
83
+ if (arguments[1] instanceof jsts.geomgraph.DirectedEdge) {
84
+ this.findStabbedSegments3(stabbingRayLeftPt, dirEdges, stabbedSegments);
85
+ return;
86
+ }
87
+
88
+ /**
89
+ * Check all forward DirectedEdges only. This is still general, because each
90
+ * Edge has a forward DirectedEdge.
91
+ */
92
+ for (var i = dirEdges.iterator(); i.hasNext();) {
93
+ var de = i.next();
94
+ if (! de.isForward())
95
+ continue;
96
+ this.findStabbedSegments3(stabbingRayLeftPt, de, stabbedSegments);
97
+ }
98
+ };
99
+
100
+ /**
101
+ * Finds all non-horizontal segments intersecting the stabbing line in the input
102
+ * dirEdge. The stabbing line is the ray to the right of stabbingRayLeftPt.
103
+ *
104
+ * @param stabbingRayLeftPt
105
+ * the left-hand origin of the stabbing line.
106
+ * @param stabbedSegments
107
+ * the current list of {@link DepthSegments} intersecting the stabbing
108
+ * line.
109
+ * @private
110
+ */
111
+ jsts.operation.buffer.SubgraphDepthLocater.prototype.findStabbedSegments3 = function(
112
+ stabbingRayLeftPt, dirEdge, stabbedSegments) {
113
+ var pts = dirEdge.getEdge().getCoordinates();
114
+ for (var i = 0; i < pts.length - 1; i++) {
115
+ this.seg.p0 = pts[i];
116
+ this.seg.p1 = pts[i + 1];
117
+ // ensure segment always points upwards
118
+ if (this.seg.p0.y > this.seg.p1.y)
119
+ this.seg.reverse();
120
+
121
+ // skip segment if it is left of the stabbing line
122
+ var maxx = Math.max(this.seg.p0.x, this.seg.p1.x);
123
+ if (maxx < stabbingRayLeftPt.x)
124
+ continue;
125
+
126
+ // skip horizontal segments (there will be a non-horizontal one carrying the
127
+ // same depth info
128
+ if (this.seg.isHorizontal())
129
+ continue;
130
+
131
+ // skip if segment is above or below stabbing line
132
+ if (stabbingRayLeftPt.y < this.seg.p0.y || stabbingRayLeftPt.y > this.seg.p1.y)
133
+ continue;
134
+
135
+ // skip if stabbing ray is right of the segment
136
+ if (jsts.algorithm.CGAlgorithms.computeOrientation(this.seg.p0, this.seg.p1,
137
+ stabbingRayLeftPt) === jsts.algorithm.CGAlgorithms.RIGHT)
138
+ continue;
139
+
140
+ // stabbing line cuts this segment, so record it
141
+ var depth = dirEdge.getDepth(jsts.geomgraph.Position.LEFT);
142
+ // if segment direction was flipped, use RHS depth instead
143
+ if (!this.seg.p0.equals(pts[i]))
144
+ depth = dirEdge.getDepth(jsts.geomgraph.Position.RIGHT);
145
+ var ds = new jsts.operation.buffer.SubgraphDepthLocater.DepthSegment(this.seg, depth);
146
+ stabbedSegments.push(ds);
147
+ }
148
+ };
149
+
150
+
151
+ /**
152
+ * A segment from a directed edge which has been assigned a depth value for its
153
+ * sides.
154
+ */
155
+ jsts.operation.buffer.SubgraphDepthLocater.DepthSegment = function(seg, depth) {
156
+ // input seg is assumed to be normalized
157
+ this.upwardSeg = new jsts.geom.LineSegment(seg);
158
+ // upwardSeg.normalize();
159
+ this.leftDepth = depth;
160
+ };
161
+ jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.upwardSeg = null;
162
+ jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.leftDepth = null;
163
+
164
+ /**
165
+ * Defines a comparision operation on DepthSegments which orders them left to
166
+ * right
167
+ *
168
+ * <pre>
169
+ * DS1 &lt; DS2 if DS1.seg is left of DS2.seg
170
+ * DS1 &gt; DS2 if DS1.seg is right of DS2.seg
171
+ * </pre>
172
+ *
173
+ * @param obj
174
+ * @return
175
+ */
176
+ jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.compareTo = function(
177
+ obj) {
178
+ var other = obj;
179
+ /**
180
+ * try and compute a determinate orientation for the segments. Test returns 1
181
+ * if other is left of this (i.e. this > other)
182
+ */
183
+ var orientIndex = this.upwardSeg.orientationIndex(other.upwardSeg);
184
+
185
+ /**
186
+ * If comparison between this and other is indeterminate, try the opposite
187
+ * call order. orientationIndex value is 1 if this is left of other, so have
188
+ * to flip sign to get proper comparison value of -1 if this is leftmost
189
+ */
190
+ if (orientIndex === 0)
191
+ orientIndex = -1 * other.upwardSeg.orientationIndex(upwardSeg);
192
+
193
+ // if orientation is determinate, return it
194
+ if (orientIndex !== 0)
195
+ return orientIndex;
196
+
197
+ // otherwise, segs must be collinear - sort based on minimum X value
198
+ return this.compareX(this.upwardSeg, other.upwardSeg);
199
+ };
200
+
201
+ /**
202
+ * Compare two collinear segments for left-most ordering. If segs are vertical,
203
+ * use vertical ordering for comparison. If segs are equal, return 0. Segments
204
+ * are assumed to be directed so that the second coordinate is >= to the first
205
+ * (e.g. up and to the right).
206
+ *
207
+ * @param seg0
208
+ * a segment to compare.
209
+ * @param seg1
210
+ * a segment to compare.
211
+ * @return
212
+ */
213
+ jsts.operation.buffer.SubgraphDepthLocater.DepthSegment.prototype.compareX = function(
214
+ seg0, seg1) {
215
+ var compare0 = seg0.p0.compareTo(seg1.p0);
216
+ if (compare0 !== 0)
217
+ return compare0;
218
+ return seg0.p1.compareTo(seg1.p1);
219
+
220
+ };