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,199 @@
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
+ * Contains information about the nature and location of a {@link Geometry}
11
+ * validation error
12
+ *
13
+ * @version 1.7
14
+ */
15
+
16
+ /**
17
+ *
18
+ * Creates a validation error with the given type and location
19
+ *
20
+ * @param errorType
21
+ * the type of the error.
22
+ *
23
+ * @param pt
24
+ * the location of the error.
25
+ *
26
+ */
27
+ jsts.operation.valid.TopologyValidationError = function(errorType, pt) {
28
+ this.errorType = errorType;
29
+ this.pt = null;
30
+
31
+ if (pt != null) {
32
+ this.pt = pt.clone();
33
+ }
34
+ };
35
+
36
+ /**
37
+ *
38
+ * Indicates that a hole of a polygon lies partially or completely in the
39
+ * exterior of the shell
40
+ *
41
+ */
42
+ jsts.operation.valid.TopologyValidationError.HOLE_OUTSIDE_SHELL = 2;
43
+
44
+ /**
45
+ *
46
+ * Indicates that a hole lies in the interior of another hole in the same
47
+ * polygon
48
+ *
49
+ */
50
+ jsts.operation.valid.TopologyValidationError.NESTED_HOLES = 3;
51
+
52
+ /**
53
+ *
54
+ * Indicates that the interior of a polygon is disjoint
55
+ *
56
+ * (often caused by set of contiguous holes splitting the polygon into two
57
+ * parts)
58
+ *
59
+ */
60
+ jsts.operation.valid.TopologyValidationError.DISCONNECTED_INTERIOR = 4;
61
+
62
+ /**
63
+ *
64
+ * Indicates that two rings of a polygonal geometry intersect
65
+ *
66
+ */
67
+ jsts.operation.valid.TopologyValidationError.SELF_INTERSECTION = 5;
68
+
69
+ /**
70
+ *
71
+ * Indicates that a ring self-intersects
72
+ *
73
+ */
74
+ jsts.operation.valid.TopologyValidationError.RING_SELF_INTERSECTION = 6;
75
+
76
+ /**
77
+ *
78
+ * Indicates that a polygon component of a MultiPolygon lies inside another
79
+ * polygonal component
80
+ *
81
+ */
82
+ jsts.operation.valid.TopologyValidationError.NESTED_SHELLS = 7;
83
+
84
+ /**
85
+ *
86
+ * Indicates that a polygonal geometry contains two rings which are identical
87
+ *
88
+ */
89
+ jsts.operation.valid.TopologyValidationError.DUPLICATE_RINGS = 8;
90
+
91
+ /**
92
+ *
93
+ * Indicates that either
94
+ * <ul>
95
+ * <li>a LineString contains a single point
96
+ * <li>a LinearRing contains 2 or 3 points
97
+ * </ul>
98
+ *
99
+ */
100
+ jsts.operation.valid.TopologyValidationError.TOO_FEW_POINTS = 9;
101
+
102
+ /**
103
+ *
104
+ * Indicates that the <code>X</code> or <code>Y</code> ordinate of
105
+ * a Coordinate is not a valid numeric value (e.g. {@link Double#NaN} )
106
+ *
107
+ */
108
+ jsts.operation.valid.TopologyValidationError.INVALID_COORDINATE = 10;
109
+
110
+ /**
111
+ *
112
+ * Indicates that a ring is not correctly closed
113
+ * (the first and the last coordinate are different)
114
+ *
115
+ */
116
+ jsts.operation.valid.TopologyValidationError.RING_NOT_CLOSED = 11;
117
+
118
+ /**
119
+ *
120
+ * Messages corresponding to error codes
121
+ *
122
+ */
123
+ jsts.operation.valid.TopologyValidationError.prototype.errMsg = [
124
+ 'Topology Validation Error',
125
+ 'Repeated Point',
126
+ 'Hole lies outside shell',
127
+ 'Holes are nested',
128
+ 'Interior is disconnected',
129
+ 'Self-intersection',
130
+ 'Ring Self-intersection',
131
+ 'Nested shells',
132
+ 'Duplicate Rings',
133
+ 'Too few distinct points in geometry component',
134
+ 'Invalid Coordinate',
135
+ 'Ring is not closed'
136
+ ];
137
+
138
+ /**
139
+ * Creates a validation error of the given type with a null location
140
+ *
141
+ * @param errorType
142
+ * the type of the error
143
+ *
144
+ * jsts.operation.valid.TopologyValidationError(int errorType) // cannot
145
+ * overload constructors, use above with null as arg 2
146
+ * {
147
+ * this(errorType, null);
148
+ * }
149
+ */
150
+
151
+ /**
152
+ *
153
+ * Returns the location of this error (on the {@link Geometry} containing the
154
+ * error).
155
+ *
156
+ *
157
+ *
158
+ * @return a {@link Coordinate} on the input geometry.
159
+ *
160
+ */
161
+ jsts.operation.valid.TopologyValidationError.prototype.getCoordinate = function() {
162
+ return this.pt;
163
+ };
164
+
165
+ /**
166
+ *
167
+ * Gets the type of this error.
168
+ * @return the error type.
169
+ *
170
+ */
171
+ jsts.operation.valid.TopologyValidationError.prototype.getErrorType = function() {
172
+ return this.errorType;
173
+ };
174
+
175
+ /**
176
+ *
177
+ * Gets an error message describing this error.
178
+ * The error message does not describe the location of the error.
179
+ * @return the error message.
180
+ *
181
+ */
182
+ jsts.operation.valid.TopologyValidationError.prototype.getMessage = function() {
183
+ return this.errMsg[this.errorType];
184
+ };
185
+
186
+ /**
187
+ *
188
+ * Gets a message describing the type and location of this error.
189
+ * @return the error message.
190
+ *
191
+ */
192
+ jsts.operation.valid.TopologyValidationError.prototype.toString = function() {
193
+ var locStr = '';
194
+ if (this.pt != null) {
195
+ locStr = ' at or near point ' + this.pt;
196
+ return this.getMessage() + locStr;
197
+ }
198
+ return locStr;
199
+ };
@@ -0,0 +1,232 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * Port source:
9
+ * /jts/jts/java/src/com/vividsolutions/jts/planargraph/DirectedEdge.java
10
+ * Revision: 6
11
+ */
12
+
13
+ /**
14
+ * @requires jsts/planargraph/GraphComponent.js
15
+ */
16
+
17
+ (function() {
18
+
19
+ var ArrayList = javascript.util.ArrayList;
20
+ var GraphComponent = jsts.planargraph.GraphComponent;
21
+
22
+ /**
23
+ * Represents a directed edge in a {@link PlanarGraph}. A DirectedEdge may or
24
+ * may not have a reference to a parent {@link Edge} (some applications of
25
+ * planar graphs may not require explicit Edge objects to be created). Usually
26
+ * a client using a <code>PlanarGraph</code> will subclass
27
+ * <code>DirectedEdge</code> to add its own application-specific data and
28
+ * methods.
29
+ *
30
+ * Constructs a DirectedEdge connecting the <code>from</code> node to the
31
+ * <code>to</code> node.
32
+ *
33
+ * @param directionPt
34
+ * specifies this DirectedEdge's direction vector (determined by the
35
+ * vector from the <code>from</code> node to
36
+ * <code>directionPt</code>).
37
+ * @param edgeDirection
38
+ * whether this DirectedEdge's direction is the same as or opposite
39
+ * to that of the parent Edge (if any).
40
+ */
41
+ var DirectedEdge = function(from, to, directionPt, edgeDirection) {
42
+ if (from === undefined) {
43
+ return;
44
+ }
45
+
46
+ this.from = from;
47
+ this.to = to;
48
+ this.edgeDirection = edgeDirection;
49
+ this.p0 = from.getCoordinate();
50
+ this.p1 = directionPt;
51
+ var dx = this.p1.x - this.p0.x;
52
+ var dy = this.p1.y - this.p0.y;
53
+ this.quadrant = jsts.geomgraph.Quadrant.quadrant(dx, dy);
54
+ this.angle = Math.atan2(dy, dx);
55
+ };
56
+
57
+ DirectedEdge.prototype = new GraphComponent();
58
+
59
+ /**
60
+ * Returns a List containing the parent Edge (possibly null) for each of the
61
+ * given DirectedEdges.
62
+ */
63
+ DirectedEdge.toEdges = function(dirEdges) {
64
+ var edges = new ArrayList();
65
+ for (var i = dirEdges.iterator(); i.hasNext();) {
66
+ edges.add((i.next()).parentEdge);
67
+ }
68
+ return edges;
69
+ };
70
+
71
+ DirectedEdge.prototype.parentEdge = null;
72
+ DirectedEdge.prototype.from = null;
73
+ DirectedEdge.prototype.to = null;
74
+ DirectedEdge.prototype.p0 = null;
75
+ DirectedEdge.prototype.p1 = null;
76
+ DirectedEdge.prototype.sym = null; // optional
77
+ DirectedEdge.prototype.edgeDirection = null;
78
+ DirectedEdge.prototype.quadrant = null;
79
+ DirectedEdge.prototype.angle = null;
80
+
81
+ /**
82
+ * Returns this DirectedEdge's parent Edge, or null if it has none.
83
+ */
84
+ DirectedEdge.prototype.getEdge = function() {
85
+ return this.parentEdge;
86
+ };
87
+
88
+ /**
89
+ * Associates this DirectedEdge with an Edge (possibly null, indicating no
90
+ * associated Edge).
91
+ */
92
+ DirectedEdge.prototype.setEdge = function(parentEdge) {
93
+ this.parentEdge = parentEdge;
94
+ };
95
+
96
+ /**
97
+ * Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's
98
+ * orientation lies.
99
+ */
100
+ DirectedEdge.prototype.getQuadrant = function() {
101
+ return this.quadrant;
102
+ };
103
+
104
+ /**
105
+ * Returns a point to which an imaginary line is drawn from the from-node to
106
+ * specify this DirectedEdge's orientation.
107
+ */
108
+ DirectedEdge.prototype.getDirectionPt = function() {
109
+ return this.p1;
110
+ };
111
+
112
+ /**
113
+ * Returns whether the direction of the parent Edge (if any) is the same as
114
+ * that of this Directed Edge.
115
+ */
116
+ DirectedEdge.prototype.getEdgeDirection = function() {
117
+ return this.edgeDirection;
118
+ };
119
+
120
+ /**
121
+ * Returns the node from which this DirectedEdge leaves.
122
+ */
123
+ DirectedEdge.prototype.getFromNode = function() {
124
+ return this.from;
125
+ };
126
+
127
+ /**
128
+ * Returns the node to which this DirectedEdge goes.
129
+ */
130
+ DirectedEdge.prototype.getToNode = function() {
131
+ return this.to;
132
+ };
133
+
134
+ /**
135
+ * Returns the coordinate of the from-node.
136
+ */
137
+ DirectedEdge.prototype.getCoordinate = function() {
138
+ return this.from.getCoordinate();
139
+ };
140
+
141
+ /**
142
+ * Returns the angle that the start of this DirectedEdge makes with the
143
+ * positive x-axis, in radians.
144
+ */
145
+ DirectedEdge.prototype.getAngle = function() {
146
+ return this.angle;
147
+ };
148
+
149
+ /**
150
+ * Returns the symmetric DirectedEdge -- the other DirectedEdge associated
151
+ * with this DirectedEdge's parent Edge.
152
+ */
153
+ DirectedEdge.prototype.getSym = function() {
154
+ return this.sym;
155
+ };
156
+
157
+ /**
158
+ * Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite
159
+ * direction.
160
+ */
161
+ DirectedEdge.prototype.setSym = function(sym) {
162
+ this.sym = sym;
163
+ };
164
+
165
+ /**
166
+ * Removes this directed edge from its containing graph.
167
+ */
168
+ DirectedEdge.prototype.remove = function() {
169
+ this.sym = null;
170
+ this.parentEdge = null;
171
+ };
172
+
173
+ /**
174
+ * Tests whether this directed edge has been removed from its containing graph
175
+ *
176
+ * @return <code>true</code> if this directed edge is removed.
177
+ */
178
+ DirectedEdge.prototype.isRemoved = function() {
179
+ return this.parentEdge == null;
180
+ };
181
+
182
+ /**
183
+ * Returns 1 if this DirectedEdge has a greater angle with the positive x-axis
184
+ * than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
185
+ * <p>
186
+ * Using the obvious algorithm of simply computing the angle is not robust,
187
+ * since the angle calculation is susceptible to roundoff. A robust algorithm
188
+ * is:
189
+ * <ul>
190
+ * <li>first compare the quadrants. If the quadrants are different, it it
191
+ * trivial to determine which vector is "greater".
192
+ * <li>if the vectors lie in the same quadrant, the robust
193
+ * {@link CGAlgorithms#computeOrientation(Coordinate, Coordinate, Coordinate)}
194
+ * function can be used to decide the relative orientation of the vectors.
195
+ * </ul>
196
+ */
197
+ DirectedEdge.prototype.compareTo = function(obj) {
198
+ var de = obj;
199
+ return this.compareDirection(de);
200
+ };
201
+
202
+ /**
203
+ * Returns 1 if this DirectedEdge has a greater angle with the positive x-axis
204
+ * than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
205
+ * <p>
206
+ * Using the obvious algorithm of simply computing the angle is not robust,
207
+ * since the angle calculation is susceptible to roundoff. A robust algorithm
208
+ * is:
209
+ * <ul>
210
+ * <li>first compare the quadrants. If the quadrants are different, it it
211
+ * trivial to determine which vector is "greater".
212
+ * <li>if the vectors lie in the same quadrant, the robust
213
+ * {@link CGAlgorithms#computeOrientation(Coordinate, Coordinate, Coordinate)}
214
+ * function can be used to decide the relative orientation of the vectors.
215
+ * </ul>
216
+ */
217
+ DirectedEdge.prototype.compareDirection = function(e) {
218
+ // if the rays are in different quadrants, determining the ordering is
219
+ // trivial
220
+ if (this.quadrant > e.quadrant)
221
+ return 1;
222
+ if (this.quadrant < e.quadrant)
223
+ return -1;
224
+ // vectors are in the same quadrant - check relative orientation of
225
+ // direction vectors
226
+ // this is > e if it is CCW of e
227
+ return jsts.algorithm.CGAlgorithms.computeOrientation(e.p0, e.p1, this.p1);
228
+ };
229
+
230
+ jsts.planargraph.DirectedEdge = DirectedEdge;
231
+
232
+ })();
@@ -0,0 +1,168 @@
1
+ /* Copyright (c) 2011 by The Authors.
2
+ * Published under the LGPL 2.1 license.
3
+ * See /license-notice.txt for the full text of the license notice.
4
+ * See /license.txt for the full text of the license.
5
+ */
6
+
7
+ /**
8
+ * Port source:
9
+ * /jts/jts/java/src/com/vividsolutions/jts/planargraph/DirectedEdge.java
10
+ * Revision: 6
11
+ */
12
+
13
+
14
+ (function() {
15
+
16
+ var ArrayList = javascript.util.ArrayList;
17
+
18
+ /**
19
+ * A sorted collection of {@link DirectedEdge}s which leave a {@link Node} in
20
+ * a {@link PlanarGraph}.
21
+ *
22
+ * Constructs a DirectedEdgeStar with no edges.
23
+ */
24
+ var DirectedEdgeStar = function() {
25
+ this.outEdges = new ArrayList();
26
+ };
27
+
28
+
29
+ /**
30
+ * The underlying list of outgoing DirectedEdges
31
+ */
32
+ DirectedEdgeStar.prototype.outEdges = null;
33
+
34
+ DirectedEdgeStar.prototype.sorted = false;
35
+
36
+ /**
37
+ * Adds a new member to this DirectedEdgeStar.
38
+ */
39
+ DirectedEdgeStar.prototype.add = function(de) {
40
+ this.outEdges.add(de);
41
+ this.sorted = false;
42
+ };
43
+ /**
44
+ * Drops a member of this DirectedEdgeStar.
45
+ */
46
+ DirectedEdgeStar.prototype.remove = function(de) {
47
+ this.outEdges.remove(de);
48
+ };
49
+ /**
50
+ * Returns an Iterator over the DirectedEdges, in ascending order by angle
51
+ * with the positive x-axis.
52
+ */
53
+ DirectedEdgeStar.prototype.iterator = function() {
54
+ this.sortEdges();
55
+ return this.outEdges.iterator();
56
+ };
57
+
58
+ /**
59
+ * Returns the number of edges around the Node associated with this
60
+ * DirectedEdgeStar.
61
+ */
62
+ DirectedEdgeStar.prototype.getDegree = function() {
63
+ return this.outEdges.size();
64
+ };
65
+
66
+ /**
67
+ * Returns the coordinate for the node at wich this star is based
68
+ */
69
+ DirectedEdgeStar.prototype.getCoordinate = function() {
70
+ var it = iterator();
71
+ if (!it.hasNext())
72
+ return null;
73
+ var e = it.next();
74
+ return e.getCoordinate();
75
+ };
76
+
77
+ /**
78
+ * Returns the DirectedEdges, in ascending order by angle with the positive
79
+ * x-axis.
80
+ */
81
+ DirectedEdgeStar.prototype.getEdges = function() {
82
+ this.sortEdges();
83
+ return this.outEdges;
84
+ };
85
+
86
+ /**
87
+ * @private
88
+ */
89
+ DirectedEdgeStar.prototype.sortEdges = function() {
90
+ if (!this.sorted) {
91
+ var array = this.outEdges.toArray();
92
+ array.sort(function(a,b) { return a.compareTo(b);});
93
+ this.outEdges = javascript.util.Arrays.asList(array);
94
+ this.sorted = true;
95
+ }
96
+ };
97
+
98
+ /**
99
+ * Returns the zero-based index of the given Edge, after sorting in ascending
100
+ * order by angle with the positive x-axis.
101
+ */
102
+ DirectedEdgeStar.prototype.getIndex = function(edge) {
103
+ if (edge instanceof jsts.planargraph.DirectedEdge) {
104
+ return this.getIndex2(edge);
105
+ } else if (typeof (edge) === 'number') {
106
+ return this.getIndex3(edge);
107
+ }
108
+
109
+ this.sortEdges();
110
+ for (var i = 0; i < this.outEdges.size(); i++) {
111
+ var de = this.outEdges.get(i);
112
+ if (de.getEdge() == edge)
113
+ return i;
114
+ }
115
+ return -1;
116
+ };
117
+
118
+ /**
119
+ * Returns the zero-based index of the given DirectedEdge, after sorting in
120
+ * ascending order by angle with the positive x-axis.
121
+ */
122
+ DirectedEdgeStar.prototype.getIndex2 = function(dirEdge) {
123
+ this.sortEdges();
124
+ for (var i = 0; i < this.outEdges.size(); i++) {
125
+ var de = this.outEdges.get(i);
126
+ if (de == dirEdge)
127
+ return i;
128
+ }
129
+ return -1;
130
+ };
131
+
132
+ /**
133
+ * Returns value of i modulo the number of edges in this DirectedEdgeStar
134
+ * (i.e. the remainder when i is divided by the number of edges)
135
+ *
136
+ * @param i
137
+ * an integer (positive, negative or zero).
138
+ */
139
+ DirectedEdgeStar.prototype.getIndex3 = function(i) {
140
+ var modi = toInt(i % this.outEdges.size());
141
+ // I don't think modi can be 0 (assuming i is positive) [Jon Aquino
142
+ // 10/28/2003]
143
+ if (modi < 0)
144
+ modi += this.outEdges.size();
145
+ return modi;
146
+ };
147
+
148
+ /**
149
+ * Returns the {@link DirectedEdge} on the left-hand (CCW) side of the given
150
+ * {@link DirectedEdge} (which must be a member of this DirectedEdgeStar).
151
+ */
152
+ DirectedEdgeStar.prototype.getNextEdge = function(dirEdge) {
153
+ var i = this.getIndex(dirEdge);
154
+ return this.outEdges.get(getIndex(i + 1));
155
+ };
156
+
157
+ /**
158
+ * Returns the {@link DirectedEdge} on the right-hand (CW) side of the given
159
+ * {@link DirectedEdge} (which must be a member of this DirectedEdgeStar).
160
+ */
161
+ DirectedEdgeStar.prototype.getNextCWEdge = function(dirEdge) {
162
+ var i = this.getIndex(dirEdge);
163
+ return this.outEdges.get(getIndex(i - 1));
164
+ };
165
+
166
+ jsts.planargraph.DirectedEdgeStar = DirectedEdgeStar;
167
+
168
+ })();