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,48 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @requires jsts/geomgraph/EdgeEndStar.js
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
/**
|
10
|
+
* An ordered list of {@link EdgeEndBundle}s around a {@link RelateNode}.
|
11
|
+
* They are maintained in CCW order (starting with the positive x-axis) around the node
|
12
|
+
* for efficient lookup and topology building.
|
13
|
+
*
|
14
|
+
* @constructor
|
15
|
+
*/
|
16
|
+
jsts.operation.relate.EdgeEndBundleStar = function() {
|
17
|
+
jsts.geomgraph.EdgeEndStar.apply(this, arguments);
|
18
|
+
};
|
19
|
+
|
20
|
+
jsts.operation.relate.EdgeEndBundleStar.prototype = new jsts.geomgraph.EdgeEndStar();
|
21
|
+
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Insert a EdgeEnd in order in the list. If there is an existing EdgeStubBundle
|
25
|
+
* which is parallel, the EdgeEnd is added to the bundle. Otherwise, a new
|
26
|
+
* EdgeEndBundle is created to contain the EdgeEnd. <br>
|
27
|
+
*/
|
28
|
+
jsts.operation.relate.EdgeEndBundleStar.prototype.insert = function(e) {
|
29
|
+
var eb = this.edgeMap.get(e);
|
30
|
+
if (eb === null) {
|
31
|
+
eb = new jsts.operation.relate.EdgeEndBundle(e);
|
32
|
+
this.insertEdgeEnd(e, eb);
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
eb.insert(e);
|
36
|
+
}
|
37
|
+
};
|
38
|
+
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Update the IM with the contribution for the EdgeStubs around the node.
|
42
|
+
*/
|
43
|
+
jsts.operation.relate.EdgeEndBundleStar.prototype.updateIM = function(im) {
|
44
|
+
for (var it = this.iterator(); it.hasNext(); ) {
|
45
|
+
var esb = it.next();
|
46
|
+
esb.updateIM(im);
|
47
|
+
}
|
48
|
+
};
|
@@ -0,0 +1,444 @@
|
|
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/geom/Location.js
|
11
|
+
* @requires jsts/util/Assert.js
|
12
|
+
*/
|
13
|
+
|
14
|
+
var Location = jsts.geom.Location;
|
15
|
+
var Assert = jsts.util.Assert;
|
16
|
+
var ArrayList = javascript.util.ArrayList;
|
17
|
+
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Computes the topological relationship between two Geometries.
|
21
|
+
* <p>
|
22
|
+
* RelateComputer does not need to build a complete graph structure to compute
|
23
|
+
* the IntersectionMatrix. The relationship between the geometries can be
|
24
|
+
* computed by simply examining the labelling of edges incident on each node.
|
25
|
+
* <p>
|
26
|
+
* RelateComputer does not currently support arbitrary GeometryCollections.
|
27
|
+
* This is because GeometryCollections can contain overlapping Polygons. In
|
28
|
+
* order to correct compute relate on overlapping Polygons, they would first
|
29
|
+
* need to be noded and merged (if not explicitly, at least implicitly).
|
30
|
+
*
|
31
|
+
* @constructor
|
32
|
+
*/
|
33
|
+
jsts.operation.relate.RelateComputer = function(arg) {
|
34
|
+
this.li = new jsts.algorithm.RobustLineIntersector();
|
35
|
+
this.ptLocator = new jsts.algorithm.PointLocator();
|
36
|
+
this.nodes = new jsts.geomgraph.NodeMap(
|
37
|
+
new jsts.operation.relate.RelateNodeFactory());
|
38
|
+
this.isolatedEdges = new ArrayList();
|
39
|
+
|
40
|
+
this.arg = arg;
|
41
|
+
};
|
42
|
+
|
43
|
+
|
44
|
+
/**
|
45
|
+
* @type {LineIntersector}
|
46
|
+
* @private
|
47
|
+
*/
|
48
|
+
jsts.operation.relate.RelateComputer.prototype.li = null;
|
49
|
+
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @type {PointLocator}
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
jsts.operation.relate.RelateComputer.prototype.ptLocator = null;
|
56
|
+
|
57
|
+
|
58
|
+
/**
|
59
|
+
* the arg(s) of the operation
|
60
|
+
*
|
61
|
+
* @type {GeometryGraph[]}
|
62
|
+
* @private
|
63
|
+
*/
|
64
|
+
jsts.operation.relate.RelateComputer.prototype.arg = null;
|
65
|
+
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @type {NodeMap}
|
69
|
+
* @private
|
70
|
+
*/
|
71
|
+
jsts.operation.relate.RelateComputer.prototype.nodes = null;
|
72
|
+
|
73
|
+
|
74
|
+
/**
|
75
|
+
* this intersection matrix will hold the results compute for the relate
|
76
|
+
*
|
77
|
+
* @type {IntersectionMatrix}
|
78
|
+
* @private
|
79
|
+
*/
|
80
|
+
jsts.operation.relate.RelateComputer.prototype.im = null;
|
81
|
+
|
82
|
+
|
83
|
+
/**
|
84
|
+
* @type {javascript.util.ArrayList}
|
85
|
+
* @private
|
86
|
+
*/
|
87
|
+
jsts.operation.relate.RelateComputer.prototype.isolatedEdges = null;
|
88
|
+
|
89
|
+
|
90
|
+
/**
|
91
|
+
* the intersection point found (if any)
|
92
|
+
*
|
93
|
+
* @type {Coordinate}
|
94
|
+
* @private
|
95
|
+
*/
|
96
|
+
jsts.operation.relate.RelateComputer.prototype.invalidPoint = null;
|
97
|
+
|
98
|
+
|
99
|
+
jsts.operation.relate.RelateComputer.prototype.computeIM = function() {
|
100
|
+
var im = new jsts.geom.IntersectionMatrix();
|
101
|
+
// since Geometries are finite and embedded in a 2-D space, the EE element
|
102
|
+
// must always be 2
|
103
|
+
im.set(Location.EXTERIOR, Location.EXTERIOR, 2);
|
104
|
+
|
105
|
+
// if the Geometries don't overlap there is nothing to do
|
106
|
+
if (!this.arg[0].getGeometry().getEnvelopeInternal().intersects(
|
107
|
+
this.arg[1].getGeometry().getEnvelopeInternal())) {
|
108
|
+
this.computeDisjointIM(im);
|
109
|
+
return im;
|
110
|
+
}
|
111
|
+
this.arg[0].computeSelfNodes(this.li, false);
|
112
|
+
this.arg[1].computeSelfNodes(this.li, false);
|
113
|
+
|
114
|
+
// compute intersections between edges of the two input geometries
|
115
|
+
var intersector = this.arg[0].computeEdgeIntersections(this.arg[1],
|
116
|
+
this.li, false);
|
117
|
+
// System.out.println("computeIM: # segment intersection tests: " +
|
118
|
+
// intersector.numTests);
|
119
|
+
this.computeIntersectionNodes(0);
|
120
|
+
this.computeIntersectionNodes(1);
|
121
|
+
/**
|
122
|
+
* Copy the labelling for the nodes in the parent Geometries. These override
|
123
|
+
* any labels determined by intersections between the geometries.
|
124
|
+
*/
|
125
|
+
this.copyNodesAndLabels(0);
|
126
|
+
this.copyNodesAndLabels(1);
|
127
|
+
|
128
|
+
// complete the labelling for any nodes which only have a label for a single
|
129
|
+
// geometry
|
130
|
+
this.labelIsolatedNodes();
|
131
|
+
|
132
|
+
// If a proper intersection was found, we can set a lower bound on the IM.
|
133
|
+
this.computeProperIntersectionIM(intersector, im);
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Now process improper intersections (eg where one or other of the
|
137
|
+
* geometries has a vertex at the intersection point) We need to compute the
|
138
|
+
* edge graph at all nodes to determine the IM.
|
139
|
+
*/
|
140
|
+
|
141
|
+
// build EdgeEnds for all intersections
|
142
|
+
var eeBuilder = new jsts.operation.relate.EdgeEndBuilder();
|
143
|
+
var ee0 = eeBuilder.computeEdgeEnds(this.arg[0].getEdgeIterator());
|
144
|
+
this.insertEdgeEnds(ee0);
|
145
|
+
var ee1 = eeBuilder.computeEdgeEnds(this.arg[1].getEdgeIterator());
|
146
|
+
this.insertEdgeEnds(ee1);
|
147
|
+
|
148
|
+
this.labelNodeEdges();
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Compute the labeling for isolated components <br>
|
152
|
+
* Isolated components are components that do not touch any other components
|
153
|
+
* in the graph. They can be identified by the fact that they will contain
|
154
|
+
* labels containing ONLY a single element, the one for their parent
|
155
|
+
* geometry. We only need to check components contained in the input graphs,
|
156
|
+
* since isolated components will not have been replaced by new components
|
157
|
+
* formed by intersections.
|
158
|
+
*/
|
159
|
+
this.labelIsolatedEdges(0, 1);
|
160
|
+
this.labelIsolatedEdges(1, 0);
|
161
|
+
|
162
|
+
// update the IM from all components
|
163
|
+
this.updateIM(im);
|
164
|
+
return im;
|
165
|
+
};
|
166
|
+
|
167
|
+
|
168
|
+
/**
|
169
|
+
* @private
|
170
|
+
*/
|
171
|
+
jsts.operation.relate.RelateComputer.prototype.insertEdgeEnds = function(ee) {
|
172
|
+
for (var i = ee.iterator(); i.hasNext();) {
|
173
|
+
var e = i.next();
|
174
|
+
this.nodes.add(e);
|
175
|
+
}
|
176
|
+
};
|
177
|
+
|
178
|
+
|
179
|
+
/**
|
180
|
+
* @param {jsts.geom.IntersectionMatrix}
|
181
|
+
* im
|
182
|
+
* @private
|
183
|
+
*/
|
184
|
+
jsts.operation.relate.RelateComputer.prototype.computeProperIntersectionIM = function(
|
185
|
+
intersector, im) {
|
186
|
+
// If a proper intersection is found, we can set a lower bound on the IM.
|
187
|
+
var dimA = this.arg[0].getGeometry().getDimension();
|
188
|
+
var dimB = this.arg[1].getGeometry().getDimension();
|
189
|
+
var hasProper = intersector.hasProperIntersection();
|
190
|
+
var hasProperInterior = intersector.hasProperInteriorIntersection();
|
191
|
+
|
192
|
+
// For Geometry's of dim 0 there can never be proper intersections.
|
193
|
+
|
194
|
+
/**
|
195
|
+
* If edge segments of Areas properly intersect, the areas must properly
|
196
|
+
* overlap.
|
197
|
+
*/
|
198
|
+
if (dimA === 2 && dimB === 2) {
|
199
|
+
if (hasProper)
|
200
|
+
im.setAtLeast('212101212');
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* If an Line segment properly intersects an edge segment of an Area, it
|
204
|
+
* follows that the Interior of the Line intersects the Boundary of the
|
205
|
+
* Area. If the intersection is a proper <i>interior</i> intersection, then
|
206
|
+
* there is an Interior-Interior intersection too. Note that it does not
|
207
|
+
* follow that the Interior of the Line intersects the Exterior of the Area,
|
208
|
+
* since there may be another Area component which contains the rest of the
|
209
|
+
* Line.
|
210
|
+
*/
|
211
|
+
else if (dimA === 2 && dimB === 1) {
|
212
|
+
if (hasProper)
|
213
|
+
im.setAtLeast('FFF0FFFF2');
|
214
|
+
if (hasProperInterior)
|
215
|
+
im.setAtLeast('1FFFFF1FF');
|
216
|
+
} else if (dimA === 1 && dimB === 2) {
|
217
|
+
if (hasProper)
|
218
|
+
im.setAtLeast('F0FFFFFF2');
|
219
|
+
if (hasProperInterior)
|
220
|
+
im.setAtLeast('1F1FFFFFF');
|
221
|
+
}
|
222
|
+
/* If edges of LineStrings properly intersect *in an interior point*, all
|
223
|
+
we can deduce is that
|
224
|
+
the interiors intersect. (We can NOT deduce that the exteriors intersect,
|
225
|
+
since some other segments in the geometries might cover the points in the
|
226
|
+
neighbourhood of the intersection.)
|
227
|
+
It is important that the point be known to be an interior point of
|
228
|
+
both Geometries, since it is possible in a self-intersecting geometry to
|
229
|
+
have a proper intersection on one segment that is also a boundary point of another segment.
|
230
|
+
*/
|
231
|
+
else if (dimA === 1 && dimB === 1) {
|
232
|
+
if (hasProperInterior)
|
233
|
+
im.setAtLeast('0FFFFFFFF');
|
234
|
+
}
|
235
|
+
};
|
236
|
+
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Copy all nodes from an arg geometry into this graph. The node label in the
|
240
|
+
* arg geometry overrides any previously computed label for that argIndex.
|
241
|
+
* (E.g. a node may be an intersection node with a computed label of BOUNDARY,
|
242
|
+
* but in the original arg Geometry it is actually in the interior due to the
|
243
|
+
* Boundary Determination Rule)
|
244
|
+
*
|
245
|
+
* @private
|
246
|
+
*/
|
247
|
+
jsts.operation.relate.RelateComputer.prototype.copyNodesAndLabels = function(
|
248
|
+
argIndex) {
|
249
|
+
for (var i = this.arg[argIndex].getNodeIterator(); i.hasNext();) {
|
250
|
+
var graphNode = i.next();
|
251
|
+
var newNode = this.nodes.addNode(graphNode.getCoordinate());
|
252
|
+
newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
|
253
|
+
}
|
254
|
+
};
|
255
|
+
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Insert nodes for all intersections on the edges of a Geometry. Label the
|
259
|
+
* created nodes the same as the edge label if they do not already have a
|
260
|
+
* label. This allows nodes created by either self-intersections or mutual
|
261
|
+
* intersections to be labelled. Endpoint nodes will already be labelled from
|
262
|
+
* when they were inserted.
|
263
|
+
*
|
264
|
+
* @private
|
265
|
+
*/
|
266
|
+
jsts.operation.relate.RelateComputer.prototype.computeIntersectionNodes = function(
|
267
|
+
argIndex) {
|
268
|
+
for (var i = this.arg[argIndex].getEdgeIterator(); i.hasNext();) {
|
269
|
+
var e = i.next();
|
270
|
+
var eLoc = e.getLabel().getLocation(argIndex);
|
271
|
+
for (var eiIt = e.getEdgeIntersectionList().iterator(); eiIt.hasNext();) {
|
272
|
+
var ei = eiIt.next();
|
273
|
+
var n = this.nodes.addNode(ei.coord);
|
274
|
+
if (eLoc === Location.BOUNDARY)
|
275
|
+
n.setLabelBoundary(argIndex);
|
276
|
+
else {
|
277
|
+
if (n.getLabel().isNull(argIndex))
|
278
|
+
n.setLabel(argIndex, Location.INTERIOR);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
};
|
283
|
+
|
284
|
+
|
285
|
+
/**
|
286
|
+
* For all intersections on the edges of a Geometry, label the corresponding
|
287
|
+
* node IF it doesn't already have a label. This allows nodes created by
|
288
|
+
* either self-intersections or mutual intersections to be labelled. Endpoint
|
289
|
+
* nodes will already be labelled from when they were inserted.
|
290
|
+
*
|
291
|
+
* @private
|
292
|
+
*/
|
293
|
+
jsts.operation.relate.RelateComputer.prototype.labelIntersectionNodes = function(
|
294
|
+
argIndex) {
|
295
|
+
for (var i = this.arg[argIndex].getEdgeIterator(); i.hasNext();) {
|
296
|
+
var e = i.next();
|
297
|
+
var eLoc = e.getLabel().getLocation(argIndex);
|
298
|
+
for (var eiIt = e.getEdgeIntersectionList().iterator(); eiIt.hasNext();) {
|
299
|
+
var ei = eiIt.next();
|
300
|
+
var n = this.nodes.find(ei.coord);
|
301
|
+
if (n.getLabel().isNull(argIndex)) {
|
302
|
+
if (eLoc === Location.BOUNDARY)
|
303
|
+
n.setLabelBoundary(argIndex);
|
304
|
+
else
|
305
|
+
n.setLabel(argIndex, Location.INTERIOR);
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
};
|
310
|
+
|
311
|
+
|
312
|
+
/**
|
313
|
+
* If the Geometries are disjoint, we need to enter their dimension and
|
314
|
+
* boundary dimension in the Ext rows in the IM
|
315
|
+
*
|
316
|
+
* @private
|
317
|
+
*/
|
318
|
+
jsts.operation.relate.RelateComputer.prototype.computeDisjointIM = function(
|
319
|
+
im) {
|
320
|
+
var ga = this.arg[0].getGeometry();
|
321
|
+
if (!ga.isEmpty()) {
|
322
|
+
im.set(Location.INTERIOR, Location.EXTERIOR, ga.getDimension());
|
323
|
+
im.set(Location.BOUNDARY, Location.EXTERIOR, ga.getBoundaryDimension());
|
324
|
+
}
|
325
|
+
var gb = this.arg[1].getGeometry();
|
326
|
+
if (!gb.isEmpty()) {
|
327
|
+
im.set(Location.EXTERIOR, Location.INTERIOR, gb.getDimension());
|
328
|
+
im.set(Location.EXTERIOR, Location.BOUNDARY, gb.getBoundaryDimension());
|
329
|
+
}
|
330
|
+
};
|
331
|
+
|
332
|
+
|
333
|
+
/**
|
334
|
+
* @private
|
335
|
+
*/
|
336
|
+
jsts.operation.relate.RelateComputer.prototype.labelNodeEdges = function() {
|
337
|
+
for (var ni = this.nodes.iterator(); ni.hasNext();) {
|
338
|
+
var node = ni.next();
|
339
|
+
node.getEdges().computeLabelling(this.arg);
|
340
|
+
}
|
341
|
+
};
|
342
|
+
|
343
|
+
|
344
|
+
/**
|
345
|
+
* update the IM with the sum of the IMs for each component
|
346
|
+
*
|
347
|
+
* @private
|
348
|
+
*/
|
349
|
+
jsts.operation.relate.RelateComputer.prototype.updateIM = function(im) {
|
350
|
+
for (var ei = this.isolatedEdges.iterator(); ei.hasNext();) {
|
351
|
+
var e = ei.next();
|
352
|
+
e.updateIM(im);
|
353
|
+
}
|
354
|
+
for (var ni = this.nodes.iterator(); ni.hasNext();) {
|
355
|
+
var node = ni.next();
|
356
|
+
node.updateIM(im);
|
357
|
+
node.updateIMFromEdges(im);
|
358
|
+
}
|
359
|
+
};
|
360
|
+
|
361
|
+
|
362
|
+
/**
|
363
|
+
* Processes isolated edges by computing their labelling and adding them to
|
364
|
+
* the isolated edges list. Isolated edges are guaranteed not to touch the
|
365
|
+
* boundary of the target (since if they did, they would have caused an
|
366
|
+
* intersection to be computed and hence would not be isolated)
|
367
|
+
*
|
368
|
+
* @private
|
369
|
+
*/
|
370
|
+
jsts.operation.relate.RelateComputer.prototype.labelIsolatedEdges = function(
|
371
|
+
thisIndex, targetIndex) {
|
372
|
+
for (var ei = this.arg[thisIndex].getEdgeIterator(); ei.hasNext();) {
|
373
|
+
var e = ei.next();
|
374
|
+
if (e.isIsolated()) {
|
375
|
+
this.labelIsolatedEdge(e, targetIndex, this.arg[targetIndex]
|
376
|
+
.getGeometry());
|
377
|
+
this.isolatedEdges.add(e);
|
378
|
+
}
|
379
|
+
}
|
380
|
+
};
|
381
|
+
|
382
|
+
|
383
|
+
/**
|
384
|
+
* Label an isolated edge of a graph with its relationship to the target
|
385
|
+
* geometry. If the target has dim 2 or 1, the edge can either be in the
|
386
|
+
* interior or the exterior. If the target has dim 0, the edge must be in the
|
387
|
+
* exterior
|
388
|
+
*
|
389
|
+
* @private
|
390
|
+
*/
|
391
|
+
jsts.operation.relate.RelateComputer.prototype.labelIsolatedEdge = function(
|
392
|
+
e, targetIndex, target) {
|
393
|
+
// this won't work for GeometryCollections with both dim 2 and 1 geoms
|
394
|
+
if (target.getDimension() > 0) {
|
395
|
+
// since edge is not in boundary, may not need the full generality of
|
396
|
+
// PointLocator?
|
397
|
+
// Possibly should use ptInArea locator instead? We probably know here
|
398
|
+
// that the edge does not touch the bdy of the target Geometry
|
399
|
+
var loc = this.ptLocator.locate(e.getCoordinate(), target);
|
400
|
+
e.getLabel().setAllLocations(targetIndex, loc);
|
401
|
+
} else {
|
402
|
+
e.getLabel().setAllLocations(targetIndex, Location.EXTERIOR);
|
403
|
+
}
|
404
|
+
};
|
405
|
+
|
406
|
+
|
407
|
+
/**
|
408
|
+
* Isolated nodes are nodes whose labels are incomplete (e.g. the location for
|
409
|
+
* one Geometry is null). This is the case because nodes in one graph which
|
410
|
+
* don't intersect nodes in the other are not completely labelled by the
|
411
|
+
* initial process of adding nodes to the nodeList. To complete the labelling
|
412
|
+
* we need to check for nodes that lie in the interior of edges, and in the
|
413
|
+
* interior of areas.
|
414
|
+
*
|
415
|
+
* @private
|
416
|
+
*/
|
417
|
+
jsts.operation.relate.RelateComputer.prototype.labelIsolatedNodes = function() {
|
418
|
+
for (var ni = this.nodes.iterator(); ni.hasNext();) {
|
419
|
+
var n = ni.next();
|
420
|
+
var label = n.getLabel();
|
421
|
+
// isolated nodes should always have at least one geometry in their label
|
422
|
+
Assert
|
423
|
+
.isTrue(label.getGeometryCount() > 0, 'node with empty label found');
|
424
|
+
if (n.isIsolated()) {
|
425
|
+
if (label.isNull(0))
|
426
|
+
this.labelIsolatedNode(n, 0);
|
427
|
+
else
|
428
|
+
this.labelIsolatedNode(n, 1);
|
429
|
+
}
|
430
|
+
}
|
431
|
+
};
|
432
|
+
|
433
|
+
|
434
|
+
/**
|
435
|
+
* Label an isolated node with its relationship to the target geometry.
|
436
|
+
*/
|
437
|
+
jsts.operation.relate.RelateComputer.prototype.labelIsolatedNode = function(
|
438
|
+
n, targetIndex) {
|
439
|
+
var loc = this.ptLocator.locate(n.getCoordinate(), this.arg[targetIndex]
|
440
|
+
.getGeometry());
|
441
|
+
n.getLabel().setAllLocations(targetIndex, loc);
|
442
|
+
};
|
443
|
+
|
444
|
+
})();
|