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,111 @@
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
+ * Computes a Delauanay Triangulation of a set of {@link Vertex}es, using an
11
+ * incrementatal insertion algorithm.
12
+ *
13
+ * @author Martin Davis
14
+ * @version 1.0
15
+ */
16
+
17
+ (function() {
18
+ /**
19
+ * Creates a new triangulator using the given {@link QuadEdgeSubdivision}.
20
+ * The triangulator uses the tolerance of the supplied subdivision.
21
+ *
22
+ * @param subdiv
23
+ * a subdivision in which to build the TIN.
24
+ */
25
+ jsts.triangulate.IncrementalDelaunayTriangulator = function(subdiv) {
26
+ this.subdiv = subdiv;
27
+ this.isUsingTolerance = subdiv.getTolerance() > 0.0;
28
+ };
29
+
30
+ /**
31
+ * Inserts all sites in a collection. The inserted vertices <b>MUST</b> be
32
+ * unique up to the provided tolerance value. (i.e. no two vertices should be
33
+ * closer than the provided tolerance value). They do not have to be rounded
34
+ * to the tolerance grid, however.
35
+ *
36
+ * @param {jsts.triangulate.quadedge.Vertex[]}
37
+ * vertices an array of Vertices.
38
+ *
39
+ * @throws LocateFailureException if the location algorithm fails to converge in a reasonable number of iterations
40
+ */
41
+ jsts.triangulate.IncrementalDelaunayTriangulator.prototype.insertSites = function(vertices) {
42
+ var i = 0, il = vertices.length, v;
43
+
44
+ for (i; i < il; i++) {
45
+ v = vertices[i];
46
+ this.insertSite(v);
47
+ }
48
+ };
49
+
50
+ /**
51
+ * Inserts a new point into a subdivision representing a Delaunay
52
+ * triangulation, and fixes the affected edges so that the result is still a
53
+ * Delaunay triangulation.
54
+ * <p>
55
+ *
56
+ * @param {jsts.triangulate.quadedge.Vertex}
57
+ * v the vertex to insert.
58
+ *
59
+ * @return {jsts.triangulate.quadedge.QuadEdge}
60
+ * a quadedge containing the inserted vertex.
61
+ */
62
+ jsts.triangulate.IncrementalDelaunayTriangulator.prototype.insertSite = function(v) {
63
+ /**
64
+ * This code is based on Guibas and Stolfi (1985), with minor modifications
65
+ * and a bug fix from Dani Lischinski (Graphic Gems 1993). (The modification
66
+ * I believe is the test for the inserted site falling exactly on an
67
+ * existing edge. Without this test zero-width triangles have been observed
68
+ * to be created)
69
+ */
70
+
71
+ var e, base, startEdge, t;
72
+
73
+ e = this.subdiv.locate(v);
74
+ if (this.subdiv.isVertexOfEdge(e, v)) {
75
+ // point is already in subdivision.
76
+ return e;
77
+ }
78
+ else if (this.subdiv.isOnEdge(e, v.getCoordinate())) {
79
+ // the point lies exactly on an edge, so delete the edge
80
+ // (it will be replaced by a pair of edges which have the point as a vertex)
81
+ e = e.oPrev();
82
+ this.subdiv.delete_jsts(e.oNext());
83
+ }
84
+
85
+ /**
86
+ * Connect the new point to the vertices of the containing triangle
87
+ * (or quadrilateral, if the new point fell on an existing edge.)
88
+ */
89
+ base = this.subdiv.makeEdge(e.orig(), v);
90
+ jsts.triangulate.quadedge.QuadEdge.splice(base, e);
91
+ startEdge = base;
92
+ do {
93
+ base = this.subdiv.connect(e, base.sym());
94
+ e = base.oPrev();
95
+ } while (e.lNext() != startEdge);
96
+
97
+ // Examine suspect edges to ensure that the Delaunay condition
98
+ // is satisfied.
99
+ do {
100
+ t = e.oPrev();
101
+ if (t.dest().rightOf(e) && v.isInCircle(e.orig(), t.dest(), e.dest())) {
102
+ jsts.triangulate.quadedge.QuadEdge.swap(e);
103
+ e = e.oPrev();
104
+ } else if (e.oNext() == startEdge) {
105
+ return base; // no more suspect edges.
106
+ } else {
107
+ e = e.oNext().lPrev();
108
+ }
109
+ } while (true);
110
+ };
111
+ }());
@@ -0,0 +1,172 @@
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 utility class which creates Voronoi Diagrams
9
+ * from collections of points.
10
+ * The diagram is returned as a {@link GeometryCollection} of {@link Polygon}s,
11
+ * clipped to the larger of a supplied envelope or to an envelope determined
12
+ * by the input sites.
13
+ *
14
+ * @author Martin Davis
15
+ *
16
+ * @constructor
17
+ */
18
+ jsts.triangulate.VoronoiDiagramBuilder = function() {
19
+ this.siteCoords = null;
20
+ this.tolerance = 0.0;
21
+ this.subdiv = null;
22
+ this.clipEnv = null;
23
+ this.diagramEnv = null;
24
+ };
25
+
26
+ /**
27
+ * Sets the sites of the builder. Will call correct setSites* based on arguments
28
+ */
29
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.setSites = function() {
30
+ var arg = arguments[0];
31
+
32
+ if (arg instanceof jsts.geom.Geometry ||
33
+ arg instanceof jsts.geom.Coordinate || arg instanceof jsts.geom.Point ||
34
+ arg instanceof jsts.geom.MultiPoint ||
35
+ arg instanceof jsts.geom.LineString ||
36
+ arg instanceof jsts.geom.MultiLineString ||
37
+ arg instanceof jsts.geom.LinearRing || arg instanceof jsts.geom.Polygon ||
38
+ arg instanceof jsts.geom.MultiPolygon) {
39
+ this.setSitesByGeometry(arg);
40
+ } else {
41
+ this.setSitesByArray(arg);
42
+ }
43
+ };
44
+
45
+ /**
46
+ * Sets the sites (point or vertices) which will be diagrammed.
47
+ * All vertices of the given geometry will be used as sites.
48
+ *
49
+ * @param {jsts.geom.Geometry}
50
+ * geom the geometry from which the sites will be extracted.
51
+ */
52
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.setSitesByGeometry = function(geom) {
53
+ //remove any duplicate points (they will cause the triangulation to fail)
54
+ this.siteCoords = jsts.triangulate.DelaunayTriangulationBuilder.extractUniqueCoordinates(geom);
55
+ };
56
+
57
+ /**
58
+ * Sets the sites (point or vertices) which will be diagrammed
59
+ * from a collection of {@link Coordinate}s.
60
+ *
61
+ * @param {jsts.geom.Coordinate[]}
62
+ * coords an array of Coordinates.
63
+ */
64
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.setSitesByArray = function(coords) {
65
+ this.siteCoords = jsts.triangulate.DelaunayTriangulationBuilder.unique(coords);
66
+ };
67
+
68
+ /**
69
+ * Sets the envelope to clip the diagram to.
70
+ * The diagram will be clipped to the larger
71
+ * of this envelope or an envelope surrounding the sites.
72
+ *
73
+ * @param {jsts.geom.Envelope}
74
+ * clipEnv the clip envelope.
75
+ */
76
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.setClipEnvelope = function(clipEnv) {
77
+ this.clipEnv = clipEnv;
78
+ };
79
+
80
+ /**
81
+ * Sets the snapping tolerance which will be used
82
+ * to improved the robustness of the triangulation computation.
83
+ * A tolerance of 0.0 specifies that no snapping will take place.
84
+ *
85
+ * @param {number}
86
+ * tolerance the tolerance distance to use.
87
+ */
88
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.setTolerance = function(tolerance)
89
+ {
90
+ this.tolerance = tolerance;
91
+ };
92
+
93
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.create = function() {
94
+ if (this.subdiv !== null) {
95
+ return;
96
+ }
97
+
98
+ var siteEnv, expandBy, vertices, triangulator;
99
+
100
+ siteEnv = jsts.triangulate.DelaunayTriangulationBuilder.envelope(this.siteCoords);
101
+ this.diagramEnv = siteEnv;
102
+
103
+ // add a buffer around the final envelope
104
+ expandBy = Math.max(this.diagramEnv.getWidth(), this.diagramEnv.getHeight());
105
+ this.diagramEnv.expandBy(expandBy);
106
+
107
+ if (this.clipEnv !== null) {
108
+ this.diagramEnv.expandToInclude(this.clipEnv);
109
+ }
110
+
111
+ vertices = jsts.triangulate.DelaunayTriangulationBuilder.toVertices(this.siteCoords);
112
+ this.subdiv = new jsts.triangulate.quadedge.QuadEdgeSubdivision(siteEnv, this.tolerance);
113
+ triangulator = new jsts.triangulate.IncrementalDelaunayTriangulator(this.subdiv);
114
+ triangulator.insertSites(vertices);
115
+ };
116
+
117
+ /**
118
+ * Gets the {@link QuadEdgeSubdivision} which models the computed diagram.
119
+ *
120
+ * @return {jsts.triangulate.quadedge.QuadEdgeSubdivision}
121
+ * the subdivision containing the triangulation.
122
+ */
123
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.getSubdivision = function() {
124
+ this.create();
125
+ return this.subdiv;
126
+ };
127
+
128
+ /**
129
+ * Gets the faces of the computed diagram as a {@link GeometryCollection}
130
+ * of {@link Polygon}s, clipped as specified.
131
+ *
132
+ * @param {jsts.geom.GeometryFactory}
133
+ * geomFact the geometry factory to use to create the output.
134
+ * @return {jsts.geom.GeometryCollection}
135
+ * the faces of the diagram.
136
+ */
137
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.getDiagram = function(geomFact) {
138
+ this.create();
139
+ var polys = this.subdiv.getVoronoiDiagram(geomFact);
140
+
141
+ // clip polys to diagramEnv
142
+ return this.clipGeometryCollection(polys, this.diagramEnv);
143
+ };
144
+
145
+ jsts.triangulate.VoronoiDiagramBuilder.prototype.clipGeometryCollection = function(geom, clipEnv) {
146
+ var clipPoly, clipped, i, il, g, result;
147
+
148
+ clipPoly = geom.getFactory().toGeometry(clipEnv);
149
+
150
+ clipped = [];
151
+ i = 0, il = geom.getNumGeometries();
152
+
153
+ for (i; i < il; i++) {
154
+ g = geom.getGeometryN(i);
155
+ result = null;
156
+ // don't clip unless necessary
157
+ if (clipEnv.contains(g.getEnvelopeInternal())) {
158
+ result = g;
159
+ }
160
+ else if (clipEnv.intersects(g.getEnvelopeInternal())) {
161
+ result = clipPoly.intersection(g);
162
+ // keep vertex key info
163
+ //result.setUserData(g.getUserData());
164
+ }
165
+
166
+ if (result !== null && !result.isEmpty()) {
167
+ clipped.push(result);
168
+ }
169
+ }
170
+
171
+ return geom.getFactory().createGeometryCollection(clipped);
172
+ };
@@ -0,0 +1,52 @@
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
+ * Locates {@link QuadEdge}s in a {@link QuadEdgeSubdivision},
11
+ * optimizing the search by starting in the
12
+ * locality of the last edge found.
13
+ *
14
+ * @author Martin Davis
15
+ */
16
+
17
+ /**
18
+ * @constructor
19
+ * @param {jsts.triangulate.quadedge.QuadEdgeSubdivision}
20
+ * subdiv the subdivision.
21
+ */
22
+ jsts.triangulate.quadedge.LastFoundQuadEdgeLocator = function(subdiv) {
23
+ this.subdiv = subdiv;
24
+ this.lastEdge = null;
25
+ this.init();
26
+ };
27
+
28
+ jsts.triangulate.quadedge.LastFoundQuadEdgeLocator.prototype.init = function() {
29
+ this.lastEdge = this.findEdge();
30
+ };
31
+
32
+ jsts.triangulate.quadedge.LastFoundQuadEdgeLocator.prototype.findEdge = function() {
33
+ var edges = this.subdiv.getEdges();
34
+ return edges[0];
35
+ };
36
+
37
+ /**
38
+ * Locates an edge e, such that either v is on e, or e is an edge of a triangle containing v.
39
+ * The search starts from the last located edge amd proceeds on the general direction of v.
40
+ *
41
+ * @param {jsts.triangulate.quadedge.Vertex}
42
+ * v the vertex.
43
+ */
44
+ jsts.triangulate.quadedge.LastFoundQuadEdgeLocator.prototype.locate = function(v) {
45
+ if (!this.lastEdge.isLive()) {
46
+ this.init();
47
+ }
48
+
49
+ var e = this.subdiv.locateFromEdge(v, this.lastEdge);
50
+ this.lastEdge = e;
51
+ return e;
52
+ };
@@ -0,0 +1,437 @@
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
+ (function() {
9
+ /**
10
+ * A class that represents the edge data structure which implements the quadedge algebra.
11
+ * The quadedge algebra was described in a well-known paper by Guibas and Stolfi,
12
+ * "Primitives for the manipulation of general subdivisions and the computation of Voronoi diagrams",
13
+ * <i>ACM Transactions on Graphics</i>, 4(2), 1985, 75-123.
14
+ * <p>
15
+ * Each edge object is part of a quartet of 4 edges,
16
+ * linked via their <tt>rot</tt> references.
17
+ * Any edge in the group may be accessed using a series of {@link #rot} operations.
18
+ * Quadedges in a subdivision are linked together via their <tt>next</tt> references.
19
+ * The linkage between the quadedge quartets determines the topology
20
+ * of the subdivision.
21
+ * <p>
22
+ * The edge class does not contain separate information for vertice or faces; a vertex is implicitly
23
+ * defined as a ring of edges (created using the <tt>next</tt> field).
24
+ *
25
+ * @author David Skea
26
+ * @author Martin Davis
27
+ */
28
+
29
+ /**
30
+ * Quadedges must be made using {@link makeEdge},
31
+ * to ensure proper construction.
32
+ *
33
+ * @constructor
34
+ */
35
+ jsts.triangulate.quadedge.QuadEdge = function() {
36
+ // the dual of this edge, directed from right to left
37
+ this.rot = null;
38
+ this.vertex = null; // The vertex that this edge represents
39
+ this.next = null; // A reference to a connected edge
40
+ this.data = null;
41
+ };
42
+
43
+ var QuadEdge = jsts.triangulate.quadedge.QuadEdge;
44
+
45
+ /**
46
+ * Creates a new QuadEdge quartet from {@link Vertex} o to {@link Vertex} d.
47
+ *
48
+ * @param {jsts.triangulate.quadedge.Vertex}
49
+ * o the origin Vertex.
50
+ * @param {jsts.triangulate.quadedge.Vertex}
51
+ * d the destination Vertex.
52
+ * @return the new QuadEdge quartet.
53
+ */
54
+ jsts.triangulate.quadedge.QuadEdge.makeEdge = function(o, d) {
55
+ var q0, q1, q2, q3, base;
56
+
57
+ q0 = new QuadEdge();
58
+ q1 = new QuadEdge();
59
+ q2 = new QuadEdge();
60
+ q3 = new QuadEdge();
61
+
62
+ q0.rot = q1;
63
+ q1.rot = q2;
64
+ q2.rot = q3;
65
+ q3.rot = q0;
66
+
67
+ q0.setNext(q0);
68
+ q1.setNext(q3);
69
+ q2.setNext(q2);
70
+ q3.setNext(q1);
71
+
72
+ base = q0;
73
+ base.setOrig(o);
74
+ base.setDest(d);
75
+ return base;
76
+ };
77
+
78
+ /**
79
+ * Creates a new QuadEdge connecting the destination of a to the origin of
80
+ * b, in such a way that all three have the same left face after the
81
+ * connection is complete. Additionally, the data pointers of the new edge
82
+ * are set.
83
+ *
84
+ * @param {jsts.triangulate.quadedge.QuadEdge}
85
+ * a the first edge to connect.
86
+ * @param {jsts.triangulate.quadedge.QuadEdge}
87
+ * b the second edge to connect.
88
+ * @return {jsts.triangulate.quadedge.QuadEdge}
89
+ * the connected edge.
90
+ */
91
+ jsts.triangulate.quadedge.QuadEdge.connect = function(a, b) {
92
+ var e = QuadEdge.makeEdge(a.dest(), b.orig());
93
+ QuadEdge.splice(e, a.lNext());
94
+ QuadEdge.splice(e.sym(), b);
95
+ return e;
96
+ };
97
+
98
+ /**
99
+ * Splices two edges together or apart.
100
+ * Splice affects the two edge rings around the origins of a and b, and, independently, the two
101
+ * edge rings around the left faces of <tt>a</tt> and <tt>b</tt>.
102
+ * In each case, (i) if the two rings are distinct,
103
+ * Splice will combine them into one, or (ii) if the two are the same ring, Splice will break it
104
+ * into two separate pieces. Thus, Splice can be used both to attach the two edges together, and
105
+ * to break them apart.
106
+ *
107
+ * @param {jsts.triangulate.quadedge.QuadEdge}
108
+ * a an edge to splice.
109
+ * @param {jsts.triangulate.quadedge.QuadEdge}
110
+ * b an edge to splice.
111
+ */
112
+ jsts.triangulate.quadedge.QuadEdge.splice = function(a, b) {
113
+ var alpha, beta, t1, t2, t3, t4;
114
+ alpha = a.oNext().rot;
115
+ beta = b.oNext().rot;
116
+
117
+ t1 = b.oNext();
118
+ t2 = a.oNext();
119
+ t3 = beta.oNext();
120
+ t4 = alpha.oNext();
121
+
122
+ a.setNext(t1);
123
+ b.setNext(t2);
124
+ alpha.setNext(t3);
125
+ beta.setNext(t4);
126
+ };
127
+
128
+ /**
129
+ * Turns an edge counterclockwise inside its enclosing quadrilateral.
130
+ *
131
+ * @param {jsts.triangulate.quadedge.QuadEdge}
132
+ * e the quadedge to turn.
133
+ */
134
+ jsts.triangulate.quadedge.QuadEdge.swap = function(e) {
135
+ var a, b;
136
+ a = e.oPrev();
137
+ b = e.sym().oPrev();
138
+ QuadEdge.splice(e, a);
139
+ QuadEdge.splice(e.sym(), b);
140
+ QuadEdge.splice(e, a.lNext());
141
+ QuadEdge.splice(e.sym(), b.lNext());
142
+ e.setOrig(a.dest());
143
+ e.setDest(b.dest());
144
+ };
145
+
146
+ /**
147
+ * Gets the primary edge of this quadedge and its <tt>sym</tt>.
148
+ * The primary edge is the one for which the origin
149
+ * and destination coordinates are ordered
150
+ * according to the standard {@link Coordinate} ordering
151
+ *
152
+ * @return the primary quadedge.
153
+ */
154
+ jsts.triangulate.quadedge.QuadEdge.prototype.getPrimary = function() {
155
+ if (this.orig().getCoordinate().compareTo(this.dest().getCoordinate()) <= 0) {
156
+ return this;
157
+ }
158
+ else {
159
+ return this.sym();
160
+ }
161
+ };
162
+
163
+ /**
164
+ * Sets the external data value for this edge.
165
+ *
166
+ * @param {Object}
167
+ * data an object containing external data.
168
+ */
169
+ jsts.triangulate.quadedge.QuadEdge.prototype.setData = function(data) {
170
+ this.data = data;
171
+ };
172
+
173
+ /**
174
+ * Gets the external data value for this edge.
175
+ *
176
+ * @return {Object}
177
+ * the data object.
178
+ */
179
+ jsts.triangulate.quadedge.QuadEdge.prototype.getData = function() {
180
+ return this.data;
181
+ };
182
+
183
+ /**
184
+ * Marks this quadedge as being deleted.
185
+ * This does not free the memory used by
186
+ * this quadedge quartet, but indicates
187
+ * that this edge no longer participates
188
+ * in a subdivision.
189
+ *
190
+ */
191
+ jsts.triangulate.quadedge.QuadEdge.prototype.delete_jsts = function() {
192
+ this.rot = null;
193
+ };
194
+
195
+ /**
196
+ * Tests whether this edge has been deleted.
197
+ *
198
+ * @return {boolean}
199
+ * true if this edge has not been deleted.
200
+ */
201
+ jsts.triangulate.quadedge.QuadEdge.prototype.isLive = function() {
202
+ return this.rot !== null;
203
+ };
204
+
205
+
206
+ /**
207
+ * Sets the connected edge
208
+ *
209
+ * @param {jsts.triangulate.quadedge.QuadEdge}
210
+ * next next-edge.
211
+ */
212
+ jsts.triangulate.quadedge.QuadEdge.prototype.setNext = function(next) {
213
+ this.next = next;
214
+ };
215
+
216
+ /***************************************************************************
217
+ * QuadEdge Algebra
218
+ ***************************************************************************
219
+ */
220
+
221
+ /**
222
+ * Gets the dual of this edge, directed from its left to its right.
223
+ *
224
+ * @return {jsts.triangulate.quadedge.QuadEdge}
225
+ * the inverse rotated edge.
226
+ */
227
+ jsts.triangulate.quadedge.QuadEdge.prototype.invRot = function() {
228
+ return this.rot.sym();
229
+ };
230
+
231
+ /**
232
+ * Gets the edge from the destination to the origin of this edge.
233
+ *
234
+ * @return {jsts.triangulate.quadedge.QuadEdge}
235
+ * the sym of the edge.
236
+ */
237
+ jsts.triangulate.quadedge.QuadEdge.prototype.sym = function() {
238
+ return this.rot.rot;
239
+ };
240
+
241
+ /**
242
+ * Gets the next CCW edge around the origin of this edge.
243
+ *
244
+ * @return {jsts.triangulate.quadedge.QuadEdge}
245
+ * the next linked edge.
246
+ */
247
+ jsts.triangulate.quadedge.QuadEdge.prototype.oNext = function() {
248
+ return this.next;
249
+ };
250
+
251
+ /**
252
+ * Gets the next CW edge around (from) the origin of this edge.
253
+ *
254
+ * @return {jsts.triangulate.quadedge.QuadEdge}
255
+ * the previous edge.
256
+ */
257
+ jsts.triangulate.quadedge.QuadEdge.prototype.oPrev = function() {
258
+ return this.rot.next.rot;
259
+ };
260
+
261
+ /**
262
+ * Gets the next CCW edge around (into) the destination of this edge.
263
+ *
264
+ * @return {jsts.triangulate.quadedge.QuadEdge}
265
+ * the next destination edge.
266
+ */
267
+ jsts.triangulate.quadedge.QuadEdge.prototype.dNext = function() {
268
+ return this.sym().oNext().sym();
269
+ };
270
+
271
+ /**
272
+ * Gets the next CW edge around (into) the destination of this edge.
273
+ *
274
+ * @return {jsts.triangulate.quadedge.QuadEdge}
275
+ * the previous destination edge.
276
+ */
277
+ jsts.triangulate.quadedge.QuadEdge.prototype.dPrev = function() {
278
+ return this.invRot().oNext().invRot();
279
+ };
280
+
281
+ /**
282
+ * Gets the CCW edge around the left face following this edge.
283
+ *
284
+ * @return {jsts.triangulate.quadedge.QuadEdge}
285
+ * the next left face edge.
286
+ */
287
+ jsts.triangulate.quadedge.QuadEdge.prototype.lNext = function() {
288
+ return this.invRot().oNext().rot;
289
+ };
290
+
291
+ /**
292
+ * Gets the CCW edge around the left face before this edge.
293
+ *
294
+ * @return {jsts.triangulate.quadedge.QuadEdge}
295
+ * the previous left face edge.
296
+ */
297
+ jsts.triangulate.quadedge.QuadEdge.prototype.lPrev = function() {
298
+ return this.next.sym();
299
+ };
300
+
301
+ /**
302
+ * Gets the edge around the right face ccw following this edge.
303
+ *
304
+ * @return {jsts.triangulate.quadedge.QuadEdge}
305
+ * the next right face edge.
306
+ */
307
+ jsts.triangulate.quadedge.QuadEdge.prototype.rNext = function() {
308
+ return this.rot.next.invRot();
309
+ };
310
+
311
+ /**
312
+ * Gets the edge around the right face ccw before this edge.
313
+ *
314
+ * @return {jsts.triangulate.quadedge.QuadEdge}
315
+ * the previous right face edge.
316
+ */
317
+ jsts.triangulate.quadedge.QuadEdge.prototype.rPrev = function() {
318
+ return this.sym().oNext();
319
+ };
320
+
321
+ /***********************************************************************************************
322
+ * Data Access
323
+ **********************************************************************************************/
324
+ /**
325
+ * Sets the vertex for this edge's origin
326
+ *
327
+ * @param {jsts.triangulate.quadedge.Vertex}
328
+ * o the origin vertex.
329
+ */
330
+ jsts.triangulate.quadedge.QuadEdge.prototype.setOrig = function(o) {
331
+ this.vertex = o;
332
+ };
333
+
334
+ /**
335
+ * Sets the vertex for this edge's destination
336
+ *
337
+ * @param {jsts.triangulate.quadedge.Vertex}
338
+ * d the destination vertex.
339
+ */
340
+ jsts.triangulate.quadedge.QuadEdge.prototype.setDest = function(d) {
341
+ this.sym().setOrig(d);
342
+ };
343
+
344
+ /**
345
+ * Gets the vertex for the edge's origin
346
+ *
347
+ * @return {jsts.triangulate.quadedge.Vertex}
348
+ * the origin vertex.
349
+ */
350
+ jsts.triangulate.quadedge.QuadEdge.prototype.orig = function() {
351
+ return this.vertex;
352
+ };
353
+
354
+ /**
355
+ * Gets the vertex for the edge's destination
356
+ *
357
+ * @return {jsts.triangulate.quadedge.Vertex}
358
+ * the destination vertex.
359
+ */
360
+ jsts.triangulate.quadedge.QuadEdge.prototype.dest = function() {
361
+ return this.sym().orig();
362
+ };
363
+
364
+ /**
365
+ * Gets the length of the geometry of this quadedge.
366
+ *
367
+ * @return {number}
368
+ * the length of the quadedge.
369
+ */
370
+ jsts.triangulate.quadedge.QuadEdge.prototype.getLength = function() {
371
+ return this.orig().getCoordinate().distance(dest().getCoordinate());
372
+ };
373
+
374
+ /**
375
+ * Tests if this quadedge and another have the same line segment geometry,
376
+ * regardless of orientation.
377
+ *
378
+ * @param {jsts.triangulate.quadedge.QuadEdge}
379
+ * qe a quadege.
380
+ * @return {boolean}
381
+ * true if the quadedges are based on the same line segment regardless of orientation.
382
+ */
383
+ jsts.triangulate.quadedge.QuadEdge.prototype.equalsNonOriented = function(qe) {
384
+ if (this.equalsOriented(qe)) {
385
+ return true;
386
+ }
387
+
388
+ if (this.equalsOriented(qe.sym())) {
389
+ return true;
390
+ }
391
+
392
+ return false;
393
+ };
394
+
395
+ /**
396
+ * Tests if this quadedge and another have the same line segment geometry
397
+ * with the same orientation.
398
+ *
399
+ * @param {jsts.triangulate.quadedge.QuadEdge}
400
+ * qe a quadege.
401
+ * @return {boolean}
402
+ * true if the quadedges are based on the same line segment.
403
+ */
404
+ jsts.triangulate.quadedge.QuadEdge.prototype.equalsOriented = function(qe) {
405
+ if (this.orig().getCoordinate().equals2D(qe.orig().getCoordinate())
406
+ && this.dest().getCoordinate().equals2D(qe.dest().getCoordinate())) {
407
+ return true;
408
+ }
409
+ return false;
410
+ };
411
+
412
+ /**
413
+ * Creates a {@link LineSegment} representing the
414
+ * geometry of this edge.
415
+ *
416
+ * @return {jsts.geom.LineSegment}
417
+ * a LineSegment.
418
+ */
419
+ jsts.triangulate.quadedge.QuadEdge.prototype.toLineSegment = function()
420
+ {
421
+ return new jsts.geom.LineSegment(this.vertex.getCoordinate(), this.dest().getCoordinate());
422
+ };
423
+
424
+ /**
425
+ * Converts this edge to a WKT two-point <tt>LINESTRING</tt> indicating
426
+ * the geometry of this edge.
427
+ *
428
+ * @return {String}
429
+ * a String representing this edge's geometry.
430
+ */
431
+ jsts.triangulate.quadedge.QuadEdge.prototype.toString = function() {
432
+ var p0, p1;
433
+ p0 = this.vertex.getCoordinate();
434
+ p1 = this.dest().getCoordinate();
435
+ return jsts.io.WKTWriter.toLineString(p0, p1);
436
+ };
437
+ })();