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,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
+ * Port source:
9
+ * /jts/jts/java/src/com/vividsolutions/jts/operation/polygonize/PolygonizeDirectedEdge.java
10
+ * Revision: 6
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/planargraph/DirectedEdge.js
15
+ */
16
+
17
+ (function() {
18
+
19
+ var DirectedEdge = jsts.planargraph.DirectedEdge;
20
+
21
+ /**
22
+ * A {@link DirectedEdge} of a {@link PolygonizeGraph}, which represents an
23
+ * edge of a polygon formed by the graph. May be logically deleted from the
24
+ * graph by setting the <code>marked</code> flag.
25
+ *
26
+ * Constructs a directed edge connecting the <code>from</code> node to the
27
+ * <code>to</code> node.
28
+ *
29
+ * @param directionPt
30
+ * specifies this DirectedEdge's direction (given by an imaginary
31
+ * line from the <code>from</code> node to <code>directionPt</code>).
32
+ * @param edgeDirection
33
+ * whether this DirectedEdge's direction is the same as or opposite
34
+ * to that of the parent Edge (if any).
35
+ */
36
+ var PolygonizeDirectedEdge = function(from, to, directionPt, edgeDirection) {
37
+ DirectedEdge.apply(this, arguments);
38
+ };
39
+
40
+ PolygonizeDirectedEdge.prototype = new DirectedEdge();
41
+
42
+ PolygonizeDirectedEdge.prototype.edgeRing = null;
43
+ PolygonizeDirectedEdge.prototype.next = null;
44
+ PolygonizeDirectedEdge.prototype.label = -1;
45
+
46
+ /**
47
+ * Returns the identifier attached to this directed edge.
48
+ */
49
+ PolygonizeDirectedEdge.prototype.getLabel = function() {
50
+ return this.label;
51
+ };
52
+ /**
53
+ * Attaches an identifier to this directed edge.
54
+ */
55
+ PolygonizeDirectedEdge.prototype.setLabel = function(label) {
56
+ this.label = label;
57
+ };
58
+
59
+ /**
60
+ * Returns the next directed edge in the EdgeRing that this directed edge is a
61
+ * member of.
62
+ */
63
+ PolygonizeDirectedEdge.prototype.getNext = function() {
64
+ return this.next;
65
+ };
66
+
67
+ /**
68
+ * Sets the next directed edge in the EdgeRing that this directed edge is a
69
+ * member of.
70
+ */
71
+ PolygonizeDirectedEdge.prototype.setNext = function(next) {
72
+ this.next = next;
73
+ };
74
+
75
+ /**
76
+ * Returns the ring of directed edges that this directed edge is a member of,
77
+ * or null if the ring has not been set.
78
+ *
79
+ * @see #setRing(EdgeRing)
80
+ */
81
+ PolygonizeDirectedEdge.prototype.isInRing = function() {
82
+ return this.edgeRing != null;
83
+ };
84
+
85
+ /**
86
+ * Sets the ring of directed edges that this directed edge is a member of.
87
+ */
88
+ PolygonizeDirectedEdge.prototype.setRing = function(edgeRing) {
89
+ this.edgeRing = edgeRing;
90
+ };
91
+
92
+ jsts.operation.polygonize.PolygonizeDirectedEdge = PolygonizeDirectedEdge;
93
+
94
+ })();
@@ -0,0 +1,31 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * Port source:
9
+ * /jts/jts/java/src/com/vividsolutions/jts/operation/polygonize/PolygonizeEdge.java
10
+ * Revision: 6
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/planargraph/Edge.js
15
+ */
16
+
17
+
18
+ /**
19
+ * An edge of a polygonization graph.
20
+ */
21
+ jsts.operation.polygonize.PolygonizeEdge = function(line) {
22
+ this.line = line;
23
+ };
24
+
25
+ jsts.operation.polygonize.PolygonizeEdge.prototype = new jsts.planargraph.Edge();
26
+
27
+ jsts.operation.polygonize.PolygonizeEdge.prototype.line = null;
28
+
29
+ jsts.operation.polygonize.PolygonizeEdge.prototype.getLine = function() {
30
+ return this.line;
31
+ };
@@ -0,0 +1,507 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * Port source:
9
+ * /jts/jts/java/src/com/vividsolutions/jts/operation/polygonize/PolygonizeDirectedEdge.java
10
+ * Revision: 6
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/operation/polygonize/EdgeRing.js
15
+ * @requires jsts/operation/polygonize/PolygonizeEdge.js
16
+ * @requires jsts/operation/polygonize/PolygonizeDirectedEdge.js
17
+ * @requires jsts/geom/Coordinate.js
18
+ * @requires jsts/planargraph/PlanarGraph.js
19
+ * @requires jsts/planargraph/Node.js
20
+ */
21
+
22
+ (function() {
23
+
24
+ var ArrayList = javascript.util.ArrayList;
25
+ var Stack = javascript.util.Stack;
26
+ var HashSet = javascript.util.HashSet;
27
+ var Assert = jsts.util.Assert;
28
+ var EdgeRing = jsts.operation.polygonize.EdgeRing;
29
+ var PolygonizeEdge = jsts.operation.polygonize.PolygonizeEdge;
30
+ var PolygonizeDirectedEdge = jsts.operation.polygonize.PolygonizeDirectedEdge;
31
+ var PlanarGraph = jsts.planargraph.PlanarGraph;
32
+ var Node = jsts.planargraph.Node;
33
+
34
+ /**
35
+ * Represents a planar graph of edges that can be used to compute a
36
+ * polygonization, and implements the algorithms to compute the
37
+ * {@link EdgeRings} formed by the graph.
38
+ * <p>
39
+ * The marked flag on {@link DirectedEdge}s is used to indicate that a
40
+ * directed edge has be logically deleted from the graph.
41
+ *
42
+ * Create a new polygonization graph.
43
+ */
44
+ var PolygonizeGraph = function(factory) {
45
+ PlanarGraph.apply(this);
46
+
47
+ this.factory = factory;
48
+ };
49
+
50
+ PolygonizeGraph.prototype = new PlanarGraph();
51
+
52
+ /**
53
+ * @private
54
+ */
55
+ PolygonizeGraph.getDegreeNonDeleted = function(node) {
56
+ var edges = node.getOutEdges().getEdges();
57
+ var degree = 0;
58
+ for (var i = edges.iterator(); i.hasNext();) {
59
+ var de = i.next();
60
+ if (!de.isMarked())
61
+ degree++;
62
+ }
63
+ return degree;
64
+ };
65
+
66
+ /**
67
+ * @private
68
+ */
69
+ PolygonizeGraph.getDegree = function(node, label) {
70
+ var edges = node.getOutEdges().getEdges();
71
+ var degree = 0;
72
+ for (var i = edges.iterator(); i.hasNext();) {
73
+ var de = i.next();
74
+ if (de.getLabel() == label)
75
+ degree++;
76
+ }
77
+ return degree;
78
+ };
79
+
80
+ /**
81
+ * Deletes all edges at a node
82
+ *
83
+ * @private
84
+ */
85
+ PolygonizeGraph.deleteAllEdges = function(node) {
86
+ var edges = node.getOutEdges().getEdges();
87
+ for (var i = edges.iterator(); i.hasNext();) {
88
+ var de = i.next();
89
+ de.setMarked(true);
90
+ var sym = de.getSym();
91
+ if (sym != null)
92
+ sym.setMarked(true);
93
+ }
94
+ };
95
+
96
+
97
+ PolygonizeGraph.prototype.factory = null;
98
+
99
+
100
+ /**
101
+ * Add a {@link LineString} forming an edge of the polygon graph.
102
+ *
103
+ * @param line
104
+ * the line to add.
105
+ */
106
+ PolygonizeGraph.prototype.addEdge = function(line) {
107
+ if (line.isEmpty()) {
108
+ return;
109
+ }
110
+ var linePts = jsts.geom.CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
111
+
112
+ if (linePts.length < 2) {
113
+ return;
114
+ }
115
+
116
+ var startPt = linePts[0];
117
+ var endPt = linePts[linePts.length - 1];
118
+
119
+ var nStart = this.getNode(startPt);
120
+ var nEnd = this.getNode(endPt);
121
+
122
+ var de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true);
123
+ var de1 = new PolygonizeDirectedEdge(nEnd, nStart,
124
+ linePts[linePts.length - 2], false);
125
+ var edge = new PolygonizeEdge(line);
126
+ edge.setDirectedEdges(de0, de1);
127
+ this.add(edge);
128
+ };
129
+
130
+ /**
131
+ * @private
132
+ */
133
+ PolygonizeGraph.prototype.getNode = function(pt) {
134
+ var node = this.findNode(pt);
135
+ if (node == null) {
136
+ node = new Node(pt);
137
+ // ensure node is only added once to graph
138
+ this.add(node);
139
+ }
140
+ return node;
141
+ };
142
+
143
+ /**
144
+ * @private
145
+ */
146
+ PolygonizeGraph.prototype.computeNextCWEdges = function() {
147
+ // set the next pointers for the edges around each node
148
+ for (var iNode = this.nodeIterator(); iNode.hasNext();) {
149
+ var node = iNode.next();
150
+ PolygonizeGraph.computeNextCWEdges(node);
151
+ }
152
+ };
153
+
154
+ /**
155
+ * Convert the maximal edge rings found by the initial graph traversal into
156
+ * the minimal edge rings required by JTS polygon topology rules.
157
+ *
158
+ * @param ringEdges
159
+ * the list of start edges for the edgeRings to convert.
160
+ * @private
161
+ */
162
+ PolygonizeGraph.prototype.convertMaximalToMinimalEdgeRings = function(
163
+ ringEdges) {
164
+ for (var i = ringEdges.iterator(); i.hasNext();) {
165
+ var de = i.next();
166
+ var label = de.getLabel();
167
+ var intNodes = PolygonizeGraph.findIntersectionNodes(de, label);
168
+
169
+ if (intNodes == null)
170
+ continue;
171
+ // flip the next pointers on the intersection nodes to create minimal edge
172
+ // rings
173
+ for (var iNode = intNodes.iterator(); iNode.hasNext();) {
174
+ var node = iNode.next();
175
+ PolygonizeGraph.computeNextCCWEdges(node, label);
176
+ }
177
+ }
178
+ };
179
+
180
+ /**
181
+ * Finds all nodes in a maximal edgering which are self-intersection nodes
182
+ *
183
+ * @param startDE
184
+ * @param label
185
+ * @return the list of intersection nodes found, or <code>null</code> if no
186
+ * intersection nodes were found.
187
+ * @private
188
+ */
189
+ PolygonizeGraph.findIntersectionNodes = function(startDE, label) {
190
+ var de = startDE;
191
+ var intNodes = null;
192
+ do {
193
+ var node = de.getFromNode();
194
+ if (PolygonizeGraph.getDegree(node, label) > 1) {
195
+ if (intNodes == null)
196
+ intNodes = new ArrayList();
197
+ intNodes.add(node);
198
+ }
199
+
200
+ de = de.getNext();
201
+ Assert.isTrue(de != null, 'found null DE in ring');
202
+ Assert
203
+ .isTrue(de == startDE || !de.isInRing(), 'found DE already in ring');
204
+ } while (de != startDE);
205
+
206
+ return intNodes;
207
+ };
208
+
209
+ /**
210
+ * Computes the minimal EdgeRings formed by the edges in this graph.
211
+ *
212
+ * @return a list of the {@link EdgeRing} s found by the polygonization
213
+ * process.
214
+ *
215
+ */
216
+ PolygonizeGraph.prototype.getEdgeRings = function() {
217
+ // maybe could optimize this, since most of these pointers should be set
218
+ // correctly already
219
+ // by deleteCutEdges()
220
+ this.computeNextCWEdges();
221
+ // clear labels of all edges in graph
222
+ PolygonizeGraph.label(this.dirEdges, -1);
223
+ var maximalRings = PolygonizeGraph.findLabeledEdgeRings(this.dirEdges);
224
+ this.convertMaximalToMinimalEdgeRings(maximalRings);
225
+
226
+ // find all edgerings (which will now be minimal ones, as required)
227
+ var edgeRingList = new ArrayList();
228
+ for (var i = this.dirEdges.iterator(); i.hasNext();) {
229
+ var de = i.next();
230
+ if (de.isMarked())
231
+ continue;
232
+ if (de.isInRing())
233
+ continue;
234
+
235
+ var er = this.findEdgeRing(de);
236
+ edgeRingList.add(er);
237
+ }
238
+ return edgeRingList;
239
+ };
240
+
241
+ /**
242
+ * Finds and labels all edgerings in the graph. The edge rings are labelling
243
+ * with unique integers. The labelling allows detecting cut edges.
244
+ *
245
+ * @param dirEdges
246
+ * a List of the DirectedEdges in the graph.
247
+ * @return a List of DirectedEdges, one for each edge ring found.
248
+ * @private
249
+ */
250
+ PolygonizeGraph.findLabeledEdgeRings = function(dirEdges) {
251
+ var edgeRingStarts = new ArrayList();
252
+ // label the edge rings formed
253
+ var currLabel = 1;
254
+ for (var i = dirEdges.iterator(); i.hasNext();) {
255
+ var de = i.next();
256
+ if (de.isMarked())
257
+ continue;
258
+ if (de.getLabel() >= 0)
259
+ continue;
260
+
261
+ edgeRingStarts.add(de);
262
+ var edges = PolygonizeGraph.findDirEdgesInRing(de);
263
+
264
+ PolygonizeGraph.label(edges, currLabel);
265
+ currLabel++;
266
+ }
267
+ return edgeRingStarts;
268
+ };
269
+
270
+ /**
271
+ * Finds and removes all cut edges from the graph.
272
+ *
273
+ * @return a list of the {@link LineString} s forming the removed cut edges.
274
+ */
275
+ PolygonizeGraph.prototype.deleteCutEdges = function() {
276
+ this.computeNextCWEdges();
277
+ // label the current set of edgerings
278
+ PolygonizeGraph.findLabeledEdgeRings(this.dirEdges);
279
+
280
+ /**
281
+ * Cut Edges are edges where both dirEdges have the same label. Delete them,
282
+ * and record them
283
+ */
284
+ var cutLines = new ArrayList();
285
+ for (var i = this.dirEdges.iterator(); i.hasNext();) {
286
+ var de = i.next();
287
+ if (de.isMarked())
288
+ continue;
289
+
290
+ var sym = de.getSym();
291
+
292
+ if (de.getLabel() == sym.getLabel()) {
293
+ de.setMarked(true);
294
+ sym.setMarked(true);
295
+
296
+ // save the line as a cut edge
297
+ var e = de.getEdge();
298
+ cutLines.add(e.getLine());
299
+ }
300
+ }
301
+ return cutLines;
302
+ };
303
+
304
+ /**
305
+ * @private
306
+ */
307
+ PolygonizeGraph.label = function(dirEdges, label) {
308
+ for (var i = dirEdges.iterator(); i.hasNext();) {
309
+ var de = i.next();
310
+ de.setLabel(label);
311
+ }
312
+ };
313
+
314
+ /**
315
+ * @private
316
+ */
317
+ PolygonizeGraph.computeNextCWEdges = function(node) {
318
+ var deStar = node.getOutEdges();
319
+ var startDE = null;
320
+ var prevDE = null;
321
+
322
+ // the edges are stored in CCW order around the star
323
+ for (var i = deStar.getEdges().iterator(); i.hasNext();) {
324
+ var outDE = i.next();
325
+ if (outDE.isMarked())
326
+ continue;
327
+
328
+ if (startDE == null)
329
+ startDE = outDE;
330
+ if (prevDE != null) {
331
+ var sym = prevDE.getSym();
332
+ sym.setNext(outDE);
333
+ }
334
+ prevDE = outDE;
335
+ }
336
+ if (prevDE != null) {
337
+ var sym = prevDE.getSym();
338
+ sym.setNext(startDE);
339
+ }
340
+ };
341
+
342
+ /**
343
+ * Computes the next edge pointers going CCW around the given node, for the
344
+ * given edgering label. This algorithm has the effect of converting maximal
345
+ * edgerings into minimal edgerings
346
+ *
347
+ * @private
348
+ *
349
+ */
350
+ PolygonizeGraph.computeNextCCWEdges = function(node, label) {
351
+ var deStar = node.getOutEdges();
352
+ // PolyDirectedEdge lastInDE = null;
353
+ var firstOutDE = null;
354
+ var prevInDE = null;
355
+
356
+ // the edges are stored in CCW order around the star
357
+ var edges = deStar.getEdges();
358
+ // for (Iterator i = deStar.getEdges().iterator(); i.hasNext(); ) {
359
+ for (var i = edges.size() - 1; i >= 0; i--) {
360
+ var de = edges.get(i);
361
+ var sym = de.getSym();
362
+
363
+ var outDE = null;
364
+ if (de.getLabel() == label)
365
+ outDE = de;
366
+ var inDE = null;
367
+ if (sym.getLabel() == label)
368
+ inDE = sym;
369
+
370
+ if (outDE == null && inDE == null)
371
+ continue; // this edge is not in edgering
372
+
373
+ if (inDE != null) {
374
+ prevInDE = inDE;
375
+ }
376
+
377
+ if (outDE != null) {
378
+ if (prevInDE != null) {
379
+ prevInDE.setNext(outDE);
380
+ prevInDE = null;
381
+ }
382
+ if (firstOutDE == null)
383
+ firstOutDE = outDE;
384
+ }
385
+ }
386
+ if (prevInDE != null) {
387
+ Assert.isTrue(firstOutDE != null);
388
+ prevInDE.setNext(firstOutDE);
389
+ }
390
+ };
391
+
392
+ /**
393
+ * Traverses a ring of DirectedEdges, accumulating them into a list. This
394
+ * assumes that all dangling directed edges have been removed from the graph,
395
+ * so that there is always a next dirEdge.
396
+ *
397
+ * @param startDE
398
+ * the DirectedEdge to start traversing at.
399
+ * @return a List of DirectedEdges that form a ring.
400
+ * @private
401
+ */
402
+ PolygonizeGraph.findDirEdgesInRing = function(startDE) {
403
+ var de = startDE;
404
+ var edges = new ArrayList();
405
+ do {
406
+ edges.add(de);
407
+ de = de.getNext();
408
+ Assert.isTrue(de != null, 'found null DE in ring');
409
+ Assert
410
+ .isTrue(de == startDE || !de.isInRing(), 'found DE already in ring');
411
+ } while (de != startDE);
412
+
413
+ return edges;
414
+ };
415
+
416
+ /**
417
+ * @private
418
+ */
419
+ PolygonizeGraph.prototype.findEdgeRing = function(startDE) {
420
+ var de = startDE;
421
+ var er = new EdgeRing(this.factory);
422
+ do {
423
+ er.add(de);
424
+ de.setRing(er);
425
+ de = de.getNext();
426
+ Assert.isTrue(de != null, 'found null DE in ring');
427
+ Assert
428
+ .isTrue(de == startDE || !de.isInRing(), 'found DE already in ring');
429
+ } while (de != startDE);
430
+
431
+ return er;
432
+ };
433
+
434
+ /**
435
+ * Marks all edges from the graph which are "dangles". Dangles are which are
436
+ * incident on a node with degree 1. This process is recursive, since removing
437
+ * a dangling edge may result in another edge becoming a dangle. In order to
438
+ * handle large recursion depths efficiently, an explicit recursion stack is
439
+ * used
440
+ *
441
+ * @return a List containing the {@link LineStrings} that formed dangles.
442
+ */
443
+ PolygonizeGraph.prototype.deleteDangles = function() {
444
+ var nodesToRemove = this.findNodesOfDegree(1);
445
+ var dangleLines = new HashSet();
446
+
447
+ var nodeStack = new Stack();
448
+ for (var i = nodesToRemove.iterator(); i.hasNext();) {
449
+ nodeStack.push(i.next());
450
+ }
451
+
452
+ while (!nodeStack.isEmpty()) {
453
+ var node = nodeStack.pop();
454
+
455
+ PolygonizeGraph.deleteAllEdges(node);
456
+ var nodeOutEdges = node.getOutEdges().getEdges();
457
+ for (var i = nodeOutEdges.iterator(); i.hasNext();) {
458
+ var de = i.next();
459
+ // delete this edge and its sym
460
+ de.setMarked(true);
461
+ var sym = de.getSym();
462
+ if (sym != null)
463
+ sym.setMarked(true);
464
+
465
+ // save the line as a dangle
466
+ var e = de.getEdge();
467
+ dangleLines.add(e.getLine());
468
+
469
+ var toNode = de.getToNode();
470
+ // add the toNode to the list to be processed, if it is now a dangle
471
+ if (PolygonizeGraph.getDegreeNonDeleted(toNode) == 1)
472
+ nodeStack.push(toNode);
473
+ }
474
+ }
475
+ return dangleLines;
476
+ };
477
+
478
+ /**
479
+ * Traverses the polygonized edge rings in the graph and computes the depth
480
+ * parity (odd or even) relative to the exterior of the graph. If the client
481
+ * has requested that the output be polygonally valid, only odd polygons will
482
+ * be constructed.
483
+ *
484
+ */
485
+ PolygonizeGraph.prototype.computeDepthParity = function() {
486
+ while (true) {
487
+ var de = null;
488
+ if (de == null)
489
+ return;
490
+ this.computeDepthParity(de);
491
+ }
492
+ };
493
+
494
+ /**
495
+ * Traverses all connected edges, computing the depth parity of the associated
496
+ * polygons.
497
+ *
498
+ * @param de
499
+ * @private
500
+ */
501
+ PolygonizeGraph.prototype.computeDepthParity = function(de) {
502
+
503
+ };
504
+
505
+ jsts.operation.polygonize.PolygonizeGraph = PolygonizeGraph;
506
+
507
+ })();