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.
- checksums.yaml +8 -8
- data/lib/jsts-rails/version.rb +1 -1
- data/vendor/assets/javascripts/javascript.util.js +33 -1
- data/vendor/assets/javascripts/jsts-original.js +164 -1573
- data/vendor/assets/javascripts/jsts.js +197 -0
- data/vendor/assets/javascripts/jsts/algorithm/Angle.js +387 -0
- data/vendor/assets/javascripts/jsts/algorithm/BoundaryNodeRule.js +67 -0
- data/vendor/assets/javascripts/jsts/algorithm/CGAlgorithms.js +596 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentralEndpointIntersector.js +118 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentroidArea.js +225 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentroidLine.js +85 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentroidPoint.js +77 -0
- data/vendor/assets/javascripts/jsts/algorithm/ConvexHull.js +409 -0
- data/vendor/assets/javascripts/jsts/algorithm/HCoordinate.js +234 -0
- data/vendor/assets/javascripts/jsts/algorithm/LineIntersector.js +502 -0
- data/vendor/assets/javascripts/jsts/algorithm/MCPointInRing.js +124 -0
- data/vendor/assets/javascripts/jsts/algorithm/PointLocator.js +247 -0
- data/vendor/assets/javascripts/jsts/algorithm/RayCrossingCounter.js +215 -0
- data/vendor/assets/javascripts/jsts/algorithm/RobustDeterminant.js +353 -0
- data/vendor/assets/javascripts/jsts/algorithm/RobustLineIntersector.js +477 -0
- data/vendor/assets/javascripts/jsts/algorithm/distance/DiscreteHausdorffDistance.js +228 -0
- data/vendor/assets/javascripts/jsts/algorithm/distance/DistanceToPoint.js +68 -0
- data/vendor/assets/javascripts/jsts/algorithm/distance/PointPairDistance.js +104 -0
- data/vendor/assets/javascripts/jsts/algorithm/locate/PointOnGeometryLocator.js +7 -0
- data/vendor/assets/javascripts/jsts/algorithm/locate/SimplePointInAreaLocator.js +102 -0
- data/vendor/assets/javascripts/jsts/geom/Coordinate.js +158 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateArrays.js +148 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateFilter.js +29 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateList.js +157 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateSequenceFilter.js +63 -0
- data/vendor/assets/javascripts/jsts/geom/Dimension.js +137 -0
- data/vendor/assets/javascripts/jsts/geom/Envelope.js +833 -0
- data/vendor/assets/javascripts/jsts/geom/Geometry.js +1535 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryCollection.js +230 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryComponentFilter.js +36 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryFactory.js +263 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryFilter.js +29 -0
- data/vendor/assets/javascripts/jsts/geom/IntersectionMatrix.js +650 -0
- data/vendor/assets/javascripts/jsts/geom/LineSegment.js +275 -0
- data/vendor/assets/javascripts/jsts/geom/LineString.js +299 -0
- data/vendor/assets/javascripts/jsts/geom/LinearRing.js +69 -0
- data/vendor/assets/javascripts/jsts/geom/Location.js +83 -0
- data/vendor/assets/javascripts/jsts/geom/MultiLineString.js +47 -0
- data/vendor/assets/javascripts/jsts/geom/MultiPoint.js +64 -0
- data/vendor/assets/javascripts/jsts/geom/MultiPolygon.js +64 -0
- data/vendor/assets/javascripts/jsts/geom/Point.js +197 -0
- data/vendor/assets/javascripts/jsts/geom/Polygon.js +263 -0
- data/vendor/assets/javascripts/jsts/geom/PrecisionModel.js +187 -0
- data/vendor/assets/javascripts/jsts/geom/Triangle.js +313 -0
- data/vendor/assets/javascripts/jsts/geom/util/GeometryCombiner.js +143 -0
- data/vendor/assets/javascripts/jsts/geom/util/GeometryExtracter.js +76 -0
- data/vendor/assets/javascripts/jsts/geom/util/GeometryTransformer.js +295 -0
- data/vendor/assets/javascripts/jsts/geom/util/LinearComponentExtracter.js +207 -0
- data/vendor/assets/javascripts/jsts/geom/util/PointExtracter.js +67 -0
- data/vendor/assets/javascripts/jsts/geom/util/PolygonExtracter.js +71 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Depth.js +145 -0
- data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdge.js +270 -0
- data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdgeStar.js +388 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Edge.js +291 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeEnd.js +188 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeEndStar.js +322 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersection.js +122 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersectionList.js +146 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeList.js +111 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeNodingValidator.js +76 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeRing.js +230 -0
- data/vendor/assets/javascripts/jsts/geomgraph/GeometryGraph.js +469 -0
- data/vendor/assets/javascripts/jsts/geomgraph/GraphComponent.js +181 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Label.js +316 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Node.js +105 -0
- data/vendor/assets/javascripts/jsts/geomgraph/NodeFactory.js +22 -0
- data/vendor/assets/javascripts/jsts/geomgraph/NodeMap.js +128 -0
- data/vendor/assets/javascripts/jsts/geomgraph/PlanarGraph.js +214 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Position.js +63 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Quadrant.js +143 -0
- data/vendor/assets/javascripts/jsts/geomgraph/TopologyLocation.js +251 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/EdgeSetIntersector.js +47 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/SegmentIntersector.js +298 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleEdgeSetIntersector.js +107 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleMCSweepLineIntersector.js +29 -0
- data/vendor/assets/javascripts/jsts/index/ArrayListVisitor.js +37 -0
- data/vendor/assets/javascripts/jsts/index/DoubleBits.js +132 -0
- data/vendor/assets/javascripts/jsts/index/IntervalSize.js +55 -0
- data/vendor/assets/javascripts/jsts/index/ItemVisitor.js +23 -0
- data/vendor/assets/javascripts/jsts/index/SpatialIndex.js +67 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Bintree.js +224 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Interval.js +160 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Key.js +110 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Node.js +204 -0
- data/vendor/assets/javascripts/jsts/index/bintree/NodeBase.js +220 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Root.js +113 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChain.js +244 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainBuilder.js +106 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainOverlapAction.js +56 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainSelectAction.js +44 -0
- data/vendor/assets/javascripts/jsts/index/kdtree/KdNode.js +171 -0
- data/vendor/assets/javascripts/jsts/index/kdtree/KdTree.js +218 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Key.js +134 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Node.js +220 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/NodeBase.js +330 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Quadtree.js +228 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Root.js +105 -0
- data/vendor/assets/javascripts/jsts/index/strtree/AbstractNode.js +107 -0
- data/vendor/assets/javascripts/jsts/index/strtree/AbstractSTRtree.js +594 -0
- data/vendor/assets/javascripts/jsts/index/strtree/Boundable.js +37 -0
- data/vendor/assets/javascripts/jsts/index/strtree/BoundablePair.js +0 -0
- data/vendor/assets/javascripts/jsts/index/strtree/Interval.js +94 -0
- data/vendor/assets/javascripts/jsts/index/strtree/ItemBoundable.js +60 -0
- data/vendor/assets/javascripts/jsts/index/strtree/SIRtree.js +122 -0
- data/vendor/assets/javascripts/jsts/index/strtree/STRtree.js +450 -0
- data/vendor/assets/javascripts/jsts/io/GeoJSONParser.js +471 -0
- data/vendor/assets/javascripts/jsts/io/GeoJSONReader.js +58 -0
- data/vendor/assets/javascripts/jsts/io/GeoJSONWriter.js +38 -0
- data/vendor/assets/javascripts/jsts/io/OpenLayersParser.js +245 -0
- data/vendor/assets/javascripts/jsts/io/WKTParser.js +421 -0
- data/vendor/assets/javascripts/jsts/io/WKTReader.js +68 -0
- data/vendor/assets/javascripts/jsts/io/WKTWriter.js +61 -0
- data/vendor/assets/javascripts/jsts/noding/BasicSegmentString.js +87 -0
- data/vendor/assets/javascripts/jsts/noding/FastNodingValidator.js +127 -0
- data/vendor/assets/javascripts/jsts/noding/InteriorIntersectionFinder.js +171 -0
- data/vendor/assets/javascripts/jsts/noding/IntersectionAdder.js +198 -0
- data/vendor/assets/javascripts/jsts/noding/IntersectionFinderAdder.js +79 -0
- data/vendor/assets/javascripts/jsts/noding/MCIndexNoder.js +147 -0
- data/vendor/assets/javascripts/jsts/noding/NodableSegmentString.js +35 -0
- data/vendor/assets/javascripts/jsts/noding/NodedSegmentString.js +235 -0
- data/vendor/assets/javascripts/jsts/noding/Noder.js +41 -0
- data/vendor/assets/javascripts/jsts/noding/NodingValidator.js +5 -0
- data/vendor/assets/javascripts/jsts/noding/Octant.js +84 -0
- data/vendor/assets/javascripts/jsts/noding/OrientedCoordinateArray.js +94 -0
- data/vendor/assets/javascripts/jsts/noding/ScaledNoder.js +105 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentIntersector.js +45 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentNode.js +70 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentNodeList.js +262 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentPointComparator.js +78 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentString.js +61 -0
- data/vendor/assets/javascripts/jsts/noding/SinglePassNoder.js +51 -0
- data/vendor/assets/javascripts/jsts/noding/snapround/HotPixel.js +271 -0
- data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexPointSnapper.js +96 -0
- data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexSnapRounder.js +147 -0
- data/vendor/assets/javascripts/jsts/operation/BoundaryOp.js +166 -0
- data/vendor/assets/javascripts/jsts/operation/GeometryGraphOperation.js +90 -0
- data/vendor/assets/javascripts/jsts/operation/IsSimpleOp.js +293 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferBuilder.js +317 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferInputLineSimplifier.js +294 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferOp.js +340 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferParameters.js +328 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferSubgraph.js +296 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveBuilder.js +369 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveSetBuilder.js +301 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentGenerator.js +777 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentString.js +109 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/RightmostEdgeFinder.js +164 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/SubgraphDepthLocater.js +220 -0
- data/vendor/assets/javascripts/jsts/operation/distance/ConnectedElementLocationFilter.js +67 -0
- data/vendor/assets/javascripts/jsts/operation/distance/DistanceOp.js +506 -0
- data/vendor/assets/javascripts/jsts/operation/distance/GeometryLocation.js +102 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/LineBuilder.js +194 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/MaximalEdgeRing.js +72 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/MinimalEdgeRing.js +33 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/OverlayNodeFactory.js +26 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/OverlayOp.js +584 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/PointBuilder.js +103 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/PolygonBuilder.js +282 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/GeometrySnapper.js +228 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/LineStringSnapper.js +228 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapIfNeededOverlayOp.js +85 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapOverlayOp.js +134 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/EdgeRing.js +259 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeDirectedEdge.js +94 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeEdge.js +31 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeGraph.js +507 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/Polygonizer.js +259 -0
- data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBuilder.js +140 -0
- data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundle.js +183 -0
- data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundleStar.js +48 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateComputer.js +444 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateNode.js +46 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeFactory.js +25 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeGraph.js +118 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateOp.js +75 -0
- data/vendor/assets/javascripts/jsts/operation/union/CascadedPolygonUnion.js +319 -0
- data/vendor/assets/javascripts/jsts/operation/union/PointGeometryUnion.js +118 -0
- data/vendor/assets/javascripts/jsts/operation/union/UnaryUnionOp.js +244 -0
- data/vendor/assets/javascripts/jsts/operation/union/UnionInteracting.js +156 -0
- data/vendor/assets/javascripts/jsts/operation/valid/ConnectedInteriorTester.js +259 -0
- data/vendor/assets/javascripts/jsts/operation/valid/ConsistentAreaTester.js +127 -0
- data/vendor/assets/javascripts/jsts/operation/valid/IndexedNestedRingTester.js +89 -0
- data/vendor/assets/javascripts/jsts/operation/valid/IsValidOp.js +619 -0
- data/vendor/assets/javascripts/jsts/operation/valid/TopologyValidationError.js +199 -0
- data/vendor/assets/javascripts/jsts/planargraph/DirectedEdge.js +232 -0
- data/vendor/assets/javascripts/jsts/planargraph/DirectedEdgeStar.js +168 -0
- data/vendor/assets/javascripts/jsts/planargraph/Edge.js +124 -0
- data/vendor/assets/javascripts/jsts/planargraph/GraphComponent.js +182 -0
- data/vendor/assets/javascripts/jsts/planargraph/Node.js +127 -0
- data/vendor/assets/javascripts/jsts/planargraph/NodeMap.js +76 -0
- data/vendor/assets/javascripts/jsts/planargraph/PlanarGraph.js +246 -0
- data/vendor/assets/javascripts/jsts/simplify/LineSegmentIndex.js +101 -0
- data/vendor/assets/javascripts/jsts/triangulate/DelaunayTriangulationBuilder.js +224 -0
- data/vendor/assets/javascripts/jsts/triangulate/IncrementalDelaunayTriangulator.js +111 -0
- data/vendor/assets/javascripts/jsts/triangulate/VoronoiDiagramBuilder.js +172 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/LastFoundQuadEdgeLocator.js +52 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdge.js +437 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdgeSubdivision.js +1064 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/TrianglePredicate.js +350 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/Vertex.js +496 -0
- data/vendor/assets/javascripts/jsts/util/Assert.js +80 -0
- data/vendor/assets/javascripts/jsts/util/AssertionFailedException.js +23 -0
- data/vendor/assets/javascripts/jsts/util/UniqueCoordinateArrayFilter.js +52 -0
- 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
|
+
};
|
File without changes
|
@@ -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
|
+
};
|