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,124 @@
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/planargraph/Edge.java
10
+ * Revision: 6
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/planargraph/GraphComponent.js
15
+ */
16
+
17
+ (function() {
18
+
19
+ var GraphComponent = jsts.planargraph.GraphComponent;
20
+
21
+ /**
22
+ * Represents an undirected edge of a {@link PlanarGraph}. An undirected edge
23
+ * in fact simply acts as a central point of reference for two opposite
24
+ * {@link DirectedEdge}s.
25
+ * <p>
26
+ * Usually a client using a <code>PlanarGraph</code> will subclass
27
+ * <code>Edge</code> to add its own application-specific data and methods.
28
+ *
29
+ * Constructs an Edge initialized with the given DirectedEdges, and for each
30
+ * DirectedEdge: sets the Edge, sets the symmetric DirectedEdge, and adds this
31
+ * Edge to its from-Node.
32
+ */
33
+ var Edge = function(de0, de1) {
34
+ if (de0 === undefined) {
35
+ return;
36
+ }
37
+ this.setDirectedEdges(de0, de1);
38
+ };
39
+
40
+ Edge.prototype = new GraphComponent();
41
+
42
+
43
+ /**
44
+ * The two DirectedEdges associated with this Edge. Index 0 is forward, 1 is
45
+ * reverse.
46
+ */
47
+ Edge.prototype.dirEdge = null;
48
+
49
+ /**
50
+ * Initializes this Edge's two DirectedEdges, and for each DirectedEdge: sets
51
+ * the Edge, sets the symmetric DirectedEdge, and adds this Edge to its
52
+ * from-Node.
53
+ */
54
+ Edge.prototype.setDirectedEdges = function(de0, de1) {
55
+ this.dirEdge = [de0, de1];
56
+ de0.setEdge(this);
57
+ de1.setEdge(this);
58
+ de0.setSym(de1);
59
+ de1.setSym(de0);
60
+ de0.getFromNode().addOutEdge(de0);
61
+ de1.getFromNode().addOutEdge(de1);
62
+ };
63
+
64
+ /**
65
+ * Returns one of the DirectedEdges associated with this Edge.
66
+ *
67
+ * @param i
68
+ * 0 or 1. 0 returns the forward directed edge, 1 returns the reverse.
69
+ */
70
+ Edge.prototype.getDirEdge = function(i) {
71
+ if (i instanceof jsts.planargraph.Node) {
72
+ this.getDirEdge2(i);
73
+ }
74
+
75
+ return this.dirEdge[i];
76
+ };
77
+
78
+ /**
79
+ * Returns the {@link DirectedEdge} that starts from the given node, or null
80
+ * if the node is not one of the two nodes associated with this Edge.
81
+ */
82
+ Edge.prototype.getDirEdge2 = function(fromNode) {
83
+ if (this.dirEdge[0].getFromNode() == fromNode)
84
+ return this.dirEdge[0];
85
+ if (this.dirEdge[1].getFromNode() == fromNode)
86
+ return this.dirEdge[1];
87
+ // node not found
88
+ // possibly should throw an exception here?
89
+ return null;
90
+ };
91
+
92
+ /**
93
+ * If <code>node</code> is one of the two nodes associated with this Edge,
94
+ * returns the other node; otherwise returns null.
95
+ */
96
+ Edge.prototype.getOppositeNode = function(node) {
97
+ if (this.dirEdge[0].getFromNode() == node)
98
+ return this.dirEdge[0].getToNode();
99
+ if (this.dirEdge[1].getFromNode() == node)
100
+ return this.dirEdge[1].getToNode();
101
+ // node not found
102
+ // possibly should throw an exception here?
103
+ return null;
104
+ };
105
+
106
+ /**
107
+ * Removes this edge from its containing graph.
108
+ */
109
+ Edge.prototype.remove = function() {
110
+ this.dirEdge = null;
111
+ };
112
+
113
+ /**
114
+ * Tests whether this edge has been removed from its containing graph
115
+ *
116
+ * @return <code>true</code> if this edge is removed.
117
+ */
118
+ Edge.prototype.isRemoved = function() {
119
+ return dirEdge == null;
120
+ };
121
+
122
+ jsts.planargraph.Edge = Edge;
123
+
124
+ })();
@@ -0,0 +1,182 @@
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/planargraph/GraphComponent.java
10
+ * Revision: 6
11
+ */
12
+
13
+ (function() {
14
+
15
+ /**
16
+ * The base class for all graph component classes. Maintains flags of use in
17
+ * generic graph algorithms. Provides two flags:
18
+ * <ul>
19
+ * <li><b>marked</b> - typically this is used to indicate a state that
20
+ * persists for the course of the graph's lifetime. For instance, it can be
21
+ * used to indicate that a component has been logically deleted from the
22
+ * graph.
23
+ * <li><b>visited</b> - this is used to indicate that a component has been
24
+ * processed or visited by an single graph algorithm. For instance, a
25
+ * breadth-first traversal of the graph might use this to indicate that a node
26
+ * has already been traversed. The visited flag may be set and cleared many
27
+ * times during the lifetime of a graph.
28
+ *
29
+ * <p>
30
+ * Graph components support storing user context data. This will typically be
31
+ * used by client algorithms which use planar graphs.
32
+ */
33
+ var GraphComponent = function() {
34
+
35
+ };
36
+
37
+ /**
38
+ * Sets the Visited state for all {@link GraphComponent}s in an
39
+ * {@link Iterator}
40
+ *
41
+ * @param i
42
+ * the Iterator to scan.
43
+ * @param visited
44
+ * the state to set the visited flag to.
45
+ */
46
+ GraphComponent.setVisited = function(i, visited) {
47
+ while (i.hasNext()) {
48
+ var comp = i.next();
49
+ comp.setVisited(visited);
50
+ }
51
+ };
52
+
53
+ /**
54
+ * Sets the Marked state for all {@link GraphComponent}s in an
55
+ * {@link Iterator}
56
+ *
57
+ * @param i
58
+ * the Iterator to scan.
59
+ * @param marked
60
+ * the state to set the Marked flag to.
61
+ */
62
+ GraphComponent.setMarked = function(i, marked) {
63
+ while (i.hasNext()) {
64
+ var comp = i.next();
65
+ comp.setMarked(marked);
66
+ }
67
+ };
68
+
69
+ /**
70
+ * Finds the first {@link GraphComponent} in a {@link Iterator} set which has
71
+ * the specified visited state.
72
+ *
73
+ * @param i
74
+ * an Iterator of GraphComponents.
75
+ * @param visitedState
76
+ * the visited state to test.
77
+ * @return the first component found, or <code>null</code> if none found.
78
+ */
79
+ GraphComponent.getComponentWithVisitedState = function(i, visitedState) {
80
+ while (i.hasNext()) {
81
+ var comp = i.next();
82
+ if (comp.isVisited() == visitedState)
83
+ return comp;
84
+ }
85
+ return null;
86
+ };
87
+
88
+ GraphComponent.prototype._isMarked = false;
89
+ GraphComponent.prototype._isVisited = false;
90
+ GraphComponent.prototype.data;
91
+
92
+
93
+ /**
94
+ * Tests if a component has been visited during the course of a graph
95
+ * algorithm
96
+ *
97
+ * @return <code>true</code> if the component has been visited.
98
+ */
99
+ GraphComponent.prototype.isVisited = function() {
100
+ return this._isVisited;
101
+ };
102
+
103
+ /**
104
+ * Sets the visited flag for this component.
105
+ *
106
+ * @param isVisited
107
+ * the desired value of the visited flag.
108
+ */
109
+ GraphComponent.prototype.setVisited = function(isVisited) {
110
+ this._isVisited = isVisited;
111
+ };
112
+
113
+ /**
114
+ * Tests if a component has been marked at some point during the processing
115
+ * involving this graph.
116
+ *
117
+ * @return <code>true</code> if the component has been marked.
118
+ */
119
+ GraphComponent.prototype.isMarked = function() {
120
+ return this._isMarked;
121
+ };
122
+
123
+ /**
124
+ * Sets the marked flag for this component.
125
+ *
126
+ * @param isMarked
127
+ * the desired value of the marked flag.
128
+ */
129
+ GraphComponent.prototype.setMarked = function(isMarked) {
130
+ this._isMarked = isMarked;
131
+ };
132
+
133
+ /**
134
+ * Sets the user-defined data for this component.
135
+ *
136
+ * @param data
137
+ * an Object containing user-defined data.
138
+ */
139
+ GraphComponent.prototype.setContext = function(data) {
140
+ this.data = data;
141
+ };
142
+
143
+ /**
144
+ * Gets the user-defined data for this component.
145
+ *
146
+ * @return the user-defined data.
147
+ */
148
+ GraphComponent.prototype.getContext = function() {
149
+ return data;
150
+ };
151
+
152
+ /**
153
+ * Sets the user-defined data for this component.
154
+ *
155
+ * @param data
156
+ * an Object containing user-defined data.
157
+ */
158
+ GraphComponent.prototype.setData = function(data) {
159
+ this.data = data;
160
+ };
161
+
162
+ /**
163
+ * Gets the user-defined data for this component.
164
+ *
165
+ * @return the user-defined data.
166
+ */
167
+ GraphComponent.prototype.getData = function() {
168
+ return data;
169
+ };
170
+
171
+ /**
172
+ * Tests whether this component has been removed from its containing graph
173
+ *
174
+ * @return <code>true</code> if this component is removed.
175
+ */
176
+ GraphComponent.prototype.isRemoved = function() {
177
+ throw new jsts.error.AbstractMethodInvocationError();
178
+ };
179
+
180
+ jsts.planargraph.GraphComponent = GraphComponent;
181
+
182
+ })();
@@ -0,0 +1,127 @@
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/planargraph/Node.java
10
+ * Revision: 6
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/planargraph/GraphComponent.js
15
+ * @requires jsts/planargraph/DirectedEdgeStar.js
16
+ */
17
+
18
+ (function() {
19
+
20
+ var GraphComponent = jsts.planargraph.GraphComponent;
21
+ var DirectedEdgeStar = jsts.planargraph.DirectedEdgeStar;
22
+
23
+ /**
24
+ * A node in a {@link PlanarGraph}is a location where 0 or more {@link Edge}s
25
+ * meet. A node is connected to each of its incident Edges via an outgoing
26
+ * DirectedEdge. Some clients using a <code>PlanarGraph</code> may want to
27
+ * subclass <code>Node</code> to add their own application-specific data and
28
+ * methods.
29
+ *
30
+ * Constructs a Node with the given location and collection of outgoing
31
+ * DirectedEdges.
32
+ */
33
+ var Node = function(pt, deStar) {
34
+ this.pt = pt;
35
+ this.deStar = deStar || new DirectedEdgeStar();
36
+ };
37
+
38
+
39
+ Node.prototype = new GraphComponent();
40
+
41
+
42
+ /**
43
+ * Returns all Edges that connect the two nodes (which are assumed to be
44
+ * different).
45
+ */
46
+ Node.getEdgesBetween = function(node0, node1) {
47
+ var edges0 = DirectedEdge.toEdges(node0.getOutEdges().getEdges());
48
+ var commonEdges = new javascript.util.HashSet(edges0);
49
+ var edges1 = DirectedEdge.toEdges(node1.getOutEdges().getEdges());
50
+ commonEdges.retainAll(edges1);
51
+ return commonEdges;
52
+ };
53
+
54
+ /** The location of this Node */
55
+ Node.prototype.pt = null;
56
+
57
+ /** The collection of DirectedEdges that leave this Node */
58
+ Node.prototype.deStar = null;
59
+
60
+ /**
61
+ * Returns the location of this Node.
62
+ */
63
+ Node.prototype.getCoordinate = function() {
64
+ return this.pt;
65
+ };
66
+
67
+ /**
68
+ * Adds an outgoing DirectedEdge to this Node.
69
+ */
70
+ Node.prototype.addOutEdge = function(de) {
71
+ this.deStar.add(de);
72
+ };
73
+
74
+ /**
75
+ * Returns the collection of DirectedEdges that leave this Node.
76
+ */
77
+ Node.prototype.getOutEdges = function() {
78
+ return this.deStar;
79
+ };
80
+
81
+ /**
82
+ * Returns the number of edges around this Node.
83
+ */
84
+ Node.prototype.getDegree = function() {
85
+ return this.deStar.getDegree();
86
+ };
87
+
88
+ /**
89
+ * Returns the zero-based index of the given Edge, after sorting in ascending
90
+ * order by angle with the positive x-axis.
91
+ */
92
+ Node.prototype.getIndex = function(edge) {
93
+ return this.deStar.getIndex(edge);
94
+ };
95
+
96
+ /**
97
+ * Removes a {@link DirectedEdge} incident on this node. Does not change the
98
+ * state of the directed edge.
99
+ */
100
+ Node.prototype.remove = function(de) {
101
+ if (de === undefined) {
102
+ return this.remove2();
103
+ }
104
+
105
+ this.deStar.remove(de);
106
+ };
107
+
108
+ /**
109
+ * Removes this node from its containing graph.
110
+ */
111
+ Node.prototype.remove2 = function() {
112
+ this.pt = null;
113
+ };
114
+
115
+
116
+ /**
117
+ * Tests whether this node has been removed from its containing graph
118
+ *
119
+ * @return <code>true</code> if this node is removed.
120
+ */
121
+ Node.prototype.isRemoved = function() {
122
+ return this.pt == null;
123
+ };
124
+
125
+ jsts.planargraph.Node = Node;
126
+
127
+ })();
@@ -0,0 +1,76 @@
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/planargraph/NodeMap.java
10
+ * Revision: 6
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/geom/Coordinate.js
15
+ * @requires jsts/planargraph/Node.js
16
+ */
17
+
18
+ (function() {
19
+
20
+ /**
21
+ * A map of {@link Node}s, indexed by the coordinate of the node.
22
+ *
23
+ * Constructs a NodeMap without any Nodes.
24
+ */
25
+ var NodeMap = function() {
26
+ this.nodeMap = new javascript.util.TreeMap();
27
+ };
28
+
29
+
30
+ NodeMap.prototype.nodeMap = null;
31
+
32
+
33
+ /**
34
+ * Adds a node to the map, replacing any that is already at that location.
35
+ *
36
+ * @return the added node.
37
+ */
38
+ NodeMap.prototype.add = function(n) {
39
+ this.nodeMap.put(n.getCoordinate(), n);
40
+ return n;
41
+ };
42
+
43
+ /**
44
+ * Removes the Node at the given location, and returns it (or null if no Node
45
+ * was there).
46
+ */
47
+ NodeMap.prototype.remove = function(pt) {
48
+ return this.nodeMap.remove(pt);
49
+ };
50
+
51
+ /**
52
+ * Returns the Node at the given location, or null if no Node was there.
53
+ */
54
+ NodeMap.prototype.find = function(coord) {
55
+ return this.nodeMap.get(coord);
56
+ };
57
+
58
+ /**
59
+ * Returns an Iterator over the Nodes in this NodeMap, sorted in ascending
60
+ * order by angle with the positive x-axis.
61
+ */
62
+ NodeMap.prototype.iterator = function() {
63
+ return this.nodeMap.values().iterator();
64
+ };
65
+
66
+ /**
67
+ * Returns the Nodes in this NodeMap, sorted in ascending order by angle with
68
+ * the positive x-axis.
69
+ */
70
+ NodeMap.prototype.values = function() {
71
+ return this.nodeMap.values();
72
+ };
73
+
74
+ jsts.planargraph.NodeMap = NodeMap;
75
+
76
+ })();