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,181 @@
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/util/Assert.js
11
+ */
12
+
13
+ var Assert = jsts.util.Assert;
14
+
15
+ /**
16
+ * A GraphComponent is the parent class for the objects' that form a graph.
17
+ * Each GraphComponent can carry a Label.
18
+ *
19
+ * @constructor
20
+ */
21
+ jsts.geomgraph.GraphComponent = function(label) {
22
+ this.label = label;
23
+ };
24
+
25
+
26
+ /**
27
+ * @type {Label}
28
+ * @protected
29
+ */
30
+ jsts.geomgraph.GraphComponent.prototype.label = null;
31
+
32
+
33
+ /**
34
+ * isInResult indicates if this component has already been included in the
35
+ * result
36
+ *
37
+ * @type {boolean}
38
+ * @private
39
+ */
40
+ jsts.geomgraph.GraphComponent.prototype._isInResult = false;
41
+
42
+
43
+ /**
44
+ * @type {boolean}
45
+ * @private
46
+ */
47
+ jsts.geomgraph.GraphComponent.prototype._isCovered = false;
48
+
49
+
50
+ /**
51
+ * @type {boolean}
52
+ * @private
53
+ */
54
+ jsts.geomgraph.GraphComponent.prototype._isCoveredSet = false;
55
+
56
+
57
+ /**
58
+ * @type {boolean}
59
+ * @private
60
+ */
61
+ jsts.geomgraph.GraphComponent.prototype._isVisited = false;
62
+
63
+ jsts.geomgraph.GraphComponent.prototype.getLabel = function() {
64
+ return this.label;
65
+ };
66
+ jsts.geomgraph.GraphComponent.prototype.setLabel = function(label) {
67
+ if (arguments.length === 2) {
68
+ this.setLabel2.apply(this, arguments);
69
+ return;
70
+ }
71
+
72
+ this.label = label;
73
+ };
74
+
75
+
76
+ /**
77
+ * @param {boolean}
78
+ * isInResult
79
+ */
80
+ jsts.geomgraph.GraphComponent.prototype.setInResult = function(isInResult) {
81
+ this._isInResult = isInResult;
82
+ };
83
+
84
+
85
+ /**
86
+ * @return {boolean}
87
+ */
88
+ jsts.geomgraph.GraphComponent.prototype.isInResult = function() {
89
+ return this._isInResult;
90
+ };
91
+
92
+
93
+ /**
94
+ * @param {boolean}
95
+ * isCovered
96
+ */
97
+ jsts.geomgraph.GraphComponent.prototype.setCovered = function(isCovered) {
98
+ this._isCovered = isCovered;
99
+ this._isCoveredSet = true;
100
+ };
101
+
102
+
103
+ /**
104
+ * @return {boolean}
105
+ */
106
+ jsts.geomgraph.GraphComponent.prototype.isCovered = function() {
107
+ return this._isCovered;
108
+ };
109
+
110
+
111
+ /**
112
+ * @return {boolean}
113
+ */
114
+ jsts.geomgraph.GraphComponent.prototype.isCoveredSet = function() {
115
+ return this._isCoveredSet;
116
+ };
117
+
118
+
119
+ /**
120
+ * @return {boolean}
121
+ */
122
+ jsts.geomgraph.GraphComponent.prototype.isVisited = function() {
123
+ return this._isVisited;
124
+ };
125
+
126
+
127
+ /**
128
+ * @param {boolean}
129
+ * isVisited
130
+ */
131
+ jsts.geomgraph.GraphComponent.prototype.setVisited = function(isVisited) {
132
+ this._isVisited = isVisited;
133
+ };
134
+
135
+
136
+ /**
137
+ * @return {Coordinate} a coordinate in this component (or null, if there are
138
+ * none).
139
+ */
140
+ jsts.geomgraph.GraphComponent.prototype.getCoordinate = function() {
141
+ throw new jsts.error.AbstractMethodInvocationError();
142
+ };
143
+
144
+
145
+ /**
146
+ * compute the contribution to an IM for this component
147
+ *
148
+ * @param {IntersectionMatrix}
149
+ * im
150
+ * @protected
151
+ */
152
+ jsts.geomgraph.GraphComponent.prototype.computeIM = function(im) {
153
+ throw new jsts.error.AbstractMethodInvocationError();
154
+ };
155
+
156
+
157
+ /**
158
+ * An isolated component is one that does not intersect or touch any other
159
+ * component. This is the case if the label has valid locations for only a
160
+ * single Geometry.
161
+ *
162
+ * @return true if this component is isolated.
163
+ */
164
+ jsts.geomgraph.GraphComponent.prototype.isIsolated = function() {
165
+ throw new jsts.error.AbstractMethodInvocationError();
166
+ };
167
+
168
+
169
+ /**
170
+ * Update the IM with the contribution for this component. A component only
171
+ * contributes if it has a labelling for both parent geometries
172
+ *
173
+ * @param {IntersectionMatrix}
174
+ * im
175
+ */
176
+ jsts.geomgraph.GraphComponent.prototype.updateIM = function(im) {
177
+ Assert.isTrue(this.label.getGeometryCount() >= 2, 'found partial label');
178
+ this.computeIM(im);
179
+ };
180
+
181
+ })();
@@ -0,0 +1,316 @@
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/TopologyLocation.js
9
+ */
10
+
11
+ /**
12
+ * A <code>Label</code> indicates the topological relationship of a component
13
+ * of a topology graph to a given <code>Geometry</code>. This class supports
14
+ * labels for relationships to two <code>Geometry</code>s, which is
15
+ * sufficient for algorithms for binary operations.
16
+ * <P>
17
+ * Topology graphs support the concept of labeling nodes and edges in the graph.
18
+ * The label of a node or edge specifies its topological relationship to one or
19
+ * more geometries. (In fact, since JTS operations have only two arguments
20
+ * labels are required for only two geometries). A label for a node or edge has
21
+ * one or two elements, depending on whether the node or edge occurs in one or
22
+ * both of the input <code>Geometry</code>s. Elements contain attributes
23
+ * which categorize the topological location of the node or edge relative to the
24
+ * parent <code>Geometry</code>; that is, whether the node or edge is in the
25
+ * interior, boundary or exterior of the <code>Geometry</code>. Attributes
26
+ * have a value from the set <code>{Interior, Boundary, Exterior}</code>. In
27
+ * a node each element has a single attribute <code>&lt;On&gt;</code>. For an
28
+ * edge each element has a triplet of attributes
29
+ * <code>&lt;Left, On, Right&gt;</code>.
30
+ * <P>
31
+ * It is up to the client code to associate the 0 and 1
32
+ * <code>TopologyLocation</code>s with specific geometries.
33
+ *
34
+ * @constructor
35
+ */
36
+ jsts.geomgraph.Label = function() {
37
+ this.elt = [];
38
+
39
+ var geomIndex, onLoc, leftLoc, lbl, rightLoc;
40
+ if (arguments.length === 4) {
41
+ geomIndex = arguments[0];
42
+ onLoc = arguments[1];
43
+ leftLoc = arguments[2];
44
+ rightLoc = arguments[3];
45
+ this.elt[0] = new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE,
46
+ jsts.geom.Location.NONE, jsts.geom.Location.NONE);
47
+ this.elt[1] = new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE,
48
+ jsts.geom.Location.NONE, jsts.geom.Location.NONE);
49
+ this.elt[geomIndex].setLocations(onLoc, leftLoc, rightLoc);
50
+ } else if (arguments.length === 3) {
51
+ onLoc = arguments[0];
52
+ leftLoc = arguments[1];
53
+ rightLoc = arguments[2];
54
+ this.elt[0] = new jsts.geomgraph.TopologyLocation(onLoc, leftLoc, rightLoc);
55
+ this.elt[1] = new jsts.geomgraph.TopologyLocation(onLoc, leftLoc, rightLoc);
56
+ } else if (arguments.length === 2) {
57
+ geomIndex = arguments[0];
58
+ onLoc = arguments[1];
59
+ this.elt[0] = new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE);
60
+ this.elt[1] = new jsts.geomgraph.TopologyLocation(jsts.geom.Location.NONE);
61
+ this.elt[geomIndex].setLocation(onLoc);
62
+ } else if (arguments[0] instanceof jsts.geomgraph.Label) {
63
+ lbl = arguments[0];
64
+ this.elt[0] = new jsts.geomgraph.TopologyLocation(lbl.elt[0]);
65
+ this.elt[1] = new jsts.geomgraph.TopologyLocation(lbl.elt[1]);
66
+ } else if (typeof arguments[0] === 'number') {
67
+ onLoc = arguments[0];
68
+ this.elt[0] = new jsts.geomgraph.TopologyLocation(onLoc);
69
+ this.elt[1] = new jsts.geomgraph.TopologyLocation(onLoc);
70
+ }
71
+ };
72
+
73
+
74
+ /**
75
+ * converts a Label to a Line label (that is, one with no side Locations)
76
+ *
77
+ * @param {label}
78
+ * label
79
+ * @return {Label}
80
+ */
81
+ jsts.geomgraph.Label.toLineLabel = function(label) {
82
+ var i, lineLabel = new jsts.geomgraph.Label(jsts.geom.Location.NONE);
83
+ for (i = 0; i < 2; i++) {
84
+ lineLabel.setLocation(i, label.getLocation(i));
85
+ }
86
+ return lineLabel;
87
+ };
88
+
89
+
90
+ /**
91
+ * @type {TopologyLocation[]}
92
+ * @private
93
+ */
94
+ jsts.geomgraph.Label.prototype.elt = null;
95
+
96
+ jsts.geomgraph.Label.prototype.flip = function() {
97
+ this.elt[0].flip();
98
+ this.elt[1].flip();
99
+ };
100
+
101
+
102
+ /**
103
+ * @param {int}
104
+ * geomIndex
105
+ * @param {int}
106
+ * posIndex
107
+ * @return {int}
108
+ */
109
+ jsts.geomgraph.Label.prototype.getLocation = function(geomIndex, posIndex) {
110
+ if (arguments.length == 1) {
111
+ return this.getLocation2.apply(this, arguments);
112
+ }
113
+ return this.elt[geomIndex].get(posIndex);
114
+ };
115
+
116
+
117
+ /**
118
+ * @param {int}
119
+ * geomIndex
120
+ * @return {int}
121
+ */
122
+ jsts.geomgraph.Label.prototype.getLocation2 = function(geomIndex) {
123
+ return this.elt[geomIndex].get(jsts.geomgraph.Position.ON);
124
+ };
125
+
126
+
127
+ /**
128
+ * @param {int}
129
+ * geomIndex
130
+ * @param {int}
131
+ * posIndex
132
+ * @param {int}
133
+ * location
134
+ */
135
+ jsts.geomgraph.Label.prototype.setLocation = function(geomIndex, posIndex,
136
+ location) {
137
+ if (arguments.length == 2) {
138
+ this.setLocation2.apply(this, arguments);
139
+ return;
140
+ }
141
+
142
+ this.elt[geomIndex].setLocation(posIndex, location);
143
+ };
144
+
145
+
146
+ /**
147
+ * @param {int}
148
+ * geomIndex
149
+ * @param {int}
150
+ * location
151
+ */
152
+ jsts.geomgraph.Label.prototype.setLocation2 = function(geomIndex, location) {
153
+ this.elt[geomIndex].setLocation(jsts.geomgraph.Position.ON, location);
154
+ };
155
+
156
+
157
+ /**
158
+ * @param {int}
159
+ * geomIndex
160
+ * @param {int}
161
+ * location
162
+ */
163
+ jsts.geomgraph.Label.prototype.setAllLocations = function(geomIndex, location) {
164
+ this.elt[geomIndex].setAllLocations(location);
165
+ };
166
+
167
+
168
+ /**
169
+ * @param {int}
170
+ * geomIndex
171
+ * @param {int}
172
+ * location
173
+ */
174
+ jsts.geomgraph.Label.prototype.setAllLocationsIfNull = function(geomIndex,
175
+ location) {
176
+ if (arguments.length == 1) {
177
+ this.setAllLocationsIfNull2.apply(this, arguments);
178
+ return;
179
+ }
180
+
181
+ this.elt[geomIndex].setAllLocationsIfNull(location);
182
+ };
183
+
184
+
185
+ /**
186
+ * @param {int}
187
+ * location
188
+ */
189
+ jsts.geomgraph.Label.prototype.setAllLocationsIfNull2 = function(location) {
190
+ this.setAllLocationsIfNull(0, location);
191
+ this.setAllLocationsIfNull(1, location);
192
+ };
193
+
194
+
195
+ /**
196
+ * Merge this label with another one. Merging updates any null attributes of
197
+ * this label with the attributes from lbl
198
+ *
199
+ * @param {Label}
200
+ * lbl
201
+ */
202
+ jsts.geomgraph.Label.prototype.merge = function(lbl) {
203
+ var i;
204
+ for (i = 0; i < 2; i++) {
205
+ if (this.elt[i] === null && lbl.elt[i] !== null) {
206
+ this.elt[i] = new jsts.geomgraph.TopologyLocation(lbl.elt[i]);
207
+ } else {
208
+ this.elt[i].merge(lbl.elt[i]);
209
+ }
210
+ }
211
+ };
212
+
213
+
214
+ /**
215
+ * @return {int}
216
+ */
217
+ jsts.geomgraph.Label.prototype.getGeometryCount = function() {
218
+ var count = 0;
219
+ if (!this.elt[0].isNull()) {
220
+ count++;
221
+ }
222
+ if (!this.elt[1].isNull()) {
223
+ count++;
224
+ }
225
+ return count;
226
+ };
227
+
228
+
229
+ /**
230
+ * @param {int}
231
+ * geomIndex
232
+ * @return {boolean}
233
+ */
234
+ jsts.geomgraph.Label.prototype.isNull = function(geomIndex) {
235
+ return this.elt[geomIndex].isNull();
236
+ };
237
+
238
+
239
+ /**
240
+ * @param {int}
241
+ * geomIndex
242
+ * @return {boolean}
243
+ */
244
+ jsts.geomgraph.Label.prototype.isAnyNull = function(geomIndex) {
245
+ return this.elt[geomIndex].isAnyNull();
246
+ };
247
+
248
+
249
+ /**
250
+ * @return {boolean}
251
+ */
252
+ jsts.geomgraph.Label.prototype.isArea = function() {
253
+ if (arguments.length == 1) {
254
+ return this.isArea2(arguments[0]);
255
+ }
256
+
257
+ return this.elt[0].isArea() || this.elt[1].isArea();
258
+ };
259
+
260
+
261
+ /**
262
+ * @param {int}
263
+ * geomIndex
264
+ * @return {boolean}
265
+ */
266
+ jsts.geomgraph.Label.prototype.isArea2 = function(geomIndex) {
267
+ return this.elt[geomIndex].isArea();
268
+ };
269
+
270
+
271
+ /**
272
+ * @param {int}
273
+ * geomIndex
274
+ * @return {boolean}
275
+ */
276
+ jsts.geomgraph.Label.prototype.isLine = function(geomIndex) {
277
+ return this.elt[geomIndex].isLine();
278
+ };
279
+
280
+
281
+ /**
282
+ * @param {Label}
283
+ * lbl
284
+ * @param {int}
285
+ * side
286
+ * @return {boolean}
287
+ */
288
+ jsts.geomgraph.Label.prototype.isEqualOnSide = function(lbl, side) {
289
+ return this.elt[0].isEqualOnSide(lbl.elt[0], side) &&
290
+ this.elt[1].isEqualOnSide(lbl.elt[1], side);
291
+ };
292
+
293
+
294
+ /**
295
+ * @param {int}
296
+ * geomIndex
297
+ * @param {int}
298
+ * loc
299
+ * @return {boolean}
300
+ */
301
+ jsts.geomgraph.Label.prototype.allPositionsEqual = function(geomIndex, loc) {
302
+ return this.elt[geomIndex].allPositionsEqual(loc);
303
+ };
304
+
305
+
306
+ /**
307
+ * Converts one GeometryLocation to a Line location
308
+ *
309
+ * @param {int}
310
+ * geomIndex
311
+ */
312
+ jsts.geomgraph.Label.prototype.toLine = function(geomIndex) {
313
+ if (this.elt[geomIndex].isArea()) {
314
+ this.elt[geomIndex] = new jsts.geomgraph.TopologyLocation(this.elt[geomIndex].location[0]);
315
+ }
316
+ };