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.
- checksums.yaml +8 -8
- data/lib/jsts-rails/version.rb +1 -1
- data/vendor/assets/javascripts/javascript.util.js +33 -1
- data/vendor/assets/javascripts/jsts-original.js +164 -1573
- data/vendor/assets/javascripts/jsts.js +197 -0
- data/vendor/assets/javascripts/jsts/algorithm/Angle.js +387 -0
- data/vendor/assets/javascripts/jsts/algorithm/BoundaryNodeRule.js +67 -0
- data/vendor/assets/javascripts/jsts/algorithm/CGAlgorithms.js +596 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentralEndpointIntersector.js +118 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentroidArea.js +225 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentroidLine.js +85 -0
- data/vendor/assets/javascripts/jsts/algorithm/CentroidPoint.js +77 -0
- data/vendor/assets/javascripts/jsts/algorithm/ConvexHull.js +409 -0
- data/vendor/assets/javascripts/jsts/algorithm/HCoordinate.js +234 -0
- data/vendor/assets/javascripts/jsts/algorithm/LineIntersector.js +502 -0
- data/vendor/assets/javascripts/jsts/algorithm/MCPointInRing.js +124 -0
- data/vendor/assets/javascripts/jsts/algorithm/PointLocator.js +247 -0
- data/vendor/assets/javascripts/jsts/algorithm/RayCrossingCounter.js +215 -0
- data/vendor/assets/javascripts/jsts/algorithm/RobustDeterminant.js +353 -0
- data/vendor/assets/javascripts/jsts/algorithm/RobustLineIntersector.js +477 -0
- data/vendor/assets/javascripts/jsts/algorithm/distance/DiscreteHausdorffDistance.js +228 -0
- data/vendor/assets/javascripts/jsts/algorithm/distance/DistanceToPoint.js +68 -0
- data/vendor/assets/javascripts/jsts/algorithm/distance/PointPairDistance.js +104 -0
- data/vendor/assets/javascripts/jsts/algorithm/locate/PointOnGeometryLocator.js +7 -0
- data/vendor/assets/javascripts/jsts/algorithm/locate/SimplePointInAreaLocator.js +102 -0
- data/vendor/assets/javascripts/jsts/geom/Coordinate.js +158 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateArrays.js +148 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateFilter.js +29 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateList.js +157 -0
- data/vendor/assets/javascripts/jsts/geom/CoordinateSequenceFilter.js +63 -0
- data/vendor/assets/javascripts/jsts/geom/Dimension.js +137 -0
- data/vendor/assets/javascripts/jsts/geom/Envelope.js +833 -0
- data/vendor/assets/javascripts/jsts/geom/Geometry.js +1535 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryCollection.js +230 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryComponentFilter.js +36 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryFactory.js +263 -0
- data/vendor/assets/javascripts/jsts/geom/GeometryFilter.js +29 -0
- data/vendor/assets/javascripts/jsts/geom/IntersectionMatrix.js +650 -0
- data/vendor/assets/javascripts/jsts/geom/LineSegment.js +275 -0
- data/vendor/assets/javascripts/jsts/geom/LineString.js +299 -0
- data/vendor/assets/javascripts/jsts/geom/LinearRing.js +69 -0
- data/vendor/assets/javascripts/jsts/geom/Location.js +83 -0
- data/vendor/assets/javascripts/jsts/geom/MultiLineString.js +47 -0
- data/vendor/assets/javascripts/jsts/geom/MultiPoint.js +64 -0
- data/vendor/assets/javascripts/jsts/geom/MultiPolygon.js +64 -0
- data/vendor/assets/javascripts/jsts/geom/Point.js +197 -0
- data/vendor/assets/javascripts/jsts/geom/Polygon.js +263 -0
- data/vendor/assets/javascripts/jsts/geom/PrecisionModel.js +187 -0
- data/vendor/assets/javascripts/jsts/geom/Triangle.js +313 -0
- data/vendor/assets/javascripts/jsts/geom/util/GeometryCombiner.js +143 -0
- data/vendor/assets/javascripts/jsts/geom/util/GeometryExtracter.js +76 -0
- data/vendor/assets/javascripts/jsts/geom/util/GeometryTransformer.js +295 -0
- data/vendor/assets/javascripts/jsts/geom/util/LinearComponentExtracter.js +207 -0
- data/vendor/assets/javascripts/jsts/geom/util/PointExtracter.js +67 -0
- data/vendor/assets/javascripts/jsts/geom/util/PolygonExtracter.js +71 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Depth.js +145 -0
- data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdge.js +270 -0
- data/vendor/assets/javascripts/jsts/geomgraph/DirectedEdgeStar.js +388 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Edge.js +291 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeEnd.js +188 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeEndStar.js +322 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersection.js +122 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeIntersectionList.js +146 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeList.js +111 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeNodingValidator.js +76 -0
- data/vendor/assets/javascripts/jsts/geomgraph/EdgeRing.js +230 -0
- data/vendor/assets/javascripts/jsts/geomgraph/GeometryGraph.js +469 -0
- data/vendor/assets/javascripts/jsts/geomgraph/GraphComponent.js +181 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Label.js +316 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Node.js +105 -0
- data/vendor/assets/javascripts/jsts/geomgraph/NodeFactory.js +22 -0
- data/vendor/assets/javascripts/jsts/geomgraph/NodeMap.js +128 -0
- data/vendor/assets/javascripts/jsts/geomgraph/PlanarGraph.js +214 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Position.js +63 -0
- data/vendor/assets/javascripts/jsts/geomgraph/Quadrant.js +143 -0
- data/vendor/assets/javascripts/jsts/geomgraph/TopologyLocation.js +251 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/EdgeSetIntersector.js +47 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/SegmentIntersector.js +298 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleEdgeSetIntersector.js +107 -0
- data/vendor/assets/javascripts/jsts/geomgraph/index/SimpleMCSweepLineIntersector.js +29 -0
- data/vendor/assets/javascripts/jsts/index/ArrayListVisitor.js +37 -0
- data/vendor/assets/javascripts/jsts/index/DoubleBits.js +132 -0
- data/vendor/assets/javascripts/jsts/index/IntervalSize.js +55 -0
- data/vendor/assets/javascripts/jsts/index/ItemVisitor.js +23 -0
- data/vendor/assets/javascripts/jsts/index/SpatialIndex.js +67 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Bintree.js +224 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Interval.js +160 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Key.js +110 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Node.js +204 -0
- data/vendor/assets/javascripts/jsts/index/bintree/NodeBase.js +220 -0
- data/vendor/assets/javascripts/jsts/index/bintree/Root.js +113 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChain.js +244 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainBuilder.js +106 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainOverlapAction.js +56 -0
- data/vendor/assets/javascripts/jsts/index/chain/MonotoneChainSelectAction.js +44 -0
- data/vendor/assets/javascripts/jsts/index/kdtree/KdNode.js +171 -0
- data/vendor/assets/javascripts/jsts/index/kdtree/KdTree.js +218 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Key.js +134 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Node.js +220 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/NodeBase.js +330 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Quadtree.js +228 -0
- data/vendor/assets/javascripts/jsts/index/quadtree/Root.js +105 -0
- data/vendor/assets/javascripts/jsts/index/strtree/AbstractNode.js +107 -0
- data/vendor/assets/javascripts/jsts/index/strtree/AbstractSTRtree.js +594 -0
- data/vendor/assets/javascripts/jsts/index/strtree/Boundable.js +37 -0
- data/vendor/assets/javascripts/jsts/index/strtree/BoundablePair.js +0 -0
- data/vendor/assets/javascripts/jsts/index/strtree/Interval.js +94 -0
- data/vendor/assets/javascripts/jsts/index/strtree/ItemBoundable.js +60 -0
- data/vendor/assets/javascripts/jsts/index/strtree/SIRtree.js +122 -0
- data/vendor/assets/javascripts/jsts/index/strtree/STRtree.js +450 -0
- data/vendor/assets/javascripts/jsts/io/GeoJSONParser.js +471 -0
- data/vendor/assets/javascripts/jsts/io/GeoJSONReader.js +58 -0
- data/vendor/assets/javascripts/jsts/io/GeoJSONWriter.js +38 -0
- data/vendor/assets/javascripts/jsts/io/OpenLayersParser.js +245 -0
- data/vendor/assets/javascripts/jsts/io/WKTParser.js +421 -0
- data/vendor/assets/javascripts/jsts/io/WKTReader.js +68 -0
- data/vendor/assets/javascripts/jsts/io/WKTWriter.js +61 -0
- data/vendor/assets/javascripts/jsts/noding/BasicSegmentString.js +87 -0
- data/vendor/assets/javascripts/jsts/noding/FastNodingValidator.js +127 -0
- data/vendor/assets/javascripts/jsts/noding/InteriorIntersectionFinder.js +171 -0
- data/vendor/assets/javascripts/jsts/noding/IntersectionAdder.js +198 -0
- data/vendor/assets/javascripts/jsts/noding/IntersectionFinderAdder.js +79 -0
- data/vendor/assets/javascripts/jsts/noding/MCIndexNoder.js +147 -0
- data/vendor/assets/javascripts/jsts/noding/NodableSegmentString.js +35 -0
- data/vendor/assets/javascripts/jsts/noding/NodedSegmentString.js +235 -0
- data/vendor/assets/javascripts/jsts/noding/Noder.js +41 -0
- data/vendor/assets/javascripts/jsts/noding/NodingValidator.js +5 -0
- data/vendor/assets/javascripts/jsts/noding/Octant.js +84 -0
- data/vendor/assets/javascripts/jsts/noding/OrientedCoordinateArray.js +94 -0
- data/vendor/assets/javascripts/jsts/noding/ScaledNoder.js +105 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentIntersector.js +45 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentNode.js +70 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentNodeList.js +262 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentPointComparator.js +78 -0
- data/vendor/assets/javascripts/jsts/noding/SegmentString.js +61 -0
- data/vendor/assets/javascripts/jsts/noding/SinglePassNoder.js +51 -0
- data/vendor/assets/javascripts/jsts/noding/snapround/HotPixel.js +271 -0
- data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexPointSnapper.js +96 -0
- data/vendor/assets/javascripts/jsts/noding/snapround/MCIndexSnapRounder.js +147 -0
- data/vendor/assets/javascripts/jsts/operation/BoundaryOp.js +166 -0
- data/vendor/assets/javascripts/jsts/operation/GeometryGraphOperation.js +90 -0
- data/vendor/assets/javascripts/jsts/operation/IsSimpleOp.js +293 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferBuilder.js +317 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferInputLineSimplifier.js +294 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferOp.js +340 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferParameters.js +328 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/BufferSubgraph.js +296 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveBuilder.js +369 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetCurveSetBuilder.js +301 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentGenerator.js +777 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/OffsetSegmentString.js +109 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/RightmostEdgeFinder.js +164 -0
- data/vendor/assets/javascripts/jsts/operation/buffer/SubgraphDepthLocater.js +220 -0
- data/vendor/assets/javascripts/jsts/operation/distance/ConnectedElementLocationFilter.js +67 -0
- data/vendor/assets/javascripts/jsts/operation/distance/DistanceOp.js +506 -0
- data/vendor/assets/javascripts/jsts/operation/distance/GeometryLocation.js +102 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/LineBuilder.js +194 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/MaximalEdgeRing.js +72 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/MinimalEdgeRing.js +33 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/OverlayNodeFactory.js +26 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/OverlayOp.js +584 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/PointBuilder.js +103 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/PolygonBuilder.js +282 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/GeometrySnapper.js +228 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/LineStringSnapper.js +228 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapIfNeededOverlayOp.js +85 -0
- data/vendor/assets/javascripts/jsts/operation/overlay/snap/SnapOverlayOp.js +134 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/EdgeRing.js +259 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeDirectedEdge.js +94 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeEdge.js +31 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/PolygonizeGraph.js +507 -0
- data/vendor/assets/javascripts/jsts/operation/polygonize/Polygonizer.js +259 -0
- data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBuilder.js +140 -0
- data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundle.js +183 -0
- data/vendor/assets/javascripts/jsts/operation/relate/EdgeEndBundleStar.js +48 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateComputer.js +444 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateNode.js +46 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeFactory.js +25 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateNodeGraph.js +118 -0
- data/vendor/assets/javascripts/jsts/operation/relate/RelateOp.js +75 -0
- data/vendor/assets/javascripts/jsts/operation/union/CascadedPolygonUnion.js +319 -0
- data/vendor/assets/javascripts/jsts/operation/union/PointGeometryUnion.js +118 -0
- data/vendor/assets/javascripts/jsts/operation/union/UnaryUnionOp.js +244 -0
- data/vendor/assets/javascripts/jsts/operation/union/UnionInteracting.js +156 -0
- data/vendor/assets/javascripts/jsts/operation/valid/ConnectedInteriorTester.js +259 -0
- data/vendor/assets/javascripts/jsts/operation/valid/ConsistentAreaTester.js +127 -0
- data/vendor/assets/javascripts/jsts/operation/valid/IndexedNestedRingTester.js +89 -0
- data/vendor/assets/javascripts/jsts/operation/valid/IsValidOp.js +619 -0
- data/vendor/assets/javascripts/jsts/operation/valid/TopologyValidationError.js +199 -0
- data/vendor/assets/javascripts/jsts/planargraph/DirectedEdge.js +232 -0
- data/vendor/assets/javascripts/jsts/planargraph/DirectedEdgeStar.js +168 -0
- data/vendor/assets/javascripts/jsts/planargraph/Edge.js +124 -0
- data/vendor/assets/javascripts/jsts/planargraph/GraphComponent.js +182 -0
- data/vendor/assets/javascripts/jsts/planargraph/Node.js +127 -0
- data/vendor/assets/javascripts/jsts/planargraph/NodeMap.js +76 -0
- data/vendor/assets/javascripts/jsts/planargraph/PlanarGraph.js +246 -0
- data/vendor/assets/javascripts/jsts/simplify/LineSegmentIndex.js +101 -0
- data/vendor/assets/javascripts/jsts/triangulate/DelaunayTriangulationBuilder.js +224 -0
- data/vendor/assets/javascripts/jsts/triangulate/IncrementalDelaunayTriangulator.js +111 -0
- data/vendor/assets/javascripts/jsts/triangulate/VoronoiDiagramBuilder.js +172 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/LastFoundQuadEdgeLocator.js +52 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdge.js +437 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/QuadEdgeSubdivision.js +1064 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/TrianglePredicate.js +350 -0
- data/vendor/assets/javascripts/jsts/triangulate/quadedge/Vertex.js +496 -0
- data/vendor/assets/javascripts/jsts/util/Assert.js +80 -0
- data/vendor/assets/javascripts/jsts/util/AssertionFailedException.js +23 -0
- data/vendor/assets/javascripts/jsts/util/UniqueCoordinateArrayFilter.js +52 -0
- metadata +204 -1
@@ -0,0 +1,502 @@
|
|
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
|
+
* A LineIntersector is an algorithm that can both test whether two line
|
11
|
+
* segments intersect and compute the intersection point if they do. The
|
12
|
+
* intersection point may be computed in a precise or non-precise manner.
|
13
|
+
* Computing it precisely involves rounding it to an integer. (This assumes that
|
14
|
+
* the input coordinates have been made precise by scaling them to an integer
|
15
|
+
* grid.)
|
16
|
+
*
|
17
|
+
* @constructor
|
18
|
+
*/
|
19
|
+
jsts.algorithm.LineIntersector = function() {
|
20
|
+
this.inputLines = [[], []];
|
21
|
+
this.intPt = [null, null];
|
22
|
+
// alias the intersection points for ease of reference
|
23
|
+
this.pa = this.intPt[0];
|
24
|
+
this.pb = this.intPt[1];
|
25
|
+
this.result = jsts.algorithm.LineIntersector.NO_INTERSECTION;
|
26
|
+
};
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Indicates that line segments do not intersect
|
31
|
+
*
|
32
|
+
* @type {int}
|
33
|
+
*/
|
34
|
+
jsts.algorithm.LineIntersector.NO_INTERSECTION = 0;
|
35
|
+
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Indicates that line segments intersect in a single point
|
39
|
+
*
|
40
|
+
* @type {int}
|
41
|
+
*/
|
42
|
+
jsts.algorithm.LineIntersector.POINT_INTERSECTION = 1;
|
43
|
+
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Indicates that line segments intersect in a line segment
|
47
|
+
*
|
48
|
+
* @type {int}
|
49
|
+
*/
|
50
|
+
jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION = 2;
|
51
|
+
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Force computed intersection to be rounded to a given precision model. No
|
55
|
+
* getter is provided, because the precision model is not required to be
|
56
|
+
* specified.
|
57
|
+
*
|
58
|
+
* @param precisionModel
|
59
|
+
*/
|
60
|
+
jsts.algorithm.LineIntersector.prototype.setPrecisionModel = function(
|
61
|
+
precisionModel) {
|
62
|
+
this.precisionModel = precisionModel;
|
63
|
+
};
|
64
|
+
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Gets an endpoint of an input segment.
|
68
|
+
*
|
69
|
+
* @param segmentIndex
|
70
|
+
* the index of the input segment (0 or 1).
|
71
|
+
* @param ptIndex
|
72
|
+
* the index of the endpoint (0 or 1).
|
73
|
+
* @return the specified endpoint.
|
74
|
+
*/
|
75
|
+
jsts.algorithm.LineIntersector.prototype.getEndpoint = function(segmentIndex,
|
76
|
+
ptIndex) {
|
77
|
+
return this.inputLines[segmentIndex][ptIndex];
|
78
|
+
};
|
79
|
+
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Computes the "edge distance" of an intersection point p along a segment. The
|
83
|
+
* edge distance is a metric of the point along the edge. The metric used is a
|
84
|
+
* robust and easy to compute metric function. It is <b>not</b> equivalent to
|
85
|
+
* the usual Euclidean metric. It relies on the fact that either the x or the y
|
86
|
+
* ordinates of the points in the edge are unique, depending on whether the edge
|
87
|
+
* is longer in the horizontal or vertical direction.
|
88
|
+
* <p>
|
89
|
+
* NOTE: This function may produce incorrect distances for inputs where p is not
|
90
|
+
* precisely on p1-p2 (E.g. p = (139,9) p1 = (139,10), p2 = (280,1) produces
|
91
|
+
* distanct 0.0, which is incorrect.
|
92
|
+
* <p>
|
93
|
+
* My hypothesis is that the function is safe to use for points which are the
|
94
|
+
* result of <b>rounding</b> points which lie on the line, but not safe to use
|
95
|
+
* for <b>truncated</b> points.
|
96
|
+
*
|
97
|
+
* @param {Coordinate}
|
98
|
+
* p
|
99
|
+
* @param {Coordinate}
|
100
|
+
* p0
|
101
|
+
* @param {Coordinate}
|
102
|
+
* p1
|
103
|
+
* @return {double}
|
104
|
+
*/
|
105
|
+
jsts.algorithm.LineIntersector.computeEdgeDistance = function(p, p0, p1) {
|
106
|
+
var dx = Math.abs(p1.x - p0.x);
|
107
|
+
var dy = Math.abs(p1.y - p0.y);
|
108
|
+
|
109
|
+
var dist = -1.0; // sentinel value
|
110
|
+
if (p.equals(p0)) {
|
111
|
+
dist = 0.0;
|
112
|
+
} else if (p.equals(p1)) {
|
113
|
+
if (dx > dy) {
|
114
|
+
dist = dx;
|
115
|
+
} else {
|
116
|
+
dist = dy;
|
117
|
+
}
|
118
|
+
} else {
|
119
|
+
var pdx = Math.abs(p.x - p0.x);
|
120
|
+
var pdy = Math.abs(p.y - p0.y);
|
121
|
+
if (dx > dy) {
|
122
|
+
dist = pdx;
|
123
|
+
} else {
|
124
|
+
dist = pdy;
|
125
|
+
}
|
126
|
+
// <FIX>
|
127
|
+
// hack to ensure that non-endpoints always have a non-zero distance
|
128
|
+
if (dist === 0.0 && !p.equals(p0)) {
|
129
|
+
dist = Math.max(pdx, pdy);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
if (dist === 0.0 && !p.equals(p0)) {
|
133
|
+
throw new jsts.error.IllegalArgumentError('Bad distance calculation');
|
134
|
+
}
|
135
|
+
return dist;
|
136
|
+
};
|
137
|
+
|
138
|
+
|
139
|
+
/**
|
140
|
+
* This function is non-robust, since it may compute the square of large
|
141
|
+
* numbers. Currently not sure how to improve this.
|
142
|
+
*
|
143
|
+
* @param {Coordinate}
|
144
|
+
* p
|
145
|
+
* @param {Coordinate}
|
146
|
+
* p0
|
147
|
+
* @param {Coordinate}
|
148
|
+
* p1
|
149
|
+
* @return {double}
|
150
|
+
*/
|
151
|
+
jsts.algorithm.LineIntersector.nonRobustComputeEdgeDistance = function(p, p1,
|
152
|
+
p2) {
|
153
|
+
var dx = p.x - p1.x;
|
154
|
+
var dy = p.y - p1.y;
|
155
|
+
var dist = Math.sqrt(dx * dx + dy * dy); // dummy value
|
156
|
+
if (!(dist === 0.0 && !p.equals(p1))) {
|
157
|
+
throw new jsts.error.IllegalArgumentError('Invalid distance calculation');
|
158
|
+
}
|
159
|
+
return dist;
|
160
|
+
};
|
161
|
+
|
162
|
+
|
163
|
+
/**
|
164
|
+
* @protected
|
165
|
+
* @type {int}
|
166
|
+
*/
|
167
|
+
jsts.algorithm.LineIntersector.prototype.result = null;
|
168
|
+
|
169
|
+
|
170
|
+
/**
|
171
|
+
* @protected
|
172
|
+
* @type {Coordinate[][] }
|
173
|
+
*/
|
174
|
+
jsts.algorithm.LineIntersector.prototype.inputLines = null;
|
175
|
+
|
176
|
+
|
177
|
+
/**
|
178
|
+
* @protected
|
179
|
+
* @type {Coordinate[]}
|
180
|
+
*/
|
181
|
+
jsts.algorithm.LineIntersector.prototype.intPt = null;
|
182
|
+
|
183
|
+
|
184
|
+
/**
|
185
|
+
* The indexes of the endpoints of the intersection lines, in order along the
|
186
|
+
* corresponding line
|
187
|
+
*/
|
188
|
+
/**
|
189
|
+
* @protected
|
190
|
+
* @type {int[][]}
|
191
|
+
*/
|
192
|
+
jsts.algorithm.LineIntersector.prototype.intLineIndex = null;
|
193
|
+
|
194
|
+
|
195
|
+
/**
|
196
|
+
* @protected
|
197
|
+
* @type {boolean}
|
198
|
+
*/
|
199
|
+
jsts.algorithm.LineIntersector.prototype._isProper = null;
|
200
|
+
|
201
|
+
|
202
|
+
/**
|
203
|
+
* @protected
|
204
|
+
* @type {Coordinate}
|
205
|
+
*/
|
206
|
+
jsts.algorithm.LineIntersector.prototype.pa = null;
|
207
|
+
|
208
|
+
|
209
|
+
/**
|
210
|
+
* @protected
|
211
|
+
* @type {Coordinate}
|
212
|
+
*/
|
213
|
+
jsts.algorithm.LineIntersector.prototype.pb = null;
|
214
|
+
|
215
|
+
|
216
|
+
/**
|
217
|
+
* @protected
|
218
|
+
* @type {PrecisionModel}
|
219
|
+
*/
|
220
|
+
jsts.algorithm.LineIntersector.prototype.precisionModel = null;
|
221
|
+
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Compute the intersection of a point p and the line p1-p2. This function
|
225
|
+
* computes the boolean value of the hasIntersection test. The actual value of
|
226
|
+
* the intersection (if there is one) is equal to the value of <code>p</code>.
|
227
|
+
*
|
228
|
+
* @param {Coordinate}
|
229
|
+
* p
|
230
|
+
* @param {Coordinate}
|
231
|
+
* p1
|
232
|
+
* @param {Coordinate}
|
233
|
+
* p2
|
234
|
+
*/
|
235
|
+
jsts.algorithm.LineIntersector.prototype.computeIntersection = function(p, p1,
|
236
|
+
p2) {
|
237
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
238
|
+
};
|
239
|
+
|
240
|
+
|
241
|
+
/**
|
242
|
+
* @return {boolean}
|
243
|
+
* @protected
|
244
|
+
*/
|
245
|
+
jsts.algorithm.LineIntersector.prototype.isCollinear = function() {
|
246
|
+
return this.result === jsts.algorithm.LineIntersector.COLLINEAR_INTERSECTION;
|
247
|
+
};
|
248
|
+
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Computes the intersection of the lines p1-p2 and p3-p4. This function
|
252
|
+
* computes both the boolean value of the hasIntersection test and the
|
253
|
+
* (approximate) value of the intersection point itself (if there is one).
|
254
|
+
*
|
255
|
+
* @param {Coordinate}
|
256
|
+
* p1
|
257
|
+
* @param {Coordinate}
|
258
|
+
* p2
|
259
|
+
* @param {Coordinate}
|
260
|
+
* p3
|
261
|
+
* @param {Coordinate}
|
262
|
+
* p4
|
263
|
+
*/
|
264
|
+
jsts.algorithm.LineIntersector.prototype.computeIntersection = function(p1, p2,
|
265
|
+
p3, p4) {
|
266
|
+
this.inputLines[0][0] = p1;
|
267
|
+
this.inputLines[0][1] = p2;
|
268
|
+
this.inputLines[1][0] = p3;
|
269
|
+
this.inputLines[1][1] = p4;
|
270
|
+
this.result = this.computeIntersect(p1, p2, p3, p4);
|
271
|
+
};
|
272
|
+
|
273
|
+
|
274
|
+
/**
|
275
|
+
* @param {Coordinate}
|
276
|
+
* p1
|
277
|
+
* @param {Coordinate}
|
278
|
+
* p2
|
279
|
+
* @param {Coordinate}
|
280
|
+
* q1
|
281
|
+
* @param {Coordinate}
|
282
|
+
* q2
|
283
|
+
* @return {int}
|
284
|
+
* @protected
|
285
|
+
*/
|
286
|
+
jsts.algorithm.LineIntersector.prototype.computeIntersect = function(p1, p2,
|
287
|
+
q1, q2) {
|
288
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
289
|
+
};
|
290
|
+
|
291
|
+
|
292
|
+
/**
|
293
|
+
* @return {boolean}
|
294
|
+
* @protected
|
295
|
+
*/
|
296
|
+
jsts.algorithm.LineIntersector.prototype.isEndPoint = function() {
|
297
|
+
return this.hasIntersection() && !this._isProper;
|
298
|
+
};
|
299
|
+
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Tests whether the input geometries intersect.
|
303
|
+
*
|
304
|
+
* @return {boolean} true if the input geometries intersect.
|
305
|
+
*/
|
306
|
+
jsts.algorithm.LineIntersector.prototype.hasIntersection = function() {
|
307
|
+
return this.result !== jsts.algorithm.LineIntersector.NO_INTERSECTION;
|
308
|
+
};
|
309
|
+
|
310
|
+
|
311
|
+
/**
|
312
|
+
* Returns the number of intersection points found. This will be either 0, 1 or
|
313
|
+
* 2.
|
314
|
+
*
|
315
|
+
* @return {int}
|
316
|
+
*/
|
317
|
+
jsts.algorithm.LineIntersector.prototype.getIntersectionNum = function() {
|
318
|
+
return this.result;
|
319
|
+
};
|
320
|
+
|
321
|
+
|
322
|
+
/**
|
323
|
+
* Returns the intIndex'th intersection point
|
324
|
+
*
|
325
|
+
* @param {int}
|
326
|
+
* intIndex is 0 or 1.
|
327
|
+
*
|
328
|
+
* @return {Coordinate} the intIndex'th intersection point.
|
329
|
+
*/
|
330
|
+
jsts.algorithm.LineIntersector.prototype.getIntersection = function(intIndex) {
|
331
|
+
return this.intPt[intIndex];
|
332
|
+
};
|
333
|
+
|
334
|
+
|
335
|
+
/**
|
336
|
+
* @protected
|
337
|
+
*/
|
338
|
+
jsts.algorithm.LineIntersector.prototype.computeIntLineIndex = function() {
|
339
|
+
if (this.intLineIndex === null) {
|
340
|
+
this.intLineIndex = [[], []];
|
341
|
+
this.computeIntLineIndex(0);
|
342
|
+
this.computeIntLineIndex(1);
|
343
|
+
}
|
344
|
+
};
|
345
|
+
|
346
|
+
|
347
|
+
/**
|
348
|
+
* Test whether a point is a intersection point of two line segments. Note that
|
349
|
+
* if the intersection is a line segment, this method only tests for equality
|
350
|
+
* with the endpoints of the intersection segment. It does <b>not</b> return
|
351
|
+
* true if the input point is internal to the intersection segment.
|
352
|
+
*
|
353
|
+
* @param {Coordinate}
|
354
|
+
* pt
|
355
|
+
* @return {boolean} true if the input point is one of the intersection points.
|
356
|
+
*/
|
357
|
+
jsts.algorithm.LineIntersector.prototype.isIntersection = function(pt) {
|
358
|
+
var i;
|
359
|
+
for (i = 0; i < this.result; i++) {
|
360
|
+
if (this.intPt[i].equals2D(pt)) {
|
361
|
+
return true;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
return false;
|
365
|
+
};
|
366
|
+
|
367
|
+
|
368
|
+
/**
|
369
|
+
* Tests whether either intersection point is an interior point of one of the
|
370
|
+
* input segments.
|
371
|
+
*
|
372
|
+
* @return {boolean} <code>true</code> if either intersection point is in the
|
373
|
+
* interior of one of the input segments.
|
374
|
+
*/
|
375
|
+
jsts.algorithm.LineIntersector.prototype.isInteriorIntersection = function() {
|
376
|
+
if (arguments.length === 1) {
|
377
|
+
return this.isInteriorIntersection2.apply(this, arguments);
|
378
|
+
}
|
379
|
+
|
380
|
+
if (this.isInteriorIntersection(0)) {
|
381
|
+
return true;
|
382
|
+
}
|
383
|
+
if (this.isInteriorIntersection(1)) {
|
384
|
+
return true;
|
385
|
+
}
|
386
|
+
return false;
|
387
|
+
};
|
388
|
+
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Tests whether either intersection point is an interior point of the specified
|
392
|
+
* input segment.
|
393
|
+
*
|
394
|
+
* @param {[]} inputLineIndex
|
395
|
+
* @return {boolean} <code>true</code> if either intersection point is in the
|
396
|
+
* interior of the input segment.
|
397
|
+
*/
|
398
|
+
jsts.algorithm.LineIntersector.prototype.isInteriorIntersection2 = function(
|
399
|
+
inputLineIndex) {
|
400
|
+
var i;
|
401
|
+
for (i = 0; i < this.result; i++) {
|
402
|
+
if (!(this.intPt[i].equals2D(this.inputLines[inputLineIndex][0]) || this.intPt[i]
|
403
|
+
.equals2D(this.inputLines[inputLineIndex][1]))) {
|
404
|
+
return true;
|
405
|
+
}
|
406
|
+
}
|
407
|
+
return false;
|
408
|
+
};
|
409
|
+
|
410
|
+
|
411
|
+
/**
|
412
|
+
* Tests whether an intersection is proper. <br>
|
413
|
+
* The intersection between two line segments is considered proper if they
|
414
|
+
* intersect in a single point in the interior of both segments (e.g. the
|
415
|
+
* intersection is a single point and is not equal to any of the endpoints).
|
416
|
+
* <p>
|
417
|
+
* The intersection between a point and a line segment is considered proper if
|
418
|
+
* the point lies in the interior of the segment (e.g. is not equal to either of
|
419
|
+
* the endpoints).
|
420
|
+
*
|
421
|
+
* @return {boolean} true if the intersection is proper.
|
422
|
+
*/
|
423
|
+
jsts.algorithm.LineIntersector.prototype.isProper = function() {
|
424
|
+
return this.hasIntersection() && this._isProper;
|
425
|
+
};
|
426
|
+
|
427
|
+
|
428
|
+
/**
|
429
|
+
* Computes the intIndex'th intersection point in the direction of a specified
|
430
|
+
* input line segment
|
431
|
+
*
|
432
|
+
* @param {int}
|
433
|
+
* segmentIndex is 0 or 1.
|
434
|
+
* @param {int}
|
435
|
+
* intIndex is 0 or 1.
|
436
|
+
*
|
437
|
+
* @return {Coordinate} the intIndex'th intersection point in the direction of
|
438
|
+
* the specified input line segment.
|
439
|
+
*/
|
440
|
+
jsts.algorithm.LineIntersector.prototype.getIntersectionAlongSegment = function(
|
441
|
+
segmentIndex, intIndex) {
|
442
|
+
// lazily compute int line array
|
443
|
+
this.computeIntLineIndex();
|
444
|
+
return this.intPt[intLineIndex[segmentIndex][intIndex]];
|
445
|
+
};
|
446
|
+
|
447
|
+
|
448
|
+
/**
|
449
|
+
* Computes the index of the intIndex'th intersection point in the direction of
|
450
|
+
* a specified input line segment
|
451
|
+
*
|
452
|
+
* @param {int}
|
453
|
+
* segmentIndex is 0 or 1.
|
454
|
+
* @param {int}
|
455
|
+
* intIndex is 0 or 1.
|
456
|
+
*
|
457
|
+
* @return {int} the index of the intersection point along the segment (0 or 1).
|
458
|
+
*/
|
459
|
+
jsts.algorithm.LineIntersector.prototype.getIndexAlongSegment = function(
|
460
|
+
segmentIndex, intIndex) {
|
461
|
+
this.computeIntLineIndex();
|
462
|
+
return this.intLineIndex[segmentIndex][intIndex];
|
463
|
+
};
|
464
|
+
|
465
|
+
|
466
|
+
/**
|
467
|
+
* @param {int}
|
468
|
+
* segmentIndex
|
469
|
+
* @protected
|
470
|
+
*/
|
471
|
+
jsts.algorithm.LineIntersector.prototype.computeIntLineIndex = function(
|
472
|
+
segmentIndex) {
|
473
|
+
var dist0 = this.getEdgeDistance(segmentIndex, 0);
|
474
|
+
var dist1 = this.getEdgeDistance(segmentIndex, 1);
|
475
|
+
if (dist0 > dist1) {
|
476
|
+
this.intLineIndex[segmentIndex][0] = 0;
|
477
|
+
this.intLineIndex[segmentIndex][1] = 1;
|
478
|
+
} else {
|
479
|
+
this.intLineIndex[segmentIndex][0] = 1;
|
480
|
+
this.intLineIndex[segmentIndex][1] = 0;
|
481
|
+
}
|
482
|
+
};
|
483
|
+
|
484
|
+
|
485
|
+
/**
|
486
|
+
* Computes the "edge distance" of an intersection point along the specified
|
487
|
+
* input line segment.
|
488
|
+
*
|
489
|
+
* @param {int}
|
490
|
+
* segmentIndex is 0 or 1.
|
491
|
+
* @param {int}
|
492
|
+
* intIndex is 0 or 1.
|
493
|
+
*
|
494
|
+
* @return {double} the edge distance of the intersection point.
|
495
|
+
*/
|
496
|
+
jsts.algorithm.LineIntersector.prototype.getEdgeDistance = function(
|
497
|
+
segmentIndex, intIndex) {
|
498
|
+
var dist = jsts.algorithm.LineIntersector.computeEdgeDistance(
|
499
|
+
this.intPt[intIndex], this.inputLines[segmentIndex][0],
|
500
|
+
this.inputLines[segmentIndex][1]);
|
501
|
+
return dist;
|
502
|
+
};
|