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,246 @@
|
|
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/planargraph/PlanarGraph.java
|
10
|
+
* Revision: 107
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/planargraph/NodeMap.js
|
15
|
+
*/
|
16
|
+
|
17
|
+
(function() {
|
18
|
+
|
19
|
+
var ArrayList = javascript.util.ArrayList;
|
20
|
+
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Represents a directed graph which is embeddable in a planar surface.
|
24
|
+
* <p>
|
25
|
+
* This class and the other classes in this package serve as a framework for
|
26
|
+
* building planar graphs for specific algorithms. This class must be
|
27
|
+
* subclassed to expose appropriate methods to construct the graph. This
|
28
|
+
* allows controlling the types of graph components ({@link DirectedEdge}s,
|
29
|
+
* {@link Edge}s and {@link Node}s) which can be added to the graph. An
|
30
|
+
* application which uses the graph framework will almost always provide
|
31
|
+
* subclasses for one or more graph components, which hold
|
32
|
+
* application-specific data and graph algorithms.
|
33
|
+
*
|
34
|
+
* Constructs a empty graph.
|
35
|
+
*/
|
36
|
+
var PlanarGraph = function() {
|
37
|
+
this.edges = new javascript.util.HashSet();
|
38
|
+
this.dirEdges = new javascript.util.HashSet();
|
39
|
+
this.nodeMap = new jsts.planargraph.NodeMap();
|
40
|
+
};
|
41
|
+
|
42
|
+
|
43
|
+
PlanarGraph.prototype.edges = null;
|
44
|
+
PlanarGraph.prototype.dirEdges = null;
|
45
|
+
PlanarGraph.prototype.nodeMap = null;
|
46
|
+
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Returns the {@link Node} at the given location, or null if no {@link Node}
|
50
|
+
* was there.
|
51
|
+
*
|
52
|
+
* @param pt
|
53
|
+
* the location to query.
|
54
|
+
* @return the node found.
|
55
|
+
* @return <code>null</code> if this graph contains no node at the location.
|
56
|
+
*/
|
57
|
+
PlanarGraph.prototype.findNode = function(pt) {
|
58
|
+
return this.nodeMap.find(pt);
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Adds a node to the map, replacing any that is already at that location.
|
63
|
+
* Only subclasses can add Nodes, to ensure Nodes are of the right type.
|
64
|
+
*
|
65
|
+
* @param node
|
66
|
+
* the node to add.
|
67
|
+
*/
|
68
|
+
PlanarGraph.prototype.add = function(node) {
|
69
|
+
if (node instanceof jsts.planargraph.Edge) {
|
70
|
+
return this.add2(node);
|
71
|
+
} else if (node instanceof jsts.planargraph.DirectedEdge) {
|
72
|
+
return this.add3(node);
|
73
|
+
}
|
74
|
+
|
75
|
+
this.nodeMap.add(node);
|
76
|
+
};
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Adds the Edge and its DirectedEdges with this PlanarGraph. Assumes that the
|
80
|
+
* Edge has already been created with its associated DirectEdges. Only
|
81
|
+
* subclasses can add Edges, to ensure the edges added are of the right class.
|
82
|
+
*/
|
83
|
+
PlanarGraph.prototype.add2 = function(edge) {
|
84
|
+
this.edges.add(edge);
|
85
|
+
this.add(edge.getDirEdge(0));
|
86
|
+
this.add(edge.getDirEdge(1));
|
87
|
+
};
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Adds the Edge to this PlanarGraph; only subclasses can add DirectedEdges,
|
91
|
+
* to ensure the edges added are of the right class.
|
92
|
+
*/
|
93
|
+
PlanarGraph.prototype.add3 = function(dirEdge) {
|
94
|
+
this.dirEdges.add(dirEdge);
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Returns an Iterator over the Nodes in this PlanarGraph.
|
99
|
+
*/
|
100
|
+
PlanarGraph.prototype.nodeIterator = function() {
|
101
|
+
return this.nodeMap.iterator();
|
102
|
+
};
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Returns the Nodes in this PlanarGraph.
|
106
|
+
*/
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Tests whether this graph contains the given {@link Edge}
|
110
|
+
*
|
111
|
+
* @param e
|
112
|
+
* the edge to query.
|
113
|
+
* @return <code>true</code> if the graph contains the edge.
|
114
|
+
*/
|
115
|
+
PlanarGraph.prototype.contains = function(e) {
|
116
|
+
if (e instanceof jsts.planargraph.DirectedEdge) {
|
117
|
+
return this.contains2(e);
|
118
|
+
}
|
119
|
+
|
120
|
+
return this.edges.contains(e);
|
121
|
+
};
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Tests whether this graph contains the given {@link DirectedEdge}
|
125
|
+
*
|
126
|
+
* @param de
|
127
|
+
* the directed edge to query.
|
128
|
+
* @return <code>true</code> if the graph contains the directed edge.
|
129
|
+
*/
|
130
|
+
PlanarGraph.prototype.contains2 = function(de) {
|
131
|
+
return this.dirEdges.contains(de);
|
132
|
+
};
|
133
|
+
|
134
|
+
PlanarGraph.prototype.getNodes = function() {
|
135
|
+
return this.nodeMap.values();
|
136
|
+
};
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Returns an Iterator over the DirectedEdges in this PlanarGraph, in the
|
140
|
+
* order in which they were added.
|
141
|
+
*
|
142
|
+
* @see #add(Edge)
|
143
|
+
* @see #add(DirectedEdge)
|
144
|
+
*/
|
145
|
+
PlanarGraph.prototype.dirEdgeIterator = function() {
|
146
|
+
return this.dirEdges.iterator();
|
147
|
+
};
|
148
|
+
/**
|
149
|
+
* Returns an Iterator over the Edges in this PlanarGraph, in the order in
|
150
|
+
* which they were added.
|
151
|
+
*
|
152
|
+
* @see #add(Edge)
|
153
|
+
*/
|
154
|
+
PlanarGraph.prototype.edgeIterator = function() {
|
155
|
+
return this.edges.iterator();
|
156
|
+
};
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Returns the Edges that have been added to this PlanarGraph
|
160
|
+
*
|
161
|
+
* @see #add(Edge)
|
162
|
+
*/
|
163
|
+
PlanarGraph.prototype.getEdges = function() {
|
164
|
+
return this.edges;
|
165
|
+
};
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Removes an {@link Edge} and its associated {@link DirectedEdge}s from
|
169
|
+
* their from-Nodes and from the graph. Note: This method does not remove the
|
170
|
+
* {@link Node}s associated with the {@link Edge}, even if the removal of
|
171
|
+
* the {@link Edge} reduces the degree of a {@link Node} to zero.
|
172
|
+
*/
|
173
|
+
PlanarGraph.prototype.remove = function(edge) {
|
174
|
+
if (edge instanceof jsts.planargraph.DirectedEdge) {
|
175
|
+
return this.remove2(edge);
|
176
|
+
}
|
177
|
+
|
178
|
+
this.remove(edge.getDirEdge(0));
|
179
|
+
this.remove(edge.getDirEdge(1));
|
180
|
+
this.edges.remove(edge);
|
181
|
+
this.edge.remove();
|
182
|
+
};
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Removes a {@link DirectedEdge} from its from-{@link Node} and from this
|
186
|
+
* graph. This method does not remove the {@link Node}s associated with the
|
187
|
+
* DirectedEdge, even if the removal of the DirectedEdge reduces the degree of
|
188
|
+
* a Node to zero.
|
189
|
+
*/
|
190
|
+
PlanarGraph.prototype.remove2 = function(de) {
|
191
|
+
if (de instanceof jsts.planargraph.Node) {
|
192
|
+
return this.remove3(de);
|
193
|
+
}
|
194
|
+
|
195
|
+
var sym = de.getSym();
|
196
|
+
if (sym != null)
|
197
|
+
sym.setSym(null);
|
198
|
+
|
199
|
+
de.getFromNode().remove(de);
|
200
|
+
de.remove();
|
201
|
+
this.dirEdges.remove(de);
|
202
|
+
};
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Removes a node from the graph, along with any associated DirectedEdges and
|
206
|
+
* Edges.
|
207
|
+
*/
|
208
|
+
PlanarGraph.prototype.remove3 = function(node) {
|
209
|
+
// unhook all directed edges
|
210
|
+
var outEdges = node.getOutEdges().getEdges();
|
211
|
+
for (var i = outEdges.iterator(); i.hasNext();) {
|
212
|
+
var de = i.next();
|
213
|
+
var sym = de.getSym();
|
214
|
+
// remove the diredge that points to this node
|
215
|
+
if (sym != null)
|
216
|
+
this.remove(sym);
|
217
|
+
// remove this diredge from the graph collection
|
218
|
+
this.dirEdges.remove(de);
|
219
|
+
|
220
|
+
var edge = de.getEdge();
|
221
|
+
if (edge != null) {
|
222
|
+
this.edges.remove(edge);
|
223
|
+
}
|
224
|
+
|
225
|
+
}
|
226
|
+
// remove the node from the graph
|
227
|
+
this.nodeMap.remove(node.getCoordinate());
|
228
|
+
node.remove();
|
229
|
+
};
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Returns all Nodes with the given number of Edges around it.
|
233
|
+
*/
|
234
|
+
PlanarGraph.prototype.findNodesOfDegree = function(degree) {
|
235
|
+
var nodesFound = new ArrayList();
|
236
|
+
for (var i = this.nodeIterator(); i.hasNext();) {
|
237
|
+
var node = i.next();
|
238
|
+
if (node.getDegree() == degree)
|
239
|
+
nodesFound.add(node);
|
240
|
+
}
|
241
|
+
return nodesFound;
|
242
|
+
};
|
243
|
+
|
244
|
+
jsts.planargraph.PlanarGraph = PlanarGraph;
|
245
|
+
|
246
|
+
})();
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
/**
|
9
|
+
* An spatial index on a set of {@link LineSegment}s. Supports adding and
|
10
|
+
* removing items.
|
11
|
+
*
|
12
|
+
* @author Martin Davis
|
13
|
+
*/
|
14
|
+
jsts.simplify.LineSegmentIndex = function() {
|
15
|
+
this.index = new jsts.index.quadtree.Quadtree();
|
16
|
+
};
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @private
|
20
|
+
*/
|
21
|
+
jsts.simplify.LineSegmentIndex.prototype.index = null;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @param {TaggedLineString}
|
25
|
+
* line
|
26
|
+
*/
|
27
|
+
jsts.simplify.LineSegmentIndex.prototype.add = function(line) {
|
28
|
+
if (line instanceof jsts.geom.LineSegment) {
|
29
|
+
this.add2(line);
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
33
|
+
var segs = line.getSegments();
|
34
|
+
for (var i = 0; i < segs.length; i++) {
|
35
|
+
var seg = segs[i];
|
36
|
+
this.add2(seg);
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @param {LineSegment}
|
42
|
+
* seg
|
43
|
+
*/
|
44
|
+
jsts.simplify.LineSegmentIndex.prototype.add2 = function(seg) {
|
45
|
+
this.index.insert(new jsts.geom.Envelope(seg.p0, seg.p1), seg);
|
46
|
+
};
|
47
|
+
/**
|
48
|
+
* @param {LineSegment}
|
49
|
+
* seg
|
50
|
+
*/
|
51
|
+
jsts.simplify.LineSegmentIndex.prototype.remove = function(seg) {
|
52
|
+
this.index.remove(new jsts.geom.Envelope(seg.p0, seg.p1), seg);
|
53
|
+
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @param {LineSegment}
|
57
|
+
* querySeg
|
58
|
+
* @return {Array}
|
59
|
+
*/
|
60
|
+
jsts.simplify.LineSegmentIndex.prototype.query = function(querySeg) {
|
61
|
+
var env = new jsts.geom.Envelope(querySeg.p0, querySeg.p1);
|
62
|
+
|
63
|
+
var visitor = new jsts.simplify.LineSegmentIndex.LineSegmentVisitor(querySeg);
|
64
|
+
this.index.query(env, visitor);
|
65
|
+
var itemsFound = visitor.getItems();
|
66
|
+
|
67
|
+
return itemsFound;
|
68
|
+
};
|
69
|
+
|
70
|
+
|
71
|
+
/**
|
72
|
+
* @requires jsts/index/ItemVisitor.js
|
73
|
+
*/
|
74
|
+
/**
|
75
|
+
* ItemVisitor subclass to reduce volume of query results.
|
76
|
+
*
|
77
|
+
* @implements {jsts.index.ItemVisitor}
|
78
|
+
*/
|
79
|
+
jsts.simplify.LineSegmentIndex.LineSegmentVisitor = function(querySeg) {
|
80
|
+
this.items = [];
|
81
|
+
|
82
|
+
this.querySeg = querySeg;
|
83
|
+
};
|
84
|
+
|
85
|
+
|
86
|
+
jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype = new jsts.index.ItemVisitor();
|
87
|
+
|
88
|
+
// MD - only seems to make about a 10% difference in overall time.
|
89
|
+
jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.querySeg = null;
|
90
|
+
jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.items = null;
|
91
|
+
|
92
|
+
jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.visitItem = function(
|
93
|
+
item) {
|
94
|
+
var seg = item;
|
95
|
+
if (jsts.geom.Envelope.intersects(seg.p0, seg.p1, this.querySeg.p0, this.querySeg.p1))
|
96
|
+
this.items.push(item);
|
97
|
+
};
|
98
|
+
|
99
|
+
jsts.simplify.LineSegmentIndex.LineSegmentVisitor.prototype.getItems = function() {
|
100
|
+
return this.items;
|
101
|
+
};
|
@@ -0,0 +1,224 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
/**
|
10
|
+
* A utility class which creates Delaunay Trianglulations from collections of
|
11
|
+
* points and extract the resulting triangulation edges or triangles as
|
12
|
+
* geometries.
|
13
|
+
*
|
14
|
+
* Initializes a new DelaunayTriangulationBuilder
|
15
|
+
*
|
16
|
+
* @constructor
|
17
|
+
*/
|
18
|
+
jsts.triangulate.DelaunayTriangulationBuilder = function() {
|
19
|
+
|
20
|
+
this.siteCoords = null;
|
21
|
+
this.tolerance = 0.0;
|
22
|
+
this.subdiv = null;
|
23
|
+
};
|
24
|
+
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Extracts the unique {@link Coordinate}s from the given {@link Geometry}.
|
28
|
+
*
|
29
|
+
* @param {jsts.geom.Geometry}
|
30
|
+
* geom the geometry to extract from.
|
31
|
+
* @return {Array{jsts.geom.Coordinate}} An array of the unique Coordinates
|
32
|
+
*/
|
33
|
+
jsts.triangulate.DelaunayTriangulationBuilder.extractUniqueCoordinates = function(
|
34
|
+
geom) {
|
35
|
+
if (geom === undefined || geom === null) {
|
36
|
+
return new jsts.geom.CoordinateList([], false).toArray();
|
37
|
+
}
|
38
|
+
|
39
|
+
var coords = geom.getCoordinates();
|
40
|
+
return jsts.triangulate.DelaunayTriangulationBuilder.unique(coords);
|
41
|
+
};
|
42
|
+
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Removes any duplicates in the passed array.
|
46
|
+
*
|
47
|
+
* @param {Array{jsts.geom.Coordinate}}
|
48
|
+
* coords The input coordinates
|
49
|
+
* @return {Array{jsts.geom.Coordinate}} An array stripped out of any duplicates
|
50
|
+
*/
|
51
|
+
jsts.triangulate.DelaunayTriangulationBuilder.unique = function(coords) {
|
52
|
+
// Sort the coordinates by their compareTo-function
|
53
|
+
coords.sort(function(a, b) {
|
54
|
+
return a.compareTo(b);
|
55
|
+
});
|
56
|
+
|
57
|
+
var coordList = new jsts.geom.CoordinateList(coords, false);
|
58
|
+
return coordList.toArray();
|
59
|
+
};
|
60
|
+
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Converts an array of coordinates to an array of vertexes
|
64
|
+
*
|
65
|
+
* @param {Array{jsts.geom.Coordinate}}
|
66
|
+
* coords the input coordinates
|
67
|
+
* @return {Array{jsts.triangulate.quadedge.Vertex}} The created vertexes
|
68
|
+
*/
|
69
|
+
jsts.triangulate.DelaunayTriangulationBuilder.toVertices = function(coords) {
|
70
|
+
var verts = new Array(coords.length), i = 0, il = coords.length, coord;
|
71
|
+
|
72
|
+
for (i; i < il; i++) {
|
73
|
+
coord = coords[i];
|
74
|
+
verts[i] = new jsts.triangulate.quadedge.Vertex(coord);
|
75
|
+
}
|
76
|
+
|
77
|
+
return verts;
|
78
|
+
};
|
79
|
+
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Computes the {jsts.geom.Envelope} of an array of {jsts.geom.Coordinate}s
|
83
|
+
*
|
84
|
+
* @param {Array{jsts.geom.Coordinate}}
|
85
|
+
* coords the input coordinates
|
86
|
+
* @return {jsts.geom.Envelope} The created envelope.
|
87
|
+
*
|
88
|
+
*/
|
89
|
+
jsts.triangulate.DelaunayTriangulationBuilder.envelope = function(coords) {
|
90
|
+
var env = new jsts.geom.Envelope(), i = 0, il = coords.length;
|
91
|
+
|
92
|
+
for (i; i < il; i++) {
|
93
|
+
env.expandToInclude(coords[i]);
|
94
|
+
}
|
95
|
+
|
96
|
+
return env;
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Sets the sites which will be triangulated. Calls the correct setSites*
|
102
|
+
* function after argument-checking
|
103
|
+
*/
|
104
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.setSites = function() {
|
105
|
+
var arg = arguments[0];
|
106
|
+
|
107
|
+
if (arg instanceof jsts.geom.Geometry ||
|
108
|
+
arg instanceof jsts.geom.Coordinate || arg instanceof jsts.geom.Point ||
|
109
|
+
arg instanceof jsts.geom.MultiPoint ||
|
110
|
+
arg instanceof jsts.geom.LineString ||
|
111
|
+
arg instanceof jsts.geom.MultiLineString ||
|
112
|
+
arg instanceof jsts.geom.LinearRing || arg instanceof jsts.geom.Polygon ||
|
113
|
+
arg instanceof jsts.geom.MultiPolygon) {
|
114
|
+
this.setSitesFromGeometry(arg);
|
115
|
+
} else {
|
116
|
+
this.setSitesFromCollection(arg);
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Sets the sites (point or vertices) which will be triangulated. All vertices
|
123
|
+
* of the given geometry will be used as sites.
|
124
|
+
*
|
125
|
+
* @param {jsts.geom.Geometry}
|
126
|
+
* geom the geometry from which the sites will be extracted.
|
127
|
+
*/
|
128
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.setSitesFromGeometry = function(
|
129
|
+
geom) {
|
130
|
+
// remove any duplicate points (they will cause the triangulation to fail)
|
131
|
+
this.siteCoords = jsts.triangulate.DelaunayTriangulationBuilder
|
132
|
+
.extractUniqueCoordinates(geom);
|
133
|
+
};
|
134
|
+
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Sets the sites (point or vertices) which will be triangulated from a
|
138
|
+
* collection of {@link Coordinate}s.
|
139
|
+
*
|
140
|
+
* @param {Array{Coordinates}}
|
141
|
+
* coords a collection of Coordinates.
|
142
|
+
*/
|
143
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.setSitesFromCollection = function(
|
144
|
+
coords) {
|
145
|
+
// remove any duplicate points (they will cause the triangulation to fail)
|
146
|
+
this.siteCoords = jsts.triangulate.DelaunayTriangulationBuilder.unique(coords);
|
147
|
+
};
|
148
|
+
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Sets the snapping tolerance which will be used to improved the robustness of
|
152
|
+
* the triangulation computation. A tolerance of 0.0 specifies that no snapping
|
153
|
+
* will take place.
|
154
|
+
*
|
155
|
+
* @param {Number}
|
156
|
+
* tolerance the tolerance distance to use.
|
157
|
+
*/
|
158
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.setTolerance = function(
|
159
|
+
tolerance) {
|
160
|
+
this.tolerance = tolerance;
|
161
|
+
};
|
162
|
+
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Creates the Delaunay-triangulation.
|
166
|
+
*
|
167
|
+
*/
|
168
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.create = function() {
|
169
|
+
if (this.subdiv === null) {
|
170
|
+
var siteEnv, vertices, triangulator;
|
171
|
+
|
172
|
+
siteEnv = jsts.triangulate.DelaunayTriangulationBuilder
|
173
|
+
.envelope(this.siteCoords);
|
174
|
+
vertices = jsts.triangulate.DelaunayTriangulationBuilder
|
175
|
+
.toVertices(this.siteCoords);
|
176
|
+
this.subdiv = new jsts.triangulate.quadedge.QuadEdgeSubdivision(siteEnv,
|
177
|
+
this.tolerance);
|
178
|
+
triangulator = new jsts.triangulate.IncrementalDelaunayTriangulator(
|
179
|
+
this.subdiv);
|
180
|
+
triangulator.insertSites(vertices);
|
181
|
+
}
|
182
|
+
};
|
183
|
+
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Gets the {jsts.triangulate.quadedge.QuadEdgeSubdivision} which models the
|
187
|
+
* computed triangulation.
|
188
|
+
*
|
189
|
+
* @return {jsts.triangulate.quadedge.QuadEdgeSubdivision} containing the
|
190
|
+
* triangulation.
|
191
|
+
*/
|
192
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.getSubdivision = function() {
|
193
|
+
this.create();
|
194
|
+
return this.subdiv;
|
195
|
+
};
|
196
|
+
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Gets the edges of the computed triangulation as a {@link MultiLineString}.
|
200
|
+
*
|
201
|
+
* @param {jsts.geom.GeometryFactory}
|
202
|
+
* geomFact the geometry factory to use to create the output.
|
203
|
+
* @return {jsts.geom.Geometry} the edges of the triangulation.
|
204
|
+
*/
|
205
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.getEdges = function(
|
206
|
+
geomFact) {
|
207
|
+
this.create();
|
208
|
+
return this.subdiv.getEdges(geomFact);
|
209
|
+
};
|
210
|
+
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Gets the faces of the computed triangulation as a {@link GeometryCollection}
|
214
|
+
* of {@link Polygon}.
|
215
|
+
*
|
216
|
+
* @param {jsts.geom.GeometryFactory}
|
217
|
+
* geomFact the geometry factory to use to create the output.
|
218
|
+
* @return {jsts.geom.Geometry} the faces of the triangulation.
|
219
|
+
*/
|
220
|
+
jsts.triangulate.DelaunayTriangulationBuilder.prototype.getTriangles = function(
|
221
|
+
geomFact) {
|
222
|
+
this.create();
|
223
|
+
return this.subdiv.getTriangles(geomFact);
|
224
|
+
};
|