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,96 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * Port source:
9
+ * /jts/jts/java/src/com/vividsolutions/jts/noding/snapround/MCIndexPointSnapper.java
10
+ * Revision: 486
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/index/chain/MonotoneChainSelectAction.js
15
+ */
16
+
17
+ (function() {
18
+
19
+ var HotPixelSnapAction = function(hotPixel, parentEdge, vertexIndex) {
20
+ this.hotPixel = hotPixel;
21
+ this.parentEdge = parentEdge;
22
+ this.vertexIndex = vertexIndex;
23
+ };
24
+
25
+ HotPixelSnapAction.prototype = new jsts.index.chain.MonotoneChainSelectAction();
26
+ HotPixelSnapAction.constructor = HotPixelSnapAction;
27
+
28
+ HotPixelSnapAction.prototype.hotPixel = null;
29
+ HotPixelSnapAction.prototype.parentEdge = null;
30
+ HotPixelSnapAction.prototype.vertexIndex = null;
31
+ HotPixelSnapAction.prototype._isNodeAdded = false;
32
+
33
+ HotPixelSnapAction.prototype.isNodeAdded = function() {
34
+ return this._isNodeAdded;
35
+ };
36
+
37
+ HotPixelSnapAction.prototype.select = function(mc, startIndex) {
38
+ var ss = mc.getContext();
39
+ // don't snap a vertex to itself
40
+ if (this.parentEdge !== null) {
41
+ if (ss === this.parentEdge && startIndex === this.vertexIndex)
42
+ return;
43
+ }
44
+ // isNodeAdded = SimpleSnapRounder.addSnappedNode(hotPixel, ss, startIndex);
45
+ this._isNodeAdded = this.hotPixel.addSnappedNode(ss, startIndex);
46
+ };
47
+
48
+
49
+ /**
50
+ * "Snaps" all {@link SegmentString}s in a {@link SpatialIndex} containing
51
+ * {@link MonotoneChain}s to a given {@link HotPixel}.
52
+ */
53
+ jsts.noding.snapround.MCIndexPointSnapper = function(index) {
54
+ this.index = index;
55
+ };
56
+
57
+ jsts.noding.snapround.MCIndexPointSnapper.prototype.index = null;
58
+
59
+ /**
60
+ * Snaps (nodes) all interacting segments to this hot pixel. The hot pixel may
61
+ * represent a vertex of an edge, in which case this routine uses the
62
+ * optimization of not noding the vertex itself
63
+ *
64
+ * @param hotPixel
65
+ * the hot pixel to snap to.
66
+ * @param parentEdge
67
+ * the edge containing the vertex, if applicable, or
68
+ * <code>null.</code>
69
+ * @param vertexIndex
70
+ * the index of the vertex, if applicable, or -1.
71
+ * @return <code>true</code> if a node was added for this pixel.
72
+ */
73
+ jsts.noding.snapround.MCIndexPointSnapper.prototype.snap = function(hotPixel,
74
+ parentEdge, vertexIndex) {
75
+ if (arguments.length === 1) {
76
+ this.snap2.apply(this, arguments);
77
+ return;
78
+ }
79
+
80
+ var pixelEnv = hotPixel.getSafeEnvelope();
81
+ var hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge,
82
+ vertexIndex);
83
+
84
+ this.index.query(pixelEnv, {
85
+ visitItem: function(testChain) {
86
+ testChain.select(pixelEnv, hotPixelSnapAction);
87
+ }
88
+ });
89
+ return hotPixelSnapAction.isNodeAdded();
90
+ };
91
+
92
+ jsts.noding.snapround.MCIndexPointSnapper.prototype.snap2 = function(hotPixel) {
93
+ return this.snap(hotPixel, null, -1);
94
+ };
95
+
96
+ })();
@@ -0,0 +1,147 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * Port source: /jts/jts/java/src/com/vividsolutions/jts/noding/snapround/MCIndexSnapRounder.java
9
+ * Revision: 486
10
+ */
11
+
12
+ /**
13
+ * @requires jsts/algorithm/RobustLineIntersector.js
14
+ * @requires jsts/noding/Noder.js
15
+ */
16
+
17
+ /**
18
+ * Uses Snap Rounding to compute a rounded, fully noded arrangement from a set
19
+ * of {@link SegmentString}s. Implements the Snap Rounding technique described
20
+ * in papers by Hobby, Guibas & Marimont, and Goodrich et al. Snap Rounding
21
+ * assumes that all vertices lie on a uniform grid; hence the precision model of
22
+ * the input must be fixed precision, and all the input vertices must be rounded
23
+ * to that precision.
24
+ * <p>
25
+ * This implementation uses a monotone chains and a spatial index to speed up
26
+ * the intersection tests.
27
+ * <p>
28
+ * This implementation appears to be fully robust using an integer precision
29
+ * model. It will function with non-integer precision models, but the results
30
+ * are not 100% guaranteed to be correctly noded.
31
+ */
32
+ jsts.noding.snapround.MCIndexSnapRounder = function(pm) {
33
+ this.pm = pm;
34
+ this.li = new jsts.algorithm.RobustLineIntersector();
35
+ this.li.setPrecisionModel(pm);
36
+ this.scaleFactor = pm.getScale();
37
+ };
38
+
39
+ jsts.noding.snapround.MCIndexSnapRounder.prototype = new jsts.noding.Noder();
40
+ jsts.noding.snapround.MCIndexSnapRounder.constructor = jsts.noding.snapround.MCIndexSnapRounder;
41
+
42
+
43
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.pm = null;
44
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.li = null;
45
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.scaleFactor = null;
46
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.noder = null;
47
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.pointSnapper = null;
48
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.nodedSegStrings = null;
49
+
50
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.getNodedSubstrings = function() {
51
+ return jsts.noding.NodedSegmentString
52
+ .getNodedSubstrings(this.nodedSegStrings);
53
+ };
54
+
55
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.computeNodes = function(
56
+ inputSegmentStrings) {
57
+ this.nodedSegStrings = inputSegmentStrings;
58
+ this.noder = new jsts.noding.MCIndexNoder();
59
+ this.pointSnapper = new jsts.noding.snapround.MCIndexPointSnapper(this.noder
60
+ .getIndex());
61
+ this.snapRound(inputSegmentStrings, this.li);
62
+ };
63
+
64
+ /**
65
+ * @private
66
+ */
67
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.snapRound = function(
68
+ segStrings, li) {
69
+ var intersections = this.findInteriorIntersections(segStrings, li);
70
+ this.computeIntersectionSnaps(intersections);
71
+ this.computeVertexSnaps(segStrings);
72
+ };
73
+
74
+ /**
75
+ * Computes all interior intersections in the collection of
76
+ * {@link SegmentString}s, and returns their
77
+ *
78
+ * @link Coordinate}s.
79
+ *
80
+ * Does NOT node the segStrings.
81
+ *
82
+ * @return a list of Coordinates for the intersections.
83
+ * @private
84
+ */
85
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.findInteriorIntersections = function(
86
+ segStrings, li) {
87
+ var intFinderAdder = new jsts.noding.IntersectionFinderAdder(li);
88
+ this.noder.setSegmentIntersector(intFinderAdder);
89
+ this.noder.computeNodes(segStrings);
90
+ return intFinderAdder.getInteriorIntersections();
91
+ };
92
+
93
+ /**
94
+ * Computes nodes introduced as a result of snapping segments to snap points
95
+ * (hot pixels)
96
+ *
97
+ * @private
98
+ */
99
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.computeIntersectionSnaps = function(
100
+ snapPts) {
101
+ for (var it = snapPts.iterator(); it.hasNext();) {
102
+ var snapPt = it.next();
103
+ var hotPixel = new jsts.noding.snapround.HotPixel(snapPt, this.scaleFactor,
104
+ this.li);
105
+ this.pointSnapper.snap(hotPixel);
106
+ }
107
+ };
108
+
109
+ /**
110
+ * Computes nodes introduced as a result of snapping segments to vertices of
111
+ * other segments
112
+ *
113
+ * @param edges
114
+ * the list of segment strings to snap together.
115
+ */
116
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.computeVertexSnaps = function(
117
+ edges) {
118
+ if (edges instanceof jsts.noding.NodedSegmentString) {
119
+ this.computeVertexSnaps2.apply(this, arguments);
120
+ return;
121
+ }
122
+
123
+ for (var i0 = edges.iterator(); i0.hasNext();) {
124
+ var edge0 = i0.next();
125
+ this.computeVertexSnaps(edge0);
126
+ }
127
+ };
128
+
129
+ /**
130
+ * Performs a brute-force comparison of every segment in each
131
+ * {@link SegmentString}. This has n^2 performance.
132
+ *
133
+ * @private
134
+ */
135
+ jsts.noding.snapround.MCIndexSnapRounder.prototype.computeVertexSnaps2 = function(
136
+ e) {
137
+ var pts0 = e.getCoordinates();
138
+ for (var i = 0; i < pts0.length - 1; i++) {
139
+ var hotPixel = new jsts.noding.snapround.HotPixel(pts0[i],
140
+ this.scaleFactor, this.li);
141
+ var isNodeAdded = this.pointSnapper.snap(hotPixel, e, i);
142
+ // if a node is created for a vertex, that vertex must be noded too
143
+ if (isNodeAdded) {
144
+ e.addIntersection(pts0[i], i);
145
+ }
146
+ }
147
+ };
@@ -0,0 +1,166 @@
1
+
2
+
3
+ /**
4
+ * Computes the boundary of a {@link Geometry}.
5
+ * Allows specifying the {@link BoundaryNodeRule} to be used.
6
+ * This operation will always return a {@link Geometry} of the appropriate
7
+ * dimension for the boundary (even if the input geometry is empty).
8
+ * The boundary of zero-dimensional geometries (Points) is
9
+ * always the empty {@link GeometryCollection}.
10
+ *
11
+ * @author Martin Davis
12
+ * @version 1.7
13
+ */
14
+
15
+ jsts.operation.BoundaryOp = function(geom, bnRule) {
16
+ this.geom = geom;
17
+ this.geomFact = geom.getFactory();
18
+ this.bnRule = bnRule || jsts.algorithm.BoundaryNodeRule.MOD2_BOUNDARY_RULE;
19
+ };
20
+
21
+
22
+ /**
23
+ * @type {Geometry}
24
+ * @private
25
+ */
26
+ jsts.operation.BoundaryOp.prototype.geom = null;
27
+
28
+
29
+ /**
30
+ * @type {GeometryFactory}
31
+ * @private
32
+ */
33
+ jsts.operation.BoundaryOp.prototype.geomFact = null;
34
+
35
+
36
+ /**
37
+ * @type {BoundaryNodeRule}
38
+ * @private
39
+ */
40
+ jsts.operation.BoundaryOp.prototype.bnRule = null;
41
+
42
+
43
+ /**
44
+ * @return {Geometry}
45
+ */
46
+ jsts.operation.BoundaryOp.prototype.getBoundary = function() {
47
+ if (this.geom instanceof jsts.geom.LineString) return this.boundaryLineString(this.geom);
48
+ if (this.geom instanceof jsts.geom.MultiLineString) return this.boundaryMultiLineString(this.geom);
49
+ return this.geom.getBoundary();
50
+ };
51
+
52
+
53
+ /**
54
+ * @return {MultiPoint}
55
+ * @private
56
+ */
57
+ jsts.operation.BoundaryOp.prototype.getEmptyMultiPoint = function() {
58
+ return this.geomFact.createMultiPoint(null);
59
+ };
60
+
61
+
62
+ /**
63
+ * @param {MultiLineString} mLine
64
+ * @return {Geometry}
65
+ * @private
66
+ */
67
+ jsts.operation.BoundaryOp.prototype.boundaryMultiLineString = function(mLine) {
68
+ if (this.geom.isEmpty()) {
69
+ return this.getEmptyMultiPoint();
70
+ }
71
+
72
+ var bdyPts = this.computeBoundaryCoordinates(mLine);
73
+
74
+ // return Point or MultiPoint
75
+ if (bdyPts.length == 1) {
76
+ return this.geomFact.createPoint(bdyPts[0]);
77
+ }
78
+ // this handles 0 points case as well
79
+ return this.geomFact.createMultiPoint(bdyPts);
80
+ };
81
+
82
+
83
+ /**
84
+ * @type {Array}
85
+ * @private
86
+ */
87
+ jsts.operation.BoundaryOp.prototype.endpoints = null;
88
+
89
+
90
+ /**
91
+ * @param {MultiLineString} mLine
92
+ * @return {Array.<Coordinate>}
93
+ * @private
94
+ */
95
+ jsts.operation.BoundaryOp.prototype.computeBoundaryCoordinates = function(mLine) {
96
+ var i, line, endpoint, bdyPts = [];
97
+
98
+ this.endpoints = [];
99
+ for (i = 0; i < mLine.getNumGeometries(); i++) {
100
+ line = mLine.getGeometryN(i);
101
+ if (line.getNumPoints() == 0)
102
+ continue;
103
+ this.addEndpoint(line.getCoordinateN(0));
104
+ this.addEndpoint(line.getCoordinateN(line.getNumPoints() - 1));
105
+ }
106
+
107
+ for (i = 0; i < this.endpoints.length; i++) {
108
+ endpoint = this.endpoints[i];
109
+ if (this.bnRule.isInBoundary(endpoint.count)) {
110
+ bdyPts.push(endpoint.coordinate);
111
+ }
112
+ }
113
+
114
+ return bdyPts;
115
+ };
116
+
117
+
118
+ /**
119
+ * @param {Coordinate} pt
120
+ * @private
121
+ */
122
+ jsts.operation.BoundaryOp.prototype.addEndpoint = function(pt) {
123
+ var i, endpoint, found = false;
124
+ for (i = 0; i < this.endpoints.length; i++) {
125
+ endpoint = this.endpoints[i];
126
+ if (endpoint.coordinate.equals(pt)) {
127
+ found = true;
128
+ break;
129
+ }
130
+ }
131
+
132
+ if (!found) {
133
+ endpoint = {};
134
+ endpoint.coordinate = pt;
135
+ endpoint.count = 0;
136
+ this.endpoints.push(endpoint);
137
+ }
138
+
139
+ endpoint.count++;
140
+ };
141
+
142
+
143
+ /**
144
+ * @param {LineString} line
145
+ * @return {Geometry}
146
+ * @private
147
+ */
148
+ jsts.operation.BoundaryOp.prototype.boundaryLineString = function(line) {
149
+ if (this.geom.isEmpty()) {
150
+ return this.getEmptyMultiPoint();
151
+ }
152
+
153
+ if (line.isClosed()) {
154
+ // check whether endpoints of valence 2 are on the boundary or not
155
+ var closedEndpointOnBoundary = this.bnRule.isInBoundary(2);
156
+ if (closedEndpointOnBoundary) {
157
+ return line.getStartPoint();
158
+ }
159
+ else {
160
+ return this.geomFact.createMultiPoint(null);
161
+ }
162
+ }
163
+ return this.geomFact.createMultiPoint([line.getStartPoint(),
164
+ line.getEndPoint()]
165
+ );
166
+ };
@@ -0,0 +1,90 @@
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
+ * The base class for operations that require {@link GeometryGraph}s.
11
+ *
12
+ * @param {Geometry}
13
+ * g0
14
+ * @param {Geometry}
15
+ * g1
16
+ * @param {BoundaryNodeRule}
17
+ * boundaryNodeRule
18
+ * @constructor
19
+ */
20
+ jsts.operation.GeometryGraphOperation = function(g0, g1, boundaryNodeRule) {
21
+ this.li = new jsts.algorithm.RobustLineIntersector();
22
+ this.arg = [];
23
+
24
+ if (g0 === undefined) {
25
+ return;
26
+ }
27
+
28
+ if (g1 === undefined) {
29
+ this.setComputationPrecision(g0.getPrecisionModel());
30
+
31
+ this.arg[0] = new jsts.geomgraph.GeometryGraph(0, g0);
32
+ return;
33
+ }
34
+
35
+ boundaryNodeRule = boundaryNodeRule ||
36
+ jsts.algorithm.BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
37
+
38
+ // use the most precise model for the result
39
+ if (g0.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0)
40
+ this.setComputationPrecision(g0.getPrecisionModel());
41
+ else
42
+ this.setComputationPrecision(g1.getPrecisionModel());
43
+
44
+ this.arg[0] = new jsts.geomgraph.GeometryGraph(0, g0, boundaryNodeRule);
45
+ this.arg[1] = new jsts.geomgraph.GeometryGraph(1, g1, boundaryNodeRule);
46
+ };
47
+
48
+
49
+ /**
50
+ * @type {LineIntersector}
51
+ * @protected
52
+ */
53
+ jsts.operation.GeometryGraphOperation.prototype.li = null;
54
+
55
+
56
+ /**
57
+ * @type {PrecisionModel}
58
+ * @protected
59
+ */
60
+ jsts.operation.GeometryGraphOperation.prototype.resultPrecisionModel = null;
61
+
62
+
63
+ /**
64
+ * The operation args into an array so they can be accessed by index
65
+ *
66
+ * @type {GeometryGraph[]}
67
+ * @protected
68
+ */
69
+ jsts.operation.GeometryGraphOperation.prototype.arg = null;
70
+
71
+
72
+ /**
73
+ * @param {int}
74
+ * i
75
+ * @return {Geometry}
76
+ */
77
+ jsts.operation.GeometryGraphOperation.prototype.getArgGeometry = function(i) {
78
+ return arg[i].getGeometry();
79
+ };
80
+
81
+
82
+ /**
83
+ * @param {PrecisionModel}
84
+ * pm
85
+ * @protected
86
+ */
87
+ jsts.operation.GeometryGraphOperation.prototype.setComputationPrecision = function(pm) {
88
+ this.resultPrecisionModel = pm;
89
+ this.li.setPrecisionModel(this.resultPrecisionModel);
90
+ };