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,259 @@
|
|
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
|
+
* This class tests that the interior of an area {@link Geometry} (
|
9
|
+
* {@link Polygon} or {@link MultiPolygon} ) is connected. This can happen if:
|
10
|
+
* <ul>
|
11
|
+
* <li>a shell self-intersects
|
12
|
+
* <li>one or more holes form a connected chain touching a shell at two
|
13
|
+
* different points
|
14
|
+
* <li>one or more holes form a ring around a subset of the interior
|
15
|
+
* </ul>
|
16
|
+
* If a disconnected situation is found the location of the problem is recorded.
|
17
|
+
*
|
18
|
+
* @version 1.7
|
19
|
+
* @constructor
|
20
|
+
*/
|
21
|
+
jsts.operation.valid.ConnectedInteriorTester = function(geomGraph) {
|
22
|
+
this.geomGraph = geomGraph;
|
23
|
+
this.geometryFactory = new jsts.geom.GeometryFactory();
|
24
|
+
|
25
|
+
// save a coordinate for any disconnected interior found
|
26
|
+
// the coordinate will be somewhere on the ring surrounding the disconnected
|
27
|
+
// interior
|
28
|
+
this.disconnectedRingcoord = null;
|
29
|
+
};
|
30
|
+
|
31
|
+
/**
|
32
|
+
* @param {jsts.geom.Coordinate[]}
|
33
|
+
* coord A coordinate array.
|
34
|
+
* @param {jsts.geom.Coordinate}
|
35
|
+
* pt
|
36
|
+
* @return {jsts.geom.Coordinate}
|
37
|
+
*/
|
38
|
+
jsts.operation.valid.ConnectedInteriorTester.findDifferentPoint = function(
|
39
|
+
coord, pt) {
|
40
|
+
var i = 0, il = coord.length;
|
41
|
+
for (i; i < il; i++) {
|
42
|
+
if (!coord[i].equals(pt))
|
43
|
+
return coord[i];
|
44
|
+
}
|
45
|
+
return null;
|
46
|
+
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Returns the coordinate for a disconnected interior
|
50
|
+
*
|
51
|
+
* @return {jsts.geom.Coordinate} the coordinate.
|
52
|
+
*/
|
53
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.getCoordinate = function() {
|
54
|
+
return this.disconnectedRingcoord;
|
55
|
+
};
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @return {Boolean}
|
59
|
+
*/
|
60
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.isInteriorsConnected = function() {
|
61
|
+
// node the edges, in case holes touch the shell
|
62
|
+
var splitEdges = new javascript.util.ArrayList();
|
63
|
+
this.geomGraph.computeSplitEdges(splitEdges);
|
64
|
+
|
65
|
+
// form the edges into rings
|
66
|
+
var graph = new jsts.geomgraph.PlanarGraph(
|
67
|
+
new jsts.operation.overlay.OverlayNodeFactory());
|
68
|
+
graph.addEdges(splitEdges);
|
69
|
+
|
70
|
+
this.setInteriorEdgesInResult(graph);
|
71
|
+
graph.linkResultDirectedEdges();
|
72
|
+
|
73
|
+
var edgeRings = this.buildEdgeRings(graph.getEdgeEnds());
|
74
|
+
|
75
|
+
/**
|
76
|
+
*
|
77
|
+
* Mark all the edges for the edgeRings corresponding to the shells
|
78
|
+
*
|
79
|
+
* of the input polygons. Note only ONE ring gets marked for each shell.
|
80
|
+
*
|
81
|
+
*/
|
82
|
+
|
83
|
+
this.visitShellInteriors(this.geomGraph.getGeometry(), graph);
|
84
|
+
|
85
|
+
|
86
|
+
/**
|
87
|
+
*
|
88
|
+
* If there are any unvisited shell edges
|
89
|
+
*
|
90
|
+
* (i.e. a ring which is not a hole and which has the interior
|
91
|
+
*
|
92
|
+
* of the parent area on the RHS)
|
93
|
+
*
|
94
|
+
* this means that one or more holes must have split the interior of the
|
95
|
+
*
|
96
|
+
* polygon into at least two pieces. The polygon is thus invalid.
|
97
|
+
*
|
98
|
+
*/
|
99
|
+
|
100
|
+
return !this.hasUnvisitedShellEdge(edgeRings);
|
101
|
+
};
|
102
|
+
|
103
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.setInteriorEdgesInResult = function(
|
104
|
+
graph) {
|
105
|
+
var it = graph.getEdgeEnds().iterator(), de;
|
106
|
+
|
107
|
+
while (it.hasNext()) {
|
108
|
+
de = it.next();
|
109
|
+
if (de.getLabel().getLocation(0, jsts.geomgraph.Position.RIGHT) == jsts.geom.Location.INTERIOR) {
|
110
|
+
de.setInResult(true);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
/**
|
116
|
+
*
|
117
|
+
* Form DirectedEdges in graph into Minimal EdgeRings. (Minimal Edgerings must
|
118
|
+
* be used, because only they are guaranteed to provide a correct isHole
|
119
|
+
* computation)
|
120
|
+
*
|
121
|
+
*/
|
122
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.buildEdgeRings = function(
|
123
|
+
dirEdges) {
|
124
|
+
var edgeRings = new javascript.util.ArrayList();
|
125
|
+
for (var it = dirEdges.iterator(); it.hasNext();) {
|
126
|
+
|
127
|
+
var de = it.next();
|
128
|
+
|
129
|
+
// if this edge has not yet been processed
|
130
|
+
if (de.isInResult()
|
131
|
+
|
132
|
+
&& de.getEdgeRing() == null) {
|
133
|
+
|
134
|
+
var er = new jsts.operation.overlay.MaximalEdgeRing(de,
|
135
|
+
this.geometryFactory);
|
136
|
+
er.linkDirectedEdgesForMinimalEdgeRings();
|
137
|
+
|
138
|
+
var minEdgeRings = er.buildMinimalRings();
|
139
|
+
|
140
|
+
var i = 0, il = minEdgeRings.length;
|
141
|
+
for (i; i < il; i++) {
|
142
|
+
edgeRings.add(minEdgeRings[i]);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
return edgeRings;
|
148
|
+
};
|
149
|
+
|
150
|
+
/**
|
151
|
+
*
|
152
|
+
* Mark all the edges for the edgeRings corresponding to the shells of the input
|
153
|
+
* polygons. Only ONE ring gets marked for each shell - if there are others
|
154
|
+
* which remain unmarked this indicates a disconnected interior.
|
155
|
+
*
|
156
|
+
*/
|
157
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.visitShellInteriors = function(
|
158
|
+
g, graph) {
|
159
|
+
if (g instanceof jsts.geom.Polygon) {
|
160
|
+
var p = g;
|
161
|
+
this.visitInteriorRing(p.getExteriorRing(), graph);
|
162
|
+
}
|
163
|
+
|
164
|
+
if (g instanceof jsts.geom.MultiPolygon) {
|
165
|
+
var mp = g;
|
166
|
+
for (var i = 0; i < mp.getNumGeometries(); i++) {
|
167
|
+
var p = mp.getGeometryN(i);
|
168
|
+
this.visitInteriorRing(p.getExteriorRing(), graph);
|
169
|
+
}
|
170
|
+
}
|
171
|
+
};
|
172
|
+
|
173
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.visitInteriorRing = function(
|
174
|
+
ring, graph) {
|
175
|
+
|
176
|
+
var pts = ring.getCoordinates();
|
177
|
+
var pt0 = pts[0];
|
178
|
+
|
179
|
+
/**
|
180
|
+
*
|
181
|
+
* Find first point in coord list different to initial point. Need special
|
182
|
+
* check since the first point may be repeated.
|
183
|
+
*
|
184
|
+
*/
|
185
|
+
var pt1 = jsts.operation.valid.ConnectedInteriorTester.findDifferentPoint(
|
186
|
+
pts, pt0);
|
187
|
+
var e = graph.findEdgeInSameDirection(pt0, pt1);
|
188
|
+
var de = graph.findEdgeEnd(e);
|
189
|
+
var intDe = null;
|
190
|
+
|
191
|
+
if (de.getLabel().getLocation(0, jsts.geomgraph.Position.RIGHT) == jsts.geom.Location.INTERIOR) {
|
192
|
+
intDe = de;
|
193
|
+
} else if (de.getSym().getLabel().getLocation(0,
|
194
|
+
jsts.geomgraph.Position.RIGHT) == jsts.geom.Location.INTERIOR) {
|
195
|
+
intDe = de.getSym();
|
196
|
+
}
|
197
|
+
|
198
|
+
this.visitLinkedDirectedEdges(intDe);
|
199
|
+
};
|
200
|
+
|
201
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.visitLinkedDirectedEdges = function(
|
202
|
+
start) {
|
203
|
+
var startDe = start;
|
204
|
+
var de = start;
|
205
|
+
do {
|
206
|
+
de.setVisited(true);
|
207
|
+
de = de.getNext();
|
208
|
+
} while (de != startDe);
|
209
|
+
};
|
210
|
+
|
211
|
+
/**
|
212
|
+
*
|
213
|
+
* Check if any shell ring has an unvisited edge. A shell ring is a ring which
|
214
|
+
* is not a hole and which has the interior of the parent area on the RHS. (Note
|
215
|
+
* that there may be non-hole rings with the interior on the LHS, since the
|
216
|
+
* interior of holes will also be polygonized into CW rings by the
|
217
|
+
* linkAllDirectedEdges() step)
|
218
|
+
*
|
219
|
+
* @return {Boolean} true if there is an unvisited edge in a non-hole ring.
|
220
|
+
*/
|
221
|
+
|
222
|
+
jsts.operation.valid.ConnectedInteriorTester.prototype.hasUnvisitedShellEdge = function(
|
223
|
+
edgeRings) {
|
224
|
+
for (var i = 0; i < edgeRings.size(); i++) {
|
225
|
+
var er = edgeRings.get(i);
|
226
|
+
|
227
|
+
// don't check hole rings
|
228
|
+
if (er.isHole()) {
|
229
|
+
continue;
|
230
|
+
}
|
231
|
+
|
232
|
+
var edges = er.getEdges();
|
233
|
+
var de = edges[0];
|
234
|
+
|
235
|
+
// don't check CW rings which are holes
|
236
|
+
// (MD - this check may now be irrelevant)
|
237
|
+
if (de.getLabel().getLocation(0, jsts.geomgraph.Position.RIGHT) != jsts.geom.Location.INTERIOR) {
|
238
|
+
continue;
|
239
|
+
}
|
240
|
+
|
241
|
+
/**
|
242
|
+
*
|
243
|
+
* the edgeRing is CW ring which surrounds the INT of the area, so check all
|
244
|
+
*
|
245
|
+
* edges have been visited. If any are unvisited, this is a disconnected
|
246
|
+
* part of the interior
|
247
|
+
*
|
248
|
+
*/
|
249
|
+
|
250
|
+
for (var j = 0; j < edges.length; j++) {
|
251
|
+
de = edges[j];
|
252
|
+
if (!de.isVisited()) {
|
253
|
+
disconnectedRingcoord = de.getCoordinate();
|
254
|
+
return true;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
return false;
|
259
|
+
};
|
@@ -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
|
+
* Checks that a {@link GeometryGraph} representing an area
|
9
|
+
* (a {@link Polygon} or {@link MultiPolygon} )
|
10
|
+
* has consistent semantics for area geometries.
|
11
|
+
* This check is required for any reasonable polygonal model
|
12
|
+
* (including the OGC-SFS model, as well as models which allow ring self-intersection at single points)
|
13
|
+
* <p>
|
14
|
+
* Checks include:
|
15
|
+
* <ul>
|
16
|
+
* <li>test for rings which properly intersect
|
17
|
+
* (but not for ring self-intersection, or intersections at vertices)
|
18
|
+
* <li>test for consistent labelling at all node points
|
19
|
+
* (this detects vertex intersections with invalid topology,
|
20
|
+
* i.e. where the exterior side of an edge lies in the interior of the area)
|
21
|
+
* <li>test for duplicate rings
|
22
|
+
* </ul>
|
23
|
+
* If an inconsistency is found the location of the problem
|
24
|
+
* is recorded and is available to the caller.
|
25
|
+
*
|
26
|
+
* @version 1.7
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
*
|
32
|
+
* Creates a new tester for consistent areas.
|
33
|
+
*
|
34
|
+
*
|
35
|
+
*
|
36
|
+
* @param geomGraph
|
37
|
+
* the topology graph of the area geometry.
|
38
|
+
*
|
39
|
+
*/
|
40
|
+
jsts.operation.valid.ConsistentAreaTester = function(geomGraph) {
|
41
|
+
this.geomGraph = geomGraph;
|
42
|
+
this.li = new jsts.algorithm.RobustLineIntersector();
|
43
|
+
this.nodeGraph = new jsts.operation.relate.RelateNodeGraph();
|
44
|
+
this.invalidPoint = null;
|
45
|
+
};
|
46
|
+
|
47
|
+
/**
|
48
|
+
*
|
49
|
+
* @return the intersection point, or <code>null</code> if none was found.
|
50
|
+
*
|
51
|
+
*/
|
52
|
+
jsts.operation.valid.ConsistentAreaTester.prototype.getInvalidPoint = function() {
|
53
|
+
return this.invalidPoint;
|
54
|
+
};
|
55
|
+
|
56
|
+
/**
|
57
|
+
*
|
58
|
+
* Check all nodes to see if their labels are consistent with area topology.
|
59
|
+
*
|
60
|
+
* @return <code>true</code> if this area has a consistent node labelling.
|
61
|
+
*
|
62
|
+
*/
|
63
|
+
jsts.operation.valid.ConsistentAreaTester.prototype.isNodeConsistentArea = function() {
|
64
|
+
/**
|
65
|
+
*
|
66
|
+
* To fully check validity, it is necessary to compute ALL intersections,
|
67
|
+
* including self-intersections within a single edge.
|
68
|
+
*
|
69
|
+
*/
|
70
|
+
var intersector = this.geomGraph.computeSelfNodes(this.li, true);
|
71
|
+
if (intersector.hasProperIntersection()) {
|
72
|
+
this.invalidPoint = intersector.getProperIntersectionPoint();
|
73
|
+
return false;
|
74
|
+
}
|
75
|
+
|
76
|
+
this.nodeGraph.build(this.geomGraph);
|
77
|
+
return this.isNodeEdgeAreaLabelsConsistent();
|
78
|
+
};
|
79
|
+
|
80
|
+
/**
|
81
|
+
*
|
82
|
+
* Check all nodes to see if their labels are consistent. If any are not, return
|
83
|
+
* false
|
84
|
+
*
|
85
|
+
* @return <code>true</code> if the edge area labels are consistent at this
|
86
|
+
* node.
|
87
|
+
*
|
88
|
+
*/
|
89
|
+
jsts.operation.valid.ConsistentAreaTester.prototype.isNodeEdgeAreaLabelsConsistent = function() {
|
90
|
+
for (var nodeIt = this.nodeGraph.getNodeIterator(); nodeIt.hasNext();) {
|
91
|
+
var node = nodeIt.next();
|
92
|
+
if (!node.getEdges().isAreaLabelsConsistent(this.geomGraph)) {
|
93
|
+
this.invalidPoint = node.getCoordinate().clone();
|
94
|
+
return false;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
return true;
|
98
|
+
};
|
99
|
+
|
100
|
+
/**
|
101
|
+
*
|
102
|
+
* Checks for two duplicate rings in an area. Duplicate rings are rings that are
|
103
|
+
* topologically equal (that is, which have the same sequence of points up to
|
104
|
+
* point order). If the area is topologically consistent (determined by calling
|
105
|
+
* the <code>isNodeConsistentArea</code>, duplicate rings can be found by
|
106
|
+
* checking for EdgeBundles which contain more than one EdgeEnd. (This is
|
107
|
+
* because topologically consistent areas cannot have two rings sharing the same
|
108
|
+
* line segment, unless the rings are equal). The start point of one of the
|
109
|
+
* equal rings will be placed in invalidPoint.
|
110
|
+
*
|
111
|
+
* @return true if this area Geometry is topologically consistent but has two
|
112
|
+
* duplicate rings.
|
113
|
+
*
|
114
|
+
*/
|
115
|
+
jsts.operation.valid.ConsistentAreaTester.prototype.hasDuplicateRings = function() {
|
116
|
+
for (var nodeIt = this.nodeGraph.getNodeIterator(); nodeIt.hasNext();) {
|
117
|
+
var node = nodeIt.next();
|
118
|
+
for (var i = node.getEdges().iterator(); i.hasNext();) {
|
119
|
+
var eeb = i.next();
|
120
|
+
if (eeb.getEdgeEnds().length > 1) {
|
121
|
+
invalidPoint = eeb.getEdge().getCoordinate(0);
|
122
|
+
return true;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
return false;
|
127
|
+
};
|
@@ -0,0 +1,89 @@
|
|
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
|
+
* Tests whether any of a set of {@link LinearRing}s are nested inside another
|
10
|
+
* ring in the set, using a spatial index to speed up the comparisons.
|
11
|
+
*
|
12
|
+
* @version 1.7
|
13
|
+
*/
|
14
|
+
|
15
|
+
jsts.operation.valid.IndexedNestedRingTester = function(graph) {
|
16
|
+
this.graph = graph;
|
17
|
+
this.rings = new javascript.util.ArrayList();
|
18
|
+
this.totalEnv = new jsts.geom.Envelope();
|
19
|
+
this.index = null;
|
20
|
+
this.nestedPt = null;
|
21
|
+
};
|
22
|
+
|
23
|
+
jsts.operation.valid.IndexedNestedRingTester.prototype.getNestedPoint = function() {
|
24
|
+
return this.nestedPt;
|
25
|
+
};
|
26
|
+
|
27
|
+
jsts.operation.valid.IndexedNestedRingTester.prototype.add = function(ring) {
|
28
|
+
this.rings.add(ring);
|
29
|
+
this.totalEnv.expandToInclude(ring.getEnvelopeInternal());
|
30
|
+
};
|
31
|
+
|
32
|
+
jsts.operation.valid.IndexedNestedRingTester.prototype.isNonNested = function() {
|
33
|
+
this.buildIndex();
|
34
|
+
for (var i = 0; i < this.rings.size(); i++) {
|
35
|
+
var innerRing = this.rings.get(i);
|
36
|
+
var innerRingPts = innerRing.getCoordinates();
|
37
|
+
var results = this.index.query(innerRing.getEnvelopeInternal());
|
38
|
+
|
39
|
+
for (var j = 0; j < results.length; j++) {
|
40
|
+
var searchRing = results[j];
|
41
|
+
var searchRingPts = searchRing.getCoordinates();
|
42
|
+
|
43
|
+
if (innerRing == searchRing) {
|
44
|
+
continue;
|
45
|
+
}
|
46
|
+
|
47
|
+
if (!innerRing.getEnvelopeInternal().intersects(
|
48
|
+
searchRing.getEnvelopeInternal())) {
|
49
|
+
continue;
|
50
|
+
}
|
51
|
+
|
52
|
+
var innerRingPt = jsts.operation.valid.IsValidOp.findPtNotNode(
|
53
|
+
innerRingPts, searchRing, this.graph);
|
54
|
+
|
55
|
+
/**
|
56
|
+
*
|
57
|
+
* If no non-node pts can be found, this means that the searchRing touches
|
58
|
+
* ALL of the innerRing vertices. This indicates an invalid polygon, since
|
59
|
+
* either the two holes create a disconnected interior, or they touch in
|
60
|
+
* an infinite number of points (i.e. along a line segment). Both of these
|
61
|
+
* cases are caught by other tests, so it is safe to simply skip this
|
62
|
+
* situation here.
|
63
|
+
*/
|
64
|
+
|
65
|
+
if (innerRingPt == null) {
|
66
|
+
continue;
|
67
|
+
}
|
68
|
+
|
69
|
+
var isInside = jsts.algorithm.CGAlgorithms.isPointInRing(innerRingPt,
|
70
|
+
searchRingPts);
|
71
|
+
|
72
|
+
if (isInside) {
|
73
|
+
this.nestedPt = innerRingPt;
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
return true;
|
79
|
+
};
|
80
|
+
|
81
|
+
jsts.operation.valid.IndexedNestedRingTester.prototype.buildIndex = function() {
|
82
|
+
this.index = new jsts.index.strtree.STRtree();
|
83
|
+
|
84
|
+
for (var i = 0; i < this.rings.size(); i++) {
|
85
|
+
var ring = this.rings.get(i);
|
86
|
+
var env = ring.getEnvelopeInternal();
|
87
|
+
this.index.insert(env, ring);
|
88
|
+
}
|
89
|
+
};
|