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,322 @@
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/geom/Location.js
9
+ */
10
+
11
+
12
+
13
+ /**
14
+ * A EdgeEndStar is an ordered list of EdgeEnds around a node. They are
15
+ * maintained in CCW order (starting with the positive x-axis) around the node
16
+ * for efficient lookup and topology building.
17
+ *
18
+ * @constructor
19
+ */
20
+ jsts.geomgraph.EdgeEndStar = function() {
21
+ this.edgeMap = new javascript.util.TreeMap();
22
+ this.edgeList = null;
23
+ this.ptInAreaLocation = [jsts.geom.Location.NONE, jsts.geom.Location.NONE];
24
+ };
25
+
26
+
27
+ /**
28
+ * A map which maintains the edges in sorted order around the node
29
+ *
30
+ * NOTE: In In JSTS a JS object replaces TreeMap. Sorting is done when needed.
31
+ *
32
+ * @protected
33
+ */
34
+ jsts.geomgraph.EdgeEndStar.prototype.edgeMap = null;
35
+
36
+
37
+ /**
38
+ * A list of all outgoing edges in the result, in CCW order
39
+ *
40
+ * @protected
41
+ */
42
+ jsts.geomgraph.EdgeEndStar.prototype.edgeList = null;
43
+
44
+
45
+ /**
46
+ * The location of the point for this star in Geometry i Areas
47
+ *
48
+ * @private
49
+ */
50
+ jsts.geomgraph.EdgeEndStar.prototype.ptInAreaLocation = null;
51
+
52
+
53
+ /**
54
+ * Insert a EdgeEnd into this EdgeEndStar
55
+ */
56
+ jsts.geomgraph.EdgeEndStar.prototype.insert = function(e) {
57
+ throw new jsts.error.AbstractMethodInvocationError();
58
+ };
59
+
60
+
61
+ /**
62
+ * Insert an EdgeEnd into the map, and clear the edgeList cache, since the list
63
+ * of edges has now changed
64
+ *
65
+ * @protected
66
+ */
67
+ jsts.geomgraph.EdgeEndStar.prototype.insertEdgeEnd = function(e, obj) {
68
+ this.edgeMap.put(e, obj);
69
+ this.edgeList = null; // edge list has changed - clear the cache
70
+ };
71
+
72
+
73
+ /**
74
+ * @return the coordinate for the node this star is based at.
75
+ */
76
+ jsts.geomgraph.EdgeEndStar.prototype.getCoordinate = function() {
77
+ var it = this.iterator();
78
+ if (!it.hasNext())
79
+ return null;
80
+ var e = it.next();
81
+ return e.getCoordinate();
82
+ };
83
+ jsts.geomgraph.EdgeEndStar.prototype.getDegree = function() {
84
+ return this.edgeMap.size();
85
+ };
86
+
87
+
88
+ /**
89
+ * Iterator access to the ordered list of edges is optimized by copying the map
90
+ * collection to a list. (This assumes that once an iterator is requested, it is
91
+ * likely that insertion into the map is complete).
92
+ */
93
+ jsts.geomgraph.EdgeEndStar.prototype.iterator = function() {
94
+ return this.getEdges().iterator();
95
+ };
96
+
97
+ jsts.geomgraph.EdgeEndStar.prototype.getEdges = function() {
98
+ if (this.edgeList === null) {
99
+ this.edgeList = new javascript.util.ArrayList(this.edgeMap.values());
100
+ }
101
+ return this.edgeList;
102
+ };
103
+
104
+ jsts.geomgraph.EdgeEndStar.prototype.getNextCW = function(ee) {
105
+ this.getEdges();
106
+ var i = this.edgeList.indexOf(ee);
107
+ var iNextCW = i - 1;
108
+ if (i === 0)
109
+ iNextCW = this.edgeList.length - 1;
110
+ return this.edgeList[iNextCW];
111
+ };
112
+
113
+ jsts.geomgraph.EdgeEndStar.prototype.computeLabelling = function(geomGraph) {
114
+ this.computeEdgeEndLabels(geomGraph[0].getBoundaryNodeRule());
115
+ this.propagateSideLabels(0);
116
+ this.propagateSideLabels(1);
117
+
118
+ /**
119
+ * If there are edges that still have null labels for a geometry this must be
120
+ * because there are no area edges for that geometry incident on this node. In
121
+ * this case, to label the edge for that geometry we must test whether the
122
+ * edge is in the interior of the geometry. To do this it suffices to
123
+ * determine whether the node for the edge is in the interior of an area. If
124
+ * so, the edge has location INTERIOR for the geometry. In all other cases
125
+ * (e.g. the node is on a line, on a point, or not on the geometry at all) the
126
+ * edge has the location EXTERIOR for the geometry.
127
+ * <p>
128
+ * Note that the edge cannot be on the BOUNDARY of the geometry, since then
129
+ * there would have been a parallel edge from the Geometry at this node also
130
+ * labelled BOUNDARY and this edge would have been labelled in the previous
131
+ * step.
132
+ * <p>
133
+ * This code causes a problem when dimensional collapses are present, since it
134
+ * may try and determine the location of a node where a dimensional collapse
135
+ * has occurred. The point should be considered to be on the EXTERIOR of the
136
+ * polygon, but locate() will return INTERIOR, since it is passed the original
137
+ * Geometry, not the collapsed version.
138
+ *
139
+ * If there are incident edges which are Line edges labelled BOUNDARY, then
140
+ * they must be edges resulting from dimensional collapses. In this case the
141
+ * other edges can be labelled EXTERIOR for this Geometry.
142
+ *
143
+ * MD 8/11/01 - NOT TRUE! The collapsed edges may in fact be in the interior
144
+ * of the Geometry, which means the other edges should be labelled INTERIOR
145
+ * for this Geometry. Not sure how solve this... Possibly labelling needs to
146
+ * be split into several phases: area label propagation, symLabel merging,
147
+ * then finally null label resolution.
148
+ */
149
+ var hasDimensionalCollapseEdge = [false, false];
150
+ for (var it = this.iterator(); it.hasNext();) {
151
+ var e = it.next();
152
+ var label = e.getLabel();
153
+ for (var geomi = 0; geomi < 2; geomi++) {
154
+ if (label.isLine(geomi) &&
155
+ label.getLocation(geomi) === jsts.geom.Location.BOUNDARY)
156
+ hasDimensionalCollapseEdge[geomi] = true;
157
+ }
158
+ }
159
+ for (var it = this.iterator(); it.hasNext();) {
160
+ var e = it.next();
161
+ var label = e.getLabel();
162
+ for (var geomi = 0; geomi < 2; geomi++) {
163
+ if (label.isAnyNull(geomi)) {
164
+ var loc = jsts.geom.Location.NONE;
165
+ if (hasDimensionalCollapseEdge[geomi]) {
166
+ loc = jsts.geom.Location.EXTERIOR;
167
+ } else {
168
+ var p = e.getCoordinate();
169
+ loc = this.getLocation(geomi, p, geomGraph);
170
+ }
171
+ label.setAllLocationsIfNull(geomi, loc);
172
+ }
173
+ }
174
+ }
175
+ };
176
+
177
+
178
+ /**
179
+ * @private
180
+ */
181
+ jsts.geomgraph.EdgeEndStar.prototype.computeEdgeEndLabels = function(
182
+ boundaryNodeRule) {
183
+ // Compute edge label for each EdgeEnd
184
+ for (var it = this.iterator(); it.hasNext();) {
185
+ var ee = it.next();
186
+ ee.computeLabel(boundaryNodeRule);
187
+ }
188
+ };
189
+
190
+
191
+ /**
192
+ * @private
193
+ */
194
+ jsts.geomgraph.EdgeEndStar.prototype.getLocation = function(geomIndex, p, geom) {
195
+ // compute location only on demand
196
+ if (this.ptInAreaLocation[geomIndex] === jsts.geom.Location.NONE) {
197
+ this.ptInAreaLocation[geomIndex] = jsts.algorithm.locate.SimplePointInAreaLocator
198
+ .locate(p, geom[geomIndex].getGeometry());
199
+ }
200
+ return this.ptInAreaLocation[geomIndex];
201
+ };
202
+
203
+ jsts.geomgraph.EdgeEndStar.prototype.isAreaLabelsConsistent = function(
204
+ geomGraph) {
205
+ this.computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());
206
+ return this.checkAreaLabelsConsistent(0);
207
+ };
208
+
209
+
210
+ /**
211
+ * @private
212
+ */
213
+ jsts.geomgraph.EdgeEndStar.prototype.checkAreaLabelsConsistent = function(
214
+ geomIndex) {
215
+ // Since edges are stored in CCW order around the node,
216
+ // As we move around the ring we move from the right to the left side of the
217
+ // edge
218
+ var edges = this.getEdges();
219
+ // if no edges, trivially consistent
220
+ if (edges.size() <= 0)
221
+ return true;
222
+ // initialize startLoc to location of last L side (if any)
223
+ var lastEdgeIndex = edges.size() - 1;
224
+ var startLabel = edges.get(lastEdgeIndex).getLabel();
225
+ var startLoc = startLabel
226
+ .getLocation(geomIndex, jsts.geomgraph.Position.LEFT);
227
+ jsts.util.Assert.isTrue(startLoc != jsts.geom.Location.NONE,
228
+ 'Found unlabelled area edge');
229
+
230
+ var currLoc = startLoc;
231
+ for (var it = this.iterator(); it.hasNext();) {
232
+ var e = it.next();
233
+ var label = e.getLabel();
234
+ // we assume that we are only checking a area
235
+ jsts.util.Assert.isTrue(label.isArea(geomIndex), 'Found non-area edge');
236
+ var leftLoc = label.getLocation(geomIndex, jsts.geomgraph.Position.LEFT);
237
+ var rightLoc = label.getLocation(geomIndex, jsts.geomgraph.Position.RIGHT);
238
+ // check that edge is really a boundary between inside and outside!
239
+ if (leftLoc === rightLoc) {
240
+ return false;
241
+ }
242
+
243
+ if (rightLoc !== currLoc) {
244
+ return false;
245
+ }
246
+ currLoc = leftLoc;
247
+ }
248
+ return true;
249
+ };
250
+
251
+
252
+ /**
253
+ * @private
254
+ */
255
+ jsts.geomgraph.EdgeEndStar.prototype.propagateSideLabels = function(geomIndex) {
256
+ // Since edges are stored in CCW order around the node,
257
+ // As we move around the ring we move from the right to the left side of the
258
+ // edge
259
+ var startLoc = jsts.geom.Location.NONE;
260
+
261
+ // initialize loc to location of last L side (if any)
262
+ for (var it = this.iterator(); it.hasNext();) {
263
+ var e = it.next();
264
+ var label = e.getLabel();
265
+ if (label.isArea(geomIndex) &&
266
+ label.getLocation(geomIndex, jsts.geomgraph.Position.LEFT) !== jsts.geom.Location.NONE)
267
+ startLoc = label.getLocation(geomIndex, jsts.geomgraph.Position.LEFT);
268
+ }
269
+
270
+ // no labelled sides found, so no labels to propagate
271
+ if (startLoc === jsts.geom.Location.NONE)
272
+ return;
273
+
274
+ var currLoc = startLoc;
275
+ for (var it = this.iterator(); it.hasNext();) {
276
+ var e = it.next();
277
+ var label = e.getLabel();
278
+ // set null ON values to be in current location
279
+ if (label.getLocation(geomIndex, jsts.geomgraph.Position.ON) === jsts.geom.Location.NONE)
280
+ label.setLocation(geomIndex, jsts.geomgraph.Position.ON, currLoc);
281
+ // set side labels (if any)
282
+ if (label.isArea(geomIndex)) {
283
+ var leftLoc = label.getLocation(geomIndex, jsts.geomgraph.Position.LEFT);
284
+ var rightLoc = label
285
+ .getLocation(geomIndex, jsts.geomgraph.Position.RIGHT);
286
+ // if there is a right location, that is the next location to propagate
287
+ if (rightLoc !== jsts.geom.Location.NONE) {
288
+ if (rightLoc !== currLoc)
289
+ throw new jsts.error.TopologyError('side location conflict', e
290
+ .getCoordinate());
291
+ if (leftLoc === jsts.geom.Location.NONE) {
292
+ jsts.util.Assert.shouldNeverReachHere('found single null side (at ' +
293
+ e.getCoordinate() + ')');
294
+ }
295
+ currLoc = leftLoc;
296
+ } else {
297
+ /**
298
+ * RHS is null - LHS must be null too. This must be an edge from the
299
+ * other geometry, which has no location labelling for this geometry.
300
+ * This edge must lie wholly inside or outside the other geometry (which
301
+ * is determined by the current location). Assign both sides to be the
302
+ * current location.
303
+ */
304
+ jsts.util.Assert.isTrue(label.getLocation(geomIndex,
305
+ jsts.geomgraph.Position.LEFT) === jsts.geom.Location.NONE,
306
+ 'found single null side');
307
+ label.setLocation(geomIndex, jsts.geomgraph.Position.RIGHT, currLoc);
308
+ label.setLocation(geomIndex, jsts.geomgraph.Position.LEFT, currLoc);
309
+ }
310
+ }
311
+ }
312
+ };
313
+
314
+ jsts.geomgraph.EdgeEndStar.prototype.findIndex = function(eSearch) {
315
+ this.iterator(); // force edgelist to be computed
316
+ for (var i = 0; i < this.edgeList.size(); i++) {
317
+ var e = this.edgeList.get(i);
318
+ if (e === eSearch)
319
+ return i;
320
+ }
321
+ return -1;
322
+ };
@@ -0,0 +1,122 @@
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
+ * @param {Coordinate}
11
+ * coord
12
+ * @param {int}
13
+ * segmentIndex
14
+ * @param {double}
15
+ * dist
16
+ * @constructor
17
+ */
18
+ jsts.geomgraph.EdgeIntersection = function(coord, segmentIndex, dist) {
19
+ this.coord = new jsts.geom.Coordinate(coord);
20
+ this.segmentIndex = segmentIndex;
21
+ this.dist = dist;
22
+ };
23
+
24
+
25
+ /**
26
+ * the point of intersection
27
+ *
28
+ * @type {Coordinate}
29
+ */
30
+ jsts.geomgraph.EdgeIntersection.prototype.coord = null;
31
+
32
+
33
+ /**
34
+ * the index of the containing line segment in the parent edge
35
+ *
36
+ * @type {int}
37
+ */
38
+ jsts.geomgraph.EdgeIntersection.prototype.segmentIndex = null;
39
+
40
+
41
+ /**
42
+ * the edge distance of this point along the containing line segment
43
+ *
44
+ * @type {double}
45
+ */
46
+ jsts.geomgraph.EdgeIntersection.prototype.dist = null;
47
+
48
+
49
+ /**
50
+ * @return {Coordinate}
51
+ */
52
+ jsts.geomgraph.EdgeIntersection.prototype.getCoordinate = function() {
53
+ return this.coord;
54
+ };
55
+
56
+
57
+ /**
58
+ * @return {int}
59
+ */
60
+ jsts.geomgraph.EdgeIntersection.prototype.getSegmentIndex = function() {
61
+ return this.segmentIndex;
62
+ };
63
+
64
+
65
+ /**
66
+ * @return {double}
67
+ */
68
+ jsts.geomgraph.EdgeIntersection.prototype.getDistance = function() {
69
+ return this.dist;
70
+ };
71
+
72
+
73
+ /**
74
+ * @param {EdgeIntersection}
75
+ * other
76
+ * @return {int}
77
+ */
78
+ jsts.geomgraph.EdgeIntersection.prototype.compareTo = function(other) {
79
+ return this.compare(other.segmentIndex, other.dist);
80
+ };
81
+
82
+
83
+ /**
84
+ * @param {int}
85
+ * segmentIndex
86
+ * @param {double}
87
+ * dist
88
+ * @return {int} -1 this EdgeIntersection is located before the argument
89
+ * location.
90
+ * @return {int} 0 this EdgeIntersection is at the argument location.
91
+ * @return {int} 1 this EdgeIntersection is located after the argument location.
92
+ */
93
+ jsts.geomgraph.EdgeIntersection.prototype.compare = function(segmentIndex, dist) {
94
+ if (this.segmentIndex < segmentIndex)
95
+ return -1;
96
+ if (this.segmentIndex > segmentIndex)
97
+ return 1;
98
+ if (this.dist < dist)
99
+ return -1;
100
+ if (this.dist > dist)
101
+ return 1;
102
+ return 0;
103
+ };
104
+
105
+
106
+ /**
107
+ * @param {int}
108
+ * maxSegmentIndex
109
+ * @return {boolean}
110
+ */
111
+ jsts.geomgraph.EdgeIntersection.prototype.isEndPoint = function(maxSegmentIndex) {
112
+ if (this.segmentIndex === 0 && this.dist === 0.0)
113
+ return true;
114
+ if (this.segmentIndex === maxSegmentIndex)
115
+ return true;
116
+ return false;
117
+ };
118
+
119
+ jsts.geomgraph.EdgeIntersection.prototype.toString = function() {
120
+ return '' + this.segmentIndex + this.dist;
121
+ };
122
+
@@ -0,0 +1,146 @@
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/geomgraph/EdgeIntersection.js
11
+ */
12
+
13
+ var EdgeIntersection = jsts.geomgraph.EdgeIntersection;
14
+ var TreeMap = javascript.util.TreeMap;
15
+
16
+ /**
17
+ * @constructor
18
+ * @name jsts.geomgraph.EdgeIntersectionList
19
+ */
20
+ jsts.geomgraph.EdgeIntersectionList = function(edge) {
21
+ this.nodeMap = new TreeMap();
22
+ this.edge = edge;
23
+ };
24
+
25
+
26
+
27
+ /**
28
+ * @type {javascript.util.Map}
29
+ * @private
30
+ */
31
+ jsts.geomgraph.EdgeIntersectionList.prototype.nodeMap = null;
32
+
33
+
34
+ /**
35
+ * the parent edge
36
+ *
37
+ * @type {Edge}
38
+ */
39
+ jsts.geomgraph.EdgeIntersectionList.prototype.edge = null;
40
+
41
+ jsts.geomgraph.EdgeIntersectionList.prototype.isIntersection = function(pt) {
42
+ for (var it = this.iterator(); it.hasNext(); ) {
43
+ var ei = it.next();
44
+ if (ei.coord.equals(pt)) {
45
+ return true;
46
+ }
47
+ }
48
+ return false;
49
+ };
50
+
51
+
52
+ /**
53
+ * Adds an intersection into the list, if it isn't already there. The input
54
+ * segmentIndex and dist are expected to be normalized.
55
+ *
56
+ * @param {Coordinate}
57
+ * intPt
58
+ * @param {int}
59
+ * segmentIndex
60
+ * @param {double}
61
+ * dist
62
+ * @return {EdgeIntersection} the EdgeIntersection found or added.
63
+ */
64
+ jsts.geomgraph.EdgeIntersectionList.prototype.add = function(intPt, segmentIndex, dist) {
65
+ var eiNew = new EdgeIntersection(intPt, segmentIndex, dist);
66
+ var ei = this.nodeMap.get(eiNew);
67
+ if (ei !== null) {
68
+ return ei;
69
+ }
70
+ this.nodeMap.put(eiNew, eiNew);
71
+ return eiNew;
72
+ };
73
+
74
+ /**
75
+ * Returns an iterator of {@link EdgeIntersection}s
76
+ *
77
+ * @return an Iterator of EdgeIntersections.
78
+ */
79
+ jsts.geomgraph.EdgeIntersectionList.prototype.iterator = function() {
80
+ return this.nodeMap.values().iterator();
81
+ };
82
+
83
+
84
+ /**
85
+ * Adds entries for the first and last points of the edge to the list
86
+ */
87
+ jsts.geomgraph.EdgeIntersectionList.prototype.addEndpoints = function() {
88
+ var maxSegIndex = this.edge.pts.length - 1;
89
+ this.add(this.edge.pts[0], 0, 0.0);
90
+ this.add(this.edge.pts[maxSegIndex], maxSegIndex, 0.0);
91
+ };
92
+
93
+ /**
94
+ * Creates new edges for all the edges that the intersections in this
95
+ * list split the parent edge into.
96
+ * Adds the edges to the input list (this is so a single list
97
+ * can be used to accumulate all split edges for a Geometry).
98
+ *
99
+ * @param edgeList a list of EdgeIntersections.
100
+ */
101
+ jsts.geomgraph.EdgeIntersectionList.prototype.addSplitEdges = function(edgeList)
102
+ {
103
+ // ensure that the list has entries for the first and last point of the edge
104
+ this.addEndpoints();
105
+
106
+ var it = this.iterator();
107
+ // there should always be at least two entries in the list
108
+ var eiPrev = it.next();
109
+ while (it.hasNext()) {
110
+ var ei = it.next();
111
+ var newEdge = this.createSplitEdge(eiPrev, ei);
112
+ edgeList.add(newEdge);
113
+
114
+ eiPrev = ei;
115
+ }
116
+ };
117
+ /**
118
+ * Create a new "split edge" with the section of points between
119
+ * (and including) the two intersections.
120
+ * The label for the new edge is the same as the label for the parent edge.
121
+ */
122
+ jsts.geomgraph.EdgeIntersectionList.prototype.createSplitEdge = function(ei0, ei1) {
123
+ var npts = ei1.segmentIndex - ei0.segmentIndex + 2;
124
+
125
+ var lastSegStartPt = this.edge.pts[ei1.segmentIndex];
126
+ // if the last intersection point is not equal to the its segment start pt,
127
+ // add it to the points list as well.
128
+ // (This check is needed because the distance metric is not totally reliable!)
129
+ // The check for point equality is 2D only - Z values are ignored
130
+ var useIntPt1 = ei1.dist > 0.0 || ! ei1.coord.equals2D(lastSegStartPt);
131
+ if (! useIntPt1) {
132
+ npts--;
133
+ }
134
+
135
+ var pts = [];
136
+ var ipt = 0;
137
+ pts[ipt++] = new jsts.geom.Coordinate(ei0.coord);
138
+ for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
139
+ pts[ipt++] = this.edge.pts[i];
140
+ }
141
+ if (useIntPt1) pts[ipt] = ei1.coord;
142
+ return new jsts.geomgraph.Edge(pts, new jsts.geomgraph.Label(this.edge.label));
143
+ };
144
+
145
+ })();
146
+