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,198 @@
|
|
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/noding/SegmentIntersector.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Computes the intersections between two line segments in {@link SegmentString}s
|
13
|
+
* and adds them to each string. The {@link SegmentIntersector} is passed to a
|
14
|
+
* {@link Noder}. The {@link addIntersections} method is called whenever the
|
15
|
+
* {@link Noder} detects that two SegmentStrings <i>might</i> intersect. This
|
16
|
+
* class is an example of the <i>Strategy</i> pattern.
|
17
|
+
*
|
18
|
+
* @constructor
|
19
|
+
*/
|
20
|
+
jsts.noding.IntersectionAdder = function(li) {
|
21
|
+
this.li = li;
|
22
|
+
};
|
23
|
+
|
24
|
+
jsts.noding.IntersectionAdder.prototype = new jsts.noding.SegmentIntersector();
|
25
|
+
jsts.noding.IntersectionAdder.constructor = jsts.noding.IntersectionAdder;
|
26
|
+
|
27
|
+
|
28
|
+
jsts.noding.IntersectionAdder.isAdjacentSegments = function(i1, i2) {
|
29
|
+
return Math.abs(i1 - i2) === 1;
|
30
|
+
};
|
31
|
+
|
32
|
+
/**
|
33
|
+
* These variables keep track of what types of intersections were found during
|
34
|
+
* ALL edges that have been intersected.
|
35
|
+
*/
|
36
|
+
/**
|
37
|
+
* @type {boolean}
|
38
|
+
* @private
|
39
|
+
*/
|
40
|
+
jsts.noding.IntersectionAdder.prototype._hasIntersection = false;
|
41
|
+
/**
|
42
|
+
* @type {boolean}
|
43
|
+
* @private
|
44
|
+
*/
|
45
|
+
jsts.noding.IntersectionAdder.prototype.hasProper = false;
|
46
|
+
/**
|
47
|
+
* @type {boolean}
|
48
|
+
* @private
|
49
|
+
*/
|
50
|
+
jsts.noding.IntersectionAdder.prototype.hasProperInterior = false;
|
51
|
+
/**
|
52
|
+
* @type {boolean}
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
jsts.noding.IntersectionAdder.prototype.hasInterior = false;
|
56
|
+
|
57
|
+
// the proper intersection point found
|
58
|
+
|
59
|
+
/**
|
60
|
+
* @type {Coordinate}
|
61
|
+
* @private
|
62
|
+
*/
|
63
|
+
jsts.noding.IntersectionAdder.prototype.properIntersectionPoint = null;
|
64
|
+
|
65
|
+
/**
|
66
|
+
* @type {LineIntersector}
|
67
|
+
* @private
|
68
|
+
*/
|
69
|
+
jsts.noding.IntersectionAdder.prototype.li = null;
|
70
|
+
/**
|
71
|
+
* @type {boolean}
|
72
|
+
* @private
|
73
|
+
*/
|
74
|
+
jsts.noding.IntersectionAdder.prototype.isSelfIntersection = null;
|
75
|
+
|
76
|
+
jsts.noding.IntersectionAdder.prototype.numIntersections = 0;
|
77
|
+
jsts.noding.IntersectionAdder.prototype.numInteriorIntersections = 0;
|
78
|
+
jsts.noding.IntersectionAdder.prototype.numProperIntersections = 0;
|
79
|
+
|
80
|
+
// testing only
|
81
|
+
jsts.noding.IntersectionAdder.prototype.numTests = 0;
|
82
|
+
|
83
|
+
|
84
|
+
jsts.noding.IntersectionAdder.prototype.getLineIntersector = function() {
|
85
|
+
return this.li;
|
86
|
+
};
|
87
|
+
|
88
|
+
/**
|
89
|
+
* @return the proper intersection point, or <code>null</code> if none was
|
90
|
+
* found.
|
91
|
+
*/
|
92
|
+
jsts.noding.IntersectionAdder.prototype.getProperIntersectionPoint = function() {
|
93
|
+
return this.properIntersectionPoint;
|
94
|
+
};
|
95
|
+
|
96
|
+
jsts.noding.IntersectionAdder.prototype.hasIntersection = function() {
|
97
|
+
return this._hasIntersection;
|
98
|
+
};
|
99
|
+
/**
|
100
|
+
* A proper intersection is an intersection which is interior to at least two
|
101
|
+
* line segments. Note that a proper intersection is not necessarily in the
|
102
|
+
* interior of the entire Geometry, since another edge may have an endpoint
|
103
|
+
* equal to the intersection, which according to SFS semantics can result in the
|
104
|
+
* point being on the Boundary of the Geometry.
|
105
|
+
*/
|
106
|
+
jsts.noding.IntersectionAdder.prototype.hasProperIntersection = function() {
|
107
|
+
return this.hasProper;
|
108
|
+
};
|
109
|
+
/**
|
110
|
+
* A proper interior intersection is a proper intersection which is <b>not</b>
|
111
|
+
* contained in the set of boundary nodes set for this SegmentIntersector.
|
112
|
+
*/
|
113
|
+
jsts.noding.IntersectionAdder.prototype.hasProperInteriorIntersection = function() {
|
114
|
+
return this.hasProperInterior;
|
115
|
+
};
|
116
|
+
/**
|
117
|
+
* An interior intersection is an intersection which is in the interior of some
|
118
|
+
* segment.
|
119
|
+
*/
|
120
|
+
jsts.noding.IntersectionAdder.prototype.hasInteriorIntersection = function() {
|
121
|
+
return this.hasInterior;
|
122
|
+
};
|
123
|
+
|
124
|
+
/**
|
125
|
+
* A trivial intersection is an apparent self-intersection which in fact is
|
126
|
+
* simply the point shared by adjacent line segments. Note that closed edges
|
127
|
+
* require a special check for the point shared by the beginning and end
|
128
|
+
* segments.
|
129
|
+
*
|
130
|
+
* @private
|
131
|
+
*/
|
132
|
+
jsts.noding.IntersectionAdder.prototype.isTrivialIntersection = function(e0,
|
133
|
+
segIndex0, e1, segIndex1) {
|
134
|
+
if (e0 == e1) {
|
135
|
+
if (this.li.getIntersectionNum() == 1) {
|
136
|
+
if (jsts.noding.IntersectionAdder
|
137
|
+
.isAdjacentSegments(segIndex0, segIndex1))
|
138
|
+
return true;
|
139
|
+
if (e0.isClosed()) {
|
140
|
+
var maxSegIndex = e0.size() - 1;
|
141
|
+
if ((segIndex0 === 0 && segIndex1 === maxSegIndex) ||
|
142
|
+
(segIndex1 === 0 && segIndex0 === maxSegIndex)) {
|
143
|
+
return true;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
return false;
|
149
|
+
};
|
150
|
+
|
151
|
+
/**
|
152
|
+
* This method is called by clients of the {@link SegmentIntersector} class to
|
153
|
+
* process intersections for two segments of the {@link SegmentString}s being
|
154
|
+
* intersected. Note that some clients (such as {@link MonotoneChain}s) may
|
155
|
+
* optimize away this call for segment pairs which they have determined do not
|
156
|
+
* intersect (e.g. by an disjoint envelope test).
|
157
|
+
*/
|
158
|
+
jsts.noding.IntersectionAdder.prototype.processIntersections = function(e0,
|
159
|
+
segIndex0, e1, segIndex1) {
|
160
|
+
if (e0 === e1 && segIndex0 === segIndex1)
|
161
|
+
return;
|
162
|
+
this.numTests++;
|
163
|
+
var p00 = e0.getCoordinates()[segIndex0];
|
164
|
+
var p01 = e0.getCoordinates()[segIndex0 + 1];
|
165
|
+
var p10 = e1.getCoordinates()[segIndex1];
|
166
|
+
var p11 = e1.getCoordinates()[segIndex1 + 1];
|
167
|
+
|
168
|
+
this.li.computeIntersection(p00, p01, p10, p11);
|
169
|
+
if (this.li.hasIntersection()) {
|
170
|
+
this.numIntersections++;
|
171
|
+
if (this.li.isInteriorIntersection()) {
|
172
|
+
this.numInteriorIntersections++;
|
173
|
+
this.hasInterior = true;
|
174
|
+
}
|
175
|
+
// if the segments are adjacent they have at least one trivial intersection,
|
176
|
+
// the shared endpoint. Don't bother adding it if it is the
|
177
|
+
// only intersection.
|
178
|
+
if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
|
179
|
+
this._hasIntersection = true;
|
180
|
+
e0.addIntersections(this.li, segIndex0, 0);
|
181
|
+
e1.addIntersections(this.li, segIndex1, 1);
|
182
|
+
if (this.li.isProper()) {
|
183
|
+
this.numProperIntersections++;
|
184
|
+
this.hasProper = true;
|
185
|
+
this.hasProperInterior = true;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
};
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Always process all intersections
|
193
|
+
*
|
194
|
+
* @return false always.
|
195
|
+
*/
|
196
|
+
jsts.noding.IntersectionAdder.prototype.isDone = function() {
|
197
|
+
return false;
|
198
|
+
};
|
@@ -0,0 +1,79 @@
|
|
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
|
+
* Port source:
|
9
|
+
* /jts/jts/java/src/com/vividsolutions/jts/noding/IntersectionFinderAdder.java
|
10
|
+
* Revision: 108
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Finds proper and interior intersections in a set of SegmentStrings,
|
15
|
+
* and adds them as nodes.
|
16
|
+
*/
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Creates an intersection finder which finds all proper intersections
|
20
|
+
*
|
21
|
+
* @param li
|
22
|
+
* the LineIntersector to use.
|
23
|
+
*/
|
24
|
+
jsts.noding.IntersectionFinderAdder = function(li) {
|
25
|
+
this.li = li;
|
26
|
+
this.interiorIntersections = new javascript.util.ArrayList();
|
27
|
+
};
|
28
|
+
|
29
|
+
jsts.noding.IntersectionFinderAdder.prototype = new jsts.noding.SegmentIntersector();
|
30
|
+
jsts.noding.IntersectionFinderAdder.constructor = jsts.noding.IntersectionFinderAdder;
|
31
|
+
|
32
|
+
|
33
|
+
jsts.noding.IntersectionFinderAdder.prototype.li = null;
|
34
|
+
jsts.noding.IntersectionFinderAdder.prototype.interiorIntersections = null;
|
35
|
+
|
36
|
+
|
37
|
+
jsts.noding.IntersectionFinderAdder.prototype.getInteriorIntersections = function() {
|
38
|
+
return this.interiorIntersections;
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* This method is called by clients of the {@link SegmentIntersector} class to
|
43
|
+
* process intersections for two segments of the {@link SegmentString}s being
|
44
|
+
* intersected. Note that some clients (such as {@link MonotoneChain}s) may
|
45
|
+
* optimize away this call for segment pairs which they have determined do not
|
46
|
+
* intersect (e.g. by an disjoint envelope test).
|
47
|
+
*/
|
48
|
+
jsts.noding.IntersectionFinderAdder.prototype.processIntersections = function(
|
49
|
+
e0, segIndex0, e1, segIndex1) {
|
50
|
+
// don't bother intersecting a segment with itself
|
51
|
+
if (e0 === e1 && segIndex0 === segIndex1)
|
52
|
+
return;
|
53
|
+
|
54
|
+
var p00 = e0.getCoordinates()[segIndex0];
|
55
|
+
var p01 = e0.getCoordinates()[segIndex0 + 1];
|
56
|
+
var p10 = e1.getCoordinates()[segIndex1];
|
57
|
+
var p11 = e1.getCoordinates()[segIndex1 + 1];
|
58
|
+
|
59
|
+
this.li.computeIntersection(p00, p01, p10, p11);
|
60
|
+
|
61
|
+
if (this.li.hasIntersection()) {
|
62
|
+
if (this.li.isInteriorIntersection()) {
|
63
|
+
for (var intIndex = 0; intIndex < this.li.getIntersectionNum(); intIndex++) {
|
64
|
+
this.interiorIntersections.add(this.li.getIntersection(intIndex));
|
65
|
+
}
|
66
|
+
e0.addIntersections(this.li, segIndex0, 0);
|
67
|
+
e1.addIntersections(this.li, segIndex1, 1);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Always process all intersections
|
74
|
+
*
|
75
|
+
* @return false always.
|
76
|
+
*/
|
77
|
+
jsts.noding.IntersectionFinderAdder.prototype.isDone = function() {
|
78
|
+
return false;
|
79
|
+
};
|
@@ -0,0 +1,147 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function() {
|
8
|
+
|
9
|
+
/**
|
10
|
+
* @requires jsts/noding/SinglePassNoder.js
|
11
|
+
* @requires jsts/index/strtree/STRtree.js
|
12
|
+
* @requires jsts/noding/NodedSegmentString.js
|
13
|
+
* @requires jsts/index/chain/MonotoneChainBuilder.js
|
14
|
+
* @requires jsts/index/chain/MonotoneChainOverlapAction.js
|
15
|
+
*/
|
16
|
+
|
17
|
+
var MonotoneChainOverlapAction = jsts.index.chain.MonotoneChainOverlapAction;
|
18
|
+
var SinglePassNoder = jsts.noding.SinglePassNoder;
|
19
|
+
var STRtree = jsts.index.strtree.STRtree;
|
20
|
+
var NodedSegmentString = jsts.noding.NodedSegmentString;
|
21
|
+
var MonotoneChainBuilder = jsts.index.chain.MonotoneChainBuilder;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @constructor
|
25
|
+
* @private
|
26
|
+
*/
|
27
|
+
var SegmentOverlapAction = function(si) {
|
28
|
+
this.si = si;
|
29
|
+
|
30
|
+
};
|
31
|
+
SegmentOverlapAction.prototype = new MonotoneChainOverlapAction();
|
32
|
+
SegmentOverlapAction.constructor = SegmentOverlapAction;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @type {SegmentIntersector}
|
36
|
+
* @private
|
37
|
+
*/
|
38
|
+
SegmentOverlapAction.prototype.si = null;
|
39
|
+
|
40
|
+
SegmentOverlapAction.prototype.overlap = function(mc1, start1, mc2, start2) {
|
41
|
+
var ss1 = mc1.getContext();
|
42
|
+
var ss2 = mc2.getContext();
|
43
|
+
this.si.processIntersections(ss1, start1, ss2, start2);
|
44
|
+
};
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @constructor
|
48
|
+
*/
|
49
|
+
jsts.noding.MCIndexNoder = function() {
|
50
|
+
this.monoChains = [];
|
51
|
+
this.index = new STRtree();
|
52
|
+
};
|
53
|
+
|
54
|
+
jsts.noding.MCIndexNoder.prototype = new SinglePassNoder();
|
55
|
+
jsts.noding.MCIndexNoder.constructor = jsts.noding.MCIndexNoder;
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @type {Array}
|
59
|
+
* @private
|
60
|
+
*/
|
61
|
+
jsts.noding.MCIndexNoder.prototype.monoChains = null;
|
62
|
+
/**
|
63
|
+
* @type {SpatialIndex}
|
64
|
+
* @private
|
65
|
+
*/
|
66
|
+
jsts.noding.MCIndexNoder.prototype.index = null;
|
67
|
+
/**
|
68
|
+
* @type {number}
|
69
|
+
* @private
|
70
|
+
*/
|
71
|
+
jsts.noding.MCIndexNoder.prototype.idCounter = 0;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @type {Array}
|
75
|
+
* @private
|
76
|
+
*/
|
77
|
+
jsts.noding.MCIndexNoder.prototype.nodedSegStrings = null;
|
78
|
+
/**
|
79
|
+
* statistics
|
80
|
+
*
|
81
|
+
* @type {number}
|
82
|
+
* @private
|
83
|
+
*/
|
84
|
+
jsts.noding.MCIndexNoder.prototype.nOverlaps = 0;
|
85
|
+
|
86
|
+
|
87
|
+
jsts.noding.MCIndexNoder.prototype.getMonotoneChains = function() {
|
88
|
+
return this.monoChains;
|
89
|
+
};
|
90
|
+
|
91
|
+
jsts.noding.MCIndexNoder.prototype.getIndex = function() {
|
92
|
+
return this.index;
|
93
|
+
};
|
94
|
+
|
95
|
+
jsts.noding.MCIndexNoder.prototype.getNodedSubstrings = function() {
|
96
|
+
return NodedSegmentString.getNodedSubstrings(this.nodedSegStrings);
|
97
|
+
};
|
98
|
+
|
99
|
+
jsts.noding.MCIndexNoder.prototype.computeNodes = function(inputSegStrings) {
|
100
|
+
this.nodedSegStrings = inputSegStrings;
|
101
|
+
for (var i = inputSegStrings.iterator(); i.hasNext(); ) {
|
102
|
+
this.add(i.next());
|
103
|
+
}
|
104
|
+
this.intersectChains();
|
105
|
+
};
|
106
|
+
|
107
|
+
/**
|
108
|
+
* @private
|
109
|
+
*/
|
110
|
+
jsts.noding.MCIndexNoder.prototype.intersectChains = function() {
|
111
|
+
var overlapAction = new SegmentOverlapAction(this.segInt);
|
112
|
+
|
113
|
+
for (var i = 0; i < this.monoChains.length; i++) {
|
114
|
+
var queryChain = this.monoChains[i];
|
115
|
+
var overlapChains = this.index.query(queryChain.getEnvelope());
|
116
|
+
for (var j = 0; j < overlapChains.length; j++) {
|
117
|
+
var testChain = overlapChains[j];
|
118
|
+
/**
|
119
|
+
* following test makes sure we only compare each pair of chains once
|
120
|
+
* and that we don't compare a chain to itself
|
121
|
+
*/
|
122
|
+
if (testChain.getId() > queryChain.getId()) {
|
123
|
+
queryChain.computeOverlaps(testChain, overlapAction);
|
124
|
+
this.nOverlaps++;
|
125
|
+
}
|
126
|
+
// short-circuit if possible
|
127
|
+
if (this.segInt.isDone())
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
};
|
132
|
+
|
133
|
+
/**
|
134
|
+
* @private
|
135
|
+
*/
|
136
|
+
jsts.noding.MCIndexNoder.prototype.add = function(segStr) {
|
137
|
+
var segChains = MonotoneChainBuilder.getChains(segStr.getCoordinates(),
|
138
|
+
segStr);
|
139
|
+
for (var i = 0; i < segChains.length; i++) {
|
140
|
+
var mc = segChains[i];
|
141
|
+
mc.setId(this.idCounter++);
|
142
|
+
this.index.insert(mc.getEnvelope(), mc);
|
143
|
+
this.monoChains.push(mc);
|
144
|
+
}
|
145
|
+
};
|
146
|
+
|
147
|
+
})();
|
@@ -0,0 +1,35 @@
|
|
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/noding/SegmentString.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
/**
|
14
|
+
* An interface for classes which support adding nodes to a segment string.
|
15
|
+
*
|
16
|
+
* @interface
|
17
|
+
*/
|
18
|
+
jsts.noding.NodableSegmentString = function() {
|
19
|
+
|
20
|
+
};
|
21
|
+
|
22
|
+
|
23
|
+
jsts.noding.NodableSegmentString.prototype = new jsts.noding.SegmentString();
|
24
|
+
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Adds an intersection node for a given point and segment to this segment
|
28
|
+
* string.
|
29
|
+
*
|
30
|
+
* @param {Coordinate}
|
31
|
+
* intPt the location of the intersection.
|
32
|
+
* @param {number}
|
33
|
+
* segmentIndex the index of the segment containing the intersection.
|
34
|
+
*/
|
35
|
+
jsts.noding.NodableSegmentString.prototype.addIntersection = jsts.abstractFunc;
|