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,94 @@
|
|
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/operation/polygonize/PolygonizeDirectedEdge.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/planargraph/DirectedEdge.js
|
15
|
+
*/
|
16
|
+
|
17
|
+
(function() {
|
18
|
+
|
19
|
+
var DirectedEdge = jsts.planargraph.DirectedEdge;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* A {@link DirectedEdge} of a {@link PolygonizeGraph}, which represents an
|
23
|
+
* edge of a polygon formed by the graph. May be logically deleted from the
|
24
|
+
* graph by setting the <code>marked</code> flag.
|
25
|
+
*
|
26
|
+
* Constructs a directed edge connecting the <code>from</code> node to the
|
27
|
+
* <code>to</code> node.
|
28
|
+
*
|
29
|
+
* @param directionPt
|
30
|
+
* specifies this DirectedEdge's direction (given by an imaginary
|
31
|
+
* line from the <code>from</code> node to <code>directionPt</code>).
|
32
|
+
* @param edgeDirection
|
33
|
+
* whether this DirectedEdge's direction is the same as or opposite
|
34
|
+
* to that of the parent Edge (if any).
|
35
|
+
*/
|
36
|
+
var PolygonizeDirectedEdge = function(from, to, directionPt, edgeDirection) {
|
37
|
+
DirectedEdge.apply(this, arguments);
|
38
|
+
};
|
39
|
+
|
40
|
+
PolygonizeDirectedEdge.prototype = new DirectedEdge();
|
41
|
+
|
42
|
+
PolygonizeDirectedEdge.prototype.edgeRing = null;
|
43
|
+
PolygonizeDirectedEdge.prototype.next = null;
|
44
|
+
PolygonizeDirectedEdge.prototype.label = -1;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Returns the identifier attached to this directed edge.
|
48
|
+
*/
|
49
|
+
PolygonizeDirectedEdge.prototype.getLabel = function() {
|
50
|
+
return this.label;
|
51
|
+
};
|
52
|
+
/**
|
53
|
+
* Attaches an identifier to this directed edge.
|
54
|
+
*/
|
55
|
+
PolygonizeDirectedEdge.prototype.setLabel = function(label) {
|
56
|
+
this.label = label;
|
57
|
+
};
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Returns the next directed edge in the EdgeRing that this directed edge is a
|
61
|
+
* member of.
|
62
|
+
*/
|
63
|
+
PolygonizeDirectedEdge.prototype.getNext = function() {
|
64
|
+
return this.next;
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Sets the next directed edge in the EdgeRing that this directed edge is a
|
69
|
+
* member of.
|
70
|
+
*/
|
71
|
+
PolygonizeDirectedEdge.prototype.setNext = function(next) {
|
72
|
+
this.next = next;
|
73
|
+
};
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Returns the ring of directed edges that this directed edge is a member of,
|
77
|
+
* or null if the ring has not been set.
|
78
|
+
*
|
79
|
+
* @see #setRing(EdgeRing)
|
80
|
+
*/
|
81
|
+
PolygonizeDirectedEdge.prototype.isInRing = function() {
|
82
|
+
return this.edgeRing != null;
|
83
|
+
};
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Sets the ring of directed edges that this directed edge is a member of.
|
87
|
+
*/
|
88
|
+
PolygonizeDirectedEdge.prototype.setRing = function(edgeRing) {
|
89
|
+
this.edgeRing = edgeRing;
|
90
|
+
};
|
91
|
+
|
92
|
+
jsts.operation.polygonize.PolygonizeDirectedEdge = PolygonizeDirectedEdge;
|
93
|
+
|
94
|
+
})();
|
@@ -0,0 +1,31 @@
|
|
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/operation/polygonize/PolygonizeEdge.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/planargraph/Edge.js
|
15
|
+
*/
|
16
|
+
|
17
|
+
|
18
|
+
/**
|
19
|
+
* An edge of a polygonization graph.
|
20
|
+
*/
|
21
|
+
jsts.operation.polygonize.PolygonizeEdge = function(line) {
|
22
|
+
this.line = line;
|
23
|
+
};
|
24
|
+
|
25
|
+
jsts.operation.polygonize.PolygonizeEdge.prototype = new jsts.planargraph.Edge();
|
26
|
+
|
27
|
+
jsts.operation.polygonize.PolygonizeEdge.prototype.line = null;
|
28
|
+
|
29
|
+
jsts.operation.polygonize.PolygonizeEdge.prototype.getLine = function() {
|
30
|
+
return this.line;
|
31
|
+
};
|
@@ -0,0 +1,507 @@
|
|
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/operation/polygonize/PolygonizeDirectedEdge.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/operation/polygonize/EdgeRing.js
|
15
|
+
* @requires jsts/operation/polygonize/PolygonizeEdge.js
|
16
|
+
* @requires jsts/operation/polygonize/PolygonizeDirectedEdge.js
|
17
|
+
* @requires jsts/geom/Coordinate.js
|
18
|
+
* @requires jsts/planargraph/PlanarGraph.js
|
19
|
+
* @requires jsts/planargraph/Node.js
|
20
|
+
*/
|
21
|
+
|
22
|
+
(function() {
|
23
|
+
|
24
|
+
var ArrayList = javascript.util.ArrayList;
|
25
|
+
var Stack = javascript.util.Stack;
|
26
|
+
var HashSet = javascript.util.HashSet;
|
27
|
+
var Assert = jsts.util.Assert;
|
28
|
+
var EdgeRing = jsts.operation.polygonize.EdgeRing;
|
29
|
+
var PolygonizeEdge = jsts.operation.polygonize.PolygonizeEdge;
|
30
|
+
var PolygonizeDirectedEdge = jsts.operation.polygonize.PolygonizeDirectedEdge;
|
31
|
+
var PlanarGraph = jsts.planargraph.PlanarGraph;
|
32
|
+
var Node = jsts.planargraph.Node;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Represents a planar graph of edges that can be used to compute a
|
36
|
+
* polygonization, and implements the algorithms to compute the
|
37
|
+
* {@link EdgeRings} formed by the graph.
|
38
|
+
* <p>
|
39
|
+
* The marked flag on {@link DirectedEdge}s is used to indicate that a
|
40
|
+
* directed edge has be logically deleted from the graph.
|
41
|
+
*
|
42
|
+
* Create a new polygonization graph.
|
43
|
+
*/
|
44
|
+
var PolygonizeGraph = function(factory) {
|
45
|
+
PlanarGraph.apply(this);
|
46
|
+
|
47
|
+
this.factory = factory;
|
48
|
+
};
|
49
|
+
|
50
|
+
PolygonizeGraph.prototype = new PlanarGraph();
|
51
|
+
|
52
|
+
/**
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
PolygonizeGraph.getDegreeNonDeleted = function(node) {
|
56
|
+
var edges = node.getOutEdges().getEdges();
|
57
|
+
var degree = 0;
|
58
|
+
for (var i = edges.iterator(); i.hasNext();) {
|
59
|
+
var de = i.next();
|
60
|
+
if (!de.isMarked())
|
61
|
+
degree++;
|
62
|
+
}
|
63
|
+
return degree;
|
64
|
+
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @private
|
68
|
+
*/
|
69
|
+
PolygonizeGraph.getDegree = function(node, label) {
|
70
|
+
var edges = node.getOutEdges().getEdges();
|
71
|
+
var degree = 0;
|
72
|
+
for (var i = edges.iterator(); i.hasNext();) {
|
73
|
+
var de = i.next();
|
74
|
+
if (de.getLabel() == label)
|
75
|
+
degree++;
|
76
|
+
}
|
77
|
+
return degree;
|
78
|
+
};
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Deletes all edges at a node
|
82
|
+
*
|
83
|
+
* @private
|
84
|
+
*/
|
85
|
+
PolygonizeGraph.deleteAllEdges = function(node) {
|
86
|
+
var edges = node.getOutEdges().getEdges();
|
87
|
+
for (var i = edges.iterator(); i.hasNext();) {
|
88
|
+
var de = i.next();
|
89
|
+
de.setMarked(true);
|
90
|
+
var sym = de.getSym();
|
91
|
+
if (sym != null)
|
92
|
+
sym.setMarked(true);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
|
97
|
+
PolygonizeGraph.prototype.factory = null;
|
98
|
+
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Add a {@link LineString} forming an edge of the polygon graph.
|
102
|
+
*
|
103
|
+
* @param line
|
104
|
+
* the line to add.
|
105
|
+
*/
|
106
|
+
PolygonizeGraph.prototype.addEdge = function(line) {
|
107
|
+
if (line.isEmpty()) {
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
var linePts = jsts.geom.CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
|
111
|
+
|
112
|
+
if (linePts.length < 2) {
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
|
116
|
+
var startPt = linePts[0];
|
117
|
+
var endPt = linePts[linePts.length - 1];
|
118
|
+
|
119
|
+
var nStart = this.getNode(startPt);
|
120
|
+
var nEnd = this.getNode(endPt);
|
121
|
+
|
122
|
+
var de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true);
|
123
|
+
var de1 = new PolygonizeDirectedEdge(nEnd, nStart,
|
124
|
+
linePts[linePts.length - 2], false);
|
125
|
+
var edge = new PolygonizeEdge(line);
|
126
|
+
edge.setDirectedEdges(de0, de1);
|
127
|
+
this.add(edge);
|
128
|
+
};
|
129
|
+
|
130
|
+
/**
|
131
|
+
* @private
|
132
|
+
*/
|
133
|
+
PolygonizeGraph.prototype.getNode = function(pt) {
|
134
|
+
var node = this.findNode(pt);
|
135
|
+
if (node == null) {
|
136
|
+
node = new Node(pt);
|
137
|
+
// ensure node is only added once to graph
|
138
|
+
this.add(node);
|
139
|
+
}
|
140
|
+
return node;
|
141
|
+
};
|
142
|
+
|
143
|
+
/**
|
144
|
+
* @private
|
145
|
+
*/
|
146
|
+
PolygonizeGraph.prototype.computeNextCWEdges = function() {
|
147
|
+
// set the next pointers for the edges around each node
|
148
|
+
for (var iNode = this.nodeIterator(); iNode.hasNext();) {
|
149
|
+
var node = iNode.next();
|
150
|
+
PolygonizeGraph.computeNextCWEdges(node);
|
151
|
+
}
|
152
|
+
};
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Convert the maximal edge rings found by the initial graph traversal into
|
156
|
+
* the minimal edge rings required by JTS polygon topology rules.
|
157
|
+
*
|
158
|
+
* @param ringEdges
|
159
|
+
* the list of start edges for the edgeRings to convert.
|
160
|
+
* @private
|
161
|
+
*/
|
162
|
+
PolygonizeGraph.prototype.convertMaximalToMinimalEdgeRings = function(
|
163
|
+
ringEdges) {
|
164
|
+
for (var i = ringEdges.iterator(); i.hasNext();) {
|
165
|
+
var de = i.next();
|
166
|
+
var label = de.getLabel();
|
167
|
+
var intNodes = PolygonizeGraph.findIntersectionNodes(de, label);
|
168
|
+
|
169
|
+
if (intNodes == null)
|
170
|
+
continue;
|
171
|
+
// flip the next pointers on the intersection nodes to create minimal edge
|
172
|
+
// rings
|
173
|
+
for (var iNode = intNodes.iterator(); iNode.hasNext();) {
|
174
|
+
var node = iNode.next();
|
175
|
+
PolygonizeGraph.computeNextCCWEdges(node, label);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
};
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Finds all nodes in a maximal edgering which are self-intersection nodes
|
182
|
+
*
|
183
|
+
* @param startDE
|
184
|
+
* @param label
|
185
|
+
* @return the list of intersection nodes found, or <code>null</code> if no
|
186
|
+
* intersection nodes were found.
|
187
|
+
* @private
|
188
|
+
*/
|
189
|
+
PolygonizeGraph.findIntersectionNodes = function(startDE, label) {
|
190
|
+
var de = startDE;
|
191
|
+
var intNodes = null;
|
192
|
+
do {
|
193
|
+
var node = de.getFromNode();
|
194
|
+
if (PolygonizeGraph.getDegree(node, label) > 1) {
|
195
|
+
if (intNodes == null)
|
196
|
+
intNodes = new ArrayList();
|
197
|
+
intNodes.add(node);
|
198
|
+
}
|
199
|
+
|
200
|
+
de = de.getNext();
|
201
|
+
Assert.isTrue(de != null, 'found null DE in ring');
|
202
|
+
Assert
|
203
|
+
.isTrue(de == startDE || !de.isInRing(), 'found DE already in ring');
|
204
|
+
} while (de != startDE);
|
205
|
+
|
206
|
+
return intNodes;
|
207
|
+
};
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Computes the minimal EdgeRings formed by the edges in this graph.
|
211
|
+
*
|
212
|
+
* @return a list of the {@link EdgeRing} s found by the polygonization
|
213
|
+
* process.
|
214
|
+
*
|
215
|
+
*/
|
216
|
+
PolygonizeGraph.prototype.getEdgeRings = function() {
|
217
|
+
// maybe could optimize this, since most of these pointers should be set
|
218
|
+
// correctly already
|
219
|
+
// by deleteCutEdges()
|
220
|
+
this.computeNextCWEdges();
|
221
|
+
// clear labels of all edges in graph
|
222
|
+
PolygonizeGraph.label(this.dirEdges, -1);
|
223
|
+
var maximalRings = PolygonizeGraph.findLabeledEdgeRings(this.dirEdges);
|
224
|
+
this.convertMaximalToMinimalEdgeRings(maximalRings);
|
225
|
+
|
226
|
+
// find all edgerings (which will now be minimal ones, as required)
|
227
|
+
var edgeRingList = new ArrayList();
|
228
|
+
for (var i = this.dirEdges.iterator(); i.hasNext();) {
|
229
|
+
var de = i.next();
|
230
|
+
if (de.isMarked())
|
231
|
+
continue;
|
232
|
+
if (de.isInRing())
|
233
|
+
continue;
|
234
|
+
|
235
|
+
var er = this.findEdgeRing(de);
|
236
|
+
edgeRingList.add(er);
|
237
|
+
}
|
238
|
+
return edgeRingList;
|
239
|
+
};
|
240
|
+
|
241
|
+
/**
|
242
|
+
* Finds and labels all edgerings in the graph. The edge rings are labelling
|
243
|
+
* with unique integers. The labelling allows detecting cut edges.
|
244
|
+
*
|
245
|
+
* @param dirEdges
|
246
|
+
* a List of the DirectedEdges in the graph.
|
247
|
+
* @return a List of DirectedEdges, one for each edge ring found.
|
248
|
+
* @private
|
249
|
+
*/
|
250
|
+
PolygonizeGraph.findLabeledEdgeRings = function(dirEdges) {
|
251
|
+
var edgeRingStarts = new ArrayList();
|
252
|
+
// label the edge rings formed
|
253
|
+
var currLabel = 1;
|
254
|
+
for (var i = dirEdges.iterator(); i.hasNext();) {
|
255
|
+
var de = i.next();
|
256
|
+
if (de.isMarked())
|
257
|
+
continue;
|
258
|
+
if (de.getLabel() >= 0)
|
259
|
+
continue;
|
260
|
+
|
261
|
+
edgeRingStarts.add(de);
|
262
|
+
var edges = PolygonizeGraph.findDirEdgesInRing(de);
|
263
|
+
|
264
|
+
PolygonizeGraph.label(edges, currLabel);
|
265
|
+
currLabel++;
|
266
|
+
}
|
267
|
+
return edgeRingStarts;
|
268
|
+
};
|
269
|
+
|
270
|
+
/**
|
271
|
+
* Finds and removes all cut edges from the graph.
|
272
|
+
*
|
273
|
+
* @return a list of the {@link LineString} s forming the removed cut edges.
|
274
|
+
*/
|
275
|
+
PolygonizeGraph.prototype.deleteCutEdges = function() {
|
276
|
+
this.computeNextCWEdges();
|
277
|
+
// label the current set of edgerings
|
278
|
+
PolygonizeGraph.findLabeledEdgeRings(this.dirEdges);
|
279
|
+
|
280
|
+
/**
|
281
|
+
* Cut Edges are edges where both dirEdges have the same label. Delete them,
|
282
|
+
* and record them
|
283
|
+
*/
|
284
|
+
var cutLines = new ArrayList();
|
285
|
+
for (var i = this.dirEdges.iterator(); i.hasNext();) {
|
286
|
+
var de = i.next();
|
287
|
+
if (de.isMarked())
|
288
|
+
continue;
|
289
|
+
|
290
|
+
var sym = de.getSym();
|
291
|
+
|
292
|
+
if (de.getLabel() == sym.getLabel()) {
|
293
|
+
de.setMarked(true);
|
294
|
+
sym.setMarked(true);
|
295
|
+
|
296
|
+
// save the line as a cut edge
|
297
|
+
var e = de.getEdge();
|
298
|
+
cutLines.add(e.getLine());
|
299
|
+
}
|
300
|
+
}
|
301
|
+
return cutLines;
|
302
|
+
};
|
303
|
+
|
304
|
+
/**
|
305
|
+
* @private
|
306
|
+
*/
|
307
|
+
PolygonizeGraph.label = function(dirEdges, label) {
|
308
|
+
for (var i = dirEdges.iterator(); i.hasNext();) {
|
309
|
+
var de = i.next();
|
310
|
+
de.setLabel(label);
|
311
|
+
}
|
312
|
+
};
|
313
|
+
|
314
|
+
/**
|
315
|
+
* @private
|
316
|
+
*/
|
317
|
+
PolygonizeGraph.computeNextCWEdges = function(node) {
|
318
|
+
var deStar = node.getOutEdges();
|
319
|
+
var startDE = null;
|
320
|
+
var prevDE = null;
|
321
|
+
|
322
|
+
// the edges are stored in CCW order around the star
|
323
|
+
for (var i = deStar.getEdges().iterator(); i.hasNext();) {
|
324
|
+
var outDE = i.next();
|
325
|
+
if (outDE.isMarked())
|
326
|
+
continue;
|
327
|
+
|
328
|
+
if (startDE == null)
|
329
|
+
startDE = outDE;
|
330
|
+
if (prevDE != null) {
|
331
|
+
var sym = prevDE.getSym();
|
332
|
+
sym.setNext(outDE);
|
333
|
+
}
|
334
|
+
prevDE = outDE;
|
335
|
+
}
|
336
|
+
if (prevDE != null) {
|
337
|
+
var sym = prevDE.getSym();
|
338
|
+
sym.setNext(startDE);
|
339
|
+
}
|
340
|
+
};
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Computes the next edge pointers going CCW around the given node, for the
|
344
|
+
* given edgering label. This algorithm has the effect of converting maximal
|
345
|
+
* edgerings into minimal edgerings
|
346
|
+
*
|
347
|
+
* @private
|
348
|
+
*
|
349
|
+
*/
|
350
|
+
PolygonizeGraph.computeNextCCWEdges = function(node, label) {
|
351
|
+
var deStar = node.getOutEdges();
|
352
|
+
// PolyDirectedEdge lastInDE = null;
|
353
|
+
var firstOutDE = null;
|
354
|
+
var prevInDE = null;
|
355
|
+
|
356
|
+
// the edges are stored in CCW order around the star
|
357
|
+
var edges = deStar.getEdges();
|
358
|
+
// for (Iterator i = deStar.getEdges().iterator(); i.hasNext(); ) {
|
359
|
+
for (var i = edges.size() - 1; i >= 0; i--) {
|
360
|
+
var de = edges.get(i);
|
361
|
+
var sym = de.getSym();
|
362
|
+
|
363
|
+
var outDE = null;
|
364
|
+
if (de.getLabel() == label)
|
365
|
+
outDE = de;
|
366
|
+
var inDE = null;
|
367
|
+
if (sym.getLabel() == label)
|
368
|
+
inDE = sym;
|
369
|
+
|
370
|
+
if (outDE == null && inDE == null)
|
371
|
+
continue; // this edge is not in edgering
|
372
|
+
|
373
|
+
if (inDE != null) {
|
374
|
+
prevInDE = inDE;
|
375
|
+
}
|
376
|
+
|
377
|
+
if (outDE != null) {
|
378
|
+
if (prevInDE != null) {
|
379
|
+
prevInDE.setNext(outDE);
|
380
|
+
prevInDE = null;
|
381
|
+
}
|
382
|
+
if (firstOutDE == null)
|
383
|
+
firstOutDE = outDE;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
if (prevInDE != null) {
|
387
|
+
Assert.isTrue(firstOutDE != null);
|
388
|
+
prevInDE.setNext(firstOutDE);
|
389
|
+
}
|
390
|
+
};
|
391
|
+
|
392
|
+
/**
|
393
|
+
* Traverses a ring of DirectedEdges, accumulating them into a list. This
|
394
|
+
* assumes that all dangling directed edges have been removed from the graph,
|
395
|
+
* so that there is always a next dirEdge.
|
396
|
+
*
|
397
|
+
* @param startDE
|
398
|
+
* the DirectedEdge to start traversing at.
|
399
|
+
* @return a List of DirectedEdges that form a ring.
|
400
|
+
* @private
|
401
|
+
*/
|
402
|
+
PolygonizeGraph.findDirEdgesInRing = function(startDE) {
|
403
|
+
var de = startDE;
|
404
|
+
var edges = new ArrayList();
|
405
|
+
do {
|
406
|
+
edges.add(de);
|
407
|
+
de = de.getNext();
|
408
|
+
Assert.isTrue(de != null, 'found null DE in ring');
|
409
|
+
Assert
|
410
|
+
.isTrue(de == startDE || !de.isInRing(), 'found DE already in ring');
|
411
|
+
} while (de != startDE);
|
412
|
+
|
413
|
+
return edges;
|
414
|
+
};
|
415
|
+
|
416
|
+
/**
|
417
|
+
* @private
|
418
|
+
*/
|
419
|
+
PolygonizeGraph.prototype.findEdgeRing = function(startDE) {
|
420
|
+
var de = startDE;
|
421
|
+
var er = new EdgeRing(this.factory);
|
422
|
+
do {
|
423
|
+
er.add(de);
|
424
|
+
de.setRing(er);
|
425
|
+
de = de.getNext();
|
426
|
+
Assert.isTrue(de != null, 'found null DE in ring');
|
427
|
+
Assert
|
428
|
+
.isTrue(de == startDE || !de.isInRing(), 'found DE already in ring');
|
429
|
+
} while (de != startDE);
|
430
|
+
|
431
|
+
return er;
|
432
|
+
};
|
433
|
+
|
434
|
+
/**
|
435
|
+
* Marks all edges from the graph which are "dangles". Dangles are which are
|
436
|
+
* incident on a node with degree 1. This process is recursive, since removing
|
437
|
+
* a dangling edge may result in another edge becoming a dangle. In order to
|
438
|
+
* handle large recursion depths efficiently, an explicit recursion stack is
|
439
|
+
* used
|
440
|
+
*
|
441
|
+
* @return a List containing the {@link LineStrings} that formed dangles.
|
442
|
+
*/
|
443
|
+
PolygonizeGraph.prototype.deleteDangles = function() {
|
444
|
+
var nodesToRemove = this.findNodesOfDegree(1);
|
445
|
+
var dangleLines = new HashSet();
|
446
|
+
|
447
|
+
var nodeStack = new Stack();
|
448
|
+
for (var i = nodesToRemove.iterator(); i.hasNext();) {
|
449
|
+
nodeStack.push(i.next());
|
450
|
+
}
|
451
|
+
|
452
|
+
while (!nodeStack.isEmpty()) {
|
453
|
+
var node = nodeStack.pop();
|
454
|
+
|
455
|
+
PolygonizeGraph.deleteAllEdges(node);
|
456
|
+
var nodeOutEdges = node.getOutEdges().getEdges();
|
457
|
+
for (var i = nodeOutEdges.iterator(); i.hasNext();) {
|
458
|
+
var de = i.next();
|
459
|
+
// delete this edge and its sym
|
460
|
+
de.setMarked(true);
|
461
|
+
var sym = de.getSym();
|
462
|
+
if (sym != null)
|
463
|
+
sym.setMarked(true);
|
464
|
+
|
465
|
+
// save the line as a dangle
|
466
|
+
var e = de.getEdge();
|
467
|
+
dangleLines.add(e.getLine());
|
468
|
+
|
469
|
+
var toNode = de.getToNode();
|
470
|
+
// add the toNode to the list to be processed, if it is now a dangle
|
471
|
+
if (PolygonizeGraph.getDegreeNonDeleted(toNode) == 1)
|
472
|
+
nodeStack.push(toNode);
|
473
|
+
}
|
474
|
+
}
|
475
|
+
return dangleLines;
|
476
|
+
};
|
477
|
+
|
478
|
+
/**
|
479
|
+
* Traverses the polygonized edge rings in the graph and computes the depth
|
480
|
+
* parity (odd or even) relative to the exterior of the graph. If the client
|
481
|
+
* has requested that the output be polygonally valid, only odd polygons will
|
482
|
+
* be constructed.
|
483
|
+
*
|
484
|
+
*/
|
485
|
+
PolygonizeGraph.prototype.computeDepthParity = function() {
|
486
|
+
while (true) {
|
487
|
+
var de = null;
|
488
|
+
if (de == null)
|
489
|
+
return;
|
490
|
+
this.computeDepthParity(de);
|
491
|
+
}
|
492
|
+
};
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Traverses all connected edges, computing the depth parity of the associated
|
496
|
+
* polygons.
|
497
|
+
*
|
498
|
+
* @param de
|
499
|
+
* @private
|
500
|
+
*/
|
501
|
+
PolygonizeGraph.prototype.computeDepthParity = function(de) {
|
502
|
+
|
503
|
+
};
|
504
|
+
|
505
|
+
jsts.operation.polygonize.PolygonizeGraph = PolygonizeGraph;
|
506
|
+
|
507
|
+
})();
|