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.
Files changed (209) hide show
  1. checksums.yaml +8 -8
  2. data/lib/jsts-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/javascript.util.js +33 -1
  4. data/vendor/assets/javascripts/jsts-original.js +164 -1573
  5. data/vendor/assets/javascripts/jsts.js +197 -0
  6. data/vendor/assets/javascripts/jsts/algorithm/Angle.js +387 -0
  7. data/vendor/assets/javascripts/jsts/algorithm/BoundaryNodeRule.js +67 -0
  8. data/vendor/assets/javascripts/jsts/algorithm/CGAlgorithms.js +596 -0
  9. data/vendor/assets/javascripts/jsts/algorithm/CentralEndpointIntersector.js +118 -0
  10. data/vendor/assets/javascripts/jsts/algorithm/CentroidArea.js +225 -0
  11. data/vendor/assets/javascripts/jsts/algorithm/CentroidLine.js +85 -0
  12. data/vendor/assets/javascripts/jsts/algorithm/CentroidPoint.js +77 -0
  13. data/vendor/assets/javascripts/jsts/algorithm/ConvexHull.js +409 -0
  14. data/vendor/assets/javascripts/jsts/algorithm/HCoordinate.js +234 -0
  15. data/vendor/assets/javascripts/jsts/algorithm/LineIntersector.js +502 -0
  16. data/vendor/assets/javascripts/jsts/algorithm/MCPointInRing.js +124 -0
  17. data/vendor/assets/javascripts/jsts/algorithm/PointLocator.js +247 -0
  18. data/vendor/assets/javascripts/jsts/algorithm/RayCrossingCounter.js +215 -0
  19. data/vendor/assets/javascripts/jsts/algorithm/RobustDeterminant.js +353 -0
  20. data/vendor/assets/javascripts/jsts/algorithm/RobustLineIntersector.js +477 -0
  21. data/vendor/assets/javascripts/jsts/algorithm/distance/DiscreteHausdorffDistance.js +228 -0
  22. data/vendor/assets/javascripts/jsts/algorithm/distance/DistanceToPoint.js +68 -0
  23. data/vendor/assets/javascripts/jsts/algorithm/distance/PointPairDistance.js +104 -0
  24. data/vendor/assets/javascripts/jsts/algorithm/locate/PointOnGeometryLocator.js +7 -0
  25. data/vendor/assets/javascripts/jsts/algorithm/locate/SimplePointInAreaLocator.js +102 -0
  26. data/vendor/assets/javascripts/jsts/geom/Coordinate.js +158 -0
  27. data/vendor/assets/javascripts/jsts/geom/CoordinateArrays.js +148 -0
  28. data/vendor/assets/javascripts/jsts/geom/CoordinateFilter.js +29 -0
  29. data/vendor/assets/javascripts/jsts/geom/CoordinateList.js +157 -0
  30. data/vendor/assets/javascripts/jsts/geom/CoordinateSequenceFilter.js +63 -0
  31. data/vendor/assets/javascripts/jsts/geom/Dimension.js +137 -0
  32. data/vendor/assets/javascripts/jsts/geom/Envelope.js +833 -0
  33. data/vendor/assets/javascripts/jsts/geom/Geometry.js +1535 -0
  34. data/vendor/assets/javascripts/jsts/geom/GeometryCollection.js +230 -0
  35. data/vendor/assets/javascripts/jsts/geom/GeometryComponentFilter.js +36 -0
  36. data/vendor/assets/javascripts/jsts/geom/GeometryFactory.js +263 -0
  37. data/vendor/assets/javascripts/jsts/geom/GeometryFilter.js +29 -0
  38. data/vendor/assets/javascripts/jsts/geom/IntersectionMatrix.js +650 -0
  39. data/vendor/assets/javascripts/jsts/geom/LineSegment.js +275 -0
  40. data/vendor/assets/javascripts/jsts/geom/LineString.js +299 -0
  41. data/vendor/assets/javascripts/jsts/geom/LinearRing.js +69 -0
  42. data/vendor/assets/javascripts/jsts/geom/Location.js +83 -0
  43. data/vendor/assets/javascripts/jsts/geom/MultiLineString.js +47 -0
  44. data/vendor/assets/javascripts/jsts/geom/MultiPoint.js +64 -0
  45. data/vendor/assets/javascripts/jsts/geom/MultiPolygon.js +64 -0
  46. data/vendor/assets/javascripts/jsts/geom/Point.js +197 -0
  47. data/vendor/assets/javascripts/jsts/geom/Polygon.js +263 -0
  48. data/vendor/assets/javascripts/jsts/geom/PrecisionModel.js +187 -0
  49. data/vendor/assets/javascripts/jsts/geom/Triangle.js +313 -0
  50. data/vendor/assets/javascripts/jsts/geom/util/GeometryCombiner.js +143 -0
  51. data/vendor/assets/javascripts/jsts/geom/util/GeometryExtracter.js +76 -0
  52. data/vendor/assets/javascripts/jsts/geom/util/GeometryTransformer.js +295 -0
  53. data/vendor/assets/javascripts/jsts/geom/util/LinearComponentExtracter.js +207 -0
  54. data/vendor/assets/javascripts/jsts/geom/util/PointExtracter.js +67 -0
  55. data/vendor/assets/javascripts/jsts/geom/util/PolygonExtracter.js +71 -0
  56. data/vendor/assets/javascripts/jsts/geomgraph/Depth.js +145 -0
  57. data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdge.js +270 -0
  58. data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdgeStar.js +388 -0
  59. data/vendor/assets/javascripts/jsts/geomgraph/Edge.js +291 -0
  60. data/vendor/assets/javascripts/jsts/geomgraph/EdgeEnd.js +188 -0
  61. data/vendor/assets/javascripts/jsts/geomgraph/EdgeEndStar.js +322 -0
  62. data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersection.js +122 -0
  63. data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersectionList.js +146 -0
  64. data/vendor/assets/javascripts/jsts/geomgraph/EdgeList.js +111 -0
  65. data/vendor/assets/javascripts/jsts/geomgraph/EdgeNodingValidator.js +76 -0
  66. data/vendor/assets/javascripts/jsts/geomgraph/EdgeRing.js +230 -0
  67. data/vendor/assets/javascripts/jsts/geomgraph/GeometryGraph.js +469 -0
  68. data/vendor/assets/javascripts/jsts/geomgraph/GraphComponent.js +181 -0
  69. data/vendor/assets/javascripts/jsts/geomgraph/Label.js +316 -0
  70. data/vendor/assets/javascripts/jsts/geomgraph/Node.js +105 -0
  71. data/vendor/assets/javascripts/jsts/geomgraph/NodeFactory.js +22 -0
  72. data/vendor/assets/javascripts/jsts/geomgraph/NodeMap.js +128 -0
  73. data/vendor/assets/javascripts/jsts/geomgraph/PlanarGraph.js +214 -0
  74. data/vendor/assets/javascripts/jsts/geomgraph/Position.js +63 -0
  75. data/vendor/assets/javascripts/jsts/geomgraph/Quadrant.js +143 -0
  76. data/vendor/assets/javascripts/jsts/geomgraph/TopologyLocation.js +251 -0
  77. data/vendor/assets/javascripts/jsts/geomgraph/index/EdgeSetIntersector.js +47 -0
  78. data/vendor/assets/javascripts/jsts/geomgraph/index/SegmentIntersector.js +298 -0
  79. data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleEdgeSetIntersector.js +107 -0
  80. data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleMCSweepLineIntersector.js +29 -0
  81. data/vendor/assets/javascripts/jsts/index/ArrayListVisitor.js +37 -0
  82. data/vendor/assets/javascripts/jsts/index/DoubleBits.js +132 -0
  83. data/vendor/assets/javascripts/jsts/index/IntervalSize.js +55 -0
  84. data/vendor/assets/javascripts/jsts/index/ItemVisitor.js +23 -0
  85. data/vendor/assets/javascripts/jsts/index/SpatialIndex.js +67 -0
  86. data/vendor/assets/javascripts/jsts/index/bintree/Bintree.js +224 -0
  87. data/vendor/assets/javascripts/jsts/index/bintree/Interval.js +160 -0
  88. data/vendor/assets/javascripts/jsts/index/bintree/Key.js +110 -0
  89. data/vendor/assets/javascripts/jsts/index/bintree/Node.js +204 -0
  90. data/vendor/assets/javascripts/jsts/index/bintree/NodeBase.js +220 -0
  91. data/vendor/assets/javascripts/jsts/index/bintree/Root.js +113 -0
  92. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChain.js +244 -0
  93. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainBuilder.js +106 -0
  94. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainOverlapAction.js +56 -0
  95. data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainSelectAction.js +44 -0
  96. data/vendor/assets/javascripts/jsts/index/kdtree/KdNode.js +171 -0
  97. data/vendor/assets/javascripts/jsts/index/kdtree/KdTree.js +218 -0
  98. data/vendor/assets/javascripts/jsts/index/quadtree/Key.js +134 -0
  99. data/vendor/assets/javascripts/jsts/index/quadtree/Node.js +220 -0
  100. data/vendor/assets/javascripts/jsts/index/quadtree/NodeBase.js +330 -0
  101. data/vendor/assets/javascripts/jsts/index/quadtree/Quadtree.js +228 -0
  102. data/vendor/assets/javascripts/jsts/index/quadtree/Root.js +105 -0
  103. data/vendor/assets/javascripts/jsts/index/strtree/AbstractNode.js +107 -0
  104. data/vendor/assets/javascripts/jsts/index/strtree/AbstractSTRtree.js +594 -0
  105. data/vendor/assets/javascripts/jsts/index/strtree/Boundable.js +37 -0
  106. data/vendor/assets/javascripts/jsts/index/strtree/BoundablePair.js +0 -0
  107. data/vendor/assets/javascripts/jsts/index/strtree/Interval.js +94 -0
  108. data/vendor/assets/javascripts/jsts/index/strtree/ItemBoundable.js +60 -0
  109. data/vendor/assets/javascripts/jsts/index/strtree/SIRtree.js +122 -0
  110. data/vendor/assets/javascripts/jsts/index/strtree/STRtree.js +450 -0
  111. data/vendor/assets/javascripts/jsts/io/GeoJSONParser.js +471 -0
  112. data/vendor/assets/javascripts/jsts/io/GeoJSONReader.js +58 -0
  113. data/vendor/assets/javascripts/jsts/io/GeoJSONWriter.js +38 -0
  114. data/vendor/assets/javascripts/jsts/io/OpenLayersParser.js +245 -0
  115. data/vendor/assets/javascripts/jsts/io/WKTParser.js +421 -0
  116. data/vendor/assets/javascripts/jsts/io/WKTReader.js +68 -0
  117. data/vendor/assets/javascripts/jsts/io/WKTWriter.js +61 -0
  118. data/vendor/assets/javascripts/jsts/noding/BasicSegmentString.js +87 -0
  119. data/vendor/assets/javascripts/jsts/noding/FastNodingValidator.js +127 -0
  120. data/vendor/assets/javascripts/jsts/noding/InteriorIntersectionFinder.js +171 -0
  121. data/vendor/assets/javascripts/jsts/noding/IntersectionAdder.js +198 -0
  122. data/vendor/assets/javascripts/jsts/noding/IntersectionFinderAdder.js +79 -0
  123. data/vendor/assets/javascripts/jsts/noding/MCIndexNoder.js +147 -0
  124. data/vendor/assets/javascripts/jsts/noding/NodableSegmentString.js +35 -0
  125. data/vendor/assets/javascripts/jsts/noding/NodedSegmentString.js +235 -0
  126. data/vendor/assets/javascripts/jsts/noding/Noder.js +41 -0
  127. data/vendor/assets/javascripts/jsts/noding/NodingValidator.js +5 -0
  128. data/vendor/assets/javascripts/jsts/noding/Octant.js +84 -0
  129. data/vendor/assets/javascripts/jsts/noding/OrientedCoordinateArray.js +94 -0
  130. data/vendor/assets/javascripts/jsts/noding/ScaledNoder.js +105 -0
  131. data/vendor/assets/javascripts/jsts/noding/SegmentIntersector.js +45 -0
  132. data/vendor/assets/javascripts/jsts/noding/SegmentNode.js +70 -0
  133. data/vendor/assets/javascripts/jsts/noding/SegmentNodeList.js +262 -0
  134. data/vendor/assets/javascripts/jsts/noding/SegmentPointComparator.js +78 -0
  135. data/vendor/assets/javascripts/jsts/noding/SegmentString.js +61 -0
  136. data/vendor/assets/javascripts/jsts/noding/SinglePassNoder.js +51 -0
  137. data/vendor/assets/javascripts/jsts/noding/snapround/HotPixel.js +271 -0
  138. data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexPointSnapper.js +96 -0
  139. data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexSnapRounder.js +147 -0
  140. data/vendor/assets/javascripts/jsts/operation/BoundaryOp.js +166 -0
  141. data/vendor/assets/javascripts/jsts/operation/GeometryGraphOperation.js +90 -0
  142. data/vendor/assets/javascripts/jsts/operation/IsSimpleOp.js +293 -0
  143. data/vendor/assets/javascripts/jsts/operation/buffer/BufferBuilder.js +317 -0
  144. data/vendor/assets/javascripts/jsts/operation/buffer/BufferInputLineSimplifier.js +294 -0
  145. data/vendor/assets/javascripts/jsts/operation/buffer/BufferOp.js +340 -0
  146. data/vendor/assets/javascripts/jsts/operation/buffer/BufferParameters.js +328 -0
  147. data/vendor/assets/javascripts/jsts/operation/buffer/BufferSubgraph.js +296 -0
  148. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveBuilder.js +369 -0
  149. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveSetBuilder.js +301 -0
  150. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentGenerator.js +777 -0
  151. data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentString.js +109 -0
  152. data/vendor/assets/javascripts/jsts/operation/buffer/RightmostEdgeFinder.js +164 -0
  153. data/vendor/assets/javascripts/jsts/operation/buffer/SubgraphDepthLocater.js +220 -0
  154. data/vendor/assets/javascripts/jsts/operation/distance/ConnectedElementLocationFilter.js +67 -0
  155. data/vendor/assets/javascripts/jsts/operation/distance/DistanceOp.js +506 -0
  156. data/vendor/assets/javascripts/jsts/operation/distance/GeometryLocation.js +102 -0
  157. data/vendor/assets/javascripts/jsts/operation/overlay/LineBuilder.js +194 -0
  158. data/vendor/assets/javascripts/jsts/operation/overlay/MaximalEdgeRing.js +72 -0
  159. data/vendor/assets/javascripts/jsts/operation/overlay/MinimalEdgeRing.js +33 -0
  160. data/vendor/assets/javascripts/jsts/operation/overlay/OverlayNodeFactory.js +26 -0
  161. data/vendor/assets/javascripts/jsts/operation/overlay/OverlayOp.js +584 -0
  162. data/vendor/assets/javascripts/jsts/operation/overlay/PointBuilder.js +103 -0
  163. data/vendor/assets/javascripts/jsts/operation/overlay/PolygonBuilder.js +282 -0
  164. data/vendor/assets/javascripts/jsts/operation/overlay/snap/GeometrySnapper.js +228 -0
  165. data/vendor/assets/javascripts/jsts/operation/overlay/snap/LineStringSnapper.js +228 -0
  166. data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapIfNeededOverlayOp.js +85 -0
  167. data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapOverlayOp.js +134 -0
  168. data/vendor/assets/javascripts/jsts/operation/polygonize/EdgeRing.js +259 -0
  169. data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeDirectedEdge.js +94 -0
  170. data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeEdge.js +31 -0
  171. data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeGraph.js +507 -0
  172. data/vendor/assets/javascripts/jsts/operation/polygonize/Polygonizer.js +259 -0
  173. data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBuilder.js +140 -0
  174. data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundle.js +183 -0
  175. data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundleStar.js +48 -0
  176. data/vendor/assets/javascripts/jsts/operation/relate/RelateComputer.js +444 -0
  177. data/vendor/assets/javascripts/jsts/operation/relate/RelateNode.js +46 -0
  178. data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeFactory.js +25 -0
  179. data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeGraph.js +118 -0
  180. data/vendor/assets/javascripts/jsts/operation/relate/RelateOp.js +75 -0
  181. data/vendor/assets/javascripts/jsts/operation/union/CascadedPolygonUnion.js +319 -0
  182. data/vendor/assets/javascripts/jsts/operation/union/PointGeometryUnion.js +118 -0
  183. data/vendor/assets/javascripts/jsts/operation/union/UnaryUnionOp.js +244 -0
  184. data/vendor/assets/javascripts/jsts/operation/union/UnionInteracting.js +156 -0
  185. data/vendor/assets/javascripts/jsts/operation/valid/ConnectedInteriorTester.js +259 -0
  186. data/vendor/assets/javascripts/jsts/operation/valid/ConsistentAreaTester.js +127 -0
  187. data/vendor/assets/javascripts/jsts/operation/valid/IndexedNestedRingTester.js +89 -0
  188. data/vendor/assets/javascripts/jsts/operation/valid/IsValidOp.js +619 -0
  189. data/vendor/assets/javascripts/jsts/operation/valid/TopologyValidationError.js +199 -0
  190. data/vendor/assets/javascripts/jsts/planargraph/DirectedEdge.js +232 -0
  191. data/vendor/assets/javascripts/jsts/planargraph/DirectedEdgeStar.js +168 -0
  192. data/vendor/assets/javascripts/jsts/planargraph/Edge.js +124 -0
  193. data/vendor/assets/javascripts/jsts/planargraph/GraphComponent.js +182 -0
  194. data/vendor/assets/javascripts/jsts/planargraph/Node.js +127 -0
  195. data/vendor/assets/javascripts/jsts/planargraph/NodeMap.js +76 -0
  196. data/vendor/assets/javascripts/jsts/planargraph/PlanarGraph.js +246 -0
  197. data/vendor/assets/javascripts/jsts/simplify/LineSegmentIndex.js +101 -0
  198. data/vendor/assets/javascripts/jsts/triangulate/DelaunayTriangulationBuilder.js +224 -0
  199. data/vendor/assets/javascripts/jsts/triangulate/IncrementalDelaunayTriangulator.js +111 -0
  200. data/vendor/assets/javascripts/jsts/triangulate/VoronoiDiagramBuilder.js +172 -0
  201. data/vendor/assets/javascripts/jsts/triangulate/quadedge/LastFoundQuadEdgeLocator.js +52 -0
  202. data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdge.js +437 -0
  203. data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdgeSubdivision.js +1064 -0
  204. data/vendor/assets/javascripts/jsts/triangulate/quadedge/TrianglePredicate.js +350 -0
  205. data/vendor/assets/javascripts/jsts/triangulate/quadedge/Vertex.js +496 -0
  206. data/vendor/assets/javascripts/jsts/util/Assert.js +80 -0
  207. data/vendor/assets/javascripts/jsts/util/AssertionFailedException.js +23 -0
  208. data/vendor/assets/javascripts/jsts/util/UniqueCoordinateArrayFilter.js +52 -0
  209. 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
+ };