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,328 @@
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
+ * Contains the parameters which describe how a buffer should be constructed.
10
+ *
11
+ * @constructor
12
+ */
13
+ jsts.operation.buffer.BufferParameters = function(quadrantSegments,
14
+ endCapStyle, joinStyle, mitreLimit) {
15
+ if (quadrantSegments)
16
+ this.setQuadrantSegments(quadrantSegments);
17
+ if (endCapStyle)
18
+ this.setEndCapStyle(endCapStyle);
19
+ if (joinStyle)
20
+ this.setJoinStyle(joinStyle);
21
+ if (mitreLimit)
22
+ this.setMitreLimit(mitreLimit);
23
+ };
24
+
25
+
26
+ /**
27
+ * Specifies a round line buffer end cap style.
28
+ *
29
+ * @type {int}
30
+ */
31
+ jsts.operation.buffer.BufferParameters.CAP_ROUND = 1;
32
+
33
+
34
+ /**
35
+ * Specifies a flat line buffer end cap style.
36
+ *
37
+ * @type {int}
38
+ */
39
+ jsts.operation.buffer.BufferParameters.CAP_FLAT = 2;
40
+
41
+
42
+ /**
43
+ * Specifies a square line buffer end cap style.
44
+ *
45
+ * @type {int}
46
+ */
47
+ jsts.operation.buffer.BufferParameters.CAP_SQUARE = 3;
48
+
49
+
50
+ /**
51
+ * Specifies a round join style.
52
+ *
53
+ * @type {int}
54
+ */
55
+ jsts.operation.buffer.BufferParameters.JOIN_ROUND = 1;
56
+
57
+
58
+ /**
59
+ * Specifies a mitre join style.
60
+ */
61
+ jsts.operation.buffer.BufferParameters.JOIN_MITRE = 2;
62
+
63
+
64
+ /**
65
+ * Specifies a bevel join style.
66
+ *
67
+ * @type {int}
68
+ */
69
+ jsts.operation.buffer.BufferParameters.JOIN_BEVEL = 3;
70
+
71
+
72
+ /**
73
+ * The default number of facets into which to divide a fillet of 90 degrees. A
74
+ * value of 8 gives less than 2% max error in the buffer distance. For a max
75
+ * error of < 1%, use QS = 12. For a max error of < 0.1%, use QS = 18.
76
+ *
77
+ * @type {int}
78
+ */
79
+ jsts.operation.buffer.BufferParameters.DEFAULT_QUADRANT_SEGMENTS = 8;
80
+
81
+
82
+ /**
83
+ * The default mitre limit Allows fairly pointy mitres.
84
+ *
85
+ * @type {double}
86
+ */
87
+ jsts.operation.buffer.BufferParameters.DEFAULT_MITRE_LIMIT = 5.0;
88
+
89
+
90
+ /**
91
+ * @type {int}
92
+ * @private
93
+ */
94
+ jsts.operation.buffer.BufferParameters.prototype.quadrantSegments = jsts.operation.buffer.BufferParameters.DEFAULT_QUADRANT_SEGMENTS;
95
+
96
+
97
+ /**
98
+ * @type {int}
99
+ * @private
100
+ */
101
+ jsts.operation.buffer.BufferParameters.prototype.endCapStyle = jsts.operation.buffer.BufferParameters.CAP_ROUND;
102
+
103
+
104
+ /**
105
+ * @type {int}
106
+ * @private
107
+ */
108
+ jsts.operation.buffer.BufferParameters.prototype.joinStyle = jsts.operation.buffer.BufferParameters.JOIN_ROUND;
109
+
110
+
111
+ /**
112
+ * @type {double}
113
+ * @private
114
+ */
115
+ jsts.operation.buffer.BufferParameters.prototype.mitreLimit = jsts.operation.buffer.BufferParameters.DEFAULT_MITRE_LIMIT;
116
+
117
+ /**
118
+ * @type {boolean}
119
+ * @private
120
+ */
121
+ jsts.operation.buffer.BufferParameters.prototype._isSingleSided = false;
122
+
123
+ /**
124
+ * Gets the number of quadrant segments which will be used
125
+ *
126
+ * @return the number of quadrant segments.
127
+ */
128
+ jsts.operation.buffer.BufferParameters.prototype.getQuadrantSegments = function() {
129
+ return this.quadrantSegments;
130
+ };
131
+
132
+
133
+ /**
134
+ * Sets the number of segments used to approximate a angle fillet
135
+ *
136
+ * @param {int}
137
+ * quadrantSegments the number of segments in a fillet for a quadrant.
138
+ */
139
+ jsts.operation.buffer.BufferParameters.prototype.setQuadrantSegments = function(
140
+ quadrantSegments) {
141
+ this.quadrantSegments = quadrantSegments;
142
+ };
143
+
144
+
145
+ /**
146
+ * Sets the number of line segments used to approximate an angle fillet.
147
+ * <ul>
148
+ * <li>If <tt>quadSegs</tt> >= 1, joins are round, and <tt>quadSegs</tt>
149
+ * indicates the number of segments to use to approximate a quarter-circle.
150
+ * <li>If <tt>quadSegs</tt> = 0, joins are bevelled (flat)
151
+ * <li>If <tt>quadSegs</tt> < 0, joins are mitred, and the value of qs
152
+ * indicates the mitre ration limit as
153
+ *
154
+ * <pre>
155
+ * mitreLimit= |
156
+ * <tt>
157
+ * quadSegs
158
+ * </tt>
159
+ * |
160
+ * </pre>
161
+ *
162
+ * </ul>
163
+ * For round joins, <tt>quadSegs</tt> determines the maximum error in the
164
+ * approximation to the true buffer curve. The default value of 8 gives less
165
+ * than 2% max error in the buffer distance. For a max error of < 1%, use QS =
166
+ * 12. For a max error of < 0.1%, use QS = 18. The error is always less than the
167
+ * buffer distance (in other words, the computed buffer curve is always inside
168
+ * the true curve).
169
+ *
170
+ * @param quadrantSegments
171
+ * the number of segments in a fillet for a quadrant.
172
+ */
173
+ jsts.operation.buffer.BufferParameters.prototype.setQuadrantSegments = function(
174
+ quadSegs) {
175
+ this.quadrantSegments = quadSegs;
176
+
177
+ /**
178
+ * Indicates how to construct fillets. If qs >= 1, fillet is round, and qs
179
+ * indicates number of segments to use to approximate a quarter-circle. If qs =
180
+ * 0, fillet is bevelled flat (i.e. no filleting is performed) If qs < 0,
181
+ * fillet is mitred, and absolute value of qs indicates maximum length of
182
+ * mitre according to
183
+ *
184
+ * mitreLimit = |qs|
185
+ */
186
+ if (this.quadrantSegments === 0)
187
+ this.joinStyle = jsts.operation.buffer.BufferParameters.JOIN_BEVEL;
188
+ if (this.quadrantSegments < 0) {
189
+ this.joinStyle = jsts.operation.buffer.BufferParameters.JOIN_MITRE;
190
+ this.mitreLimit = Math.abs(this.quadrantSegments);
191
+ }
192
+
193
+ if (quadSegs <= 0) {
194
+ this.quadrantSegments = 1;
195
+ }
196
+
197
+ /**
198
+ * If join style was set by the quadSegs value, use the default for the actual
199
+ * quadrantSegments value.
200
+ */
201
+ if (this.joinStyle !== jsts.operation.buffer.BufferParameters.JOIN_ROUND) {
202
+ this.quadrantSegments = jsts.operation.buffer.BufferParameters.DEFAULT_QUADRANT_SEGMENTS;
203
+ }
204
+ };
205
+
206
+
207
+ /**
208
+ * Computes the maximum distance error due to a given level of approximation to
209
+ * a true arc.
210
+ *
211
+ * @param quadSegs
212
+ * the number of segments used to approximate a quarter-circle.
213
+ * @return the error of approximation.
214
+ */
215
+ jsts.operation.buffer.BufferParameters.bufferDistanceError = function(quadSegs) {
216
+ var alpha = Math.PI / 2.0 / quadSegs;
217
+ return 1 - Math.cos(alpha / 2.0);
218
+ };
219
+
220
+
221
+ /**
222
+ * Gets the end cap style.
223
+ *
224
+ * @return the end cap style.
225
+ */
226
+ jsts.operation.buffer.BufferParameters.prototype.getEndCapStyle = function() {
227
+ return this.endCapStyle;
228
+ };
229
+
230
+
231
+ /**
232
+ * Specifies the end cap style of the generated buffer. The styles supported are
233
+ * {@link #CAP_ROUND}, {@link #CAP_BUTT}, and {@link #CAP_SQUARE}. The
234
+ * default is CAP_ROUND.
235
+ *
236
+ * @param {int}
237
+ * endCapStyle the end cap style to specify.
238
+ */
239
+ jsts.operation.buffer.BufferParameters.prototype.setEndCapStyle = function(
240
+ endCapStyle) {
241
+ this.endCapStyle = endCapStyle;
242
+ };
243
+
244
+
245
+ /**
246
+ * Gets the join style
247
+ *
248
+ * @return the join style code.
249
+ */
250
+ jsts.operation.buffer.BufferParameters.prototype.getJoinStyle = function() {
251
+ return this.joinStyle;
252
+ };
253
+
254
+
255
+ /**
256
+ * Sets the join style for outside (reflex) corners between line segments.
257
+ * Allowable values are {@link JOIN_ROUND} (which is the default),
258
+ * {@link JOIN_MITRE} and {link JOIN_BEVEL}.
259
+ *
260
+ * @param joinStyle
261
+ * the code for the join style.
262
+ */
263
+ jsts.operation.buffer.BufferParameters.prototype.setJoinStyle = function(
264
+ joinStyle) {
265
+ this.joinStyle = joinStyle;
266
+ };
267
+
268
+
269
+ /**
270
+ * Gets the mitre ratio limit.
271
+ *
272
+ * @return the limit value.
273
+ */
274
+ jsts.operation.buffer.BufferParameters.prototype.getMitreLimit = function() {
275
+ return this.mitreLimit;
276
+ };
277
+
278
+
279
+ /**
280
+ * Sets the limit on the mitre ratio used for very sharp corners. The mitre
281
+ * ratio is the ratio of the distance from the corner to the end of the mitred
282
+ * offset corner. When two line segments meet at a sharp angle, a miter join
283
+ * will extend far beyond the original geometry. (and in the extreme case will
284
+ * be infinitely far.) To prevent unreasonable geometry, the mitre limit allows
285
+ * controlling the maximum length of the join corner. Corners with a ratio which
286
+ * exceed the limit will be beveled.
287
+ *
288
+ * @param mitreLimit
289
+ * the mitre ratio limit.
290
+ */
291
+ jsts.operation.buffer.BufferParameters.prototype.setMitreLimit = function(
292
+ mitreLimit) {
293
+ this.mitreLimit = mitreLimit;
294
+ };
295
+
296
+
297
+ /**
298
+ * Sets whether the computed buffer should be single-sided. A single-sided
299
+ * buffer is constructed on only one side of each input line.
300
+ * <p>
301
+ * The side used is determined by the sign of the buffer distance:
302
+ * <ul>
303
+ * <li>a positive distance indicates the left-hand side
304
+ * <li>a negative distance indicates the right-hand side
305
+ * </ul>
306
+ * The single-sided buffer of point geometries is the same as the regular
307
+ * buffer.
308
+ * <p>
309
+ * The End Cap Style for single-sided buffers is always ignored, and forced to
310
+ * the equivalent of <tt>CAP_FLAT</tt>.
311
+ *
312
+ * @param isSingleSided
313
+ * true if a single-sided buffer should be constructed.
314
+ */
315
+ jsts.operation.buffer.BufferParameters.prototype.setSingleSided = function(
316
+ isSingleSided) {
317
+ this._isSingleSided = isSingleSided;
318
+ };
319
+
320
+
321
+ /**
322
+ * Tests whether the buffer is to be generated on a single side only.
323
+ *
324
+ * @return true if the generated buffer is to be single-sided.
325
+ */
326
+ jsts.operation.buffer.BufferParameters.prototype.isSingleSided = function() {
327
+ return this._isSingleSided;
328
+ };
@@ -0,0 +1,296 @@
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
+ * A connected subset of the graph of {@link DirectedEdge}s and {@link Node}s.
9
+ * Its edges will generate either
10
+ * <ul>
11
+ * <li> a single polygon in the complete buffer, with zero or more holes, or
12
+ * <li> one or more connected holes
13
+ * </ul>
14
+ *
15
+ *
16
+ * @constructor
17
+ */
18
+ jsts.operation.buffer.BufferSubgraph = function() {
19
+ this.dirEdgeList = new javascript.util.ArrayList();
20
+ this.nodes = new javascript.util.ArrayList();
21
+
22
+ this.finder = new jsts.operation.buffer.RightmostEdgeFinder();
23
+ };
24
+
25
+ /**
26
+ * @type {RightmostEdgeFinder}
27
+ * @private
28
+ */
29
+ jsts.operation.buffer.BufferSubgraph.prototype.finder = null;
30
+ /**
31
+ * @type {Array}
32
+ * @private
33
+ */
34
+ jsts.operation.buffer.BufferSubgraph.prototype.dirEdgeList = null;
35
+ /**
36
+ * @type {Array}
37
+ * @private
38
+ */
39
+ jsts.operation.buffer.BufferSubgraph.prototype.nodes = null;
40
+ /**
41
+ * @type {Coordinate}
42
+ * @private
43
+ */
44
+ jsts.operation.buffer.BufferSubgraph.prototype.rightMostCoord = null;
45
+ /**
46
+ * @type {Envelope}
47
+ * @private
48
+ */
49
+ jsts.operation.buffer.BufferSubgraph.prototype.env = null;
50
+
51
+
52
+ jsts.operation.buffer.BufferSubgraph.prototype.getDirectedEdges = function() {
53
+ return this.dirEdgeList;
54
+ };
55
+ jsts.operation.buffer.BufferSubgraph.prototype.getNodes = function() {
56
+ return this.nodes;
57
+ };
58
+
59
+ /**
60
+ * Computes the envelope of the edges in the subgraph. The envelope is cached
61
+ * after being computed.
62
+ *
63
+ * @return the envelope of the graph.
64
+ */
65
+ jsts.operation.buffer.BufferSubgraph.prototype.getEnvelope = function() {
66
+ if (this.env === null) {
67
+ var edgeEnv = new jsts.geom.Envelope();
68
+ for (var it = this.dirEdgeList.iterator(); it.hasNext(); ) {
69
+ var dirEdge = it.next();
70
+ var pts = dirEdge.getEdge().getCoordinates();
71
+ for (var j = 0; j < pts.length - 1; j++) {
72
+ edgeEnv.expandToInclude(pts[j]);
73
+ }
74
+ }
75
+ this.env = edgeEnv;
76
+ }
77
+ return this.env;
78
+ };
79
+
80
+ /**
81
+ * Gets the rightmost coordinate in the edges of the subgraph
82
+ */
83
+ jsts.operation.buffer.BufferSubgraph.prototype.getRightmostCoordinate = function() {
84
+ return this.rightMostCoord;
85
+ };
86
+
87
+ /**
88
+ * Creates the subgraph consisting of all edges reachable from this node. Finds
89
+ * the edges in the graph and the rightmost coordinate.
90
+ *
91
+ * @param node
92
+ * a node to start the graph traversal from.
93
+ */
94
+ jsts.operation.buffer.BufferSubgraph.prototype.create = function(node) {
95
+ this.addReachable(node);
96
+ this.finder.findEdge(this.dirEdgeList);
97
+ this.rightMostCoord = this.finder.getCoordinate();
98
+ };
99
+
100
+ /**
101
+ * Adds all nodes and edges reachable from this node to the subgraph. Uses an
102
+ * explicit stack to avoid a large depth of recursion.
103
+ *
104
+ * @param node
105
+ * a node known to be in the subgraph.
106
+ * @private
107
+ */
108
+ jsts.operation.buffer.BufferSubgraph.prototype.addReachable = function(
109
+ startNode) {
110
+ var nodeStack = [];
111
+ nodeStack.push(startNode);
112
+ while (nodeStack.length !== 0) {
113
+ var node = nodeStack.pop();
114
+ this.add(node, nodeStack);
115
+ }
116
+ };
117
+
118
+ /**
119
+ * Adds the argument node and all its out edges to the subgraph
120
+ *
121
+ * @param node
122
+ * the node to add.
123
+ * @param nodeStack
124
+ * the current set of nodes being traversed.
125
+ * @private
126
+ */
127
+ jsts.operation.buffer.BufferSubgraph.prototype.add = function(node, nodeStack) {
128
+ node.setVisited(true);
129
+ this.nodes.add(node);
130
+ for (var i = node.getEdges().iterator(); i.hasNext(); ) {
131
+ var de = i.next();
132
+ this.dirEdgeList.add(de);
133
+ var sym = de.getSym();
134
+ var symNode = sym.getNode();
135
+ /**
136
+ * NOTE: this is a depth-first traversal of the graph. This will cause a
137
+ * large depth of recursion. It might be better to do a breadth-first
138
+ * traversal.
139
+ */
140
+ if (!symNode.isVisited())
141
+ nodeStack.push(symNode);
142
+ }
143
+ };
144
+
145
+ jsts.operation.buffer.BufferSubgraph.prototype.clearVisitedEdges = function() {
146
+ for (var it = this.dirEdgeList.iterator(); it.hasNext(); ) {
147
+ var de = it.next();
148
+ de.setVisited(false);
149
+ }
150
+ };
151
+
152
+ jsts.operation.buffer.BufferSubgraph.prototype.computeDepth = function(
153
+ outsideDepth) {
154
+ this.clearVisitedEdges();
155
+ // find an outside edge to assign depth to
156
+ var de = this.finder.getEdge();
157
+ var n = de.getNode();
158
+ var label = de.getLabel();
159
+ // right side of line returned by finder is on the outside
160
+ de.setEdgeDepths(jsts.geomgraph.Position.RIGHT, outsideDepth);
161
+ this.copySymDepths(de);
162
+
163
+ this.computeDepths(de);
164
+ };
165
+
166
+ /**
167
+ * Compute depths for all dirEdges via breadth-first traversal of nodes in graph
168
+ *
169
+ * @param startEdge
170
+ * edge to start processing with.
171
+ * @private
172
+ */
173
+ // <FIX> MD - use iteration & queue rather than recursion, for speed and
174
+ // robustness
175
+ jsts.operation.buffer.BufferSubgraph.prototype.computeDepths = function(
176
+ startEdge) {
177
+ var nodesVisited = [];
178
+ var nodeQueue = [];
179
+
180
+ var startNode = startEdge.getNode();
181
+ nodeQueue.push(startNode);
182
+ nodesVisited.push(startNode);
183
+ startEdge.setVisited(true);
184
+
185
+ while (nodeQueue.length !== 0) {
186
+ var n = nodeQueue.shift();
187
+ nodesVisited.push(n);
188
+ // compute depths around node, starting at this edge since it has depths
189
+ // assigned
190
+ this.computeNodeDepth(n);
191
+
192
+ // add all adjacent nodes to process queue,
193
+ // unless the node has been visited already
194
+ for (var i = n.getEdges().iterator(); i.hasNext(); ) {
195
+ var de = i.next();
196
+ var sym = de.getSym();
197
+ if (sym.isVisited())
198
+ continue;
199
+ var adjNode = sym.getNode();
200
+ if (nodesVisited.indexOf(adjNode) === -1) {
201
+ nodeQueue.push(adjNode);
202
+ nodesVisited.push(adjNode);
203
+ }
204
+ }
205
+ }
206
+ };
207
+
208
+ /**
209
+ * @private
210
+ */
211
+ jsts.operation.buffer.BufferSubgraph.prototype.computeNodeDepth = function(n) {
212
+ // find a visited dirEdge to start at
213
+ var startEdge = null;
214
+ for (var i = n.getEdges().iterator(); i.hasNext(); ) {
215
+ var de = i.next();
216
+ if (de.isVisited() || de.getSym().isVisited()) {
217
+ startEdge = de;
218
+ break;
219
+ }
220
+ }
221
+ // MD - testing Result: breaks algorithm
222
+ // if (startEdge == null) return;
223
+
224
+ // only compute string append if assertion would fail
225
+ if (startEdge == null)
226
+ throw new jsts.error.TopologyError(
227
+ 'unable to find edge to compute depths at ' + n.getCoordinate());
228
+
229
+ n.getEdges().computeDepths(startEdge);
230
+
231
+ // copy depths to sym edges
232
+ for (var i = n.getEdges().iterator(); i.hasNext(); ) {
233
+ var de = i.next();
234
+ de.setVisited(true);
235
+ this.copySymDepths(de);
236
+ }
237
+ };
238
+
239
+ /**
240
+ * @private
241
+ */
242
+ jsts.operation.buffer.BufferSubgraph.prototype.copySymDepths = function(de) {
243
+ var sym = de.getSym();
244
+ sym.setDepth(jsts.geomgraph.Position.LEFT, de
245
+ .getDepth(jsts.geomgraph.Position.RIGHT));
246
+ sym.setDepth(jsts.geomgraph.Position.RIGHT, de
247
+ .getDepth(jsts.geomgraph.Position.LEFT));
248
+ };
249
+
250
+ /**
251
+ * Find all edges whose depths indicates that they are in the result area(s).
252
+ * Since we want polygon shells to be oriented CW, choose dirEdges with the
253
+ * interior of the result on the RHS. Mark them as being in the result. Interior
254
+ * Area edges are the result of dimensional collapses. They do not form part of
255
+ * the result area boundary.
256
+ */
257
+ jsts.operation.buffer.BufferSubgraph.prototype.findResultEdges = function() {
258
+ for (var it = this.dirEdgeList.iterator(); it.hasNext(); ) {
259
+ var de = it.next();
260
+ /**
261
+ * Select edges which have an interior depth on the RHS
262
+ * and an exterior depth on the LHS.
263
+ * Note that because of weird rounding effects there may be
264
+ * edges which have negative depths! Negative depths
265
+ * count as "outside".
266
+ */
267
+ // <FIX> - handle negative depths
268
+ if (de.getDepth(jsts.geomgraph.Position.RIGHT) >= 1 &&
269
+ de.getDepth(jsts.geomgraph.Position.LEFT) <= 0 &&
270
+ !de.isInteriorAreaEdge()) {
271
+ de.setInResult(true);
272
+ }
273
+ }
274
+ };
275
+
276
+ /**
277
+ * BufferSubgraphs are compared on the x-value of their rightmost Coordinate.
278
+ * This defines a partial ordering on the graphs such that:
279
+ * <p>
280
+ * g1 >= g2 <==> Ring(g2) does not contain Ring(g1)
281
+ * <p>
282
+ * where Polygon(g) is the buffer polygon that is built from g.
283
+ * <p>
284
+ * This relationship is used to sort the BufferSubgraphs so that shells are
285
+ * guaranteed to be built before holes.
286
+ */
287
+ jsts.operation.buffer.BufferSubgraph.prototype.compareTo = function(o) {
288
+ var graph = o;
289
+ if (this.rightMostCoord.x < graph.rightMostCoord.x) {
290
+ return -1;
291
+ }
292
+ if (this.rightMostCoord.x > graph.rightMostCoord.x) {
293
+ return 1;
294
+ }
295
+ return 0;
296
+ };