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,29 @@
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
+ * <code>GeometryCollection</code> classes support the concept of applying a
10
+ * <code>GeometryFilter</code> to the <code>Geometry</code>. The filter is
11
+ * applied to every element <code>Geometry</code>. A
12
+ * <code>GeometryFilter</code> can either record information about the
13
+ * <code>Geometry</code> or change the <code>Geometry</code> in some way.
14
+ * <code>GeometryFilter</code> is an example of the Gang-of-Four Visitor
15
+ * pattern.
16
+ */
17
+ jsts.geom.GeometryFilter = function() {
18
+ };
19
+
20
+
21
+ /**
22
+ * Performs an operation with or on <code>geom</code>.
23
+ *
24
+ * @param {Geometry}
25
+ * geom a <code>Geometry</code> to which the filter is applied.
26
+ */
27
+ jsts.geom.GeometryFilter.prototype.filter = function(geom) {
28
+ throw new jsts.error.AbstractMethodInvocationError();
29
+ };
@@ -0,0 +1,650 @@
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
+ (function() {
8
+
9
+ /**
10
+ * @requires jsts/geom/Location.js
11
+ * @requires jsts/geom/Dimension.js
12
+ */
13
+
14
+ var Location = jsts.geom.Location;
15
+ var Dimension = jsts.geom.Dimension;
16
+
17
+ /**
18
+ * Models a Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
19
+ * This class is used to represent intersection matrices (such as "212FF1FF2")
20
+ * capturing the topological relationship between two {@link Geometry}s. It
21
+ * can also be represent patterns (such as "T*T******")for matching existing
22
+ * matrices.
23
+ *
24
+ * Methods are provided to:
25
+ * <UL>
26
+ * <LI> set and query the elements of the matrix in a convenient fashion
27
+ * <LI> convert to and from the standard string representation (specified in
28
+ * SFS Section 2.1.13.2).
29
+ * <LI> test to see if a matrix matches a given pattern string.
30
+ * </UL>
31
+ * <P>
32
+ *
33
+ * For a description of the DE-9IM, see the <A
34
+ * HREF="http://www.opengis.org/techno/specs.htm">OpenGIS Simple Features
35
+ * Specification for SQL</A>.
36
+ *
37
+ * The entries of the matrix are defined by the constants in the
38
+ * {@link Dimension} class. The indices of the matrix represent the
39
+ * topological locations that occur in a geometry (Interior, Boundary,
40
+ * Exterior). These are provided as constants in the {@link Location} class.
41
+ *
42
+ * @param {string/IntersectionMatrix}
43
+ * elements
44
+ * @constructor
45
+ */
46
+ jsts.geom.IntersectionMatrix = function(elements) {
47
+ var other = elements;
48
+
49
+ if (elements === undefined || elements === null) {
50
+ this.matrix = [[], [], []];
51
+ this.setAll(Dimension.FALSE);
52
+ } else if (typeof elements === 'string') {
53
+ this.set(elements);
54
+ } else if (other instanceof jsts.geom.IntersectionMatrix) {
55
+
56
+ this.matrix[Location.INTERIOR][Location.INTERIOR] = other.matrix[Location.INTERIOR][Location.INTERIOR];
57
+ this.matrix[Location.INTERIOR][Location.BOUNDARY] = other.matrix[Location.INTERIOR][Location.BOUNDARY];
58
+ this.matrix[Location.INTERIOR][Location.EXTERIOR] = other.matrix[Location.INTERIOR][Location.EXTERIOR];
59
+ this.matrix[Location.BOUNDARY][Location.INTERIOR] = other.matrix[Location.BOUNDARY][Location.INTERIOR];
60
+ this.matrix[Location.BOUNDARY][Location.BOUNDARY] = other.matrix[Location.BOUNDARY][Location.BOUNDARY];
61
+ this.matrix[Location.BOUNDARY][Location.EXTERIOR] = other.matrix[Location.BOUNDARY][Location.EXTERIOR];
62
+ this.matrix[Location.EXTERIOR][Location.INTERIOR] = other.matrix[Location.EXTERIOR][Location.INTERIOR];
63
+ this.matrix[Location.EXTERIOR][Location.BOUNDARY] = other.matrix[Location.EXTERIOR][Location.BOUNDARY];
64
+ this.matrix[Location.EXTERIOR][Location.EXTERIOR] = other.matrix[Location.EXTERIOR][Location.EXTERIOR];
65
+ }
66
+ };
67
+
68
+
69
+ /**
70
+ * Internal representation of this <code>IntersectionMatrix</code>.
71
+ *
72
+ * @type {int[][]}
73
+ * @private
74
+ */
75
+ jsts.geom.IntersectionMatrix.prototype.matrix = null;
76
+
77
+
78
+ /**
79
+ * Adds one matrix to another. Addition is defined by taking the maximum
80
+ * dimension value of each position in the summand matrices.
81
+ *
82
+ * @param {IntersectionMatrix}
83
+ * im the matrix to add.
84
+ */
85
+ jsts.geom.IntersectionMatrix.prototype.add = function(im) {
86
+ var i, j;
87
+ for (i = 0; i < 3; i++) {
88
+ for (j = 0; j < 3; j++) {
89
+ this.setAtLeast(i, j, im.get(i, j));
90
+ }
91
+ }
92
+ };
93
+
94
+
95
+ /**
96
+ * Returns true if the dimension value satisfies the dimension symbol.
97
+ *
98
+ * @param {int}
99
+ * actualDimensionValue a number that can be stored in the
100
+ * <code>IntersectionMatrix</code> . Possible values are
101
+ * <code>{TRUE, FALSE, DONTCARE, 0, 1, 2}</code>.
102
+ * @param {string}
103
+ * requiredDimensionSymbol a character used in the string
104
+ * representation of an <code>IntersectionMatrix</code>. Possible
105
+ * values are <code>{T, F, * , 0, 1, 2}</code>.
106
+ * @return {boolean} true if the dimension symbol encompasses the dimension
107
+ * value.
108
+ */
109
+ jsts.geom.IntersectionMatrix.matches = function(actualDimensionValue,
110
+ requiredDimensionSymbol) {
111
+ if (typeof actualDimensionValue === 'string') {
112
+ return jsts.geom.IntersectionMatrix.matches2.call(this, arguments);
113
+ }
114
+
115
+ if (requiredDimensionSymbol === '*') {
116
+ return true;
117
+ }
118
+ if (requiredDimensionSymbol === 'T' &&
119
+ (actualDimensionValue >= 0 || actualDimensionValue === Dimension.TRUE)) {
120
+ return true;
121
+ }
122
+ if (requiredDimensionSymbol === 'F' &&
123
+ actualDimensionValue === Dimension.FALSE) {
124
+ return true;
125
+ }
126
+ if (requiredDimensionSymbol === '0' && actualDimensionValue === Dimension.P) {
127
+ return true;
128
+ }
129
+ if (requiredDimensionSymbol === '1' && actualDimensionValue === Dimension.L) {
130
+ return true;
131
+ }
132
+ if (requiredDimensionSymbol === '2' && actualDimensionValue === Dimension.A) {
133
+ return true;
134
+ }
135
+ return false;
136
+ };
137
+
138
+
139
+ /**
140
+ * Returns true if each of the actual dimension symbols satisfies the
141
+ * corresponding required dimension symbol.
142
+ *
143
+ * @param {string}
144
+ * actualDimensionSymbols nine dimension symbols to validate.
145
+ * Possible values are <code>{T, F, * , 0, 1, 2}</code>.
146
+ * @param {string}
147
+ * requiredDimensionSymbols nine dimension symbols to validate
148
+ * against. Possible values are <code>{T, F, * , 0, 1, 2}</code>.
149
+ * @return {boolean} true if each of the required dimension symbols encompass
150
+ * the corresponding actual dimension symbol.
151
+ */
152
+ jsts.geom.IntersectionMatrix.matches2 = function(actualDimensionSymbols,
153
+ requiredDimensionSymbols) {
154
+ var m = new jsts.geom.IntersectionMatrix(actualDimensionSymbols);
155
+ return m.matches(requiredDimensionSymbols);
156
+ };
157
+
158
+
159
+ /**
160
+ * Changes the value of one of this <code>IntersectionMatrix</code>s
161
+ * elements.
162
+ *
163
+ * @param {int}
164
+ * row the row of this <code>IntersectionMatrix</code>, indicating
165
+ * the interior, boundary or exterior of the first
166
+ * <code>Geometry.</code>
167
+ * @param {int}
168
+ * column the column of this <code>IntersectionMatrix</code>,
169
+ * indicating the interior, boundary or exterior of the second
170
+ * <code>Geometry.</code>
171
+ * @param {int}
172
+ * dimensionValue the new value of the element.
173
+ */
174
+ jsts.geom.IntersectionMatrix.prototype.set = function(row, column, dimensionValue) {
175
+ if (typeof row === 'string') {
176
+ this.set2(row);
177
+ return;
178
+ }
179
+
180
+ this.matrix[row][column] = dimensionValue;
181
+ };
182
+
183
+
184
+ /**
185
+ * Changes the elements of this <code>IntersectionMatrix</code> to the
186
+ * dimension symbols in <code>dimensionSymbols</code>.
187
+ *
188
+ * @param {String}
189
+ * dimensionSymbols nine dimension symbols to which to set this
190
+ * <code>IntersectionMatrix</code> s elements. Possible values are
191
+ * <code>{T, F, * , 0, 1, 2}.</code>
192
+ */
193
+ jsts.geom.IntersectionMatrix.prototype.set2 = function(dimensionSymbols) {
194
+ for (var i = 0; i < dimensionSymbols.length(); i++) {
195
+ var row = i / 3;
196
+ var col = i % 3;
197
+ this.matrix[row][col] = Dimension.toDimensionValue(dimensionSymbols
198
+ .charAt(i));
199
+ }
200
+ };
201
+
202
+
203
+ /**
204
+ * Changes the specified element to <code>minimumDimensionValue</code> if
205
+ * the element is less.
206
+ *
207
+ * @param {int}
208
+ * row the row of this <code>IntersectionMatrix</code> , indicating
209
+ * the interior, boundary or exterior of the first
210
+ * <code>Geometry.</code>
211
+ * @param {int}
212
+ * column the column of this <code>IntersectionMatrix</code> ,
213
+ * indicating the interior, boundary or exterior of the second
214
+ * <code>Geometry.</code>
215
+ * @param {int}
216
+ * minimumDimensionValue the dimension value with which to compare
217
+ * the element. The order of dimension values from least to greatest
218
+ * is <code>{DONTCARE, TRUE, FALSE, 0, 1, 2}</code>.
219
+ */
220
+ jsts.geom.IntersectionMatrix.prototype.setAtLeast = function(row, column,
221
+ minimumDimensionValue) {
222
+ if (arguments.length === 1) {
223
+ this.setAtLeast2(arguments[0]);
224
+ return;
225
+ }
226
+
227
+ if (this.matrix[row][column] < minimumDimensionValue) {
228
+ this.matrix[row][column] = minimumDimensionValue;
229
+ }
230
+ };
231
+
232
+
233
+ /**
234
+ * If row >= 0 and column >= 0, changes the specified element to
235
+ * <code>minimumDimensionValue</code> if the element is less. Does nothing
236
+ * if row <0 or column < 0.
237
+ *
238
+ * @param {int}
239
+ * row the row of this <code>IntersectionMatrix</code> , indicating
240
+ * the interior, boundary or exterior of the first
241
+ * <code>Geometry.</code>
242
+ * @param {int}
243
+ * column the column of this <code>IntersectionMatrix</code> ,
244
+ * indicating the interior, boundary or exterior of the second
245
+ * <code>Geometry.</code>
246
+ * @param {int}
247
+ * minimumDimensionValue the dimension value with which to compare
248
+ * the element. The order of dimension values from least to greatest
249
+ * is <code>{DONTCARE, TRUE, FALSE, 0, 1, 2}</code>.
250
+ */
251
+ jsts.geom.IntersectionMatrix.prototype.setAtLeastIfValid = function(row, column,
252
+ minimumDimensionValue) {
253
+ if (row >= 0 && column >= 0) {
254
+ this.setAtLeast(row, column, minimumDimensionValue);
255
+ }
256
+ };
257
+
258
+
259
+ /**
260
+ * For each element in this <code>IntersectionMatrix</code>, changes the
261
+ * element to the corresponding minimum dimension symbol if the element is
262
+ * less.
263
+ *
264
+ * @param {string}
265
+ * minimumDimensionSymbols nine dimension symbols with which to
266
+ * compare the elements of this <code>IntersectionMatrix</code>.
267
+ * The order of dimension values from least to greatest is
268
+ * <code>{DONTCARE, TRUE, FALSE, 0, 1, 2}</code> .
269
+ */
270
+ jsts.geom.IntersectionMatrix.prototype.setAtLeast2 = function(minimumDimensionSymbols) {
271
+ var i;
272
+ for (i = 0; i < minimumDimensionSymbols.length; i++) {
273
+ var row = parseInt(i / 3);
274
+ var col = parseInt(i % 3);
275
+ this.setAtLeast(row, col, jsts.geom.Dimension
276
+ .toDimensionValue(minimumDimensionSymbols.charAt(i)));
277
+ }
278
+ };
279
+
280
+
281
+ /**
282
+ * Changes the elements of this <code>IntersectionMatrix</code> to
283
+ * <code>dimensionValue</code> .
284
+ *
285
+ * @param {int}
286
+ * dimensionValue the dimension value to which to set this
287
+ * <code>IntersectionMatrix</code> s elements. Possible values
288
+ * <code>{TRUE, FALSE, DONTCARE, 0, 1, 2}</code> .
289
+ */
290
+ jsts.geom.IntersectionMatrix.prototype.setAll = function(dimensionValue) {
291
+ var ai, bi;
292
+ for (ai = 0; ai < 3; ai++) {
293
+ for (bi = 0; bi < 3; bi++) {
294
+ this.matrix[ai][bi] = dimensionValue;
295
+ }
296
+ }
297
+ };
298
+
299
+
300
+ /**
301
+ * Returns the value of one of this matrix entries. The value of the provided
302
+ * index is one of the values from the {@link Location} class. The value
303
+ * returned is a constant from the {@link Dimension} class.
304
+ *
305
+ * @param {int}
306
+ * row the row of this <code>IntersectionMatrix</code>, indicating
307
+ * the interior, boundary or exterior of the first
308
+ * <code>Geometry.</code>
309
+ * @param {int}
310
+ * column the column of this <code>IntersectionMatrix</code>,
311
+ * indicating the interior, boundary or exterior of the second
312
+ * <code>Geometry.</code>
313
+ * @return {int} the dimension value at the given matrix position.
314
+ */
315
+ jsts.geom.IntersectionMatrix.prototype.get = function(row, column) {
316
+ return this.matrix[row][column];
317
+ };
318
+
319
+
320
+ /**
321
+ * Returns <code>true</code> if this <code>IntersectionMatrix</code> is
322
+ * FF*FF****.
323
+ *
324
+ * @return {boolean} <code>true</code> if the two <code>Geometry</code>s
325
+ * related by this <code>IntersectionMatrix</code> are disjoint.
326
+ */
327
+ jsts.geom.IntersectionMatrix.prototype.isDisjoint = function() {
328
+ return this.matrix[Location.INTERIOR][Location.INTERIOR] === Dimension.FALSE &&
329
+ this.matrix[Location.INTERIOR][Location.BOUNDARY] === Dimension.FALSE &&
330
+ this.matrix[Location.BOUNDARY][Location.INTERIOR] === Dimension.FALSE &&
331
+ this.matrix[Location.BOUNDARY][Location.BOUNDARY] === Dimension.FALSE;
332
+ };
333
+
334
+
335
+ /**
336
+ * Returns <code>true</code> if <code>isDisjoint</code> returns false.
337
+ *
338
+ * @return {boolean} <code>true</code> if the two <code>Geometry</code>s
339
+ * related by this <code>IntersectionMatrix</code> intersect.
340
+ */
341
+ jsts.geom.IntersectionMatrix.prototype.isIntersects = function() {
342
+ return !this.isDisjoint();
343
+ };
344
+
345
+
346
+ /**
347
+ * Returns <code>true</code> if this <code>IntersectionMatrix</code> is
348
+ * FT*******, F**T***** or F***T****.
349
+ *
350
+ * @param {int}
351
+ * dimensionOfGeometryA the dimension of the first
352
+ * <code>Geometry.</code>
353
+ * @param {int}
354
+ * dimensionOfGeometryB the dimension of the second
355
+ * <code>Geometry.</code>
356
+ * @return {boolean} <code>true</code> if the two <code>Geometry</code> s
357
+ * related by this <code>IntersectionMatrix</code> touch; Returns
358
+ * false if both <code>Geometry</code>s are points.
359
+ */
360
+ jsts.geom.IntersectionMatrix.prototype.isTouches = function(dimensionOfGeometryA,
361
+ dimensionOfGeometryB) {
362
+ if (dimensionOfGeometryA > dimensionOfGeometryB) {
363
+ // no need to get transpose because pattern matrix is symmetrical
364
+ return this.isTouches(dimensionOfGeometryB, dimensionOfGeometryA);
365
+ }
366
+ if ((dimensionOfGeometryA == Dimension.A && dimensionOfGeometryB == Dimension.A) ||
367
+ (dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.L) ||
368
+ (dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.A) ||
369
+ (dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.A) ||
370
+ (dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.L)) {
371
+ return this.matrix[Location.INTERIOR][Location.INTERIOR] === Dimension.FALSE &&
372
+ (jsts.geom.IntersectionMatrix.matches(
373
+ this.matrix[Location.INTERIOR][Location.BOUNDARY], 'T') ||
374
+ jsts.geom.IntersectionMatrix.matches(
375
+ this.matrix[Location.BOUNDARY][Location.INTERIOR], 'T') || jsts.geom.IntersectionMatrix
376
+ .matches(this.matrix[Location.BOUNDARY][Location.BOUNDARY], 'T'));
377
+ }
378
+ return false;
379
+ };
380
+
381
+
382
+ /**
383
+ * Tests whether this geometry crosses the specified geometry.
384
+ * <p>
385
+ * The <code>crosses</code> predicate has the following equivalent
386
+ * definitions:
387
+ * <ul>
388
+ * <li>The geometries have some but not all interior points in common.
389
+ * <li>The DE-9IM Intersection Matrix for the two geometries is
390
+ * <ul>
391
+ * <li>T*T****** (for P/L, P/A, and L/A situations)
392
+ * <li>T*****T** (for L/P, L/A, and A/L situations)
393
+ * <li>0******** (for L/L situations)
394
+ * </ul>
395
+ * </ul>
396
+ * For any other combination of dimensions this predicate returns
397
+ * <code>false</code>.
398
+ * <p>
399
+ * The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations.
400
+ * JTS extends the definition to apply to L/P, A/P and A/L situations as well.
401
+ * This makes the relation symmetric.
402
+ *
403
+ * @param {int}
404
+ * dimensionOfGeometryA the dimension of the first
405
+ * <code>Geometry.</code>
406
+ * @param {int}
407
+ * dimensionOfGeometryB the dimension of the second
408
+ * <code>Geometry.</code>
409
+ * @return {boolean} <code>true</code> if the two <code>Geometry</code>s
410
+ * related by this <code>IntersectionMatrix</code> cross.
411
+ */
412
+ jsts.geom.IntersectionMatrix.prototype.isCrosses = function(dimensionOfGeometryA,
413
+ dimensionOfGeometryB) {
414
+ if ((dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.L) ||
415
+ (dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.A) ||
416
+ (dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.A)) {
417
+ return jsts.geom.IntersectionMatrix.matches(
418
+ this.matrix[Location.INTERIOR][Location.INTERIOR], 'T') &&
419
+ jsts.geom.IntersectionMatrix.matches(
420
+ this.matrix[Location.INTERIOR][Location.EXTERIOR], 'T');
421
+ }
422
+ if ((dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.P) ||
423
+ (dimensionOfGeometryA == Dimension.A && dimensionOfGeometryB == Dimension.P) ||
424
+ (dimensionOfGeometryA == Dimension.A && dimensionOfGeometryB == Dimension.L)) {
425
+ return jsts.geom.IntersectionMatrix.matches(
426
+ matrix[Location.INTERIOR][Location.INTERIOR], 'T') &&
427
+ jsts.geom.IntersectionMatrix.matches(
428
+ this.matrix[Location.EXTERIOR][Location.INTERIOR], 'T');
429
+ }
430
+ if (dimensionOfGeometryA === Dimension.L &&
431
+ dimensionOfGeometryB === Dimension.L) {
432
+ return this.matrix[Location.INTERIOR][Location.INTERIOR] === 0;
433
+ }
434
+ return false;
435
+ };
436
+
437
+
438
+ /**
439
+ * Tests whether this <code>IntersectionMatrix</code> is T*F**F***.
440
+ *
441
+ * @return {boolean} <code>true</code> if the first <code>Geometry</code>
442
+ * is within the second.
443
+ */
444
+ jsts.geom.IntersectionMatrix.prototype.isWithin = function() {
445
+ return jsts.geom.IntersectionMatrix.matches(
446
+ this.matrix[Location.INTERIOR][Location.INTERIOR], 'T') &&
447
+ this.matrix[Location.INTERIOR][Location.EXTERIOR] == Dimension.FALSE &&
448
+ this.matrix[Location.BOUNDARY][Location.EXTERIOR] == Dimension.FALSE;
449
+ };
450
+
451
+
452
+ /**
453
+ * Tests whether this <code>IntersectionMatrix</code> is T*****FF*.
454
+ *
455
+ * @return {boolean} <code>true</code> if the first <code>Geometry</code>
456
+ * contains the second.
457
+ */
458
+ jsts.geom.IntersectionMatrix.prototype.isContains = function() {
459
+ return jsts.geom.IntersectionMatrix.matches(
460
+ this.matrix[Location.INTERIOR][Location.INTERIOR], 'T') &&
461
+ this.matrix[Location.EXTERIOR][Location.INTERIOR] == Dimension.FALSE &&
462
+ this.matrix[Location.EXTERIOR][Location.BOUNDARY] == Dimension.FALSE;
463
+ };
464
+
465
+
466
+ /**
467
+ * Returns <code>true</code> if this <code>IntersectionMatrix</code> is
468
+ * <code>T*****FF*</code> or <code>*T****FF*</code> or
469
+ * <code>***T**FF*</code> or <code>****T*FF*</code>
470
+ *
471
+ * @return {boolean} <code>true</code> if the first <code>Geometry</code>
472
+ * covers the second.
473
+ */
474
+ jsts.geom.IntersectionMatrix.prototype.isCovers = function() {
475
+ var hasPointInCommon = jsts.geom.IntersectionMatrix.matches(
476
+ this.matrix[Location.INTERIOR][Location.INTERIOR], 'T') ||
477
+ jsts.geom.IntersectionMatrix.matches(
478
+ this.matrix[Location.INTERIOR][Location.BOUNDARY], 'T') ||
479
+ jsts.geom.IntersectionMatrix.matches(
480
+ this.matrix[Location.BOUNDARY][Location.INTERIOR], 'T') ||
481
+ jsts.geom.IntersectionMatrix.matches(
482
+ this.matrix[Location.BOUNDARY][Location.BOUNDARY], 'T');
483
+
484
+ return hasPointInCommon &&
485
+ this.matrix[Location.EXTERIOR][Location.INTERIOR] == Dimension.FALSE &&
486
+ this.matrix[Location.EXTERIOR][Location.BOUNDARY] == Dimension.FALSE;
487
+ };
488
+
489
+
490
+ /**
491
+ * Returns <code>true</code> if this <code>IntersectionMatrix</code> is
492
+ * <code>T*F**F***</code> or <code>*TF**F***</code> or
493
+ * <code>**FT*F***</code> or <code>**F*TF***</code>
494
+ *
495
+ * @return {boolean} <code>true</code> if the first <code>Geometry</code>
496
+ * is covered by the second.
497
+ */
498
+ jsts.geom.IntersectionMatrix.prototype.isCoveredBy = function() {
499
+ var hasPointInCommon = jsts.geom.IntersectionMatrix.matches(
500
+ this.matrix[Location.INTERIOR][Location.INTERIOR], 'T') ||
501
+ jsts.geom.IntersectionMatrix.matches(
502
+ this.matrix[Location.INTERIOR][Location.BOUNDARY], 'T') ||
503
+ jsts.geom.IntersectionMatrix.matches(
504
+ this.matrix[Location.BOUNDARY][Location.INTERIOR], 'T') ||
505
+ jsts.geom.IntersectionMatrix.matches(
506
+ this.matrix[Location.BOUNDARY][Location.BOUNDARY], 'T');
507
+
508
+ return hasPointInCommon &&
509
+ this.matrix[Location.INTERIOR][Location.EXTERIOR] === Dimension.FALSE &&
510
+ this.matrix[Location.BOUNDARY][Location.EXTERIOR] === Dimension.FALSE;
511
+ };
512
+
513
+
514
+ /**
515
+ * Returns <code>true</code> if this <code>IntersectionMatrix</code> is
516
+ * T*F**FFF*.
517
+ *
518
+ * @param {int}
519
+ * dimensionOfGeometryA the dimension of the first
520
+ * <code>Geometry.</code>
521
+ * @param {int}
522
+ * dimensionOfGeometryB the dimension of the second
523
+ * <code>Geometry.</code>
524
+ * @return {boolean} <code>true</code> if the two <code>Geometry</code> s
525
+ * related by this <code>IntersectionMatrix</code> are equal; the
526
+ * <code>Geometry</code>s must have the same dimension for this
527
+ * function to return <code>true.</code>
528
+ */
529
+ jsts.geom.IntersectionMatrix.prototype.isEquals = function(dimensionOfGeometryA,
530
+ dimensionOfGeometryB) {
531
+ if (dimensionOfGeometryA !== dimensionOfGeometryB) {
532
+ return false;
533
+ }
534
+ return jsts.geom.IntersectionMatrix.matches(
535
+ this.matrix[Location.INTERIOR][Location.INTERIOR], 'T') &&
536
+ this.matrix[Location.EXTERIOR][Location.INTERIOR] === Dimension.FALSE &&
537
+ this.matrix[Location.INTERIOR][Location.EXTERIOR] === Dimension.FALSE &&
538
+ this.matrix[Location.EXTERIOR][Location.BOUNDARY] === Dimension.FALSE &&
539
+ this.matrix[Location.BOUNDARY][Location.EXTERIOR] === Dimension.FALSE;
540
+ };
541
+
542
+
543
+ /**
544
+ * Returns <code>true</code> if this <code>IntersectionMatrix</code> is
545
+ * <UL>
546
+ * <LI> T*T***T** (for two points or two surfaces)
547
+ * <LI> 1*T***T** (for two curves)
548
+ * </UL>.
549
+ *
550
+ * @param {int}
551
+ * dimensionOfGeometryA the dimension of the first
552
+ * <code>Geometry.</code>
553
+ * @param {int}
554
+ * dimensionOfGeometryB the dimension of the second
555
+ * <code>Geometry.</code>
556
+ * @return {boolean} <code>true</code> if the two <code>Geometry</code>s
557
+ * related by this <code>IntersectionMatrix</code> overlap. For this
558
+ * function to return <code>true</code>, the <code>Geometry</code>s
559
+ * must be two points, two curves or two surfaces.
560
+ */
561
+ jsts.geom.IntersectionMatrix.prototype.isOverlaps = function(dimensionOfGeometryA,
562
+ dimensionOfGeometryB) {
563
+ if ((dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB === Dimension.P) ||
564
+ (dimensionOfGeometryA == Dimension.A && dimensionOfGeometryB === Dimension.A)) {
565
+ return jsts.geom.IntersectionMatrix.matches(
566
+ this.matrix[Location.INTERIOR][Location.INTERIOR], 'T') &&
567
+ jsts.geom.IntersectionMatrix.matches(
568
+ this.matrix[Location.INTERIOR][Location.EXTERIOR], 'T') &&
569
+ jsts.geom.IntersectionMatrix.matches(
570
+ this.matrix[Location.EXTERIOR][Location.INTERIOR], 'T');
571
+ }
572
+ if (dimensionOfGeometryA === Dimension.L &&
573
+ dimensionOfGeometryB === Dimension.L) {
574
+ return this.matrix[Location.INTERIOR][Location.INTERIOR] == 1 &&
575
+ jsts.geom.IntersectionMatrix.matches(
576
+ this.matrix[Location.INTERIOR][Location.EXTERIOR], 'T') &&
577
+ jsts.geom.IntersectionMatrix.matches(
578
+ this.matrix[Location.EXTERIOR][Location.INTERIOR], 'T');
579
+ }
580
+ return false;
581
+ };
582
+
583
+
584
+ /**
585
+ * Returns whether the elements of this <code>IntersectionMatrix</code>
586
+ * satisfies the required dimension symbols.
587
+ *
588
+ * @param {string}
589
+ * requiredDimensionSymbols nine dimension symbols with which to
590
+ * compare the elements of this <code>IntersectionMatrix</code>.
591
+ * Possible values are <code>{T, F, * , 0, 1, 2}</code>.
592
+ * @return {boolean} <code>true</code> if this
593
+ * <code>IntersectionMatrix</code> matches the required dimension
594
+ * symbols.
595
+ */
596
+ jsts.geom.IntersectionMatrix.prototype.matches = function(requiredDimensionSymbols) {
597
+ if (requiredDimensionSymbols.length != 9) {
598
+ throw new jsts.error.IllegalArgumentException('Should be length 9: ' +
599
+ requiredDimensionSymbols);
600
+ }
601
+ for (var ai = 0; ai < 3; ai++) {
602
+ for (var bi = 0; bi < 3; bi++) {
603
+ if (!jsts.geom.IntersectionMatrix.matches(this.matrix[ai][bi],
604
+ requiredDimensionSymbols.charAt(3 * ai + bi))) {
605
+ return false;
606
+ }
607
+ }
608
+ }
609
+ return true;
610
+ };
611
+
612
+
613
+ /**
614
+ * Transposes this jsts.geom.IntersectionMatrix.
615
+ *
616
+ * @return {IntersectionMatrix} this <code>IntersectionMatrix</code> as a
617
+ * convenience.
618
+ */
619
+ jsts.geom.IntersectionMatrix.prototype.transpose = function() {
620
+ var temp = matrix[1][0];
621
+ this.matrix[1][0] = this.matrix[0][1];
622
+ this.matrix[0][1] = temp;
623
+ temp = this.matrix[2][0];
624
+ this.matrix[2][0] = this.matrix[0][2];
625
+ this.matrix[0][2] = temp;
626
+ temp = this.matrix[2][1];
627
+ this.matrix[2][1] = this.matrix[1][2];
628
+ this.matrix[1][2] = temp;
629
+ return this;
630
+ };
631
+
632
+
633
+ /**
634
+ * Returns a nine-character <code>String</code> representation of this
635
+ * <code>IntersectionMatrix</code> .
636
+ *
637
+ * @return {string} the nine dimension symbols of this
638
+ * <code>IntersectionMatrix</code> in row-major order.
639
+ */
640
+ jsts.geom.IntersectionMatrix.prototype.toString = function() {
641
+ var ai, bi, buf = '';
642
+ for (ai = 0; ai < 3; ai++) {
643
+ for (bi = 0; bi < 3; bi++) {
644
+ buf += Dimension.toDimensionSymbol(this.matrix[ai][bi]);
645
+ }
646
+ }
647
+ return buf;
648
+ };
649
+
650
+ })();