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,63 @@
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
+ (function() {
9
+
10
+ /**
11
+ * A Position indicates the position of a Location relative to a graph
12
+ * component (Node, Edge, or Area).
13
+ *
14
+ * @constructor
15
+ */
16
+ jsts.geomgraph.Position = function() {
17
+
18
+ };
19
+
20
+
21
+ /**
22
+ * An indicator that a Location is <i>on</i> a GraphComponent
23
+ *
24
+ * @type {int}
25
+ */
26
+ jsts.geomgraph.Position.ON = 0;
27
+
28
+
29
+ /**
30
+ * An indicator that a Location is to the <i>left</i> of a GraphComponent
31
+ *
32
+ * @type {int}
33
+ */
34
+ jsts.geomgraph.Position.LEFT = 1;
35
+
36
+
37
+ /**
38
+ * An indicator that a Location is to the <i>right</i> of a GraphComponent
39
+ *
40
+ * @type {int}
41
+ */
42
+ jsts.geomgraph.Position.RIGHT = 2;
43
+
44
+
45
+ /**
46
+ * Returns LEFT if the position is RIGHT, RIGHT if the position is LEFT, or
47
+ * the position otherwise.
48
+ *
49
+ * @param {int}
50
+ * position
51
+ * @return {int}
52
+ */
53
+ jsts.geomgraph.Position.opposite = function(position) {
54
+ if (position === jsts.geomgraph.Position.LEFT) {
55
+ return jsts.geomgraph.Position.RIGHT;
56
+ }
57
+ if (position === jsts.geomgraph.Position.RIGHT) {
58
+ return jsts.geomgraph.Position.LEFT;
59
+ }
60
+ return position;
61
+ };
62
+
63
+ })();
@@ -0,0 +1,143 @@
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
+ * Utility functions for working with quadrants, which are numbered as follows:
11
+ *
12
+ * <pre>
13
+ * 1 | 0
14
+ * --+--
15
+ * 2 | 3
16
+ * &lt;pre&gt;
17
+ * @constructor
18
+ *
19
+ */
20
+ jsts.geomgraph.Quadrant = function() {
21
+
22
+ };
23
+
24
+ jsts.geomgraph.Quadrant.NE = 0;
25
+ jsts.geomgraph.Quadrant.NW = 1;
26
+ jsts.geomgraph.Quadrant.SW = 2;
27
+ jsts.geomgraph.Quadrant.SE = 3;
28
+
29
+
30
+ /**
31
+ * Returns the quadrant of a directed line segment (specified as x and y
32
+ * displacements, which cannot both be 0).
33
+ *
34
+ * @throws IllegalArgumentException
35
+ * if the displacements are both 0
36
+ */
37
+ jsts.geomgraph.Quadrant.quadrant = function(dx, dy) {
38
+ if (dx instanceof jsts.geom.Coordinate) {
39
+ return jsts.geomgraph.Quadrant.quadrant2.apply(this, arguments);
40
+ }
41
+
42
+ if (dx === 0.0 && dy === 0.0)
43
+ throw new jsts.error.IllegalArgumentError(
44
+ 'Cannot compute the quadrant for point ( ' + dx + ', ' + dy + ' )');
45
+ if (dx >= 0.0) {
46
+ if (dy >= 0.0)
47
+ return jsts.geomgraph.Quadrant.NE;
48
+ else
49
+ return jsts.geomgraph.Quadrant.SE;
50
+ } else {
51
+ if (dy >= 0.0)
52
+ return jsts.geomgraph.Quadrant.NW;
53
+ else
54
+ return jsts.geomgraph.Quadrant.SW;
55
+ }
56
+ };
57
+
58
+
59
+ /**
60
+ * Returns the quadrant of a directed line segment from p0 to p1.
61
+ *
62
+ * @throws IllegalArgumentException
63
+ * if the points are equal
64
+ */
65
+ jsts.geomgraph.Quadrant.quadrant2 = function(p0, p1) {
66
+ if (p1.x === p0.x && p1.y === p0.y)
67
+ throw new jsts.error.IllegalArgumentError(
68
+ 'Cannot compute the quadrant for two identical points ' + p0);
69
+
70
+ if (p1.x >= p0.x) {
71
+ if (p1.y >= p0.y)
72
+ return jsts.geomgraph.Quadrant.NE;
73
+ else
74
+ return jsts.geomgraph.Quadrant.SE;
75
+ } else {
76
+ if (p1.y >= p0.y)
77
+ return jsts.geomgraph.Quadrant.NW;
78
+ else
79
+ return jsts.geomgraph.Quadrant.SW;
80
+ }
81
+ };
82
+
83
+
84
+ /**
85
+ * Returns true if the quadrants are 1 and 3, or 2 and 4
86
+ */
87
+ jsts.geomgraph.Quadrant.isOpposite = function(quad1, quad2) {
88
+ if (quad1 === quad2)
89
+ return false;
90
+ var diff = (quad1 - quad2 + 4) % 4;
91
+ // if quadrants are not adjacent, they are opposite
92
+ if (diff === 2)
93
+ return true;
94
+ return false;
95
+ };
96
+
97
+
98
+ /**
99
+ * Returns the right-hand quadrant of the halfplane defined by the two
100
+ * quadrants, or -1 if the quadrants are opposite, or the quadrant if they are
101
+ * identical.
102
+ */
103
+ jsts.geomgraph.Quadrant.commonHalfPlane = function(quad1, quad2) {
104
+ // if quadrants are the same they do not determine a unique common halfplane.
105
+ // Simply return one of the two possibilities
106
+ if (quad1 === quad2)
107
+ return quad1;
108
+ var diff = (quad1 - quad2 + 4) % 4;
109
+ // if quadrants are not adjacent, they do not share a common halfplane
110
+ if (diff === 2)
111
+ return -1;
112
+ //
113
+ var min = (quad1 < quad2) ? quad1 : quad2;
114
+ var max = (quad1 > quad2) ? quad1 : quad2;
115
+ // for this one case, the righthand plane is NOT the minimum index;
116
+ if (min === 0 && max === 3)
117
+ return 3;
118
+ // in general, the halfplane index is the minimum of the two adjacent
119
+ // quadrants
120
+ return min;
121
+ };
122
+
123
+
124
+ /**
125
+ * Returns whether the given quadrant lies within the given halfplane (specified
126
+ * by its right-hand quadrant).
127
+ */
128
+ jsts.geomgraph.Quadrant.isInHalfPlane = function(quad, halfPlane) {
129
+ if (halfPlane === jsts.geomgraph.Quadrant.SE) {
130
+ return quad === jsts.geomgraph.Quadrant.SE ||
131
+ quad === jsts.geomgraph.Quadrant.SW;
132
+ }
133
+ return quad === halfPlane || quad === halfPlane + 1;
134
+ };
135
+
136
+
137
+ /**
138
+ * Returns true if the given quadrant is 0 or 1.
139
+ */
140
+ jsts.geomgraph.Quadrant.isNorthern = function(quad) {
141
+ return quad === jsts.geomgraph.Quadrant.NE ||
142
+ quad === jsts.geomgraph.Quadrant.NW;
143
+ };
@@ -0,0 +1,251 @@
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/Position.js
9
+ */
10
+
11
+ /**
12
+ * A TopologyLocation is the labelling of a GraphComponent's topological
13
+ * relationship to a single Geometry.
14
+ * <p>
15
+ * If the parent component is an area edge, each side and the edge itself have a
16
+ * topological location. These locations are named
17
+ * <ul>
18
+ * <li> ON: on the edge
19
+ * <li> LEFT: left-hand side of the edge
20
+ * <li> RIGHT: right-hand side
21
+ * </ul>
22
+ * If the parent component is a line edge or node, there is a single topological
23
+ * relationship attribute, ON.
24
+ * <p>
25
+ * The possible values of a topological location are {Location.NONE,
26
+ * Location.EXTERIOR, Location.BOUNDARY, Location.INTERIOR}
27
+ * <p>
28
+ * The labelling is stored in an array location[j] where where j has the values
29
+ * ON, LEFT, RIGHT
30
+ *
31
+ * @constructor
32
+ */
33
+ jsts.geomgraph.TopologyLocation = function() {
34
+ this.location = [];
35
+
36
+ if (arguments.length === 3) {
37
+ var on = arguments[0];
38
+ var left = arguments[1];
39
+ var right = arguments[2];
40
+ this.init(3);
41
+ this.location[jsts.geomgraph.Position.ON] = on;
42
+ this.location[jsts.geomgraph.Position.LEFT] = left;
43
+ this.location[jsts.geomgraph.Position.RIGHT] = right;
44
+ } else if (arguments[0] instanceof jsts.geomgraph.TopologyLocation) {
45
+ var gl = arguments[0];
46
+ this.init(gl.location.length);
47
+ if (gl != null) {
48
+ for (var i = 0; i < this.location.length; i++) {
49
+ this.location[i] = gl.location[i];
50
+ }
51
+ }
52
+ } else if (typeof arguments[0] === 'number') {
53
+ var on = arguments[0];
54
+ this.init(1);
55
+ this.location[jsts.geomgraph.Position.ON] = on;
56
+ } else if (arguments[0] instanceof Array) {
57
+ var location = arguments[0];
58
+ this.init(location.length);
59
+ }
60
+ };
61
+
62
+
63
+ /**
64
+ * @private
65
+ */
66
+ jsts.geomgraph.TopologyLocation.prototype.location = null;
67
+
68
+
69
+ /**
70
+ * @param {int}
71
+ * size
72
+ * @private
73
+ */
74
+ jsts.geomgraph.TopologyLocation.prototype.init = function(size) {
75
+ this.location[size - 1] = null;
76
+ this.setAllLocations(jsts.geom.Location.NONE);
77
+ };
78
+
79
+
80
+ /**
81
+ * @param {int}
82
+ * posIndex
83
+ * @return {int}
84
+ */
85
+ jsts.geomgraph.TopologyLocation.prototype.get = function(posIndex) {
86
+ if (posIndex < this.location.length)
87
+ return this.location[posIndex];
88
+ return jsts.geom.Location.NONE;
89
+ };
90
+
91
+
92
+ /**
93
+ * @return {boolean} true if all locations are NULL.
94
+ */
95
+ jsts.geomgraph.TopologyLocation.prototype.isNull = function() {
96
+ for (var i = 0; i < this.location.length; i++) {
97
+ if (this.location[i] !== jsts.geom.Location.NONE)
98
+ return false;
99
+ }
100
+ return true;
101
+ };
102
+
103
+
104
+ /**
105
+ * @return {boolean} true if any locations are NULL.
106
+ */
107
+ jsts.geomgraph.TopologyLocation.prototype.isAnyNull = function() {
108
+ for (var i = 0; i < this.location.length; i++) {
109
+ if (this.location[i] === jsts.geom.Location.NONE)
110
+ return true;
111
+ }
112
+ return false;
113
+ };
114
+
115
+
116
+ /**
117
+ * @param {TopologyLocation}
118
+ * le
119
+ * @param {int}
120
+ * locIndex
121
+ * @return {boolean}
122
+ */
123
+ jsts.geomgraph.TopologyLocation.prototype.isEqualOnSide = function(le, locIndex) {
124
+ return this.location[locIndex] == le.location[locIndex];
125
+ };
126
+
127
+
128
+ /**
129
+ * @return {boolean}
130
+ */
131
+ jsts.geomgraph.TopologyLocation.prototype.isArea = function() {
132
+ return this.location.length > 1;
133
+ };
134
+
135
+
136
+ /**
137
+ * @return {boolean}
138
+ */
139
+ jsts.geomgraph.TopologyLocation.prototype.isLine = function() {
140
+ return this.location.length === 1;
141
+ };
142
+
143
+ jsts.geomgraph.TopologyLocation.prototype.flip = function() {
144
+ if (this.location.length <= 1)
145
+ return;
146
+ var temp = this.location[jsts.geomgraph.Position.LEFT];
147
+ this.location[jsts.geomgraph.Position.LEFT] = this.location[jsts.geomgraph.Position.RIGHT];
148
+ this.location[jsts.geomgraph.Position.RIGHT] = temp;
149
+ };
150
+
151
+
152
+ /**
153
+ * @param {int}
154
+ * locValue
155
+ */
156
+ jsts.geomgraph.TopologyLocation.prototype.setAllLocations = function(locValue) {
157
+ for (var i = 0; i < this.location.length; i++) {
158
+ this.location[i] = locValue;
159
+ }
160
+ };
161
+
162
+
163
+ /**
164
+ * @param {int}
165
+ * locValue
166
+ */
167
+ jsts.geomgraph.TopologyLocation.prototype.setAllLocationsIfNull = function(
168
+ locValue) {
169
+ for (var i = 0; i < this.location.length; i++) {
170
+ if (this.location[i] === jsts.geom.Location.NONE)
171
+ this.location[i] = locValue;
172
+ }
173
+ };
174
+
175
+
176
+ /**
177
+ * @param {int}
178
+ * locIndex
179
+ * @param {int}
180
+ * locValue
181
+ */
182
+ jsts.geomgraph.TopologyLocation.prototype.setLocation = function(locIndex,
183
+ locValue) {
184
+ if (locValue !== undefined) {
185
+ this.location[locIndex] = locValue;
186
+ } else {
187
+ this.setLocation(jsts.geomgraph.Position.ON, locIndex);
188
+ }
189
+ };
190
+
191
+
192
+ /**
193
+ * @return {int[]}
194
+ */
195
+ jsts.geomgraph.TopologyLocation.prototype.getLocations = function() {
196
+ return location;
197
+ };
198
+
199
+
200
+ /**
201
+ * @param {int}
202
+ * on
203
+ * @param {int}
204
+ * left
205
+ * @param {int}
206
+ * right
207
+ */
208
+ jsts.geomgraph.TopologyLocation.prototype.setLocations = function(on, left,
209
+ right) {
210
+ this.location[jsts.geomgraph.Position.ON] = on;
211
+ this.location[jsts.geomgraph.Position.LEFT] = left;
212
+ this.location[jsts.geomgraph.Position.RIGHT] = right;
213
+ };
214
+
215
+
216
+ /**
217
+ * @param {int}
218
+ * loc
219
+ * @return {boolean}
220
+ */
221
+ jsts.geomgraph.TopologyLocation.prototype.allPositionsEqual = function(loc) {
222
+ for (var i = 0; i < this.location.length; i++) {
223
+ if (this.location[i] !== loc)
224
+ return false;
225
+ }
226
+ return true;
227
+ };
228
+
229
+
230
+ /**
231
+ * merge updates only the NULL attributes of this object with the attributes of
232
+ * another.
233
+ *
234
+ * @param {TopologyLocation}
235
+ * gl
236
+ */
237
+ jsts.geomgraph.TopologyLocation.prototype.merge = function(gl) {
238
+ // if the src is an Area label & and the dest is not, increase the dest to be
239
+ // an Area
240
+ if (gl.location.length > this.location.length) {
241
+ var newLoc = [];
242
+ newLoc[jsts.geomgraph.Position.ON] = this.location[jsts.geomgraph.Position.ON];
243
+ newLoc[jsts.geomgraph.Position.LEFT] = jsts.geom.Location.NONE;
244
+ newLoc[jsts.geomgraph.Position.RIGHT] = jsts.geom.Location.NONE;
245
+ this.location = newLoc;
246
+ }
247
+ for (var i = 0; i < this.location.length; i++) {
248
+ if (this.location[i] === jsts.geom.Location.NONE && i < gl.location.length)
249
+ this.location[i] = gl.location[i];
250
+ }
251
+ };