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,46 @@
|
|
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/Node.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
/**
|
14
|
+
* A RelateNode is a Node that maintains a list of EdgeStubs for the edges that
|
15
|
+
* are incident on it.
|
16
|
+
*
|
17
|
+
* Represents a node in the topological graph used to compute spatial
|
18
|
+
* relationships.
|
19
|
+
*
|
20
|
+
* @augments {Node}
|
21
|
+
* @constructor
|
22
|
+
*/
|
23
|
+
jsts.operation.relate.RelateNode = function(coord, edges) {
|
24
|
+
jsts.geomgraph.Node.apply(this, arguments);
|
25
|
+
};
|
26
|
+
|
27
|
+
jsts.operation.relate.RelateNode.prototype = new jsts.geomgraph.Node();
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Update the IM with the contribution for this component. A component only
|
32
|
+
* contributes if it has a labelling for both parent geometries
|
33
|
+
*
|
34
|
+
* @protected
|
35
|
+
*/
|
36
|
+
jsts.operation.relate.RelateNode.prototype.computeIM = function(im) {
|
37
|
+
im.setAtLeastIfValid(this.label.getLocation(0), this.label.getLocation(1), 0);
|
38
|
+
};
|
39
|
+
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Update the IM with the contribution for the EdgeEnds incident on this node.
|
43
|
+
*/
|
44
|
+
jsts.operation.relate.RelateNode.prototype.updateIMFromEdges = function(im) {
|
45
|
+
this.edges.updateIM(im);
|
46
|
+
};
|
@@ -0,0 +1,25 @@
|
|
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
|
+
* Used by the {@link NodeMap} in a {@link RelateNodeGraph} to create
|
11
|
+
* {@link RelateNode}s.
|
12
|
+
*
|
13
|
+
* @augments {jsts.geomgraph.NodeFactory}
|
14
|
+
* @constructor
|
15
|
+
*/
|
16
|
+
jsts.operation.relate.RelateNodeFactory = function() {
|
17
|
+
|
18
|
+
};
|
19
|
+
|
20
|
+
jsts.operation.relate.RelateNodeFactory.prototype = new jsts.geomgraph.NodeFactory();
|
21
|
+
|
22
|
+
jsts.operation.relate.RelateNodeFactory.prototype.createNode = function(coord) {
|
23
|
+
return new jsts.operation.relate.RelateNode(coord,
|
24
|
+
new jsts.operation.relate.EdgeEndBundleStar());
|
25
|
+
};
|
@@ -0,0 +1,118 @@
|
|
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
|
+
|
16
|
+
/**
|
17
|
+
* Implements the simple graph of Nodes and EdgeEnd which is all that is
|
18
|
+
* required to determine topological relationships between Geometries. Also
|
19
|
+
* supports building a topological graph of a single Geometry, to allow
|
20
|
+
* verification of valid topology.
|
21
|
+
* <p>
|
22
|
+
* It is <b>not</b> necessary to create a fully linked PlanarGraph to
|
23
|
+
* determine relationships, since it is sufficient to know how the Geometries
|
24
|
+
* interact locally around the nodes. In fact, this is not even feasible,
|
25
|
+
* since it is not possible to compute exact intersection points, and hence
|
26
|
+
* the topology around those nodes cannot be computed robustly. The only Nodes
|
27
|
+
* that are created are for improper intersections; that is, nodes which occur
|
28
|
+
* at existing vertices of the Geometries. Proper intersections (e.g. ones
|
29
|
+
* which occur between the interior of line segments) have their topology
|
30
|
+
* determined implicitly, without creating a Node object to represent them.
|
31
|
+
*
|
32
|
+
* @constructor
|
33
|
+
*/
|
34
|
+
jsts.operation.relate.RelateNodeGraph = function() {
|
35
|
+
this.nodes = new jsts.geomgraph.NodeMap(
|
36
|
+
new jsts.operation.relate.RelateNodeFactory());
|
37
|
+
};
|
38
|
+
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @private
|
42
|
+
*/
|
43
|
+
jsts.operation.relate.RelateNodeGraph.prototype.nodes = null;
|
44
|
+
|
45
|
+
|
46
|
+
jsts.operation.relate.RelateNodeGraph.prototype.build = function(geomGraph) {
|
47
|
+
// compute nodes for intersections between previously noded edges
|
48
|
+
this.computeIntersectionNodes(geomGraph, 0);
|
49
|
+
/**
|
50
|
+
* Copy the labelling for the nodes in the parent Geometry. These override
|
51
|
+
* any labels determined by intersections.
|
52
|
+
*/
|
53
|
+
this.copyNodesAndLabels(geomGraph, 0);
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Build EdgeEnds for all intersections.
|
57
|
+
*/
|
58
|
+
var eeBuilder = new jsts.operation.relate.EdgeEndBuilder();
|
59
|
+
var eeList = eeBuilder.computeEdgeEnds(geomGraph.getEdgeIterator());
|
60
|
+
this.insertEdgeEnds(eeList);
|
61
|
+
};
|
62
|
+
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Insert nodes for all intersections on the edges of a Geometry. Label the
|
66
|
+
* created nodes the same as the edge label if they do not already have a
|
67
|
+
* label. This allows nodes created by either self-intersections or mutual
|
68
|
+
* intersections to be labelled. Endpoint nodes will already be labelled from
|
69
|
+
* when they were inserted.
|
70
|
+
* <p>
|
71
|
+
* Precondition: edge intersections have been computed.
|
72
|
+
*/
|
73
|
+
jsts.operation.relate.RelateNodeGraph.prototype.computeIntersectionNodes = function(geomGraph,
|
74
|
+
argIndex) {
|
75
|
+
for (var edgeIt = geomGraph.getEdgeIterator(); edgeIt.hasNext();) {
|
76
|
+
var e = edgeIt.next();
|
77
|
+
var eLoc = e.getLabel().getLocation(argIndex);
|
78
|
+
for (var eiIt = e.getEdgeIntersectionList().iterator(); eiIt.hasNext();) {
|
79
|
+
var ei = eiIt.next();
|
80
|
+
var n = this.nodes.addNode(ei.coord);
|
81
|
+
if (eLoc === Location.BOUNDARY)
|
82
|
+
n.setLabelBoundary(argIndex);
|
83
|
+
else {
|
84
|
+
if (n.getLabel().isNull(argIndex))
|
85
|
+
n.setLabel(argIndex, Location.INTERIOR);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Copy all nodes from an arg geometry into this graph. The node label in the
|
94
|
+
* arg geometry overrides any previously computed label for that argIndex.
|
95
|
+
* (E.g. a node may be an intersection node with a computed label of BOUNDARY,
|
96
|
+
* but in the original arg Geometry it is actually in the interior due to the
|
97
|
+
* Boundary Determination Rule)
|
98
|
+
*/
|
99
|
+
jsts.operation.relate.RelateNodeGraph.prototype.copyNodesAndLabels = function(geomGraph, argIndex) {
|
100
|
+
for (var nodeIt = geomGraph.getNodeIterator(); nodeIt.hasNext();) {
|
101
|
+
var graphNode = nodeIt.next();
|
102
|
+
var newNode = this.nodes.addNode(graphNode.getCoordinate());
|
103
|
+
newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
|
104
|
+
}
|
105
|
+
};
|
106
|
+
|
107
|
+
jsts.operation.relate.RelateNodeGraph.prototype.insertEdgeEnds = function(ee) {
|
108
|
+
for (var i = ee.iterator(); i.hasNext();) {
|
109
|
+
var e = i.next();
|
110
|
+
this.nodes.add(e);
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
jsts.operation.relate.RelateNodeGraph.prototype.getNodeIterator = function() {
|
115
|
+
return this.nodes.iterator();
|
116
|
+
};
|
117
|
+
|
118
|
+
})();
|
@@ -0,0 +1,75 @@
|
|
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
|
+
* Implements the SFS <tt>relate()</tt> operation on two {@link Geometry}s.
|
11
|
+
* This class supports specifying a custom {@link BoundaryNodeRule} to be used
|
12
|
+
* during the relate computation.
|
13
|
+
* <p>
|
14
|
+
* <b>Note:</b> custom Boundary Node Rules do not (currently) affect the
|
15
|
+
* results of other Geometry methods (such as {@link Geometry#getBoundary}. The
|
16
|
+
* results of these methods may not be consistent with the relationship computed
|
17
|
+
* by a custom Boundary Node Rule.
|
18
|
+
*
|
19
|
+
* Creates a new Relate operation with a specified Boundary Node Rule.
|
20
|
+
*
|
21
|
+
* @param g0
|
22
|
+
* a Geometry to relate.
|
23
|
+
* @param g1
|
24
|
+
* another Geometry to relate.
|
25
|
+
* @param boundaryNodeRule
|
26
|
+
* the Boundary Node Rule to use.
|
27
|
+
*
|
28
|
+
* @extends {jsts.operation.GeometryGraphOperation}
|
29
|
+
* @constructor
|
30
|
+
*/
|
31
|
+
jsts.operation.relate.RelateOp = function() {
|
32
|
+
jsts.operation.GeometryGraphOperation.apply(this, arguments);
|
33
|
+
this._relate = new jsts.operation.relate.RelateComputer(this.arg);
|
34
|
+
};
|
35
|
+
|
36
|
+
jsts.operation.relate.RelateOp.prototype = new jsts.operation.GeometryGraphOperation();
|
37
|
+
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Computes the {@link IntersectionMatrix} for the spatial relationship between
|
41
|
+
* two {@link Geometry}s using a specified Boundary Node Rule.
|
42
|
+
*
|
43
|
+
* @param a
|
44
|
+
* a Geometry to test.
|
45
|
+
* @param b
|
46
|
+
* a Geometry to test.
|
47
|
+
* @param boundaryNodeRule
|
48
|
+
* the Boundary Node Rule to use.
|
49
|
+
* @return the IntersectonMatrix for the spatial relationship between the input
|
50
|
+
* geometries.
|
51
|
+
*/
|
52
|
+
jsts.operation.relate.RelateOp.relate = function(a, b, boundaryNodeRule) {
|
53
|
+
var relOp = new jsts.operation.relate.RelateOp(a, b, boundaryNodeRule);
|
54
|
+
var im = relOp.getIntersectionMatrix();
|
55
|
+
return im;
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
/**
|
60
|
+
* @type {RelateComputer}
|
61
|
+
* @private
|
62
|
+
*/
|
63
|
+
jsts.operation.relate.RelateOp.prototype._relate = null;
|
64
|
+
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Gets the IntersectionMatrix for the spatial relationship between the input
|
68
|
+
* geometries.
|
69
|
+
*
|
70
|
+
* @return the IntersectonMatrix for the spatial relationship between the input
|
71
|
+
* geometries.
|
72
|
+
*/
|
73
|
+
jsts.operation.relate.RelateOp.prototype.getIntersectionMatrix = function() {
|
74
|
+
return this._relate.computeIM();
|
75
|
+
};
|
@@ -0,0 +1,319 @@
|
|
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
|
+
* Provides an efficient method of unioning a collection of
|
8
|
+
* {@link Polygonal} geometrys.
|
9
|
+
* This algorithm is faster and likely more robust than
|
10
|
+
* the simple iterated approach of
|
11
|
+
* repeatedly unioning each polygon to a result geometry.
|
12
|
+
* <p>
|
13
|
+
* The <tt>buffer(0)</tt> trick is sometimes faster, but can be less robust and
|
14
|
+
* can sometimes take an exceptionally long time to complete.
|
15
|
+
* This is particularly the case where there is a high degree of overlap
|
16
|
+
* between the polygons. In this case, <tt>buffer(0)</tt> is forced to compute
|
17
|
+
* with <i>all</i> line segments from the outset,
|
18
|
+
* whereas cascading can eliminate many segments
|
19
|
+
* at each stage of processing.
|
20
|
+
* The best case for buffer(0) is the trivial case
|
21
|
+
* where there is <i>no</i> overlap between the input geometries.
|
22
|
+
* However, this case is likely rare in practice.
|
23
|
+
*
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Creates a new instance to union
|
30
|
+
* the given collection of {@link Geometry}s.
|
31
|
+
*
|
32
|
+
* @param {Array.<jsts.geom.Geometry>} geoms a collection of {@link Polygonal} {@link Geometry}s.
|
33
|
+
* @constructor
|
34
|
+
*/
|
35
|
+
jsts.operation.union.CascadedPolygonUnion = function(polys) {
|
36
|
+
this.inputPolys = polys;
|
37
|
+
};
|
38
|
+
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Computes the union of
|
42
|
+
* a collection of {@link Polygonal} {@link Geometry}s.
|
43
|
+
*
|
44
|
+
* @param {Array.<jsts.geom.Geometry>} polys a collection of {@link Polygonal} {@link Geometry}s.
|
45
|
+
* @return {jsts.geom.Geometry}
|
46
|
+
* @public
|
47
|
+
*/
|
48
|
+
jsts.operation.union.CascadedPolygonUnion.union = function(polys) {
|
49
|
+
var op = new jsts.operation.union.CascadedPolygonUnion(polys);
|
50
|
+
return op.union();
|
51
|
+
};
|
52
|
+
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @type {Array.<jsts.geom.Geometry>}
|
56
|
+
*/
|
57
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.inputPolys;
|
58
|
+
|
59
|
+
|
60
|
+
/**
|
61
|
+
* @type {jsts.geom.GeometryFactory}
|
62
|
+
*/
|
63
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.geomFactory = null;
|
64
|
+
|
65
|
+
|
66
|
+
/**
|
67
|
+
* The effectiveness of the index is somewhat sensitive
|
68
|
+
* to the node capacity.
|
69
|
+
* Testing indicates that a smaller capacity is better.
|
70
|
+
* For an STRtree, 4 is probably a good number (since
|
71
|
+
* this produces 2x2 "squares").
|
72
|
+
*
|
73
|
+
* @type {number}
|
74
|
+
* @const
|
75
|
+
*/
|
76
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.STRTREE_NODE_CAPACITY = 4;
|
77
|
+
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Computes the union of the input geometries.
|
81
|
+
*
|
82
|
+
* @return {?jsts.geom.Geometry} the union of the input geometries, null if no input geometries were provided.
|
83
|
+
* @public
|
84
|
+
*/
|
85
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.union = function() {
|
86
|
+
if (this.inputPolys.length === 0) {
|
87
|
+
return null;
|
88
|
+
}
|
89
|
+
this.geomFactory = this.inputPolys[0].getFactory();
|
90
|
+
|
91
|
+
/**
|
92
|
+
* A spatial index to organize the collection
|
93
|
+
* into groups of close geometries.
|
94
|
+
* This makes unioning more efficient, since vertices are more likely
|
95
|
+
* to be eliminated on each round.
|
96
|
+
*/
|
97
|
+
|
98
|
+
var index = new jsts.index.strtree.STRtree(this.STRTREE_NODE_CAPACITY);
|
99
|
+
for (var i = 0, l = this.inputPolys.length; i < l; i++) {
|
100
|
+
var item = this.inputPolys[i];
|
101
|
+
index.insert(item.getEnvelopeInternal(), item);
|
102
|
+
}
|
103
|
+
var itemTree = index.itemsTree();
|
104
|
+
var unionAll = this.unionTree(itemTree);
|
105
|
+
return unionAll;
|
106
|
+
};
|
107
|
+
|
108
|
+
|
109
|
+
/**
|
110
|
+
*
|
111
|
+
* @param {Array.<jsts.geom.Geometry>} geomTree
|
112
|
+
* @return {jsts.geom.Geometry}
|
113
|
+
* @private
|
114
|
+
*/
|
115
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.unionTree = function(geomTree) {
|
116
|
+
/**
|
117
|
+
* Recursively unions all subtrees in the list into single geometries.
|
118
|
+
* The result is a list of Geometrys only
|
119
|
+
*/
|
120
|
+
var geoms = this.reduceToGeometries(geomTree);
|
121
|
+
var union = this.binaryUnion(geoms);
|
122
|
+
return union;
|
123
|
+
};
|
124
|
+
|
125
|
+
|
126
|
+
//TODO: Implement experimental methods?
|
127
|
+
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Unions a list of geometries
|
131
|
+
* by treating the list as a flattened binary tree,
|
132
|
+
* and performing a cascaded union on the tree.
|
133
|
+
*
|
134
|
+
* Unions a section of a list using a recursive binary union on each half
|
135
|
+
* of the section.
|
136
|
+
*
|
137
|
+
* @param {Array.<jsts.geom.Geometry>} geoms
|
138
|
+
* @param {number=} [start].
|
139
|
+
* @param {number=} [end].
|
140
|
+
* @return {jsts.geom.Geometry} the union of the list section.
|
141
|
+
* @private
|
142
|
+
*/
|
143
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.binaryUnion = function(geoms, start, end) {
|
144
|
+
start = start || 0;
|
145
|
+
end = end || geoms.length;
|
146
|
+
|
147
|
+
if (end - start <= 1) {
|
148
|
+
var g0 = this.getGeometry(geoms, start);
|
149
|
+
return this.unionSafe(g0, null);
|
150
|
+
}
|
151
|
+
else if (end - start === 2) {
|
152
|
+
return this.unionSafe(this.getGeometry(geoms, start), this.getGeometry(geoms, start + 1));
|
153
|
+
}
|
154
|
+
else {
|
155
|
+
// recurse on both halves of the list
|
156
|
+
var mid = parseInt((end + start) / 2);
|
157
|
+
var g0 = this.binaryUnion(geoms, start, mid);
|
158
|
+
var g1 = this.binaryUnion(geoms, mid, end);
|
159
|
+
return this.unionSafe(g0, g1);
|
160
|
+
}
|
161
|
+
};
|
162
|
+
|
163
|
+
|
164
|
+
/**
|
165
|
+
*
|
166
|
+
* @param {Array.<jsts.geom.Geometry>} list
|
167
|
+
* @param {number} index
|
168
|
+
* @return {jsts.geom.Geometry}
|
169
|
+
* @private
|
170
|
+
*/
|
171
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.getGeometry = function(list, index) {
|
172
|
+
if (index >= list.length) {
|
173
|
+
return null;
|
174
|
+
}
|
175
|
+
return list[index];
|
176
|
+
};
|
177
|
+
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Reduces a tree of geometries to a list of geometries
|
181
|
+
* by recursively unioning the subtrees in the list.
|
182
|
+
*
|
183
|
+
* @param {Array} geomTree a tree-structured list of geometries.
|
184
|
+
* @return {Array.<jsts.geom.Geometry>} a list of Geometrys.
|
185
|
+
* @private
|
186
|
+
*/
|
187
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.reduceToGeometries = function(geomTree) {
|
188
|
+
var geoms = [];
|
189
|
+
for (var i = 0, l = geomTree.length; i < l; i++) {
|
190
|
+
var o = geomTree[i],
|
191
|
+
geom = null;
|
192
|
+
if (o instanceof Array) {
|
193
|
+
geom = this.unionTree(o);
|
194
|
+
}
|
195
|
+
else if (o instanceof jsts.geom.Geometry) {
|
196
|
+
geom = o;
|
197
|
+
}
|
198
|
+
geoms.push(geom);
|
199
|
+
}
|
200
|
+
return geoms;
|
201
|
+
};
|
202
|
+
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Computes the union of two geometries,
|
206
|
+
* either of both of which may be null.
|
207
|
+
*
|
208
|
+
* @param {jsts.geom.Geometry} g0 a Geometry.
|
209
|
+
* @param {jsts.geom.Geometry} g1 a Geometry.
|
210
|
+
* @return {?jsts.geom.Geometry} the union of the input(s),
|
211
|
+
* null if both inputs are null.
|
212
|
+
* @private
|
213
|
+
*/
|
214
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.unionSafe = function(g0, g1) {
|
215
|
+
if (g0 === null && g1 === null) {
|
216
|
+
return null;
|
217
|
+
}
|
218
|
+
if (g0 === null) {
|
219
|
+
return g1.clone();
|
220
|
+
}
|
221
|
+
if (g1 === null) {
|
222
|
+
return g0.clone();
|
223
|
+
}
|
224
|
+
|
225
|
+
//what if both are null? Maybe return empty GC?
|
226
|
+
|
227
|
+
return this.unionOptimized(g0, g1);
|
228
|
+
};
|
229
|
+
|
230
|
+
|
231
|
+
/**
|
232
|
+
* @param {jsts.geom.Geometry} g0 a Geometry.
|
233
|
+
* @param {jsts.geom.Geometry} g1 a Geometry.
|
234
|
+
* @return {jsts.geom.Geometry} the union of the input(s).
|
235
|
+
* @private
|
236
|
+
*/
|
237
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.unionOptimized = function(g0, g1) {
|
238
|
+
var g0Env = g0.getEnvelopeInternal(),
|
239
|
+
g1Env = g1.getEnvelopeInternal();
|
240
|
+
|
241
|
+
if (!g0Env.intersects(g1Env)) {
|
242
|
+
var combo = jsts.geom.util.GeometryCombiner.combine(g0, g1);
|
243
|
+
return combo;
|
244
|
+
}
|
245
|
+
|
246
|
+
if (g0.getNumGeometries <= 1 && g1.getNumGeometries <= 1) {
|
247
|
+
return this.unionActual(g0, g1);
|
248
|
+
}
|
249
|
+
|
250
|
+
var commonEnv = g0Env.intersection(g1Env);
|
251
|
+
return this.unionUsingEnvelopeIntersection(g0, g1, commonEnv);
|
252
|
+
};
|
253
|
+
|
254
|
+
|
255
|
+
/**
|
256
|
+
* Unions two polygonal geometries.
|
257
|
+
* The case of MultiPolygons is optimized to union only
|
258
|
+
* the polygons which lie in the intersection of the two geometry's envelopes.
|
259
|
+
* Polygons outside this region can simply be combined with the union result,
|
260
|
+
* which is potentially much faster.
|
261
|
+
* This case is likely to occur often during cascaded union, and may also
|
262
|
+
* occur in real world data (such as unioning data for parcels on different street blocks).
|
263
|
+
*
|
264
|
+
* @param {jsts.geom.Geometry} g0 a polygonal geometry.
|
265
|
+
* @param {jsts.geom.Geometry} g1 a polygonal geometry.
|
266
|
+
* @param {jsts.geom.Envelope} common the intersection of the envelopes of the inputs.
|
267
|
+
* @return {jsts.geom.Geometry} the union of the inputs.
|
268
|
+
* @private
|
269
|
+
*/
|
270
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.unionUsingEnvelopeIntersection = function(g0, g1, common) {
|
271
|
+
var disjointPolys = new javascript.util.ArrayList();
|
272
|
+
var g0Int = this.extractByEnvelope(common, g0, disjointPolys);
|
273
|
+
var g1Int = this.extractByEnvelope(common, g1, disjointPolys);
|
274
|
+
|
275
|
+
var union = this.unionActual(g0Int, g1Int);
|
276
|
+
|
277
|
+
disjointPolys.add(union);
|
278
|
+
var overallUnion = jsts.geom.util.GeometryCombiner.combine(disjointPolys);
|
279
|
+
|
280
|
+
return overallUnion;
|
281
|
+
};
|
282
|
+
|
283
|
+
|
284
|
+
/**
|
285
|
+
*
|
286
|
+
* @param {jsts.geom.Envelope} env
|
287
|
+
* @param {jsts.geom.Geometry} geom
|
288
|
+
* @param {Array.<jsts.geom.Geometry>} disjointGeoms
|
289
|
+
* @return {jsts.geom.Geometry}
|
290
|
+
* @private
|
291
|
+
*/
|
292
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.extractByEnvelope = function(env, geom, disjointGeoms) {
|
293
|
+
var intersectingGeoms = new javascript.util.ArrayList();
|
294
|
+
|
295
|
+
for (var i = 0; i < geom.getNumGeometries(); i++) {
|
296
|
+
var elem = geom.getGeometryN(i);
|
297
|
+
if (elem.getEnvelopeInternal().intersects(env)) {
|
298
|
+
intersectingGeoms.add(elem);
|
299
|
+
}
|
300
|
+
else {
|
301
|
+
disjointGeoms.add(elem);
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
305
|
+
return this.geomFactory.buildGeometry(intersectingGeoms);
|
306
|
+
};
|
307
|
+
|
308
|
+
|
309
|
+
/**
|
310
|
+
* Encapsulates the actual unioning of two polygonal geometries.
|
311
|
+
*
|
312
|
+
* @param {jsts.geom.Geometry} g0
|
313
|
+
* @param {jsts.geom.Geometry} g1
|
314
|
+
* @return {jsts.geom.Geometry}
|
315
|
+
* @private
|
316
|
+
*/
|
317
|
+
jsts.operation.union.CascadedPolygonUnion.prototype.unionActual = function(g0, g1) {
|
318
|
+
return g0.union(g1);
|
319
|
+
};
|