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,37 @@
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
+ * A spatial object in an AbstractSTRtree.
9
+ *
10
+ * @version 1.7
11
+ */
12
+
13
+
14
+
15
+ /**
16
+ * @constructor
17
+ * @interface
18
+ */
19
+ jsts.index.strtree.Boundable = function() {
20
+
21
+ };
22
+
23
+
24
+ /**
25
+ * Returns a representation of space that encloses this Boundable, preferably
26
+ * not much bigger than this Boundable's boundary yet fast to test for intersection
27
+ * with the bounds of other Boundables. The class of object returned depends
28
+ * on the subclass of AbstractSTRtree.
29
+ *
30
+ * @return {Object} an Envelope (for STRtrees), an Interval (for SIRtrees), or other object
31
+ * (for other subclasses of AbstractSTRtree).
32
+ * @see jsts.index.strtree.AbstractSTRtree.IntersectsOp
33
+ * @public
34
+ */
35
+ jsts.index.strtree.Boundable.prototype.getBounds = function() {
36
+ throw new jsts.error.AbstractMethodInvocationError();
37
+ };
@@ -0,0 +1,94 @@
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
+ * A contiguous portion of 1D-space. Used internally by SIRtree.
9
+ *
10
+ * @param {jsts.index.strtree.Interval}
11
+ * [other].
12
+ * @param {number}
13
+ * [min].
14
+ * @param {number}
15
+ * [max].
16
+ * @see SIRtree
17
+ * @constructor
18
+ */
19
+ jsts.index.strtree.Interval = function() {
20
+ var other;
21
+ if (arguments.length === 1) {
22
+ other = arguments[0];
23
+ return jsts.index.strtree.Interval(other.min, other.max);
24
+ } else if (arguments.length === 2) {
25
+ jsts.util.Assert.isTrue(this.min <= this.max);
26
+ this.min = arguments[0];
27
+ this.max = arguments[1];
28
+ }
29
+ };
30
+
31
+
32
+ /**
33
+ * @type {number}
34
+ * @private
35
+ */
36
+ jsts.index.strtree.Interval.prototype.min = null;
37
+
38
+
39
+ /**
40
+ * @type {number}
41
+ * @private
42
+ */
43
+ jsts.index.strtree.Interval.prototype.max = null;
44
+
45
+
46
+ /**
47
+ * @return {number}
48
+ * @public
49
+ */
50
+ jsts.index.strtree.Interval.prototype.getCentre = function() {
51
+ return (this.min + this.max) / 2;
52
+ };
53
+
54
+
55
+ /**
56
+ *
57
+ * @param {jsts.index.strtree.Interval}
58
+ * other
59
+ * @return {jsts.index.strtree.Interval} this.
60
+ * @public
61
+ */
62
+ jsts.index.strtree.Interval.prototype.expandToInclude = function(other) {
63
+ this.max = Math.max(this.max, other.max);
64
+ this.min = Math.min(this.min, other.min);
65
+ return this;
66
+ };
67
+
68
+
69
+ /**
70
+ *
71
+ * @param {jsts.index.strtree.Interval}
72
+ * other
73
+ * @return {boolean}
74
+ * @public
75
+ */
76
+ jsts.index.strtree.Interval.prototype.intersects = function(other) {
77
+ return !(other.min > this.max || other.max < this.min);
78
+ };
79
+
80
+
81
+ /**
82
+ *
83
+ * @param {Object}
84
+ * o
85
+ * @return {boolean}
86
+ * @public
87
+ */
88
+ jsts.index.strtree.Interval.prototype.equals = function(o) {
89
+ if (!(o instanceof jsts.index.strtree.Interval)) {
90
+ return false;
91
+ }
92
+ other = o;
93
+ return this.min === other.min && this.max === other.max;
94
+ };
@@ -0,0 +1,60 @@
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
+ * Boundable wrapper for a non-Boundable spatial object. Used internally by
9
+ * AbstractSTRtree.
10
+ *
11
+ * @requires jsts/index/strtree/Boundable.js
12
+ */
13
+
14
+
15
+
16
+ /**
17
+ * @param {Object} bounds
18
+ * @param {Object} item
19
+ * @extends {jsts.index.strtree.Boundable}
20
+ * @constructor
21
+ */
22
+ jsts.index.strtree.ItemBoundable = function(bounds, item) {
23
+ this.bounds = bounds;
24
+ this.item = item;
25
+ };
26
+
27
+ jsts.index.strtree.ItemBoundable.prototype = new jsts.index.strtree.Boundable();
28
+ jsts.index.strtree.ItemBoundable.constructor = jsts.index.strtree.ItemBoundable;
29
+
30
+
31
+ /**
32
+ * @type {Object}
33
+ * @private
34
+ */
35
+ jsts.index.strtree.ItemBoundable.prototype.bounds = null;
36
+
37
+
38
+ /**
39
+ * @type {Object}
40
+ * @private
41
+ */
42
+ jsts.index.strtree.ItemBoundable.prototype.item = null;
43
+
44
+
45
+ /**
46
+ * @return {Object}
47
+ * @public
48
+ */
49
+ jsts.index.strtree.ItemBoundable.prototype.getBounds = function() {
50
+ return this.bounds;
51
+ };
52
+
53
+
54
+ /**
55
+ * @return {Object}
56
+ * @public
57
+ */
58
+ jsts.index.strtree.ItemBoundable.prototype.getItem = function() {
59
+ return this.item;
60
+ };
@@ -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
+ * One-dimensional version of an STR-packed R-tree. SIR stands for
9
+ * "Sort-Interval-Recursive". STR-packed R-trees are described in:
10
+ * P. Rigaux, Michel Scholl and Agnes Voisard. Spatial Databases With
11
+ * Application To GIS. Morgan Kaufmann, San Francisco, 2002.
12
+ * @see STRtree
13
+ *
14
+ * @requires jsts/index/strtree/AbstractNode.js
15
+ * @requires jsts/index/strtree/AbstractSTRtree.js
16
+ */
17
+
18
+
19
+
20
+ /**
21
+ * @param {number} [nodeCapacity].
22
+ * @augments jsts.index.strtree.AbstractSTRtree
23
+ * @constructor
24
+ */
25
+ jsts.index.strtree.SIRtree = function(nodeCapacity) {
26
+ nodeCapacity = nodeCapacity || 10;
27
+ jsts.index.strtree.AbstractSTRtree.call(this, nodeCapacity);
28
+ };
29
+
30
+ jsts.index.strtree.SIRtree.prototype = new jsts.index.strtree.AbstractSTRtree();
31
+ jsts.index.strtree.SIRtree.constructor = jsts.index.strtree.SIRtree;
32
+
33
+ //TODO: Verify that this comparison really works
34
+ jsts.index.strtree.SIRtree.prototype.comperator = {
35
+ compare: function(o1, o2) {
36
+ return o1.getBounds().getCentre() - o2.getBounds().getCentre();
37
+ }
38
+ };
39
+
40
+
41
+ /**
42
+ * @type {Object}
43
+ * @extends {jsts.index.strtree.AbstractSTRtree.IntersectsOp}
44
+ * @private
45
+ */
46
+ jsts.index.strtree.SIRtree.prototype.intersectionOp = {
47
+ intersects: function(aBounds, bBounds) {
48
+ return aBounds.intersects(bBounds);
49
+ }
50
+ };
51
+
52
+
53
+ /**
54
+ *
55
+ * @param {number} level
56
+ * @return {AbstractNode}
57
+ * @protected
58
+ */
59
+ jsts.index.strtree.SIRtree.prototype.createNode = function(level) {
60
+
61
+ //TODO: Does it really have to be so complex?
62
+ var AbstractNode = function(level) {
63
+ jsts.index.strtree.AbstractNode.apply(this, arguments);
64
+ };
65
+
66
+ AbstractNode.prototype = new jsts.index.strtree.AbstractNode();
67
+ AbstractNode.constructor = AbstractNode;
68
+
69
+ AbstractNode.prototype.computeBounds = function() {
70
+ var bounds = null,
71
+ childBoundables = this.getChildBoundables(),
72
+ childBoundable;
73
+
74
+ for (var i = 0, l = childBoundables.length; i < l; i++) {
75
+ childBoundable = childBoundables[i];
76
+ if (bounds === null) {
77
+ bounds = new jsts.index.strtree.Interval(childBoundable.getBounds());
78
+ }
79
+ else {
80
+ bounds.expandToInclude(childBoundable.getBounds());
81
+ }
82
+ }
83
+ return bounds;
84
+ };
85
+
86
+ return AbstractNode;
87
+ };
88
+
89
+
90
+ /**
91
+ * Inserts an item having the given bounds into the tree.
92
+ *
93
+ * @param {number} x1
94
+ * @param {number} x2
95
+ * @param {Object} item
96
+ */
97
+ jsts.index.strtree.SIRtree.prototype.insert = function(x1, x2, item) {
98
+ jsts.index.strtree.AbstractSTRtree.prototype.insert(
99
+ new jsts.index.strtree.Interval(Math.min(x1, x2), Math.max(x1, x2)),
100
+ item);
101
+ };
102
+
103
+
104
+ /**
105
+ * Returns items whose bounds intersect the given bounds.
106
+ *
107
+ * @param {number} x1 possibly equal to x2.
108
+ * @param {number} [x2].
109
+ * @return {Array}
110
+ */
111
+ jsts.index.strtree.SIRtree.prototype.query = function(x1, x2) {
112
+ x2 = x2 || x1;
113
+ jsts.index.strtree.AbstractSTRtree.prototype.query(new jsts.index.strtree.Interval(Math.min(x1, x2), Math.max(x1, x2)));
114
+ };
115
+
116
+ jsts.index.strtree.SIRtree.prototype.getIntersectsOp = function() {
117
+ return this.intersectionOp;
118
+ };
119
+
120
+ jsts.index.strtree.SIRtree.prototype.getComparator = function() {
121
+ return this.comperator;
122
+ };
@@ -0,0 +1,450 @@
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
+ * A query-only R-tree created using the Sort-Tile-Recursive (STR) algorithm.
9
+ * For two-dimensional spatial data.
10
+ * <P>
11
+ * The STR packed R-tree is simple to implement and maximizes space
12
+ * utilization; that is, as many leaves as possible are filled to capacity.
13
+ * Overlap between nodes is far less than in a basic R-tree. However, once the
14
+ * tree has been built (explicitly or on the first call to #query), items may
15
+ * not be added or removed.
16
+ * <P>
17
+ * Described in: P. Rigaux, Michel Scholl and Agnes Voisard.
18
+ * <i>Spatial Databases With Application To GIS</i>.
19
+ * Morgan Kaufmann, San Francisco, 2002.
20
+ *
21
+ * @requires jsts/index/SpatialIndex.js
22
+ * @requires jsts/index/strtree/STRtree.js
23
+ * @requires jsts/index/strtree/AbstractSTRtree.js
24
+ */
25
+
26
+
27
+
28
+ /**
29
+ * Constructs an STRtree with the default node capacity or with the given
30
+ * maximum number of child nodes that a node may have.
31
+ * <p>
32
+ * The minimum recommended capacity setting is 4.
33
+ *
34
+ *
35
+ * @param {number}
36
+ * [nodeCapacity].
37
+ * @extends {jsts.index.strtree.AbstractSTRtree}
38
+ * @extends {jsts.index.SpatialIndex}
39
+ * @constructor
40
+ */
41
+ jsts.index.strtree.STRtree = function(nodeCapacity) {
42
+ nodeCapacity = nodeCapacity ||
43
+ jsts.index.strtree.STRtree.DEFAULT_NODE_CAPACITY;
44
+ jsts.index.strtree.AbstractSTRtree.call(this, nodeCapacity);
45
+ };
46
+
47
+ jsts.index.strtree.STRtree.prototype = new jsts.index.strtree.AbstractSTRtree();
48
+ jsts.index.strtree.STRtree.constructor = jsts.index.strtree.STRtree;
49
+
50
+ /**
51
+ * @type {Object} implements function for comparison
52
+ * @private
53
+ */
54
+ jsts.index.strtree.STRtree.prototype.xComparator = function(o1, o2) {
55
+ return jsts.index.strtree.AbstractSTRtree.prototype.compareDoubles(
56
+ jsts.index.strtree.STRtree.prototype.centreX(o1.getBounds()),
57
+ jsts.index.strtree.STRtree.prototype.centreX(o2.getBounds()));
58
+ };
59
+
60
+
61
+ /**
62
+ * @type {Object} implements function for comparison
63
+ * @private
64
+ */
65
+ jsts.index.strtree.STRtree.prototype.yComparator = function(o1, o2) {
66
+ return jsts.index.strtree.AbstractSTRtree.prototype.compareDoubles(
67
+ jsts.index.strtree.STRtree.prototype.centreY(o1.getBounds()),
68
+ jsts.index.strtree.STRtree.prototype.centreY(o2.getBounds()));
69
+ };
70
+
71
+
72
+ /**
73
+ * @param {jsts.geom.Envelope}
74
+ * e
75
+ * @return {number}
76
+ */
77
+ jsts.index.strtree.STRtree.prototype.centreX = function(e) {
78
+ return jsts.index.strtree.STRtree.prototype.avg(e.getMinX(), e.getMaxX());
79
+ };
80
+
81
+
82
+ /**
83
+ * @param {jsts.geom.Envelope}
84
+ * e
85
+ * @return {number}
86
+ */
87
+ jsts.index.strtree.STRtree.prototype.centreY = function(e) {
88
+ return jsts.index.strtree.STRtree.prototype.avg(e.getMinY(), e.getMaxY());
89
+ };
90
+
91
+
92
+ /**
93
+ * @param {number}
94
+ * a
95
+ * @param {number}
96
+ * b
97
+ * @return {number}
98
+ */
99
+ jsts.index.strtree.STRtree.prototype.avg = function(a, b) {
100
+ return (a + b) / 2.0;
101
+ };
102
+
103
+
104
+ /**
105
+ * @type {Object}
106
+ * @extends {jsts.index.strtree.AbstractSTRtree.IntersectsOp}
107
+ * @private
108
+ */
109
+ jsts.index.strtree.STRtree.prototype.intersectsOp = {
110
+ intersects: function(aBounds, bBounds) {
111
+ return aBounds.intersects(bBounds);
112
+ }
113
+ };
114
+
115
+
116
+ /**
117
+ * Creates the parent level for the given child level. First, orders the items
118
+ * by the x-values of the midpoints, and groups them into vertical slices. For
119
+ * each slice, orders the items by the y-values of the midpoints, and group them
120
+ * into runs of size M (the node capacity). For each run, creates a new (parent)
121
+ * node.
122
+ *
123
+ * @param {Array}
124
+ * childBoundables
125
+ * @param {number}
126
+ * newLevel
127
+ * @return {Array}
128
+ * @protected
129
+ */
130
+ jsts.index.strtree.STRtree.prototype.createParentBoundables = function(
131
+ childBoundables, newLevel) {
132
+ jsts.util.Assert.isTrue(!(childBoundables.length === 0));
133
+ var minLeafCount = Math.ceil(childBoundables.length / this.getNodeCapacity());
134
+ var sortedChildBoundables = [];
135
+ for (var i = 0; i < childBoundables.length; i++) {
136
+ sortedChildBoundables.push(childBoundables[i]);
137
+ }
138
+ sortedChildBoundables.sort(this.xComparator);
139
+ var verticalSlices = this.verticalSlices(sortedChildBoundables, Math
140
+ .ceil(Math.sqrt(minLeafCount)));
141
+ return this
142
+ .createParentBoundablesFromVerticalSlices(verticalSlices, newLevel);
143
+ };
144
+
145
+
146
+ /**
147
+ *
148
+ * @param {Array.
149
+ * <Array>} verticalSlices
150
+ * @param {number}
151
+ * newLevel
152
+ * @return {Array.<Array>}
153
+ * @private
154
+ */
155
+ jsts.index.strtree.STRtree.prototype.createParentBoundablesFromVerticalSlices = function(
156
+ verticalSlices, newLevel) {
157
+ jsts.util.Assert.isTrue(verticalSlices.length > 0);
158
+ var parentBoundables = [];
159
+ for (var i = 0; i < verticalSlices.length; i++) {
160
+ parentBoundables = parentBoundables.concat(this.createParentBoundablesFromVerticalSlice(
161
+ verticalSlices[i], newLevel));
162
+ }
163
+ return parentBoundables;
164
+ };
165
+
166
+
167
+ /**
168
+ *
169
+ * @param {Array}
170
+ * childBoundables
171
+ * @param {number}
172
+ * newLevel
173
+ * @return {Array}
174
+ * @protected
175
+ */
176
+ jsts.index.strtree.STRtree.prototype.createParentBoundablesFromVerticalSlice = function(
177
+ childBoundables, newLevel) {
178
+ return jsts.index.strtree.AbstractSTRtree.prototype.createParentBoundables
179
+ .call(this, childBoundables, newLevel);
180
+ };
181
+
182
+
183
+ /**
184
+ *
185
+ * @param {Array}
186
+ * childBoundables
187
+ * @param {number}
188
+ * sliceCount
189
+ * @return {Array.<Array>}
190
+ * @protected
191
+ */
192
+ jsts.index.strtree.STRtree.prototype.verticalSlices = function(childBoundables,
193
+ sliceCount) {
194
+ var sliceCapacity = Math.ceil(childBoundables.length / sliceCount);
195
+ var slices = [];
196
+
197
+ var i = 0, boundablesAddedToSlice, childBoundable;
198
+
199
+ for (var j = 0; j < sliceCount; j++) {
200
+ slices[j] = [];
201
+ boundablesAddedToSlice = 0;
202
+ while (i < childBoundables.length && boundablesAddedToSlice < sliceCapacity) {
203
+ childBoundable = childBoundables[i++];
204
+ slices[j].push(childBoundable);
205
+ boundablesAddedToSlice++;
206
+ }
207
+ }
208
+
209
+ return slices;
210
+ };
211
+
212
+
213
+ /**
214
+ * @type {number}
215
+ * @const
216
+ * @private
217
+ */
218
+ jsts.index.strtree.STRtree.DEFAULT_NODE_CAPACITY = 10;
219
+
220
+
221
+ /**
222
+ * @param {number}
223
+ * level
224
+ * @return {jsts.index.strtree.AbstractNode}
225
+ * @protected
226
+ */
227
+ jsts.index.strtree.STRtree.prototype.createNode = function(level) {
228
+ var abstractNode = new jsts.index.strtree.AbstractNode(level);
229
+
230
+ abstractNode.computeBounds = function() {
231
+ var bounds = null;
232
+ var childBoundables = this.getChildBoundables();
233
+ for (var i = 0; i < childBoundables.length; i++) {
234
+ var childBoundable = childBoundables[i];
235
+ if (bounds === null) {
236
+ bounds = new jsts.geom.Envelope(childBoundable.getBounds());
237
+ } else {
238
+ bounds.expandToInclude(childBoundable.getBounds());
239
+ }
240
+ }
241
+ return bounds;
242
+ };
243
+
244
+ return abstractNode;
245
+ };
246
+
247
+
248
+ /**
249
+ * @return {jsts.index.strtree.AbstractSTRtree.IntersectsOp}
250
+ * @protected
251
+ */
252
+ jsts.index.strtree.STRtree.prototype.getIntersectsOp = function() {
253
+ return this.intersectsOp;
254
+ };
255
+
256
+
257
+ /**
258
+ * Inserts an item having the given bounds into the tree.
259
+ *
260
+ * @param {jsts.geom.Envelope}
261
+ * itemEnv
262
+ * @param {Object}
263
+ * item
264
+ * @public
265
+ */
266
+ jsts.index.strtree.STRtree.prototype.insert = function(itemEnv, item) {
267
+ if (itemEnv.isNull()) {
268
+ return;
269
+ }
270
+ jsts.index.strtree.AbstractSTRtree.prototype.insert.call(this, itemEnv, item);
271
+ };
272
+
273
+
274
+ /**
275
+ * Returns items whose bounds intersect the given envelope.
276
+ *
277
+ * @param {jsts.geom.Envelope}
278
+ * searchEnv
279
+ * @param {jsts.index.ItemVisitor}
280
+ * visitor
281
+ * @return {Array}
282
+ * @public
283
+ */
284
+ jsts.index.strtree.STRtree.prototype.query = function(searchEnv, visitor) {
285
+ // Yes this method does something. It specifies that the bounds is an
286
+ // Envelope. super.query takes an Object, not an Envelope. [Jon Aquino
287
+ // 10/24/2003]
288
+ return jsts.index.strtree.AbstractSTRtree.prototype.query.apply(this,
289
+ arguments);
290
+ };
291
+
292
+
293
+ /**
294
+ * Removes a single item from the tree.
295
+ *
296
+ * @param {jsts.geom.Envelope}
297
+ * itemEnv the Envelope of the item to remove.
298
+ * @param {Object}
299
+ * item the item to remove.
300
+ * @return {boolean} <code>true</code> if the item was found.
301
+ * @public
302
+ */
303
+ jsts.index.strtree.STRtree.prototype.remove = function(itemEnv, item) {
304
+ return jsts.index.strtree.AbstractSTRtree.prototype.remove.call(this,
305
+ itemEnv, item);
306
+ };
307
+
308
+
309
+ /**
310
+ * Returns the number of items in the tree.
311
+ *
312
+ * @return {number} the number of items in the tree.
313
+ * @public
314
+ */
315
+ jsts.index.strtree.STRtree.prototype.size = function() {
316
+ return jsts.index.strtree.AbstractSTRtree.prototype.size.call(this);
317
+ };
318
+
319
+
320
+ /**
321
+ * Returns the number of items in the tree.
322
+ *
323
+ * @return {number} the number of items in the tree.
324
+ * @public
325
+ */
326
+ jsts.index.strtree.STRtree.prototype.depth = function() {
327
+ return jsts.index.strtree.AbstractSTRtree.prototype.depth.call(this);
328
+ };
329
+
330
+
331
+ /**
332
+ * @return {Object}
333
+ * @protected
334
+ */
335
+ jsts.index.strtree.STRtree.prototype.getComparator = function() {
336
+ return this.yComparator;
337
+ };
338
+
339
+ /**
340
+ * Finds the two nearest items in the tree, using {@link ItemDistance} as the
341
+ * distance metric. A Branch-and-Bound tree traversal algorithm is used to
342
+ * provide an efficient search.
343
+ *
344
+ * @param {ItemDistance}
345
+ * itemDist a distance metric applicable to the items in this tree.
346
+ * @return {Object[]} the pair of the nearest items.
347
+ */
348
+ jsts.index.strtree.STRtree.prototype.nearestNeighbour = function(itemDist) {
349
+ var bp = new jsts.index.strtree.BoundablePair(this.getRoot(), this.getRoot(),
350
+ itemDist);
351
+ return this.nearestNeighbour4(bp);
352
+ };
353
+
354
+ /**
355
+ * Finds the nearest item to the given object in this tree, using
356
+ * {@link ItemDistance} as the distance metric. A Branch-and-Bound tree
357
+ * traversal algorithm is used to provide an efficient search.
358
+ *
359
+ * @param {Envelope}
360
+ * env the envelope of the query item.
361
+ * @param {Object}
362
+ * item the item to find the nearest neighbour of.
363
+ * @param {ItemDistance}
364
+ * itemDist a distance metric applicable to the items in this tree and
365
+ * the query item.
366
+ * @return {Object[]} the nearest item in this tree.
367
+ */
368
+ jsts.index.strtree.STRtree.prototype.nearestNeighbour2 = function(env, item,
369
+ itemDist) {
370
+ var bnd = new jsts.index.strtree.ItemBoundable(env, item);
371
+ var bp = new jsts.index.strtree.BoundablePair(this.getRoot(), bnd, itemDist);
372
+ return this.nearestNeighbour4(bp)[0];
373
+ };
374
+
375
+ /**
376
+ * Finds the two nearest items from this tree and another tree, using
377
+ * {@link ItemDistance} as the distance metric. A Branch-and-Bound tree
378
+ * traversal algorithm is used to provide an efficient search. The result value
379
+ * is a pair of items, the first from this tree and the second from the argument
380
+ * tree.
381
+ *
382
+ * @param {STRtree}
383
+ * tree another tree.
384
+ * @param {ItemDistance}
385
+ * itemDist a distance metric applicable to the items in the trees.
386
+ * @return {Object[]} the pair of the nearest items, one from each tree.
387
+ */
388
+ jsts.index.strtree.STRtree.prototype.nearestNeighbour3 = function(tree,
389
+ itemDist) {
390
+ var bp = new jsts.index.strtree.BoundablePair(this.getRoot(), tree.getRoot(),
391
+ itemDist);
392
+ return this.nearestNeighbour4(bp);
393
+ };
394
+
395
+ jsts.index.strtree.STRtree.prototype.nearestNeighbour4 = function(initBndPair) {
396
+ return this.nearestNeighbour5(initBndPair, Double.POSITIVE_INFINITY);
397
+ };
398
+
399
+ /**
400
+ * NOTE: PriorityQueue replaces by js array
401
+ *
402
+ * @param initBndPair
403
+ * @param maxDistance
404
+ * @return {Array}
405
+ */
406
+ jsts.index.strtree.STRtree.prototype.nearestNeighbour5 = function(initBndPair,
407
+ maxDistance) {
408
+ var distanceLowerBound = maxDistance;
409
+ var minPair = null;
410
+
411
+ // initialize internal structures
412
+ var priQ = [];
413
+
414
+ // initialize queue
415
+ priQ.push(initBndPair);
416
+
417
+ while (!priQ.isEmpty() && distanceLowerBound > 0.0) {
418
+ // pop head of queue and expand one side of pair
419
+ var bndPair = priQ.pop();
420
+ var currentDistance = bndPair.getDistance();
421
+
422
+ /**
423
+ * If the distance for the first node in the queue is >= the current minimum
424
+ * distance, all other nodes in the queue must also have a greater distance.
425
+ * So the current minDistance must be the true minimum, and we are done.
426
+ */
427
+ if (currentDistance >= distanceLowerBound)
428
+ break;
429
+
430
+ /**
431
+ * If the pair members are leaves then their distance is the exact lower
432
+ * bound. Update the distanceLowerBound to reflect this (which must be
433
+ * smaller, due to the test immediately prior to this).
434
+ */
435
+ if (bndPair.isLeaves()) {
436
+ // assert: currentDistance < minimumDistanceFound
437
+ distanceLowerBound = currentDistance;
438
+ minPair = bndPair;
439
+ } else {
440
+ /**
441
+ * Otherwise, expand one side of the pair, (the choice of which side to
442
+ * expand is heuristically determined) and insert the new expanded pairs
443
+ * into the queue
444
+ */
445
+ bndPair.expandToQueue(priQ, distanceLowerBound);
446
+ }
447
+ }
448
+ // done - return items with min distance
449
+ return [minPair.getBoundable(0).getItem(), minPair.getBoundable(1).getItem()];
450
+ };