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,105 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * @requires jsts/geomgraph/GraphComponent.js
9
+ */
10
+
11
+
12
+
13
+ /**
14
+ * @constructor
15
+ * @param {jsts.geom.Coordinate}
16
+ * coord
17
+ * @param {jsts.geom.EdgeEndStar}
18
+ * edges
19
+ * @augments jsts.geomgraph.GraphComponent
20
+ */
21
+ jsts.geomgraph.Node = function(coord, edges) {
22
+ this.coord = coord;
23
+ this.edges = edges;
24
+ this.label = new jsts.geomgraph.Label(0, jsts.geom.Location.NONE);
25
+ };
26
+
27
+ jsts.geomgraph.Node.prototype = new jsts.geomgraph.GraphComponent();
28
+
29
+
30
+ /**
31
+ * only non-null if this node is precise
32
+ */
33
+ jsts.geomgraph.Node.prototype.coord = null;
34
+ jsts.geomgraph.Node.prototype.edges = null;
35
+
36
+ jsts.geomgraph.Node.prototype.isIsolated = function() {
37
+ return (this.label.getGeometryCount() == 1);
38
+ };
39
+
40
+ jsts.geomgraph.Node.prototype.setLabel2 = function(argIndex, onLocation) {
41
+ if (this.label === null) {
42
+ this.label = new jsts.geomgraph.Label(argIndex, onLocation);
43
+ } else
44
+ this.label.setLocation(argIndex, onLocation);
45
+ };
46
+
47
+
48
+ /**
49
+ * Updates the label of a node to BOUNDARY, obeying the mod-2
50
+ * boundaryDetermination rule.
51
+ */
52
+ jsts.geomgraph.Node.prototype.setLabelBoundary = function(argIndex) {
53
+ // determine the current location for the point (if any)
54
+ var loc = jsts.geom.Location.NONE;
55
+ if (this.label !== null)
56
+ loc = this.label.getLocation(argIndex);
57
+ // flip the loc
58
+ var newLoc;
59
+ switch (loc) {
60
+ case jsts.geom.Location.BOUNDARY:
61
+ newLoc = jsts.geom.Location.INTERIOR;
62
+ break;
63
+ case jsts.geom.Location.INTERIOR:
64
+ newLoc = jsts.geom.Location.BOUNDARY;
65
+ break;
66
+ default:
67
+ newLoc = jsts.geom.Location.BOUNDARY;
68
+ break;
69
+ }
70
+ this.label.setLocation(argIndex, newLoc);
71
+ };
72
+
73
+
74
+ /**
75
+ * Add the edge to the list of edges at this node
76
+ */
77
+ jsts.geomgraph.Node.prototype.add = function(e) {
78
+ this.edges.insert(e);
79
+ e.setNode(this);
80
+ };
81
+
82
+ jsts.geomgraph.Node.prototype.getCoordinate = function() {
83
+ return this.coord;
84
+ };
85
+ jsts.geomgraph.Node.prototype.getEdges = function() {
86
+ return this.edges;
87
+ };
88
+
89
+ /**
90
+ * Tests whether any incident edge is flagged as being in the result. This test
91
+ * can be used to determine if the node is in the result, since if any incident
92
+ * edge is in the result, the node must be in the result as well.
93
+ *
94
+ * @return <code>true</code> if any indicident edge in the in the result.
95
+ */
96
+ jsts.geomgraph.Node.prototype.isIncidentEdgeInResult = function() {
97
+ for (var it = this.getEdges().getEdges().iterator(); it.hasNext();) {
98
+ var de = it.next();
99
+ if (de.getEdge().isInResult())
100
+ return true;
101
+ }
102
+ return false;
103
+ };
104
+
105
+ // TODO: port rest
@@ -0,0 +1,22 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+
8
+
9
+ /**
10
+ * @constructor
11
+ */
12
+ jsts.geomgraph.NodeFactory = function() {
13
+
14
+ };
15
+
16
+
17
+ /**
18
+ * The basic node constructor does not allow for incident edges
19
+ */
20
+ jsts.geomgraph.NodeFactory.prototype.createNode = function(coord) {
21
+ return new jsts.geomgraph.Node(coord, null);
22
+ };
@@ -0,0 +1,128 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ (function() {
8
+
9
+ /**
10
+ * @requires jsts/geom/Location.js
11
+ */
12
+
13
+ var Location = jsts.geom.Location;
14
+ var ArrayList = javascript.util.ArrayList;
15
+ var TreeMap = javascript.util.TreeMap;
16
+
17
+ /**
18
+ * A map of nodes, indexed by the coordinate of the node.
19
+ *
20
+ * @constructor
21
+ */
22
+ jsts.geomgraph.NodeMap = function(nodeFactory) {
23
+ this.nodeMap = new TreeMap();
24
+ this.nodeFact = nodeFactory;
25
+ };
26
+
27
+
28
+ /**
29
+ * NOTE: Seems like the index isn't functionally important, so in JSTS a JS
30
+ * object replaces TreeMap. Sorting is done when needed.
31
+ *
32
+ * @type {javascript.util.HashMap}
33
+ */
34
+ jsts.geomgraph.NodeMap.prototype.nodeMap = null;
35
+
36
+ jsts.geomgraph.NodeMap.prototype.nodeFact = null;
37
+
38
+
39
+ /**
40
+ * This method expects that a node has a coordinate value.
41
+ *
42
+ * In JSTS this replaces multiple overloaded methods from JTS.
43
+ *
44
+ * @param {jsts.geom.Coordinate/jsts.geomgraph.Node}
45
+ * arg
46
+ * @return {jsts.geomgraph.Node}
47
+ */
48
+ jsts.geomgraph.NodeMap.prototype.addNode = function(arg) {
49
+ var node, coord;
50
+
51
+ if (arg instanceof jsts.geom.Coordinate) {
52
+ coord = arg;
53
+ node = this.nodeMap.get(coord);
54
+ if (node === null) {
55
+ node = this.nodeFact.createNode(coord);
56
+ this.nodeMap.put(coord, node);
57
+ }
58
+ return node;
59
+ } else if (arg instanceof jsts.geomgraph.Node) {
60
+ var n = arg;
61
+ coord = n.getCoordinate();
62
+ node = this.nodeMap.get(coord);
63
+ if (node === null) {
64
+ this.nodeMap.put(coord, n);
65
+ return n;
66
+ }
67
+ node.mergeLabel(n);
68
+ return node;
69
+ }
70
+ };
71
+
72
+
73
+ /**
74
+ * Adds a node for the start point of this EdgeEnd (if one does not already
75
+ * exist in this map). Adds the EdgeEnd to the (possibly new) node.
76
+ *
77
+ * @param {jsts.geomgraph.EdgeEnd}
78
+ * e
79
+ */
80
+ jsts.geomgraph.NodeMap.prototype.add = function(e) {
81
+ var p = e.getCoordinate();
82
+ var n = this.addNode(p);
83
+ n.add(e);
84
+ };
85
+
86
+
87
+ /**
88
+ * @param {jsts.geom.Coordinate}
89
+ * coord
90
+ * @return {jsts.geomgraph.Node} the node if found; null otherwise.
91
+ */
92
+ jsts.geomgraph.NodeMap.prototype.find = function(coord) {
93
+ return this.nodeMap.get(coord);
94
+ };
95
+
96
+
97
+ /**
98
+ * @return {javascript.util.Collection}
99
+ */
100
+ jsts.geomgraph.NodeMap.prototype.values = function() {
101
+ return this.nodeMap.values();
102
+ };
103
+
104
+ /**
105
+ * @return {javascript.util.Collection}
106
+ */
107
+ jsts.geomgraph.NodeMap.prototype.iterator = function() {
108
+ return this.values().iterator();
109
+ };
110
+
111
+
112
+ /**
113
+ * @param {number}
114
+ * geomIndex
115
+ * @return {Array.<Node>}
116
+ */
117
+ jsts.geomgraph.NodeMap.prototype.getBoundaryNodes = function(geomIndex) {
118
+ var bdyNodes = new ArrayList();
119
+ for (var i = this.iterator(); i.hasNext();) {
120
+ var node = i.next();
121
+ if (node.getLabel().getLocation(geomIndex) === Location.BOUNDARY) {
122
+ bdyNodes.add(node);
123
+ }
124
+ }
125
+ return bdyNodes;
126
+ };
127
+
128
+ })();
@@ -0,0 +1,214 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * @requires jsts/geomgraph/NodeMap.js
9
+ * @requires jsts/geomgraph/NodeFactory.js
10
+ */
11
+
12
+ (function() {
13
+
14
+ var ArrayList = javascript.util.ArrayList;
15
+
16
+ /**
17
+ * The computation of the <code>IntersectionMatrix</code> relies on the use
18
+ * of a structure called a "topology graph". The topology graph contains nodes
19
+ * and edges corresponding to the nodes and line segments of a
20
+ * <code>Geometry</code>. Each node and edge in the graph is labeled with
21
+ * its topological location relative to the source geometry.
22
+ * <P>
23
+ * Note that there is no requirement that points of self-intersection be a
24
+ * vertex. Thus to obtain a correct topology graph, <code>Geometry</code>s
25
+ * must be self-noded before constructing their graphs.
26
+ * <P>
27
+ * Two fundamental operations are supported by topology graphs:
28
+ * <UL>
29
+ * <LI>Computing the intersections between all the edges and nodes of a
30
+ * single graph
31
+ * <LI>Computing the intersections between the edges and nodes of two
32
+ * different graphs
33
+ * </UL>
34
+ *
35
+ * @constructor
36
+ */
37
+ jsts.geomgraph.PlanarGraph = function(nodeFactory) {
38
+ this.edges = new ArrayList();
39
+ this.edgeEndList = new ArrayList();
40
+ this.nodes = new jsts.geomgraph.NodeMap(nodeFactory ||
41
+ new jsts.geomgraph.NodeFactory());
42
+ };
43
+
44
+
45
+ /**
46
+ * @type {javascript.util.ArrayList}
47
+ * @protected
48
+ */
49
+ jsts.geomgraph.PlanarGraph.prototype.edges = null;
50
+
51
+
52
+ /**
53
+ * @type {jsts.geomgraph.NodeMap}
54
+ * @protected
55
+ */
56
+ jsts.geomgraph.PlanarGraph.prototype.nodes = null;
57
+ /**
58
+ * @type {javascript.util.ArrayList}
59
+ * @protected
60
+ */
61
+ jsts.geomgraph.PlanarGraph.prototype.edgeEndList = null;
62
+
63
+ /**
64
+ * For nodes in the Collection, link the DirectedEdges at the node that are in
65
+ * the result. This allows clients to link only a subset of nodes in the
66
+ * graph, for efficiency (because they know that only a subset is of
67
+ * interest).
68
+ */
69
+ jsts.geomgraph.PlanarGraph.linkResultDirectedEdges = function(nodes) {
70
+ for (var nodeit = nodes.iterator(); nodeit.hasNext();) {
71
+ var node = nodeit.next();
72
+ node.getEdges().linkResultDirectedEdges();
73
+ }
74
+ };
75
+
76
+
77
+ jsts.geomgraph.PlanarGraph.prototype.getEdgeIterator = function() {
78
+ return this.edges.iterator();
79
+ };
80
+ jsts.geomgraph.PlanarGraph.prototype.getEdgeEnds = function() {
81
+ return this.edgeEndList;
82
+ };
83
+
84
+ jsts.geomgraph.PlanarGraph.prototype.isBoundaryNode = function(geomIndex,
85
+ coord) {
86
+ var node = this.nodes.find(coord);
87
+ if (node === null)
88
+ return false;
89
+ var label = node.getLabel();
90
+ if (label !== null &&
91
+ label.getLocation(geomIndex) === jsts.geom.Location.BOUNDARY)
92
+ return true;
93
+ return false;
94
+ };
95
+
96
+ jsts.geomgraph.PlanarGraph.prototype.insertEdge = function(e) {
97
+ this.edges.add(e);
98
+ };
99
+
100
+ jsts.geomgraph.PlanarGraph.prototype.add = function(e) {
101
+ this.nodes.add(e);
102
+ this.edgeEndList.add(e);
103
+ };
104
+
105
+ /**
106
+ * @return {javascript.util.Iterator}
107
+ */
108
+ jsts.geomgraph.PlanarGraph.prototype.getNodeIterator = function() {
109
+ return this.nodes.iterator();
110
+ };
111
+
112
+ /**
113
+ * @return {javascript.util.Collection}
114
+ */
115
+ jsts.geomgraph.PlanarGraph.prototype.getNodes = function() {
116
+ return this.nodes.values();
117
+ };
118
+
119
+ jsts.geomgraph.PlanarGraph.prototype.addNode = function(node) {
120
+ return this.nodes.addNode(node);
121
+ };
122
+
123
+ /**
124
+ * Add a set of edges to the graph. For each edge two DirectedEdges will be
125
+ * created. DirectedEdges are NOT linked by this method.
126
+ *
127
+ * @param {javascript.util.List}
128
+ * edgedToAdd
129
+ */
130
+ jsts.geomgraph.PlanarGraph.prototype.addEdges = function(edgesToAdd) {
131
+ // create all the nodes for the edges
132
+ for (var it = edgesToAdd.iterator(); it.hasNext();) {
133
+ var e = it.next();
134
+ this.edges.add(e);
135
+
136
+ var de1 = new jsts.geomgraph.DirectedEdge(e, true);
137
+ var de2 = new jsts.geomgraph.DirectedEdge(e, false);
138
+ de1.setSym(de2);
139
+ de2.setSym(de1);
140
+
141
+ this.add(de1);
142
+ this.add(de2);
143
+ }
144
+ };
145
+
146
+ jsts.geomgraph.PlanarGraph.prototype.linkResultDirectedEdges = function() {
147
+ for (var nodeit = this.nodes.iterator(); nodeit.hasNext();) {
148
+ var node = nodeit.next();
149
+ node.getEdges().linkResultDirectedEdges();
150
+ }
151
+ };
152
+
153
+ /**
154
+ * Returns the edge which starts at p0 and whose first segment is parallel to
155
+ * p1
156
+ *
157
+ * @return the edge, if found <code>null</code> if the edge was not found.
158
+ */
159
+ jsts.geomgraph.PlanarGraph.prototype.findEdgeInSameDirection = function(p0,
160
+ p1) {
161
+ var i = 0, il = this.edges.size(), e, eCoord;
162
+ for (i; i < il; i++) {
163
+ e = this.edges.get(i);
164
+ eCoord = e.getCoordinates();
165
+
166
+ if (this.matchInSameDirection(p0, p1, eCoord[0], eCoord[1])) {
167
+ return e;
168
+ }
169
+
170
+ if (this.matchInSameDirection(p0, p1, eCoord[eCoord.length - 1],
171
+ eCoord[eCoord.length - 2])) {
172
+ return e;
173
+ }
174
+ }
175
+ return null;
176
+ };
177
+
178
+ /**
179
+ * The coordinate pairs match if they define line segments lying in the same
180
+ * direction. E.g. the segments are parallel and in the same quadrant (as
181
+ * opposed to parallel and opposite!).
182
+ */
183
+ jsts.geomgraph.PlanarGraph.prototype.matchInSameDirection = function(p0, p1,
184
+ ep0, ep1) {
185
+ if (!p0.equals(ep0)) {
186
+ return false;
187
+ }
188
+
189
+ if (jsts.algorithm.CGAlgorithms.computeOrientation(p0, p1, ep1) === jsts.algorithm.CGAlgorithms.COLLINEAR &&
190
+ jsts.geomgraph.Quadrant.quadrant(p0, p1) === jsts.geomgraph.Quadrant
191
+ .quadrant(ep0, ep1)) {
192
+ return true;
193
+ }
194
+ return false;
195
+ };
196
+
197
+ /**
198
+ * Returns the EdgeEnd which has edge e as its base edge (MD 18 Feb 2002 -
199
+ * this should return a pair of edges)
200
+ *
201
+ * @return the edge, if found <code>null</code> if the edge was not found.
202
+ */
203
+ jsts.geomgraph.PlanarGraph.prototype.findEdgeEnd = function(e) {
204
+ for (var i = this.getEdgeEnds().iterator(); i.hasNext();) {
205
+ var ee = i.next();
206
+ if (ee.getEdge() === e) {
207
+ return ee;
208
+ }
209
+ }
210
+ return null;
211
+ };
212
+ })();
213
+
214
+ // TODO: port rest of class