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,124 @@
|
|
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/Edge.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/planargraph/GraphComponent.js
|
15
|
+
*/
|
16
|
+
|
17
|
+
(function() {
|
18
|
+
|
19
|
+
var GraphComponent = jsts.planargraph.GraphComponent;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Represents an undirected edge of a {@link PlanarGraph}. An undirected edge
|
23
|
+
* in fact simply acts as a central point of reference for two opposite
|
24
|
+
* {@link DirectedEdge}s.
|
25
|
+
* <p>
|
26
|
+
* Usually a client using a <code>PlanarGraph</code> will subclass
|
27
|
+
* <code>Edge</code> to add its own application-specific data and methods.
|
28
|
+
*
|
29
|
+
* Constructs an Edge initialized with the given DirectedEdges, and for each
|
30
|
+
* DirectedEdge: sets the Edge, sets the symmetric DirectedEdge, and adds this
|
31
|
+
* Edge to its from-Node.
|
32
|
+
*/
|
33
|
+
var Edge = function(de0, de1) {
|
34
|
+
if (de0 === undefined) {
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
this.setDirectedEdges(de0, de1);
|
38
|
+
};
|
39
|
+
|
40
|
+
Edge.prototype = new GraphComponent();
|
41
|
+
|
42
|
+
|
43
|
+
/**
|
44
|
+
* The two DirectedEdges associated with this Edge. Index 0 is forward, 1 is
|
45
|
+
* reverse.
|
46
|
+
*/
|
47
|
+
Edge.prototype.dirEdge = null;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Initializes this Edge's two DirectedEdges, and for each DirectedEdge: sets
|
51
|
+
* the Edge, sets the symmetric DirectedEdge, and adds this Edge to its
|
52
|
+
* from-Node.
|
53
|
+
*/
|
54
|
+
Edge.prototype.setDirectedEdges = function(de0, de1) {
|
55
|
+
this.dirEdge = [de0, de1];
|
56
|
+
de0.setEdge(this);
|
57
|
+
de1.setEdge(this);
|
58
|
+
de0.setSym(de1);
|
59
|
+
de1.setSym(de0);
|
60
|
+
de0.getFromNode().addOutEdge(de0);
|
61
|
+
de1.getFromNode().addOutEdge(de1);
|
62
|
+
};
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Returns one of the DirectedEdges associated with this Edge.
|
66
|
+
*
|
67
|
+
* @param i
|
68
|
+
* 0 or 1. 0 returns the forward directed edge, 1 returns the reverse.
|
69
|
+
*/
|
70
|
+
Edge.prototype.getDirEdge = function(i) {
|
71
|
+
if (i instanceof jsts.planargraph.Node) {
|
72
|
+
this.getDirEdge2(i);
|
73
|
+
}
|
74
|
+
|
75
|
+
return this.dirEdge[i];
|
76
|
+
};
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Returns the {@link DirectedEdge} that starts from the given node, or null
|
80
|
+
* if the node is not one of the two nodes associated with this Edge.
|
81
|
+
*/
|
82
|
+
Edge.prototype.getDirEdge2 = function(fromNode) {
|
83
|
+
if (this.dirEdge[0].getFromNode() == fromNode)
|
84
|
+
return this.dirEdge[0];
|
85
|
+
if (this.dirEdge[1].getFromNode() == fromNode)
|
86
|
+
return this.dirEdge[1];
|
87
|
+
// node not found
|
88
|
+
// possibly should throw an exception here?
|
89
|
+
return null;
|
90
|
+
};
|
91
|
+
|
92
|
+
/**
|
93
|
+
* If <code>node</code> is one of the two nodes associated with this Edge,
|
94
|
+
* returns the other node; otherwise returns null.
|
95
|
+
*/
|
96
|
+
Edge.prototype.getOppositeNode = function(node) {
|
97
|
+
if (this.dirEdge[0].getFromNode() == node)
|
98
|
+
return this.dirEdge[0].getToNode();
|
99
|
+
if (this.dirEdge[1].getFromNode() == node)
|
100
|
+
return this.dirEdge[1].getToNode();
|
101
|
+
// node not found
|
102
|
+
// possibly should throw an exception here?
|
103
|
+
return null;
|
104
|
+
};
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Removes this edge from its containing graph.
|
108
|
+
*/
|
109
|
+
Edge.prototype.remove = function() {
|
110
|
+
this.dirEdge = null;
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Tests whether this edge has been removed from its containing graph
|
115
|
+
*
|
116
|
+
* @return <code>true</code> if this edge is removed.
|
117
|
+
*/
|
118
|
+
Edge.prototype.isRemoved = function() {
|
119
|
+
return dirEdge == null;
|
120
|
+
};
|
121
|
+
|
122
|
+
jsts.planargraph.Edge = Edge;
|
123
|
+
|
124
|
+
})();
|
@@ -0,0 +1,182 @@
|
|
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/GraphComponent.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
(function() {
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The base class for all graph component classes. Maintains flags of use in
|
17
|
+
* generic graph algorithms. Provides two flags:
|
18
|
+
* <ul>
|
19
|
+
* <li><b>marked</b> - typically this is used to indicate a state that
|
20
|
+
* persists for the course of the graph's lifetime. For instance, it can be
|
21
|
+
* used to indicate that a component has been logically deleted from the
|
22
|
+
* graph.
|
23
|
+
* <li><b>visited</b> - this is used to indicate that a component has been
|
24
|
+
* processed or visited by an single graph algorithm. For instance, a
|
25
|
+
* breadth-first traversal of the graph might use this to indicate that a node
|
26
|
+
* has already been traversed. The visited flag may be set and cleared many
|
27
|
+
* times during the lifetime of a graph.
|
28
|
+
*
|
29
|
+
* <p>
|
30
|
+
* Graph components support storing user context data. This will typically be
|
31
|
+
* used by client algorithms which use planar graphs.
|
32
|
+
*/
|
33
|
+
var GraphComponent = function() {
|
34
|
+
|
35
|
+
};
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Sets the Visited state for all {@link GraphComponent}s in an
|
39
|
+
* {@link Iterator}
|
40
|
+
*
|
41
|
+
* @param i
|
42
|
+
* the Iterator to scan.
|
43
|
+
* @param visited
|
44
|
+
* the state to set the visited flag to.
|
45
|
+
*/
|
46
|
+
GraphComponent.setVisited = function(i, visited) {
|
47
|
+
while (i.hasNext()) {
|
48
|
+
var comp = i.next();
|
49
|
+
comp.setVisited(visited);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Sets the Marked state for all {@link GraphComponent}s in an
|
55
|
+
* {@link Iterator}
|
56
|
+
*
|
57
|
+
* @param i
|
58
|
+
* the Iterator to scan.
|
59
|
+
* @param marked
|
60
|
+
* the state to set the Marked flag to.
|
61
|
+
*/
|
62
|
+
GraphComponent.setMarked = function(i, marked) {
|
63
|
+
while (i.hasNext()) {
|
64
|
+
var comp = i.next();
|
65
|
+
comp.setMarked(marked);
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Finds the first {@link GraphComponent} in a {@link Iterator} set which has
|
71
|
+
* the specified visited state.
|
72
|
+
*
|
73
|
+
* @param i
|
74
|
+
* an Iterator of GraphComponents.
|
75
|
+
* @param visitedState
|
76
|
+
* the visited state to test.
|
77
|
+
* @return the first component found, or <code>null</code> if none found.
|
78
|
+
*/
|
79
|
+
GraphComponent.getComponentWithVisitedState = function(i, visitedState) {
|
80
|
+
while (i.hasNext()) {
|
81
|
+
var comp = i.next();
|
82
|
+
if (comp.isVisited() == visitedState)
|
83
|
+
return comp;
|
84
|
+
}
|
85
|
+
return null;
|
86
|
+
};
|
87
|
+
|
88
|
+
GraphComponent.prototype._isMarked = false;
|
89
|
+
GraphComponent.prototype._isVisited = false;
|
90
|
+
GraphComponent.prototype.data;
|
91
|
+
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Tests if a component has been visited during the course of a graph
|
95
|
+
* algorithm
|
96
|
+
*
|
97
|
+
* @return <code>true</code> if the component has been visited.
|
98
|
+
*/
|
99
|
+
GraphComponent.prototype.isVisited = function() {
|
100
|
+
return this._isVisited;
|
101
|
+
};
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Sets the visited flag for this component.
|
105
|
+
*
|
106
|
+
* @param isVisited
|
107
|
+
* the desired value of the visited flag.
|
108
|
+
*/
|
109
|
+
GraphComponent.prototype.setVisited = function(isVisited) {
|
110
|
+
this._isVisited = isVisited;
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Tests if a component has been marked at some point during the processing
|
115
|
+
* involving this graph.
|
116
|
+
*
|
117
|
+
* @return <code>true</code> if the component has been marked.
|
118
|
+
*/
|
119
|
+
GraphComponent.prototype.isMarked = function() {
|
120
|
+
return this._isMarked;
|
121
|
+
};
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Sets the marked flag for this component.
|
125
|
+
*
|
126
|
+
* @param isMarked
|
127
|
+
* the desired value of the marked flag.
|
128
|
+
*/
|
129
|
+
GraphComponent.prototype.setMarked = function(isMarked) {
|
130
|
+
this._isMarked = isMarked;
|
131
|
+
};
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Sets the user-defined data for this component.
|
135
|
+
*
|
136
|
+
* @param data
|
137
|
+
* an Object containing user-defined data.
|
138
|
+
*/
|
139
|
+
GraphComponent.prototype.setContext = function(data) {
|
140
|
+
this.data = data;
|
141
|
+
};
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Gets the user-defined data for this component.
|
145
|
+
*
|
146
|
+
* @return the user-defined data.
|
147
|
+
*/
|
148
|
+
GraphComponent.prototype.getContext = function() {
|
149
|
+
return data;
|
150
|
+
};
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Sets the user-defined data for this component.
|
154
|
+
*
|
155
|
+
* @param data
|
156
|
+
* an Object containing user-defined data.
|
157
|
+
*/
|
158
|
+
GraphComponent.prototype.setData = function(data) {
|
159
|
+
this.data = data;
|
160
|
+
};
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Gets the user-defined data for this component.
|
164
|
+
*
|
165
|
+
* @return the user-defined data.
|
166
|
+
*/
|
167
|
+
GraphComponent.prototype.getData = function() {
|
168
|
+
return data;
|
169
|
+
};
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Tests whether this component has been removed from its containing graph
|
173
|
+
*
|
174
|
+
* @return <code>true</code> if this component is removed.
|
175
|
+
*/
|
176
|
+
GraphComponent.prototype.isRemoved = function() {
|
177
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
178
|
+
};
|
179
|
+
|
180
|
+
jsts.planargraph.GraphComponent = GraphComponent;
|
181
|
+
|
182
|
+
})();
|
@@ -0,0 +1,127 @@
|
|
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/Node.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/planargraph/GraphComponent.js
|
15
|
+
* @requires jsts/planargraph/DirectedEdgeStar.js
|
16
|
+
*/
|
17
|
+
|
18
|
+
(function() {
|
19
|
+
|
20
|
+
var GraphComponent = jsts.planargraph.GraphComponent;
|
21
|
+
var DirectedEdgeStar = jsts.planargraph.DirectedEdgeStar;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* A node in a {@link PlanarGraph}is a location where 0 or more {@link Edge}s
|
25
|
+
* meet. A node is connected to each of its incident Edges via an outgoing
|
26
|
+
* DirectedEdge. Some clients using a <code>PlanarGraph</code> may want to
|
27
|
+
* subclass <code>Node</code> to add their own application-specific data and
|
28
|
+
* methods.
|
29
|
+
*
|
30
|
+
* Constructs a Node with the given location and collection of outgoing
|
31
|
+
* DirectedEdges.
|
32
|
+
*/
|
33
|
+
var Node = function(pt, deStar) {
|
34
|
+
this.pt = pt;
|
35
|
+
this.deStar = deStar || new DirectedEdgeStar();
|
36
|
+
};
|
37
|
+
|
38
|
+
|
39
|
+
Node.prototype = new GraphComponent();
|
40
|
+
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Returns all Edges that connect the two nodes (which are assumed to be
|
44
|
+
* different).
|
45
|
+
*/
|
46
|
+
Node.getEdgesBetween = function(node0, node1) {
|
47
|
+
var edges0 = DirectedEdge.toEdges(node0.getOutEdges().getEdges());
|
48
|
+
var commonEdges = new javascript.util.HashSet(edges0);
|
49
|
+
var edges1 = DirectedEdge.toEdges(node1.getOutEdges().getEdges());
|
50
|
+
commonEdges.retainAll(edges1);
|
51
|
+
return commonEdges;
|
52
|
+
};
|
53
|
+
|
54
|
+
/** The location of this Node */
|
55
|
+
Node.prototype.pt = null;
|
56
|
+
|
57
|
+
/** The collection of DirectedEdges that leave this Node */
|
58
|
+
Node.prototype.deStar = null;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Returns the location of this Node.
|
62
|
+
*/
|
63
|
+
Node.prototype.getCoordinate = function() {
|
64
|
+
return this.pt;
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Adds an outgoing DirectedEdge to this Node.
|
69
|
+
*/
|
70
|
+
Node.prototype.addOutEdge = function(de) {
|
71
|
+
this.deStar.add(de);
|
72
|
+
};
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Returns the collection of DirectedEdges that leave this Node.
|
76
|
+
*/
|
77
|
+
Node.prototype.getOutEdges = function() {
|
78
|
+
return this.deStar;
|
79
|
+
};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Returns the number of edges around this Node.
|
83
|
+
*/
|
84
|
+
Node.prototype.getDegree = function() {
|
85
|
+
return this.deStar.getDegree();
|
86
|
+
};
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Returns the zero-based index of the given Edge, after sorting in ascending
|
90
|
+
* order by angle with the positive x-axis.
|
91
|
+
*/
|
92
|
+
Node.prototype.getIndex = function(edge) {
|
93
|
+
return this.deStar.getIndex(edge);
|
94
|
+
};
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Removes a {@link DirectedEdge} incident on this node. Does not change the
|
98
|
+
* state of the directed edge.
|
99
|
+
*/
|
100
|
+
Node.prototype.remove = function(de) {
|
101
|
+
if (de === undefined) {
|
102
|
+
return this.remove2();
|
103
|
+
}
|
104
|
+
|
105
|
+
this.deStar.remove(de);
|
106
|
+
};
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Removes this node from its containing graph.
|
110
|
+
*/
|
111
|
+
Node.prototype.remove2 = function() {
|
112
|
+
this.pt = null;
|
113
|
+
};
|
114
|
+
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Tests whether this node has been removed from its containing graph
|
118
|
+
*
|
119
|
+
* @return <code>true</code> if this node is removed.
|
120
|
+
*/
|
121
|
+
Node.prototype.isRemoved = function() {
|
122
|
+
return this.pt == null;
|
123
|
+
};
|
124
|
+
|
125
|
+
jsts.planargraph.Node = Node;
|
126
|
+
|
127
|
+
})();
|
@@ -0,0 +1,76 @@
|
|
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/NodeMap.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/geom/Coordinate.js
|
15
|
+
* @requires jsts/planargraph/Node.js
|
16
|
+
*/
|
17
|
+
|
18
|
+
(function() {
|
19
|
+
|
20
|
+
/**
|
21
|
+
* A map of {@link Node}s, indexed by the coordinate of the node.
|
22
|
+
*
|
23
|
+
* Constructs a NodeMap without any Nodes.
|
24
|
+
*/
|
25
|
+
var NodeMap = function() {
|
26
|
+
this.nodeMap = new javascript.util.TreeMap();
|
27
|
+
};
|
28
|
+
|
29
|
+
|
30
|
+
NodeMap.prototype.nodeMap = null;
|
31
|
+
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Adds a node to the map, replacing any that is already at that location.
|
35
|
+
*
|
36
|
+
* @return the added node.
|
37
|
+
*/
|
38
|
+
NodeMap.prototype.add = function(n) {
|
39
|
+
this.nodeMap.put(n.getCoordinate(), n);
|
40
|
+
return n;
|
41
|
+
};
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Removes the Node at the given location, and returns it (or null if no Node
|
45
|
+
* was there).
|
46
|
+
*/
|
47
|
+
NodeMap.prototype.remove = function(pt) {
|
48
|
+
return this.nodeMap.remove(pt);
|
49
|
+
};
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Returns the Node at the given location, or null if no Node was there.
|
53
|
+
*/
|
54
|
+
NodeMap.prototype.find = function(coord) {
|
55
|
+
return this.nodeMap.get(coord);
|
56
|
+
};
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Returns an Iterator over the Nodes in this NodeMap, sorted in ascending
|
60
|
+
* order by angle with the positive x-axis.
|
61
|
+
*/
|
62
|
+
NodeMap.prototype.iterator = function() {
|
63
|
+
return this.nodeMap.values().iterator();
|
64
|
+
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Returns the Nodes in this NodeMap, sorted in ascending order by angle with
|
68
|
+
* the positive x-axis.
|
69
|
+
*/
|
70
|
+
NodeMap.prototype.values = function() {
|
71
|
+
return this.nodeMap.values();
|
72
|
+
};
|
73
|
+
|
74
|
+
jsts.planargraph.NodeMap = NodeMap;
|
75
|
+
|
76
|
+
})();
|