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,105 @@
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/ScaledNoder.java
9
+ * Revision: 478
10
+ */
11
+
12
+ jsts.noding.ScaledNoder = function(noder, scaleFactor, offsetX, offsetY) {
13
+ this.offsetX = offsetX ? offsetX : 0;
14
+ this.offsetY = offsetY ? offsetY : 0;
15
+
16
+ this.noder = noder;
17
+ this.scaleFactor = scaleFactor;
18
+
19
+ // no need to scale if input precision is already integral
20
+ this.isScaled = !this.isIntegerPrecision();
21
+ };
22
+
23
+ jsts.noding.ScaledNoder.prototype = new jsts.noding.Noder();
24
+ jsts.noding.ScaledNoder.constructor = jsts.noding.ScaledNoder;
25
+
26
+ jsts.noding.ScaledNoder.prototype.noder = null;
27
+ jsts.noding.ScaledNoder.prototype.scaleFactor = undefined;
28
+ jsts.noding.ScaledNoder.prototype.offsetX = undefined;
29
+ jsts.noding.ScaledNoder.prototype.offsetY = undefined;
30
+ jsts.noding.ScaledNoder.prototype.isScaled = false;
31
+
32
+ jsts.noding.ScaledNoder.prototype.isIntegerPrecision = function() {
33
+ return this.scaleFactor === 1.0;
34
+ };
35
+
36
+ jsts.noding.ScaledNoder.prototype.getNodedSubstrings = function() {
37
+ var splitSS = this.noder.getNodedSubstrings();
38
+ if (this.isScaled)
39
+ this.rescale(splitSS);
40
+ return splitSS;
41
+ };
42
+
43
+ jsts.noding.ScaledNoder.prototype.computeNodes = function(inputSegStrings) {
44
+ var intSegStrings = inputSegStrings;
45
+ if (this.isScaled)
46
+ intSegStrings = this.scale(inputSegStrings);
47
+ this.noder.computeNodes(intSegStrings);
48
+ };
49
+
50
+ /**
51
+ * @private
52
+ */
53
+ jsts.noding.ScaledNoder.prototype.scale = function(segStrings) {
54
+ if (segStrings instanceof Array) {
55
+ return this.scale2(segStrings);
56
+ }
57
+
58
+ var transformed = new javascript.util.ArrayList();
59
+ for (var i = segStrings.iterator(); i.hasNext();) {
60
+ var ss = i.next();
61
+ transformed.add(new jsts.noding.NodedSegmentString(this.scale(ss
62
+ .getCoordinates()), ss.getData()));
63
+ }
64
+
65
+ return transformed;
66
+ };
67
+
68
+ /**
69
+ * @private
70
+ */
71
+ jsts.noding.ScaledNoder.prototype.scale2 = function(pts) {
72
+ var roundPts = [];
73
+ for (var i = 0; i < pts.length; i++) {
74
+ roundPts[i] = new jsts.geom.Coordinate(Math
75
+ .round((pts[i].x - this.offsetX) * this.scaleFactor), Math
76
+ .round((pts[i].y - this.offsetY) * this.scaleFactor));
77
+ }
78
+ var roundPtsNoDup = jsts.geom.CoordinateArrays.removeRepeatedPoints(roundPts);
79
+ return roundPtsNoDup;
80
+ };
81
+
82
+ /**
83
+ * @private
84
+ */
85
+ jsts.noding.ScaledNoder.prototype.rescale = function(segStrings) {
86
+ if (segStrings instanceof Array) {
87
+ this.rescale2(segStrings);
88
+ return;
89
+ }
90
+
91
+ for (var i = segStrings.iterator(); i.hasNext();) {
92
+ var ss = i.next();
93
+ this.rescale(ss.getCoordinates());
94
+ }
95
+ };
96
+
97
+ /**
98
+ * @private
99
+ */
100
+ jsts.noding.ScaledNoder.prototype.rescale2 = function(pts) {
101
+ for (var i = 0; i < pts.length; i++) {
102
+ pts[i].x = pts[i].x / this.scaleFactor + this.offsetX;
103
+ pts[i].y = pts[i].y / this.scaleFactor + this.offsetY;
104
+ }
105
+ };
@@ -0,0 +1,45 @@
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
+ * Processes possible intersections detected by a {@link Noder}. The
9
+ * {@link SegmentIntersector} is passed to a {@link Noder}. The
10
+ * {@link addIntersections} method is called whenever the {@link Noder} detects
11
+ * that two SegmentStrings <i>might</i> intersect. This class may be used
12
+ * either to find all intersections, or to detect the presence of an
13
+ * intersection. In the latter case, Noders may choose to short-circuit their
14
+ * computation by calling the {@link isDone} method. This class is an example of
15
+ * the <i>Strategy</i> pattern.
16
+ *
17
+ * @interface
18
+ */
19
+ jsts.noding.SegmentIntersector = function() {
20
+
21
+ };
22
+
23
+ /**
24
+ * This method is called by clients of the {@link SegmentIntersector} interface
25
+ * to process intersections for two segments of the {@link SegmentString}s
26
+ * being intersected.
27
+ *
28
+ * @param {SegmentString}
29
+ * e0
30
+ * @param {number}
31
+ * segIndex0
32
+ * @param {SegmentString}
33
+ * e1
34
+ * @param {number}
35
+ * segIndex0
36
+ */
37
+ jsts.noding.SegmentIntersector.prototype.processIntersections = jsts.abstractFunc;
38
+
39
+ /**
40
+ * Reports whether the client of this class needs to continue testing all
41
+ * intersections in an arrangement.
42
+ *
43
+ * @return {boolean} true if there is no need to continue testing segments.
44
+ */
45
+ jsts.noding.SegmentIntersector.prototype.isDone = jsts.abstractFunc;
@@ -0,0 +1,70 @@
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/SegmentNode.java
9
+ * Revision: 478
10
+ */
11
+
12
+ /**
13
+ * Represents an intersection point between two {@link SegmentString}s.
14
+ *
15
+ * @constructor
16
+ */
17
+ jsts.noding.SegmentNode = function(segString, coord, segmentIndex, segmentOctant) {
18
+ this.segString = segString;
19
+ this.coord = new jsts.geom.Coordinate(coord);
20
+ this.segmentIndex = segmentIndex;
21
+ this.segmentOctant = segmentOctant;
22
+ this._isInterior = ! coord.equals2D(segString.getCoordinate(segmentIndex));
23
+ };
24
+
25
+
26
+ /**
27
+ * @type {NodedSegmentString}
28
+ * @private
29
+ */
30
+ jsts.noding.SegmentNode.prototype.segString = null;
31
+ jsts.noding.SegmentNode.prototype.coord = null; // the point of intersection
32
+ jsts.noding.SegmentNode.prototype.segmentIndex = null; // the index of the containing line segment in the parent edge
33
+ jsts.noding.SegmentNode.prototype.segmentOctant = null;
34
+ jsts.noding.SegmentNode.prototype._isInterior = null;
35
+
36
+ /**
37
+ * Gets the {@link Coordinate} giving the location of this node.
38
+ *
39
+ * @return the coordinate of the node.
40
+ */
41
+ jsts.noding.SegmentNode.prototype.getCoordinate = function() {
42
+ return this.coord;
43
+ };
44
+
45
+
46
+ jsts.noding.SegmentNode.prototype.isInterior = function() { return this._isInterior; };
47
+
48
+ jsts.noding.SegmentNode.prototype.isEndPoint = function(maxSegmentIndex) {
49
+ if (this.segmentIndex === 0 && ! this._isInterior) return true;
50
+ if (this.segmentIndex === this.maxSegmentIndex) return true;
51
+ return false;
52
+ };
53
+
54
+
55
+ /**
56
+ * @return -1 this SegmentNode is located before the argument location.
57
+ * @return 0 this SegmentNode is at the argument location.
58
+ * @return 1 this SegmentNode is located after the argument location.
59
+ */
60
+ jsts.noding.SegmentNode.prototype.compareTo = function(obj) {
61
+ var other = obj;
62
+
63
+ if (this.segmentIndex < other.segmentIndex) return -1;
64
+ if (this.segmentIndex > other.segmentIndex) return 1;
65
+
66
+ if (this.coord.equals2D(other.coord)) return 0;
67
+
68
+ return jsts.noding.SegmentPointComparator.compare(this.segmentOctant, this.coord, other.coord);
69
+ };
70
+
@@ -0,0 +1,262 @@
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/SegmentNodeList.java
9
+ * Revision: 478
10
+ */
11
+
12
+
13
+ /**
14
+ * A list of the {@link SegmentNode}s present along a noded
15
+ * {@link SegmentString}.
16
+ *
17
+ * @constructor
18
+ */
19
+ jsts.noding.SegmentNodeList = function(edge) {
20
+ this.nodeMap = new javascript.util.TreeMap();
21
+
22
+ this.edge = edge;
23
+ };
24
+
25
+
26
+ /**
27
+ * @type {javascript.util.TreeMap}
28
+ * @private
29
+ */
30
+ jsts.noding.SegmentNodeList.prototype.nodeMap = null;
31
+
32
+ /**
33
+ * returns an iterator of SegmentNodes
34
+ */
35
+ jsts.noding.SegmentNodeList.prototype.iterator = function() {
36
+ return this.nodeMap.values().iterator();
37
+ };
38
+
39
+
40
+ /**
41
+ * the parent edge
42
+ *
43
+ * @type {NodedSegmentString}
44
+ * @private
45
+ */
46
+ jsts.noding.SegmentNodeList.prototype.edge = null;
47
+
48
+
49
+ jsts.noding.SegmentNodeList.prototype.getEdge = function() {
50
+ return this.edge;
51
+ };
52
+
53
+
54
+ /**
55
+ * Adds an intersection into the list, if it isn't already there. The input
56
+ * segmentIndex and dist are expected to be normalized.
57
+ *
58
+ * @return the SegmentIntersection found or added.
59
+ */
60
+ jsts.noding.SegmentNodeList.prototype.add = function(intPt, segmentIndex) {
61
+ var eiNew = new jsts.noding.SegmentNode(this.edge, intPt, segmentIndex,
62
+ this.edge.getSegmentOctant(segmentIndex));
63
+ var ei = this.nodeMap.get(eiNew);
64
+ if (ei !== null) {
65
+ jsts.util.Assert.isTrue(ei.coord.equals2D(intPt),
66
+ 'Found equal nodes with different coordinates');
67
+ return ei;
68
+ }
69
+ // node does not exist, so create it
70
+ this.nodeMap.put(eiNew, eiNew);
71
+ return eiNew;
72
+ };
73
+
74
+
75
+ /**
76
+ * Adds nodes for the first and last points of the edge
77
+ *
78
+ * @private
79
+ */
80
+ jsts.noding.SegmentNodeList.prototype.addEndpoints = function() {
81
+ var maxSegIndex = this.edge.size() - 1;
82
+ this.add(this.edge.getCoordinate(0), 0);
83
+ this.add(this.edge.getCoordinate(maxSegIndex), maxSegIndex);
84
+ };
85
+
86
+
87
+ /**
88
+ * Adds nodes for any collapsed edge pairs. Collapsed edge pairs can be caused
89
+ * by inserted nodes, or they can be pre-existing in the edge vertex list. In
90
+ * order to provide the correct fully noded semantics, the vertex at the base of
91
+ * a collapsed pair must also be added as a node.
92
+ *
93
+ * @private
94
+ */
95
+ jsts.noding.SegmentNodeList.prototype.addCollapsedNodes = function() {
96
+ var collapsedVertexIndexes = [];
97
+
98
+ this.findCollapsesFromInsertedNodes(collapsedVertexIndexes);
99
+ this.findCollapsesFromExistingVertices(collapsedVertexIndexes);
100
+
101
+ // node the collapses
102
+ for (var i = 0; i < collapsedVertexIndexes.length; i++) {
103
+ var vertexIndex = collapsedVertexIndexes[i];
104
+ this.add(this.edge.getCoordinate(vertexIndex), vertexIndex);
105
+ }
106
+ };
107
+
108
+
109
+ /**
110
+ * Adds nodes for any collapsed edge pairs which are pre-existing in the vertex
111
+ * list.
112
+ *
113
+ * @private
114
+ */
115
+ jsts.noding.SegmentNodeList.prototype.findCollapsesFromExistingVertices = function(
116
+ collapsedVertexIndexes) {
117
+ for (var i = 0; i < this.edge.size() - 2; i++) {
118
+ var p0 = this.edge.getCoordinate(i);
119
+ var p1 = this.edge.getCoordinate(i + 1);
120
+ var p2 = this.edge.getCoordinate(i + 2);
121
+ if (p0.equals2D(p2)) {
122
+ // add base of collapse as node
123
+ collapsedVertexIndexes.push(i + 1);
124
+ }
125
+ }
126
+ };
127
+
128
+
129
+ /**
130
+ * Adds nodes for any collapsed edge pairs caused by inserted nodes Collapsed
131
+ * edge pairs occur when the same coordinate is inserted as a node both before
132
+ * and after an existing edge vertex. To provide the correct fully noded
133
+ * semantics, the vertex must be added as a node as well.
134
+ *
135
+ * @private
136
+ */
137
+ jsts.noding.SegmentNodeList.prototype.findCollapsesFromInsertedNodes = function(
138
+ collapsedVertexIndexes) {
139
+ var collapsedVertexIndex = [null];
140
+ var it = this.iterator();
141
+ // there should always be at least two entries in the list, since the
142
+ // endpoints are nodes
143
+ var eiPrev = it.next();
144
+ while (it.hasNext()) {
145
+ var ei = it.next();
146
+ var isCollapsed = this.findCollapseIndex(eiPrev, ei, collapsedVertexIndex);
147
+ if (isCollapsed)
148
+ collapsedVertexIndexes.push(collapsedVertexIndex[0]);
149
+
150
+ eiPrev = ei;
151
+ }
152
+ };
153
+
154
+
155
+ /**
156
+ * @private
157
+ */
158
+ jsts.noding.SegmentNodeList.prototype.findCollapseIndex = function(ei0, ei1,
159
+ collapsedVertexIndex) {
160
+ // only looking for equal nodes
161
+ if (!ei0.coord.equals2D(ei1.coord))
162
+ return false;
163
+
164
+ var numVerticesBetween = ei1.segmentIndex - ei0.segmentIndex;
165
+ if (!ei1.isInterior()) {
166
+ numVerticesBetween--;
167
+ }
168
+
169
+ // if there is a single vertex between the two equal nodes, this is a collapse
170
+ if (numVerticesBetween === 1) {
171
+ collapsedVertexIndex[0] = ei0.segmentIndex + 1;
172
+ return true;
173
+ }
174
+ return false;
175
+ };
176
+
177
+
178
+ /**
179
+ * Creates new edges for all the edges that the intersections in this list split
180
+ * the parent edge into. Adds the edges to the provided argument list (this is
181
+ * so a single list can be used to accumulate all split edges for a set of
182
+ * {@link SegmentString}s).
183
+ *
184
+ * @param {Array}
185
+ * edgeList
186
+ */
187
+ jsts.noding.SegmentNodeList.prototype.addSplitEdges = function(edgeList) {
188
+ // ensure that the list has entries for the first and last point of the edge
189
+ this.addEndpoints();
190
+ this.addCollapsedNodes();
191
+
192
+ var it = this.iterator();
193
+ // there should always be at least two entries in the list, since the
194
+ // endpoints are nodes
195
+ var eiPrev = it.next();
196
+ while (it.hasNext()) {
197
+ var ei = it.next();
198
+ var newEdge = this.createSplitEdge(eiPrev, ei);
199
+ edgeList.add(newEdge);
200
+ eiPrev = ei;
201
+ }
202
+ };
203
+
204
+
205
+ /**
206
+ * Checks the correctness of the set of split edges corresponding to this edge.
207
+ *
208
+ * @param {Array}
209
+ * splitEdges the split edges for this edge (in order).
210
+ * @private
211
+ */
212
+ jsts.noding.SegmentNodeList.prototype.checkSplitEdgesCorrectness = function(
213
+ splitEdges) {
214
+ var edgePts = edge.getCoordinates();
215
+
216
+ // check that first and last points of split edges are same as endpoints of
217
+ // edge
218
+ var split0 = splitEdges[0];
219
+ var pt0 = split0.getCoordinate(0);
220
+ if (!pt0.equals2D(edgePts[0]))
221
+ throw new Error('bad split edge start point at ' + pt0);
222
+
223
+ var splitn = splitEdges[splitEdges.length - 1];
224
+ var splitnPts = splitn.getCoordinates();
225
+ var ptn = splitnPts[splitnPts.length - 1];
226
+ if (!ptn.equals2D(edgePts[edgePts.length - 1]))
227
+ throw new Error('bad split edge end point at ' + ptn);
228
+ };
229
+
230
+
231
+ /**
232
+ * Create a new "split edge" with the section of points between (and including)
233
+ * the two intersections. The label for the new edge is the same as the label
234
+ * for the parent edge.
235
+ *
236
+ * @private
237
+ */
238
+ jsts.noding.SegmentNodeList.prototype.createSplitEdge = function(ei0, ei1) {
239
+ var npts = ei1.segmentIndex - ei0.segmentIndex + 2;
240
+
241
+ var lastSegStartPt = this.edge.getCoordinate(ei1.segmentIndex);
242
+ // if the last intersection point is not equal to the its segment start pt,
243
+ // add it to the points list as well.
244
+ // (This check is needed because the distance metric is not totally reliable!)
245
+ // The check for point equality is 2D only - Z values are ignored
246
+ var useIntPt1 = ei1.isInterior() || !ei1.coord.equals2D(lastSegStartPt);
247
+ if (!useIntPt1) {
248
+ npts--;
249
+ }
250
+
251
+ var pts = [];
252
+ // pts.length = npts;
253
+ var ipt = 0;
254
+ pts[ipt++] = new jsts.geom.Coordinate(ei0.coord);
255
+ for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
256
+ pts[ipt++] = this.edge.getCoordinate(i);
257
+ }
258
+ if (useIntPt1)
259
+ pts[ipt] = ei1.coord;
260
+
261
+ return new jsts.noding.NodedSegmentString(pts, this.edge.getData());
262
+ };