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,293 @@
|
|
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
|
+
* Tests whether a <code>Geometry</code> is simple.
|
9
|
+
* In general, the SFS specification of simplicity
|
10
|
+
* follows the rule:
|
11
|
+
* <ul>
|
12
|
+
* <li>A Geometry is simple if and only if the only self-intersections are at
|
13
|
+
* boundary points.</li>
|
14
|
+
* </ul>
|
15
|
+
* This definition relies on the definition of boundary points.
|
16
|
+
* The SFS uses the Mod-2 rule to determine which points are on the boundary of
|
17
|
+
* lineal geometries, but this class supports
|
18
|
+
* using other {@link BoundaryNodeRule}s as well.
|
19
|
+
* <p>
|
20
|
+
* Simplicity is defined for each {@link Geometry} subclass as follows:
|
21
|
+
* <ul>
|
22
|
+
* <li>Valid polygonal geometries are simple by definition, so
|
23
|
+
* <code>isSimple</code> trivially returns true.
|
24
|
+
* (Hint: in order to check if a polygonal geometry has self-intersections,
|
25
|
+
* use {@link Geometry#isValid}).
|
26
|
+
* <li>Linear geometries are simple iff they do not self-intersect at points
|
27
|
+
* other than boundary points.
|
28
|
+
* (Using the Mod-2 rule, this means that closed linestrings
|
29
|
+
* cannot be touched at their endpoints, since these are
|
30
|
+
* interior points, not boundary points).
|
31
|
+
* <li>Zero-dimensional geometries (points) are simple iff they have no
|
32
|
+
* repeated points.
|
33
|
+
* <li>Empty <code>Geometry</code>s are always simple
|
34
|
+
* </ul>
|
35
|
+
*
|
36
|
+
* @see BoundaryNodeRule
|
37
|
+
*/
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Creates a simplicity checker using the default SFS Mod-2 Boundary Node Rule
|
43
|
+
*
|
44
|
+
* @param {Geometry}
|
45
|
+
* geom the geometry to test.
|
46
|
+
* @constructor
|
47
|
+
*/
|
48
|
+
jsts.operation.IsSimpleOp = function(geom) {
|
49
|
+
this.geom = geom;
|
50
|
+
};
|
51
|
+
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @type {jsts.geom.Geometry}
|
55
|
+
*/
|
56
|
+
jsts.operation.IsSimpleOp.prototype.geom = null;
|
57
|
+
|
58
|
+
|
59
|
+
/**
|
60
|
+
* @type {boolean}
|
61
|
+
*/
|
62
|
+
jsts.operation.IsSimpleOp.prototype.isClosedEndpointsInInterior = true;
|
63
|
+
|
64
|
+
|
65
|
+
/**
|
66
|
+
* @type {jsts.geom.Coordinate}
|
67
|
+
*/
|
68
|
+
jsts.operation.IsSimpleOp.prototype.nonSimpleLocation = null;
|
69
|
+
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Creates a simplicity checker using the default SFS Mod-2 Boundary Node Rule
|
73
|
+
*
|
74
|
+
* @param {Geometry}
|
75
|
+
* geom the geometry to test.
|
76
|
+
*/
|
77
|
+
jsts.operation.IsSimpleOp.prototype.IsSimpleOp = function(geom) {
|
78
|
+
this.geom = geom;
|
79
|
+
};
|
80
|
+
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Tests whether the geometry is simple.
|
84
|
+
*
|
85
|
+
* @return {boolean} true if the geometry is simple.
|
86
|
+
*/
|
87
|
+
jsts.operation.IsSimpleOp.prototype.isSimple = function() {
|
88
|
+
this.nonSimpleLocation = null;
|
89
|
+
if (this.geom instanceof jsts.geom.LineString) {
|
90
|
+
return this.isSimpleLinearGeometry(this.geom);
|
91
|
+
}
|
92
|
+
if (this.geom instanceof jsts.geom.MultiLineString) {
|
93
|
+
return this.isSimpleLinearGeometry(this.geom);
|
94
|
+
}
|
95
|
+
if (this.geom instanceof jsts.geom.MultiPoint) {
|
96
|
+
return this.isSimpleMultiPoint(this.geom);
|
97
|
+
}
|
98
|
+
// all other geometry types are simple by definition
|
99
|
+
return true;
|
100
|
+
};
|
101
|
+
|
102
|
+
|
103
|
+
/**
|
104
|
+
* @param {MultiPoint}
|
105
|
+
* mp
|
106
|
+
* @return {boolean} true if the geometry is simple.
|
107
|
+
* @private
|
108
|
+
*/
|
109
|
+
jsts.operation.IsSimpleOp.prototype.isSimpleMultiPoint = function(mp) {
|
110
|
+
if (mp.isEmpty())
|
111
|
+
return true;
|
112
|
+
var points = [];
|
113
|
+
for (var i = 0; i < mp.getNumGeometries(); i++) {
|
114
|
+
var pt = mp.getGeometryN(i);
|
115
|
+
var p = pt.getCoordinate();
|
116
|
+
for (var j = 0; j < points.length; j++) {
|
117
|
+
var point = points[j];
|
118
|
+
if (p.equals2D(point)) {
|
119
|
+
this.nonSimpleLocation = p;
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
points.push(p);
|
124
|
+
}
|
125
|
+
return true;
|
126
|
+
};
|
127
|
+
|
128
|
+
|
129
|
+
/**
|
130
|
+
* @param {Geometry}
|
131
|
+
* geom input geometry.
|
132
|
+
* @return {boolean} true if the geometry is simple.
|
133
|
+
* @private
|
134
|
+
*/
|
135
|
+
jsts.operation.IsSimpleOp.prototype.isSimpleLinearGeometry = function(geom) {
|
136
|
+
if (geom.isEmpty())
|
137
|
+
return true;
|
138
|
+
var graph = new jsts.geomgraph.GeometryGraph(0, geom);
|
139
|
+
var li = new jsts.algorithm.RobustLineIntersector();
|
140
|
+
var si = graph.computeSelfNodes(li, true);
|
141
|
+
// if no self-intersection, must be simple
|
142
|
+
if (!si.hasIntersection())
|
143
|
+
return true;
|
144
|
+
if (si.hasProperIntersection()) {
|
145
|
+
this.nonSimpleLocation = si.getProperIntersectionPoint();
|
146
|
+
return false;
|
147
|
+
}
|
148
|
+
if (this.hasNonEndpointIntersection(graph))
|
149
|
+
return false;
|
150
|
+
if (this.isClosedEndpointsInInterior) {
|
151
|
+
if (this.hasClosedEndpointIntersection(graph))
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
return true;
|
155
|
+
};
|
156
|
+
|
157
|
+
|
158
|
+
/**
|
159
|
+
* For all edges, check if there are any intersections which are NOT at an
|
160
|
+
* endpoint. The Geometry is not simple if there are intersections not at
|
161
|
+
* endpoints.
|
162
|
+
*
|
163
|
+
* @param {GeometryGraph}
|
164
|
+
* graph
|
165
|
+
* @return {boolean}
|
166
|
+
* @private
|
167
|
+
*/
|
168
|
+
jsts.operation.IsSimpleOp.prototype.hasNonEndpointIntersection = function(graph) {
|
169
|
+
for (var i = graph.getEdgeIterator(); i.hasNext(); ) {
|
170
|
+
var e = i.next();
|
171
|
+
var maxSegmentIndex = e.getMaximumSegmentIndex();
|
172
|
+
for (var eiIt = e.getEdgeIntersectionList().iterator(); eiIt.hasNext(); ) {
|
173
|
+
var ei = eiIt.next();
|
174
|
+
if (! ei.isEndPoint(maxSegmentIndex)) {
|
175
|
+
this.nonSimpleLocation = ei.getCoordinate();
|
176
|
+
return true;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
return false;
|
181
|
+
};
|
182
|
+
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Tests that no edge intersection is the endpoint of a closed line. This
|
186
|
+
* ensures that closed lines are not touched at their endpoint, which is an
|
187
|
+
* interior point according to the Mod-2 rule To check this we compute the
|
188
|
+
* degree of each endpoint. The degree of endpoints of closed lines must be
|
189
|
+
* exactly 2.
|
190
|
+
*
|
191
|
+
* @param {GeometryGraph}
|
192
|
+
* graph
|
193
|
+
* @return {boolean}
|
194
|
+
* @private
|
195
|
+
*/
|
196
|
+
jsts.operation.IsSimpleOp.prototype.hasClosedEndpointIntersection = function(
|
197
|
+
graph) {
|
198
|
+
var endPoints = new javascript.util.TreeMap();
|
199
|
+
for (var i = graph.getEdgeIterator(); i.hasNext(); ) {
|
200
|
+
var e = i.next();
|
201
|
+
var maxSegmentIndex = e.getMaximumSegmentIndex();
|
202
|
+
var isClosed = e.isClosed();
|
203
|
+
var p0 = e.getCoordinate(0);
|
204
|
+
this.addEndpoint(endPoints, p0, isClosed);
|
205
|
+
var p1 = e.getCoordinate(e.getNumPoints() - 1);
|
206
|
+
this.addEndpoint(endPoints, p1, isClosed);
|
207
|
+
}
|
208
|
+
|
209
|
+
for (var i = endPoints.values().iterator(); i.hasNext(); ) {
|
210
|
+
var eiInfo = i.next();
|
211
|
+
if (eiInfo.isClosed && eiInfo.degree != 2) {
|
212
|
+
this.nonSimpleLocation = eiInfo.getCoordinate();
|
213
|
+
return true;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
return false;
|
217
|
+
};
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
/**
|
222
|
+
* private
|
223
|
+
*
|
224
|
+
* @constructor
|
225
|
+
*/
|
226
|
+
jsts.operation.IsSimpleOp.EndpointInfo = function(pt) {
|
227
|
+
|
228
|
+
this.pt = pt;
|
229
|
+
this.isClosed = false;
|
230
|
+
this.degree = 0;
|
231
|
+
};
|
232
|
+
|
233
|
+
|
234
|
+
/**
|
235
|
+
* @type {Coordinate}
|
236
|
+
* @private
|
237
|
+
*/
|
238
|
+
jsts.operation.IsSimpleOp.EndpointInfo.prototype.pt = null;
|
239
|
+
|
240
|
+
|
241
|
+
/**
|
242
|
+
* @type {boolean}
|
243
|
+
* @private
|
244
|
+
*/
|
245
|
+
jsts.operation.IsSimpleOp.EndpointInfo.prototype.isClosed = null;
|
246
|
+
|
247
|
+
|
248
|
+
/**
|
249
|
+
* @type {int}
|
250
|
+
* @private
|
251
|
+
*/
|
252
|
+
jsts.operation.IsSimpleOp.EndpointInfo.prototype.degree = null;
|
253
|
+
|
254
|
+
|
255
|
+
/**
|
256
|
+
* @return {Coordinate}
|
257
|
+
*/
|
258
|
+
jsts.operation.IsSimpleOp.EndpointInfo.prototype.getCoordinate = function() {
|
259
|
+
return this.pt;
|
260
|
+
};
|
261
|
+
|
262
|
+
|
263
|
+
/**
|
264
|
+
* @param {boolean}
|
265
|
+
* isClosed
|
266
|
+
*/
|
267
|
+
jsts.operation.IsSimpleOp.EndpointInfo.prototype.addEndpoint = function(
|
268
|
+
isClosed) {
|
269
|
+
this.degree++;
|
270
|
+
this.isClosed = this.isClosed || isClosed;
|
271
|
+
};
|
272
|
+
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Add an endpoint to the map, creating an entry for it if none exists
|
276
|
+
*
|
277
|
+
* @param {javascript.util.Map}
|
278
|
+
* endPoints
|
279
|
+
* @param {jsts.geom.Coordinate}
|
280
|
+
* p
|
281
|
+
* @param {boolean}
|
282
|
+
* isClosed
|
283
|
+
* @private
|
284
|
+
*/
|
285
|
+
jsts.operation.IsSimpleOp.prototype.addEndpoint = function(endPoints, p,
|
286
|
+
isClosed) {
|
287
|
+
var eiInfo = endPoints.get(p);
|
288
|
+
if (eiInfo === null) {
|
289
|
+
eiInfo = new jsts.operation.IsSimpleOp.EndpointInfo(p);
|
290
|
+
endPoints.put(p, eiInfo);
|
291
|
+
}
|
292
|
+
eiInfo.addEndpoint(isClosed);
|
293
|
+
};
|
@@ -0,0 +1,317 @@
|
|
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
|
+
* Builds the buffer geometry for a given input geometry and precision model.
|
11
|
+
* Allows setting the level of approximation for circular arcs, and the
|
12
|
+
* precision model in which to carry out the computation.
|
13
|
+
* <p>
|
14
|
+
* When computing buffers in floating point double-precision it can happen that
|
15
|
+
* the process of iterated noding can fail to converge (terminate). In this case
|
16
|
+
* a TopologyException will be thrown. Retrying the computation in a fixed
|
17
|
+
* precision can produce more robust results.
|
18
|
+
*
|
19
|
+
* @param {jsts.operation.buffer.BufferBuilder.BufferParameters}
|
20
|
+
* bufParams
|
21
|
+
* @constructor
|
22
|
+
*/
|
23
|
+
jsts.operation.buffer.BufferBuilder = function(bufParams) {
|
24
|
+
this.bufParams = bufParams;
|
25
|
+
|
26
|
+
this.edgeList = new jsts.geomgraph.EdgeList();
|
27
|
+
};
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Compute the change in depth as an edge is crossed from R to L
|
32
|
+
*
|
33
|
+
* @param {Label}
|
34
|
+
* label
|
35
|
+
* @return {Number}
|
36
|
+
*/
|
37
|
+
jsts.operation.buffer.BufferBuilder.depthDelta = function(label) {
|
38
|
+
var lLoc = label.getLocation(0, jsts.geomgraph.Position.LEFT);
|
39
|
+
var rLoc = label.getLocation(0, jsts.geomgraph.Position.RIGHT);
|
40
|
+
if (lLoc === jsts.geom.Location.INTERIOR &&
|
41
|
+
rLoc === jsts.geom.Location.EXTERIOR)
|
42
|
+
return 1;
|
43
|
+
else if (lLoc === jsts.geom.Location.EXTERIOR &&
|
44
|
+
rLoc === jsts.geom.Location.INTERIOR)
|
45
|
+
return -1;
|
46
|
+
return 0;
|
47
|
+
};
|
48
|
+
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @type {BufferParameters}
|
52
|
+
* @private
|
53
|
+
*/
|
54
|
+
jsts.operation.buffer.BufferBuilder.prototype.bufParams = null;
|
55
|
+
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @type {PrecisionModel}
|
59
|
+
* @private
|
60
|
+
*/
|
61
|
+
jsts.operation.buffer.BufferBuilder.prototype.workingPrecisionModel = null;
|
62
|
+
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @type {Noder}
|
66
|
+
* @private
|
67
|
+
*/
|
68
|
+
jsts.operation.buffer.BufferBuilder.prototype.workingNoder = null;
|
69
|
+
|
70
|
+
|
71
|
+
/**
|
72
|
+
* @type {GeometryFactory}
|
73
|
+
* @private
|
74
|
+
*/
|
75
|
+
jsts.operation.buffer.BufferBuilder.prototype.geomFact = null;
|
76
|
+
|
77
|
+
|
78
|
+
/**
|
79
|
+
* @type {PlanarGraph}
|
80
|
+
* @private
|
81
|
+
*/
|
82
|
+
jsts.operation.buffer.BufferBuilder.prototype.graph = null;
|
83
|
+
|
84
|
+
|
85
|
+
/**
|
86
|
+
* @type {EdgeList}
|
87
|
+
* @private
|
88
|
+
*/
|
89
|
+
jsts.operation.buffer.BufferBuilder.prototype.edgeList = null;
|
90
|
+
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Sets the precision model to use during the curve computation and noding, if
|
94
|
+
* it is different to the precision model of the Geometry. If the precision
|
95
|
+
* model is less than the precision of the Geometry precision model, the
|
96
|
+
* Geometry must have previously been rounded to that precision.
|
97
|
+
*
|
98
|
+
* @param pm
|
99
|
+
* the precision model to use.
|
100
|
+
*/
|
101
|
+
jsts.operation.buffer.BufferBuilder.prototype.setWorkingPrecisionModel = function(
|
102
|
+
pm) {
|
103
|
+
this.workingPrecisionModel = pm;
|
104
|
+
};
|
105
|
+
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Sets the {@link Noder} to use during noding. This allows choosing fast but
|
109
|
+
* non-robust noding, or slower but robust noding.
|
110
|
+
*
|
111
|
+
* @param noder
|
112
|
+
* the noder to use.
|
113
|
+
*/
|
114
|
+
jsts.operation.buffer.BufferBuilder.prototype.setNoder = function(noder) {
|
115
|
+
this.workingNoder = noder;
|
116
|
+
};
|
117
|
+
|
118
|
+
jsts.operation.buffer.BufferBuilder.prototype.buffer = function(g, distance) {
|
119
|
+
var precisionModel = this.workingPrecisionModel;
|
120
|
+
if (precisionModel === null)
|
121
|
+
precisionModel = g.getPrecisionModel();
|
122
|
+
|
123
|
+
// factory must be the same as the one used by the input
|
124
|
+
this.geomFact = g.getFactory();
|
125
|
+
|
126
|
+
var curveBuilder = new jsts.operation.buffer.OffsetCurveBuilder(
|
127
|
+
precisionModel, this.bufParams);
|
128
|
+
|
129
|
+
var curveSetBuilder = new jsts.operation.buffer.OffsetCurveSetBuilder(g,
|
130
|
+
distance, curveBuilder);
|
131
|
+
|
132
|
+
var bufferSegStrList = curveSetBuilder.getCurves();
|
133
|
+
|
134
|
+
// short-circuit test
|
135
|
+
if (bufferSegStrList.size() <= 0) {
|
136
|
+
return this.createEmptyResultGeometry();
|
137
|
+
}
|
138
|
+
|
139
|
+
this.computeNodedEdges(bufferSegStrList, precisionModel);
|
140
|
+
this.graph = new jsts.geomgraph.PlanarGraph(
|
141
|
+
new jsts.operation.overlay.OverlayNodeFactory());
|
142
|
+
this.graph.addEdges(this.edgeList.getEdges());
|
143
|
+
|
144
|
+
var subgraphList = this.createSubgraphs(this.graph);
|
145
|
+
var polyBuilder = new jsts.operation.overlay.PolygonBuilder(this.geomFact);
|
146
|
+
this.buildSubgraphs(subgraphList, polyBuilder);
|
147
|
+
var resultPolyList = polyBuilder.getPolygons();
|
148
|
+
|
149
|
+
// just in case...
|
150
|
+
if (resultPolyList.size() <= 0) {
|
151
|
+
return this.createEmptyResultGeometry();
|
152
|
+
}
|
153
|
+
|
154
|
+
var resultGeom = this.geomFact.buildGeometry(resultPolyList);
|
155
|
+
return resultGeom;
|
156
|
+
};
|
157
|
+
|
158
|
+
|
159
|
+
/**
|
160
|
+
* @private
|
161
|
+
*/
|
162
|
+
jsts.operation.buffer.BufferBuilder.prototype.getNoder = function(
|
163
|
+
precisionModel) {
|
164
|
+
if (this.workingNoder !== null)
|
165
|
+
return this.workingNoder;
|
166
|
+
|
167
|
+
// otherwise use a fast (but non-robust) noder
|
168
|
+
var noder = new jsts.noding.MCIndexNoder();
|
169
|
+
var li = new jsts.algorithm.RobustLineIntersector();
|
170
|
+
li.setPrecisionModel(precisionModel);
|
171
|
+
noder.setSegmentIntersector(new jsts.noding.IntersectionAdder(li));
|
172
|
+
return noder;
|
173
|
+
};
|
174
|
+
|
175
|
+
|
176
|
+
/**
|
177
|
+
* @private
|
178
|
+
*/
|
179
|
+
jsts.operation.buffer.BufferBuilder.prototype.computeNodedEdges = function(
|
180
|
+
bufferSegStrList, precisionModel) {
|
181
|
+
var noder = this.getNoder(precisionModel);
|
182
|
+
noder.computeNodes(bufferSegStrList);
|
183
|
+
var nodedSegStrings = noder.getNodedSubstrings();
|
184
|
+
|
185
|
+
for (var i = nodedSegStrings.iterator(); i.hasNext();) {
|
186
|
+
var segStr = i.next();
|
187
|
+
var oldLabel = segStr.getData();
|
188
|
+
var edge = new jsts.geomgraph.Edge(segStr.getCoordinates(),
|
189
|
+
new jsts.geomgraph.Label(oldLabel));
|
190
|
+
this.insertUniqueEdge(edge);
|
191
|
+
}
|
192
|
+
};
|
193
|
+
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Inserted edges are checked to see if an identical edge already exists. If so,
|
197
|
+
* the edge is not inserted, but its label is merged with the existing edge.
|
198
|
+
*
|
199
|
+
* @protected
|
200
|
+
*/
|
201
|
+
jsts.operation.buffer.BufferBuilder.prototype.insertUniqueEdge = function(e) {
|
202
|
+
var existingEdge = this.edgeList.findEqualEdge(e);
|
203
|
+
|
204
|
+
// If an identical edge already exists, simply update its label
|
205
|
+
if (existingEdge != null) {
|
206
|
+
var existingLabel = existingEdge.getLabel();
|
207
|
+
|
208
|
+
var labelToMerge = e.getLabel();
|
209
|
+
// check if new edge is in reverse direction to existing edge
|
210
|
+
// if so, must flip the label before merging it
|
211
|
+
if (!existingEdge.isPointwiseEqual(e)) {
|
212
|
+
labelToMerge = new jsts.geomgraph.Label(e.getLabel());
|
213
|
+
labelToMerge.flip();
|
214
|
+
}
|
215
|
+
existingLabel.merge(labelToMerge);
|
216
|
+
|
217
|
+
// compute new depth delta of sum of edges
|
218
|
+
var mergeDelta = jsts.operation.buffer.BufferBuilder
|
219
|
+
.depthDelta(labelToMerge);
|
220
|
+
var existingDelta = existingEdge.getDepthDelta();
|
221
|
+
var newDelta = existingDelta + mergeDelta;
|
222
|
+
existingEdge.setDepthDelta(newDelta);
|
223
|
+
} else {
|
224
|
+
// no matching existing edge was found
|
225
|
+
// add this new edge to the list of edges in this graph
|
226
|
+
this.edgeList.add(e);
|
227
|
+
e.setDepthDelta(jsts.operation.buffer.BufferBuilder
|
228
|
+
.depthDelta(e.getLabel()));
|
229
|
+
}
|
230
|
+
};
|
231
|
+
|
232
|
+
|
233
|
+
/**
|
234
|
+
* @param {PlanarGraph}
|
235
|
+
* graph
|
236
|
+
* @private
|
237
|
+
*/
|
238
|
+
jsts.operation.buffer.BufferBuilder.prototype.createSubgraphs = function(graph) {
|
239
|
+
var subgraphList = [];
|
240
|
+
for (var i = graph.getNodes().iterator(); i.hasNext();) {
|
241
|
+
var node = i.next();
|
242
|
+
if (!node.isVisited()) {
|
243
|
+
var subgraph = new jsts.operation.buffer.BufferSubgraph();
|
244
|
+
subgraph.create(node);
|
245
|
+
subgraphList.push(subgraph);
|
246
|
+
}
|
247
|
+
}
|
248
|
+
/**
|
249
|
+
* Sort the subgraphs in descending order of their rightmost coordinate. This
|
250
|
+
* ensures that when the Polygons for the subgraphs are built, subgraphs for
|
251
|
+
* shells will have been built before the subgraphs for any holes they
|
252
|
+
* contain.
|
253
|
+
*/
|
254
|
+
|
255
|
+
var compare = function(a, b) {
|
256
|
+
return a.compareTo(b);
|
257
|
+
};
|
258
|
+
subgraphList.sort(compare);
|
259
|
+
subgraphList.reverse();
|
260
|
+
return subgraphList;
|
261
|
+
};
|
262
|
+
|
263
|
+
|
264
|
+
/**
|
265
|
+
* Completes the building of the input subgraphs by depth-labelling them, and
|
266
|
+
* adds them to the PolygonBuilder. The subgraph list must be sorted in
|
267
|
+
* rightmost-coordinate order.
|
268
|
+
*
|
269
|
+
* @param {Array}
|
270
|
+
* subgraphList the subgraphs to build.
|
271
|
+
* @param {PolygonBuilder}
|
272
|
+
* polyBuilder the PolygonBuilder which will build the final polygons.
|
273
|
+
* @private
|
274
|
+
*/
|
275
|
+
jsts.operation.buffer.BufferBuilder.prototype.buildSubgraphs = function(
|
276
|
+
subgraphList, polyBuilder) {
|
277
|
+
var processedGraphs = [];
|
278
|
+
for (var i = 0; i < subgraphList.length; i++) {
|
279
|
+
var subgraph = subgraphList[i];
|
280
|
+
var p = subgraph.getRightmostCoordinate();
|
281
|
+
var locater = new jsts.operation.buffer.SubgraphDepthLocater(
|
282
|
+
processedGraphs);
|
283
|
+
var outsideDepth = locater.getDepth(p);
|
284
|
+
subgraph.computeDepth(outsideDepth);
|
285
|
+
subgraph.findResultEdges();
|
286
|
+
processedGraphs.push(subgraph);
|
287
|
+
polyBuilder.add(subgraph.getDirectedEdges(), subgraph.getNodes());
|
288
|
+
}
|
289
|
+
};
|
290
|
+
|
291
|
+
|
292
|
+
/**
|
293
|
+
* @private
|
294
|
+
*/
|
295
|
+
jsts.operation.buffer.BufferBuilder.convertSegStrings = function(it) {
|
296
|
+
var fact = new jsts.geom.GeometryFactory();
|
297
|
+
var lines = new javascript.util.ArrayList();
|
298
|
+
while (it.hasNext()) {
|
299
|
+
var ss = it.next();
|
300
|
+
var line = fact.createLineString(ss.getCoordinates());
|
301
|
+
lines.add(line);
|
302
|
+
}
|
303
|
+
return fact.buildGeometry(lines);
|
304
|
+
};
|
305
|
+
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Gets the standard result for an empty buffer. Since buffer always returns a
|
309
|
+
* polygonal result, this is chosen to be an empty polygon.
|
310
|
+
*
|
311
|
+
* @return the empty result geometry.
|
312
|
+
* @private
|
313
|
+
*/
|
314
|
+
jsts.operation.buffer.BufferBuilder.prototype.createEmptyResultGeometry = function() {
|
315
|
+
var emptyGeom = this.geomFact.createPolygon(null, null);
|
316
|
+
return emptyGeom;
|
317
|
+
};
|