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,29 @@
|
|
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/index/EdgeSetIntersector.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Finds all intersections in one or two sets of edges,
|
15
|
+
* using an x-axis sweepline algorithm in conjunction with Monotone Chains.
|
16
|
+
* While still O(n^2) in the worst case, this algorithm
|
17
|
+
* drastically improves the average-case time.
|
18
|
+
* The use of MonotoneChains as the items in the index
|
19
|
+
* seems to offer an improvement in performance over a sweep-line alone.
|
20
|
+
* @constructor
|
21
|
+
*/
|
22
|
+
jsts.geomgraph.index.SimpleMCSweepLineIntersector = function() {
|
23
|
+
throw new jsts.error.NotImplementedError();
|
24
|
+
};
|
25
|
+
|
26
|
+
|
27
|
+
jsts.geomgraph.index.SimpleMCSweepLineIntersector.prototype = new jsts.geomgraph.index.EdgeSetIntersector();
|
28
|
+
|
29
|
+
// TODO: port
|
@@ -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
|
+
|
9
|
+
/**
|
10
|
+
* An array-visitor
|
11
|
+
*
|
12
|
+
* @constructor
|
13
|
+
*/
|
14
|
+
jsts.index.ArrayListVisitor = function() {
|
15
|
+
this.items = [];
|
16
|
+
};
|
17
|
+
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Visits an item
|
21
|
+
*
|
22
|
+
* @param {Object}
|
23
|
+
* item the item to visit.
|
24
|
+
*/
|
25
|
+
jsts.index.ArrayListVisitor.prototype.visitItem = function(item) {
|
26
|
+
this.items.push(item);
|
27
|
+
};
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Returns all visited items
|
32
|
+
*
|
33
|
+
* @return {Array} An array with all visited items.
|
34
|
+
*/
|
35
|
+
jsts.index.ArrayListVisitor.prototype.getItems = function() {
|
36
|
+
return this.items;
|
37
|
+
};
|
@@ -0,0 +1,132 @@
|
|
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
|
+
* DoubleBits manipulates Double numbers by using bit manipulation and bit-field
|
11
|
+
* extraction. For some operations (such as determining the exponent) this is
|
12
|
+
* more accurate than using mathematical operations (which suffer from round-off
|
13
|
+
* error).
|
14
|
+
* <p>
|
15
|
+
* The algorithms and constants in this class apply only to IEEE-754
|
16
|
+
* double-precision floating point format.
|
17
|
+
*
|
18
|
+
* NOTE: Since the only numberformat in JavaScript is IEEE-754 the code in
|
19
|
+
* DoubleBits could not be easily ported.
|
20
|
+
*
|
21
|
+
* Instead, using algorithms found here:
|
22
|
+
* http://www.merlyn.demon.co.uk/js-exact.htm
|
23
|
+
*
|
24
|
+
* @constructor
|
25
|
+
*/
|
26
|
+
jsts.index.DoubleBits = function() {
|
27
|
+
|
28
|
+
};
|
29
|
+
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Calculates the power of two for a number
|
33
|
+
*
|
34
|
+
* @param {Number}
|
35
|
+
* exp value to pow.
|
36
|
+
* @return {Number} the pow'ed value.
|
37
|
+
*/
|
38
|
+
jsts.index.DoubleBits.powerOf2 = function(exp) {
|
39
|
+
// TODO: Make sure the accuracy of this is sufficient (why else would JTS have
|
40
|
+
// this in DoubleBits?)
|
41
|
+
return Math.pow(2, exp);
|
42
|
+
};
|
43
|
+
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Calculates the exponent-part of the bit-pattern for a number
|
47
|
+
*
|
48
|
+
* @param {Number}
|
49
|
+
* d the IEEE-754-value to calculate the exponent for.
|
50
|
+
* @return {Number} the exponent part of the bit-mask.
|
51
|
+
*/
|
52
|
+
jsts.index.DoubleBits.exponent = function(d) {
|
53
|
+
return jsts.index.DoubleBits.CVTFWD(64, d) - 1023;
|
54
|
+
};
|
55
|
+
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Calculates the exponent of the bit-pattern for a number. Uses code from:
|
59
|
+
* http://www.merlyn.demon.co.uk/js-exact.htm
|
60
|
+
*
|
61
|
+
* @param {Number}
|
62
|
+
* NumW 32 or 64 to denote the number of bits.
|
63
|
+
* @param {Number}
|
64
|
+
* Qty the number to calculate the bit pattern for.
|
65
|
+
* @return {Number} The integer value of the exponent.
|
66
|
+
*/
|
67
|
+
jsts.index.DoubleBits.CVTFWD = function(NumW, Qty) {
|
68
|
+
var Sign, Expo, Mant, Bin, nb01 = ''; // , OutW = NumW/4
|
69
|
+
var Inf = {
|
70
|
+
32: {
|
71
|
+
d: 0x7F,
|
72
|
+
c: 0x80,
|
73
|
+
b: 0,
|
74
|
+
a: 0
|
75
|
+
},
|
76
|
+
64: {
|
77
|
+
d: 0x7FF0,
|
78
|
+
c: 0,
|
79
|
+
b: 0,
|
80
|
+
a: 0
|
81
|
+
}
|
82
|
+
};
|
83
|
+
var ExW = {
|
84
|
+
32: 8,
|
85
|
+
64: 11
|
86
|
+
}[NumW], MtW = NumW - ExW - 1;
|
87
|
+
|
88
|
+
if (!Bin) {
|
89
|
+
Sign = Qty < 0 || 1 / Qty < 0; // OK for +-0
|
90
|
+
if (!isFinite(Qty)) {
|
91
|
+
Bin = Inf[NumW];
|
92
|
+
if (Sign) {
|
93
|
+
Bin.d += 1 << (NumW / 4 - 1);
|
94
|
+
}
|
95
|
+
Expo = Math.pow(2, ExW) - 1;
|
96
|
+
Mant = 0;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
if (!Bin) {
|
101
|
+
Expo = {
|
102
|
+
32: 127,
|
103
|
+
64: 1023
|
104
|
+
}[NumW];
|
105
|
+
Mant = Math.abs(Qty);
|
106
|
+
while (Mant >= 2) {
|
107
|
+
Expo++;
|
108
|
+
Mant /= 2;
|
109
|
+
}
|
110
|
+
while (Mant < 1 && Expo > 0) {
|
111
|
+
Expo--;
|
112
|
+
Mant *= 2;
|
113
|
+
}
|
114
|
+
if (Expo <= 0) {
|
115
|
+
Mant /= 2;
|
116
|
+
nb01 = 'Zero or Denormal';
|
117
|
+
}
|
118
|
+
if (NumW === 32 && Expo > 254) {
|
119
|
+
nb01 = 'Too big for Single';
|
120
|
+
Bin = {
|
121
|
+
d: Sign ? 0xFF : 0x7F,
|
122
|
+
c: 0x80,
|
123
|
+
b: 0,
|
124
|
+
a: 0
|
125
|
+
};
|
126
|
+
Expo = Math.pow(2, ExW) - 1;
|
127
|
+
Mant = 0;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
return Expo;
|
132
|
+
};
|
@@ -0,0 +1,55 @@
|
|
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
|
+
* Provides a test for whether an interval is so small it should be considered
|
11
|
+
* as zero for the purposes of inserting it into a binary tree. The reason this
|
12
|
+
* check is necessary is that round-off error can cause the algorithm used to
|
13
|
+
* subdivide an interval to fail, by computing a midpoint value which does not
|
14
|
+
* lie strictly between the endpoints.
|
15
|
+
*
|
16
|
+
* @constructor
|
17
|
+
*/
|
18
|
+
jsts.index.IntervalSize = function() {
|
19
|
+
|
20
|
+
};
|
21
|
+
|
22
|
+
|
23
|
+
/**
|
24
|
+
* This value is chosen to be a few powers of 2 less than the number of bits
|
25
|
+
* available in the double representation (i.e. 53). This should allow enough
|
26
|
+
* extra precision for simple computations to be correct, at least for
|
27
|
+
* comparison purposes.
|
28
|
+
*/
|
29
|
+
jsts.index.IntervalSize.MIN_BINARY_EXPONENT = -50;
|
30
|
+
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Computes whether the interval [min, max] is effectively zero width. I.e. the
|
34
|
+
* width of the interval is so much less than the location of the interval that
|
35
|
+
* the midpoint of the interval cannot be represented precisely.
|
36
|
+
*
|
37
|
+
* @param {Number}
|
38
|
+
* min the min-value in the interval.
|
39
|
+
* @param {Number}
|
40
|
+
* max the max-value in the interval.
|
41
|
+
* @return {Boolean} true if the interval should be considered zero.
|
42
|
+
*/
|
43
|
+
jsts.index.IntervalSize.isZeroWidth = function(min, max) {
|
44
|
+
var width = max - min;
|
45
|
+
if (width === 0.0) {
|
46
|
+
return true;
|
47
|
+
}
|
48
|
+
|
49
|
+
var maxAbs, scaledInterval, level;
|
50
|
+
maxAbs = Math.max(Math.abs(min), Math.abs(max));
|
51
|
+
scaledInterval = width / maxAbs;
|
52
|
+
|
53
|
+
level = jsts.index.DoubleBits.exponent(scaledInterval);
|
54
|
+
return level <= jsts.index.IntervalSize.MIN_BINARY_EXPONENT;
|
55
|
+
};
|
@@ -0,0 +1,23 @@
|
|
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 visitor for items in an index.
|
9
|
+
*
|
10
|
+
* @interface
|
11
|
+
*/
|
12
|
+
jsts.index.ItemVisitor = function() {
|
13
|
+
|
14
|
+
};
|
15
|
+
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @param {Object} item
|
19
|
+
* @public
|
20
|
+
*/
|
21
|
+
jsts.index.ItemVisitor.prototype.visitItem = function() {
|
22
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
23
|
+
};
|
@@ -0,0 +1,67 @@
|
|
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
|
+
* The basic operations supported by classes
|
9
|
+
* implementing spatial index algorithms.
|
10
|
+
* <p>
|
11
|
+
* A spatial index typically provides a primary filter for range rectangle queries.
|
12
|
+
* A secondary filter is required to test for exact intersection.
|
13
|
+
* The secondary filter may consist of other kinds of tests,
|
14
|
+
* such as testing other spatial relationships.
|
15
|
+
*
|
16
|
+
* @version 1.7
|
17
|
+
*/
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @interface
|
23
|
+
*/
|
24
|
+
jsts.index.SpatialIndex = function() {
|
25
|
+
|
26
|
+
};
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Adds a spatial item with an extent specified by the given {@link Envelope} to the index
|
31
|
+
*
|
32
|
+
* @param {jsts.geom.Envelope} itemEnv
|
33
|
+
* @param {Object} item
|
34
|
+
* @public
|
35
|
+
*/
|
36
|
+
jsts.index.SpatialIndex.prototype.insert = function(itemEnv, item) {
|
37
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
38
|
+
};
|
39
|
+
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Queries the index for all items whose extents intersect the given search {@link Envelope}
|
43
|
+
* and applies an {@link ItemVisitor} to them (if provided).
|
44
|
+
* Note that some kinds of indexes may also return objects which do not in fact
|
45
|
+
* intersect the query envelope.
|
46
|
+
*
|
47
|
+
* @param {jsts.geom.Envelope} searchEnv the envelope to query for.
|
48
|
+
* @param {jsts.index.ItemVisitor=} [visitor] a visitor object to apply to the items found.
|
49
|
+
* @return {?Array} a list of the items found by the query.
|
50
|
+
* @public
|
51
|
+
*/
|
52
|
+
jsts.index.SpatialIndex.prototype.query = function(searchEnv, visitor) {
|
53
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
54
|
+
};
|
55
|
+
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Removes a single item from the tree.
|
59
|
+
*
|
60
|
+
* @param {jsts.geom.Envelope} itemEnv the Envelope of the item to remove.
|
61
|
+
* @param {Object} item the item to remove.
|
62
|
+
* @return {boolean} <code>true</code> if the item was found.
|
63
|
+
* @public
|
64
|
+
*/
|
65
|
+
jsts.index.SpatialIndex.prototype.remove = function(itemEnv, item) {
|
66
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
67
|
+
};
|
@@ -0,0 +1,224 @@
|
|
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
|
+
* An <code>BinTree</code> (or "Binary Interval Tree") is a 1-dimensional
|
10
|
+
* version of a quadtree. It indexes 1-dimensional intervals (which may be the
|
11
|
+
* projection of 2-D objects on an axis). It supports range searching (where the
|
12
|
+
* range may be a single point). This structure is dynamic - new items can be
|
13
|
+
* added at any time, and it will support deletion of items (although this is
|
14
|
+
* not currently implemented).
|
15
|
+
* <p>
|
16
|
+
* This implementation does not require specifying the extent of the inserted
|
17
|
+
* items beforehand. It will automatically expand to accomodate any extent of
|
18
|
+
* dataset.
|
19
|
+
* <p>
|
20
|
+
* The bintree structure is used to provide a primary filter for interval
|
21
|
+
* queries. The query() method returns a list of all objects which <i>may</i>
|
22
|
+
* intersect the query interval. Note that it may return objects which do not in
|
23
|
+
* fact intersect. A secondary filter is required to test for exact
|
24
|
+
* intersection. Of course, this secondary filter may consist of other tests
|
25
|
+
* besides intersection, such as testing other kinds of spatial relationships.
|
26
|
+
* <p>
|
27
|
+
* This index is different to the Interval Tree of Edelsbrunner or the Segment
|
28
|
+
* Tree of Bentley.
|
29
|
+
*/
|
30
|
+
(function() {
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @requires jsts/index/bintree/Root.js
|
34
|
+
* @requires jsts/index/bintree/Interval.js
|
35
|
+
*/
|
36
|
+
|
37
|
+
var Interval = jsts.index.bintree.Interval;
|
38
|
+
var Root = jsts.index.bintree.Root;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Constructs a new Bintree
|
42
|
+
*
|
43
|
+
* @constructor
|
44
|
+
*/
|
45
|
+
var Bintree = function() {
|
46
|
+
this.root = new Root();
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Statistics
|
50
|
+
*
|
51
|
+
* minExtent is the minimum extent of all items inserted into the tree so
|
52
|
+
* far. It is used as a heuristic value to construct non-zero extents for
|
53
|
+
* features with zero extent. Start with a non-zero extent, in case the
|
54
|
+
* first feature inserted has a zero extent in both directions. This value
|
55
|
+
* may be non-optimal, but only one feature will be inserted with this
|
56
|
+
* value.
|
57
|
+
*/
|
58
|
+
this.minExtent = 1.0;
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Ensure that the Interval for the inserted item has non-zero extents. Use
|
63
|
+
* the current minExtent to pad it, if necessary
|
64
|
+
*
|
65
|
+
* @param {jsts.index.bintree.Interval}
|
66
|
+
* itemInterval the interval.
|
67
|
+
* @param {Number}
|
68
|
+
* minExtent used to pad the extent if necessary.
|
69
|
+
*/
|
70
|
+
Bintree.ensureExtent = function(itemInterval, minExtent) {
|
71
|
+
var min, max;
|
72
|
+
|
73
|
+
min = itemInterval.getMin();
|
74
|
+
max = itemInterval.getMax();
|
75
|
+
|
76
|
+
// has a non-zero extent
|
77
|
+
if (min !== max) {
|
78
|
+
return itemInterval;
|
79
|
+
}
|
80
|
+
|
81
|
+
// pad extent
|
82
|
+
if (min === max) {
|
83
|
+
min = min - (minExtent / 2.0);
|
84
|
+
max = min + (minExtent / 2.0);
|
85
|
+
}
|
86
|
+
|
87
|
+
return new Interval(min, max);
|
88
|
+
};
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Calculates the depth of the tree
|
92
|
+
*
|
93
|
+
* @return {Number} the depth.
|
94
|
+
*/
|
95
|
+
Bintree.prototype.depth = function() {
|
96
|
+
if (this.root !== null) {
|
97
|
+
return this.root.depth();
|
98
|
+
}
|
99
|
+
return 0;
|
100
|
+
};
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Calculates the size of the tree
|
104
|
+
*
|
105
|
+
* @return {Number} the size.
|
106
|
+
*/
|
107
|
+
Bintree.prototype.size = function() {
|
108
|
+
if (this.root !== null) {
|
109
|
+
return this.root.size();
|
110
|
+
}
|
111
|
+
return 0;
|
112
|
+
};
|
113
|
+
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Compute the total number of nodes in the tree
|
117
|
+
*
|
118
|
+
* @return {Number} the number of nodes in the tree.
|
119
|
+
*/
|
120
|
+
Bintree.prototype.nodeSize = function() {
|
121
|
+
if (this.root !== null) {
|
122
|
+
return this.root.nodeSize();
|
123
|
+
}
|
124
|
+
return 0;
|
125
|
+
};
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Inserts an object in the tree
|
129
|
+
*
|
130
|
+
* @param {jsts.index.bintree.Interval}
|
131
|
+
* itemInterval the interval for the item.
|
132
|
+
* @param {Object}
|
133
|
+
* item the item to insert.
|
134
|
+
*/
|
135
|
+
Bintree.prototype.insert = function(itemInterval, item) {
|
136
|
+
this.collectStats(itemInterval);
|
137
|
+
var insertInterval = Bintree.ensureExtent(itemInterval, this.minExtent);
|
138
|
+
this.root.insert(insertInterval, item);
|
139
|
+
};
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Removes a single item from the tree.
|
143
|
+
*
|
144
|
+
* @param {jsts.index.bintree.Interval}
|
145
|
+
* itemInterval the Interval of the item to be removed.
|
146
|
+
* @param {Object}
|
147
|
+
* item the item to remove.
|
148
|
+
* @return {Boolean} <code>true</code> if the item was found (and thus
|
149
|
+
* removed).
|
150
|
+
*/
|
151
|
+
Bintree.prototype.remove = function(itemInterval, item) {
|
152
|
+
var insertInterval = Bintree.ensureExtent(itemInterval, this.minExtent);
|
153
|
+
return this.root.remove(insertInterval, item);
|
154
|
+
};
|
155
|
+
|
156
|
+
Bintree.prototype.iterator = function() {
|
157
|
+
var foundItems = new javascript.util.ArrayList();
|
158
|
+
this.root.addAllItems(foundItems);
|
159
|
+
return foundItems.iterator();
|
160
|
+
};
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Queries the tree by Interval or number
|
164
|
+
*
|
165
|
+
* @param {Number}
|
166
|
+
* x OR {jsts.index.bintree.Interval} x.
|
167
|
+
* @return {javascript.util.ArrayList} the found items.
|
168
|
+
*/
|
169
|
+
Bintree.prototype.query = function() {
|
170
|
+
if (arguments.length === 2) {
|
171
|
+
this.queryAndAdd(arguments[0], arguments[1]);
|
172
|
+
} else {
|
173
|
+
var x = arguments[0];
|
174
|
+
if (!x instanceof Interval) {
|
175
|
+
x = new Interval(x, x);
|
176
|
+
}
|
177
|
+
|
178
|
+
return this.queryInterval(x);
|
179
|
+
}
|
180
|
+
};
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Queries the tree to find all candidate items which may overlap the query
|
184
|
+
* interval. If the query interval is <tt>null</tt>, all items in the tree
|
185
|
+
* are found.
|
186
|
+
*
|
187
|
+
* min and max may be the same value
|
188
|
+
*
|
189
|
+
* @param {jsts.index.bintree.Interval}
|
190
|
+
* interval the interval to query by.
|
191
|
+
*/
|
192
|
+
Bintree.prototype.queryInterval = function(interval) {
|
193
|
+
/**
|
194
|
+
* the items that are matched are all items in intervals which overlap the
|
195
|
+
* query interval
|
196
|
+
*/
|
197
|
+
var foundItems = new javascript.util.ArrayList();
|
198
|
+
this.query(interval, foundItems);
|
199
|
+
return foundItems;
|
200
|
+
};
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Adds items in the tree which potentially overlap the query interval to the
|
204
|
+
* given collection. If the query interval is <tt>null</tt>, add all items
|
205
|
+
* in the tree.
|
206
|
+
*
|
207
|
+
* @param {jsts.index.bintree.Interval}
|
208
|
+
* interval a query nterval, or null.
|
209
|
+
* @param {javascript.util.ArrayList}
|
210
|
+
* resultItems the candidate items found.
|
211
|
+
*/
|
212
|
+
Bintree.prototype.queryAndAdd = function(interval, foundItems) {
|
213
|
+
this.root.addAllItemsFromOverlapping(interval, foundItems);
|
214
|
+
};
|
215
|
+
|
216
|
+
Bintree.prototype.collectStats = function(interval) {
|
217
|
+
var del = interval.getWidth();
|
218
|
+
if (del < this.minExtent && del > 0.0) {
|
219
|
+
this.minExtent = del;
|
220
|
+
}
|
221
|
+
};
|
222
|
+
|
223
|
+
jsts.index.bintree.Bintree = Bintree;
|
224
|
+
})();
|