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,409 @@
|
|
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/algorithm/CGAlgorithms.js
|
11
|
+
* @requires jsts/util/UniqueCoordinateArrayFilter.js
|
12
|
+
* @requires jsts/util/Assert.js
|
13
|
+
*/
|
14
|
+
|
15
|
+
var CGAlgorithms = jsts.algorithm.CGAlgorithms;
|
16
|
+
var UniqueCoordinateArrayFilter = jsts.util.UniqueCoordinateArrayFilter;
|
17
|
+
var Assert = jsts.util.Assert;
|
18
|
+
var Stack = javascript.util.Stack;
|
19
|
+
var ArrayList = javascript.util.ArrayList;
|
20
|
+
var Arrays = javascript.util.Arrays;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Compares {@link Coordinate}s for their angle and distance relative to an
|
24
|
+
* origin.
|
25
|
+
*
|
26
|
+
* @private
|
27
|
+
*/
|
28
|
+
var RadialComparator = function(origin) {
|
29
|
+
this.origin = origin;
|
30
|
+
};
|
31
|
+
|
32
|
+
RadialComparator.prototype.origin = null;
|
33
|
+
|
34
|
+
RadialComparator.prototype.compare = function(o1, o2) {
|
35
|
+
var p1 = o1;
|
36
|
+
var p2 = o2;
|
37
|
+
return RadialComparator.polarCompare(this.origin, p1, p2);
|
38
|
+
};
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Given two points p and q compare them with respect to their radial ordering
|
42
|
+
* about point o. First checks radial ordering. If points are collinear, the
|
43
|
+
* comparison is based on their distance to the origin.
|
44
|
+
* <p>
|
45
|
+
* p < q iff
|
46
|
+
* <ul>
|
47
|
+
* <li>ang(o-p) < ang(o-q) (e.g. o-p-q is CCW)
|
48
|
+
* <li>or ang(o-p) == ang(o-q) && dist(o,p) < dist(o,q)
|
49
|
+
* </ul>
|
50
|
+
*
|
51
|
+
* @param o
|
52
|
+
* the origin.
|
53
|
+
* @param p
|
54
|
+
* a point.
|
55
|
+
* @param q
|
56
|
+
* another point.
|
57
|
+
* @return -1, 0 or 1 depending on whether p is less than, equal to or greater
|
58
|
+
* than q.
|
59
|
+
*/
|
60
|
+
RadialComparator.polarCompare = function(o, p, q) {
|
61
|
+
var dxp = p.x - o.x;
|
62
|
+
var dyp = p.y - o.y;
|
63
|
+
var dxq = q.x - o.x;
|
64
|
+
var dyq = q.y - o.y;
|
65
|
+
|
66
|
+
var orient = CGAlgorithms.computeOrientation(o, p, q);
|
67
|
+
|
68
|
+
if (orient == CGAlgorithms.COUNTERCLOCKWISE)
|
69
|
+
return 1;
|
70
|
+
if (orient == CGAlgorithms.CLOCKWISE)
|
71
|
+
return -1;
|
72
|
+
|
73
|
+
// points are collinear - check distance
|
74
|
+
var op = dxp * dxp + dyp * dyp;
|
75
|
+
var oq = dxq * dxq + dyq * dyq;
|
76
|
+
if (op < oq) {
|
77
|
+
return -1;
|
78
|
+
}
|
79
|
+
if (op > oq) {
|
80
|
+
return 1;
|
81
|
+
}
|
82
|
+
return 0;
|
83
|
+
};
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Computes the convex hull of a {@link Geometry}. The convex hull is the
|
87
|
+
* smallest convex Geometry that contains all the points in the input
|
88
|
+
* Geometry.
|
89
|
+
* <p>
|
90
|
+
* Uses the Graham Scan algorithm.
|
91
|
+
*
|
92
|
+
* @constructor
|
93
|
+
*/
|
94
|
+
jsts.algorithm.ConvexHull = function() {
|
95
|
+
if (arguments.length === 1) {
|
96
|
+
var geometry = arguments[0];
|
97
|
+
|
98
|
+
this.inputPts = jsts.algorithm.ConvexHull.extractCoordinates(geometry);
|
99
|
+
this.geomFactory = geometry.getFactory();
|
100
|
+
} else {
|
101
|
+
this.pts = arguments[0];
|
102
|
+
this.geomFactory = arguments[1];
|
103
|
+
}
|
104
|
+
};
|
105
|
+
jsts.algorithm.ConvexHull.prototype.geomFactory = null;
|
106
|
+
jsts.algorithm.ConvexHull.prototype.inputPts = null;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* @private
|
110
|
+
*/
|
111
|
+
jsts.algorithm.ConvexHull.extractCoordinates = function(geom) {
|
112
|
+
var filter = new UniqueCoordinateArrayFilter();
|
113
|
+
geom.apply(filter);
|
114
|
+
return filter.getCoordinates();
|
115
|
+
};
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Returns a {@link Geometry} that represents the convex hull of the input
|
119
|
+
* geometry. The returned geometry contains the minimal number of points
|
120
|
+
* needed to represent the convex hull. In particular, no more than two
|
121
|
+
* consecutive points will be collinear.
|
122
|
+
*
|
123
|
+
* @return if the convex hull contains 3 or more points, a {@link Polygon} ; 2
|
124
|
+
* points, a {@link LineString}; 1 point, a {@link Point}; 0 points,
|
125
|
+
* an empty {@link GeometryCollection}.
|
126
|
+
*/
|
127
|
+
jsts.algorithm.ConvexHull.prototype.getConvexHull = function() {
|
128
|
+
|
129
|
+
if (this.inputPts.length == 0) {
|
130
|
+
return this.geomFactory.createGeometryCollection(null);
|
131
|
+
}
|
132
|
+
if (this.inputPts.length == 1) {
|
133
|
+
return this.geomFactory.createPoint(this.inputPts[0]);
|
134
|
+
}
|
135
|
+
if (this.inputPts.length == 2) {
|
136
|
+
return this.geomFactory.createLineString(this.inputPts);
|
137
|
+
}
|
138
|
+
|
139
|
+
var reducedPts = this.inputPts;
|
140
|
+
// use heuristic to reduce points, if large
|
141
|
+
if (this.inputPts.length > 50) {
|
142
|
+
reducedPts = this.reduce(this.inputPts);
|
143
|
+
}
|
144
|
+
// sort points for Graham scan.
|
145
|
+
var sortedPts = this.preSort(reducedPts);
|
146
|
+
|
147
|
+
// Use Graham scan to find convex hull.
|
148
|
+
var cHS = this.grahamScan(sortedPts);
|
149
|
+
|
150
|
+
// Convert stack to an array.
|
151
|
+
var cH = cHS.toArray();
|
152
|
+
|
153
|
+
// Convert array to appropriate output geometry.
|
154
|
+
return this.lineOrPolygon(cH);
|
155
|
+
};
|
156
|
+
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Uses a heuristic to reduce the number of points scanned to compute the
|
160
|
+
* hull. The heuristic is to find a polygon guaranteed to be in (or on) the
|
161
|
+
* hull, and eliminate all points inside it. A quadrilateral defined by the
|
162
|
+
* extremal points in the four orthogonal directions can be used, but even
|
163
|
+
* more inclusive is to use an octilateral defined by the points in the 8
|
164
|
+
* cardinal directions.
|
165
|
+
* <p>
|
166
|
+
* Note that even if the method used to determine the polygon vertices is not
|
167
|
+
* 100% robust, this does not affect the robustness of the convex hull.
|
168
|
+
* <p>
|
169
|
+
* To satisfy the requirements of the Graham Scan algorithm, the returned
|
170
|
+
* array has at least 3 entries.
|
171
|
+
*
|
172
|
+
* @param pts
|
173
|
+
* the points to reduce.
|
174
|
+
* @return the reduced list of points (at least 3).
|
175
|
+
* @private
|
176
|
+
*/
|
177
|
+
jsts.algorithm.ConvexHull.prototype.reduce = function(inputPts) {
|
178
|
+
var polyPts = this.computeOctRing(inputPts);
|
179
|
+
|
180
|
+
// unable to compute interior polygon for some reason
|
181
|
+
if (polyPts == null)
|
182
|
+
return this.inputPts;
|
183
|
+
|
184
|
+
// add points defining polygon
|
185
|
+
var reducedSet = new javascript.util.TreeSet();
|
186
|
+
for (var i = 0; i < polyPts.length; i++) {
|
187
|
+
reducedSet.add(polyPts[i]);
|
188
|
+
}
|
189
|
+
/**
|
190
|
+
* Add all unique points not in the interior poly.
|
191
|
+
* CGAlgorithms.isPointInRing is not defined for points actually on the
|
192
|
+
* ring, but this doesn't matter since the points of the interior polygon
|
193
|
+
* are forced to be in the reduced set.
|
194
|
+
*/
|
195
|
+
for (var i = 0; i < inputPts.length; i++) {
|
196
|
+
if (!CGAlgorithms.isPointInRing(inputPts[i], polyPts)) {
|
197
|
+
reducedSet.add(inputPts[i]);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
var reducedPts = reducedSet.toArray();
|
201
|
+
|
202
|
+
// ensure that computed array has at least 3 points (not necessarily unique)
|
203
|
+
if (reducedPts.length < 3)
|
204
|
+
return this.padArray3(reducedPts);
|
205
|
+
return reducedPts;
|
206
|
+
};
|
207
|
+
|
208
|
+
/**
|
209
|
+
* @private
|
210
|
+
*/
|
211
|
+
jsts.algorithm.ConvexHull.prototype.padArray3 = function(pts) {
|
212
|
+
var pad = [];
|
213
|
+
for (var i = 0; i < pad.length; i++) {
|
214
|
+
if (i < pts.length) {
|
215
|
+
pad[i] = pts[i];
|
216
|
+
} else
|
217
|
+
pad[i] = pts[0];
|
218
|
+
}
|
219
|
+
return pad;
|
220
|
+
};
|
221
|
+
|
222
|
+
/**
|
223
|
+
* @private
|
224
|
+
*/
|
225
|
+
jsts.algorithm.ConvexHull.prototype.preSort = function(pts) {
|
226
|
+
var t;
|
227
|
+
|
228
|
+
// find the lowest point in the set. If two or more points have
|
229
|
+
// the same minimum y coordinate choose the one with the minimu x.
|
230
|
+
// This focal point is put in array location pts[0].
|
231
|
+
for (var i = 1; i < pts.length; i++) {
|
232
|
+
if ((pts[i].y < pts[0].y) ||
|
233
|
+
((pts[i].y == pts[0].y) && (pts[i].x < pts[0].x))) {
|
234
|
+
t = pts[0];
|
235
|
+
pts[0] = pts[i];
|
236
|
+
pts[i] = t;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
// sort the points radially around the focal point.
|
241
|
+
Arrays.sort(pts, 1, pts.length, new RadialComparator(pts[0]));
|
242
|
+
|
243
|
+
return pts;
|
244
|
+
};
|
245
|
+
|
246
|
+
/**
|
247
|
+
* Uses the Graham Scan algorithm to compute the convex hull vertices.
|
248
|
+
*
|
249
|
+
* @param c
|
250
|
+
* a list of points, with at least 3 entries.
|
251
|
+
* @return a Stack containing the ordered points of the convex hull ring.
|
252
|
+
*/
|
253
|
+
/**
|
254
|
+
* @private
|
255
|
+
*/
|
256
|
+
jsts.algorithm.ConvexHull.prototype.grahamScan = function(c) {
|
257
|
+
var p;
|
258
|
+
var ps = new Stack();
|
259
|
+
p = ps.push(c[0]);
|
260
|
+
p = ps.push(c[1]);
|
261
|
+
p = ps.push(c[2]);
|
262
|
+
for (var i = 3; i < c.length; i++) {
|
263
|
+
p = ps.pop();
|
264
|
+
// check for empty stack to guard against robustness problems
|
265
|
+
while (!ps.empty() &&
|
266
|
+
CGAlgorithms.computeOrientation(ps.peek(), p, c[i]) > 0) {
|
267
|
+
p = ps.pop();
|
268
|
+
}
|
269
|
+
p = ps.push(p);
|
270
|
+
p = ps.push(c[i]);
|
271
|
+
}
|
272
|
+
p = ps.push(c[0]);
|
273
|
+
return ps;
|
274
|
+
};
|
275
|
+
|
276
|
+
/**
|
277
|
+
* @return whether the three coordinates are collinear and c2 lies between c1
|
278
|
+
* and c3 inclusive.
|
279
|
+
*
|
280
|
+
* @private
|
281
|
+
*/
|
282
|
+
jsts.algorithm.ConvexHull.prototype.isBetween = function(c1, c2, c3) {
|
283
|
+
if (CGAlgorithms.computeOrientation(c1, c2, c3) !== 0) {
|
284
|
+
return false;
|
285
|
+
}
|
286
|
+
if (c1.x != c3.x) {
|
287
|
+
if (c1.x <= c2.x && c2.x <= c3.x) {
|
288
|
+
return true;
|
289
|
+
}
|
290
|
+
if (c3.x <= c2.x && c2.x <= c1.x) {
|
291
|
+
return true;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
if (c1.y != c3.y) {
|
295
|
+
if (c1.y <= c2.y && c2.y <= c3.y) {
|
296
|
+
return true;
|
297
|
+
}
|
298
|
+
if (c3.y <= c2.y && c2.y <= c1.y) {
|
299
|
+
return true;
|
300
|
+
}
|
301
|
+
}
|
302
|
+
return false;
|
303
|
+
};
|
304
|
+
|
305
|
+
/**
|
306
|
+
* @private
|
307
|
+
*/
|
308
|
+
jsts.algorithm.ConvexHull.prototype.computeOctRing = function(inputPts) {
|
309
|
+
var octPts = this.computeOctPts(inputPts);
|
310
|
+
var coordList = new jsts.geom.CoordinateList();
|
311
|
+
coordList.add(octPts, false);
|
312
|
+
|
313
|
+
// points must all lie in a line
|
314
|
+
if (coordList.size() < 3) {
|
315
|
+
return null;
|
316
|
+
}
|
317
|
+
coordList.closeRing();
|
318
|
+
return coordList.toCoordinateArray();
|
319
|
+
};
|
320
|
+
|
321
|
+
/**
|
322
|
+
* @private
|
323
|
+
*/
|
324
|
+
jsts.algorithm.ConvexHull.prototype.computeOctPts = function(inputPts) {
|
325
|
+
var pts = [];
|
326
|
+
for (var j = 0; j < 8; j++) {
|
327
|
+
pts[j] = inputPts[0];
|
328
|
+
}
|
329
|
+
for (var i = 1; i < inputPts.length; i++) {
|
330
|
+
if (inputPts[i].x < pts[0].x) {
|
331
|
+
pts[0] = inputPts[i];
|
332
|
+
}
|
333
|
+
if (inputPts[i].x - inputPts[i].y < pts[1].x - pts[1].y) {
|
334
|
+
pts[1] = inputPts[i];
|
335
|
+
}
|
336
|
+
if (inputPts[i].y > pts[2].y) {
|
337
|
+
pts[2] = inputPts[i];
|
338
|
+
}
|
339
|
+
if (inputPts[i].x + inputPts[i].y > pts[3].x + pts[3].y) {
|
340
|
+
pts[3] = inputPts[i];
|
341
|
+
}
|
342
|
+
if (inputPts[i].x > pts[4].x) {
|
343
|
+
pts[4] = inputPts[i];
|
344
|
+
}
|
345
|
+
if (inputPts[i].x - inputPts[i].y > pts[5].x - pts[5].y) {
|
346
|
+
pts[5] = inputPts[i];
|
347
|
+
}
|
348
|
+
if (inputPts[i].y < pts[6].y) {
|
349
|
+
pts[6] = inputPts[i];
|
350
|
+
}
|
351
|
+
if (inputPts[i].x + inputPts[i].y < pts[7].x + pts[7].y) {
|
352
|
+
pts[7] = inputPts[i];
|
353
|
+
}
|
354
|
+
}
|
355
|
+
return pts;
|
356
|
+
|
357
|
+
};
|
358
|
+
|
359
|
+
|
360
|
+
/**
|
361
|
+
* @param vertices
|
362
|
+
* the vertices of a linear ring, which may or may not be flattened
|
363
|
+
* (i.e. vertices collinear).
|
364
|
+
* @return a 2-vertex <code>LineString</code> if the vertices are collinear;
|
365
|
+
* otherwise, a <code>Polygon</code> with unnecessary (collinear)
|
366
|
+
* vertices removed.
|
367
|
+
* @private
|
368
|
+
*/
|
369
|
+
jsts.algorithm.ConvexHull.prototype.lineOrPolygon = function(coordinates) {
|
370
|
+
coordinates = this.cleanRing(coordinates);
|
371
|
+
if (coordinates.length == 3) {
|
372
|
+
return this.geomFactory
|
373
|
+
.createLineString([coordinates[0], coordinates[1]]);
|
374
|
+
}
|
375
|
+
var linearRing = this.geomFactory.createLinearRing(coordinates);
|
376
|
+
return this.geomFactory.createPolygon(linearRing, null);
|
377
|
+
};
|
378
|
+
|
379
|
+
/**
|
380
|
+
* @param vertices
|
381
|
+
* the vertices of a linear ring, which may or may not be flattened
|
382
|
+
* (i.e. vertices collinear).
|
383
|
+
* @return the coordinates with unnecessary (collinear) vertices removed.
|
384
|
+
* @private
|
385
|
+
*/
|
386
|
+
jsts.algorithm.ConvexHull.prototype.cleanRing = function(original) {
|
387
|
+
Assert.equals(original[0], original[original.length - 1]);
|
388
|
+
var cleanedRing = new ArrayList();
|
389
|
+
var previousDistinctCoordinate = null;
|
390
|
+
for (var i = 0; i <= original.length - 2; i++) {
|
391
|
+
var currentCoordinate = original[i];
|
392
|
+
var nextCoordinate = original[i + 1];
|
393
|
+
if (currentCoordinate.equals(nextCoordinate)) {
|
394
|
+
continue;
|
395
|
+
}
|
396
|
+
if (previousDistinctCoordinate != null &&
|
397
|
+
this.isBetween(previousDistinctCoordinate, currentCoordinate,
|
398
|
+
nextCoordinate)) {
|
399
|
+
continue;
|
400
|
+
}
|
401
|
+
cleanedRing.add(currentCoordinate);
|
402
|
+
previousDistinctCoordinate = currentCoordinate;
|
403
|
+
}
|
404
|
+
cleanedRing.add(original[original.length - 1]);
|
405
|
+
var cleanedRingCoordinates = [];
|
406
|
+
return cleanedRing.toArray(cleanedRingCoordinates);
|
407
|
+
};
|
408
|
+
|
409
|
+
})();
|
@@ -0,0 +1,234 @@
|
|
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
|
+
* Represents a homogeneous coordinate in a 2-D coordinate space. In JTS
|
11
|
+
* {@link HCoordinate}s are used as a clean way of computing intersections
|
12
|
+
* between line segments.
|
13
|
+
*
|
14
|
+
* Will call correct init* function depending on argument.
|
15
|
+
*
|
16
|
+
* @constructor
|
17
|
+
*/
|
18
|
+
jsts.algorithm.HCoordinate = function() {
|
19
|
+
this.x = 0.0;
|
20
|
+
this.y = 0.0;
|
21
|
+
this.w = 1.0;
|
22
|
+
|
23
|
+
if (arguments.length === 1) {
|
24
|
+
this.initFrom1Coordinate(arguments[0]);
|
25
|
+
} else if (arguments.length === 2 &&
|
26
|
+
arguments[0] instanceof jsts.geom.Coordinate) {
|
27
|
+
this.initFrom2Coordinates(arguments[0], arguments[1]);
|
28
|
+
} else if (arguments.length === 2 &&
|
29
|
+
arguments[0] instanceof jsts.algorithm.HCoordinate) {
|
30
|
+
this.initFrom2HCoordinates(arguments[0], arguments[1]);
|
31
|
+
} else if (arguments.length === 2) {
|
32
|
+
this.initFromXY(arguments[0], arguments[1]);
|
33
|
+
} else if (arguments.length === 3) {
|
34
|
+
this.initFromXYW(arguments[0], arguments[1], arguments[2]);
|
35
|
+
} else if (arguments.length === 4) {
|
36
|
+
this.initFromXYW(arguments[0], arguments[1], arguments[2], arguments[3]);
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Computes the (approximate) intersection point between two line segments using
|
43
|
+
* homogeneous coordinates.
|
44
|
+
* <p>
|
45
|
+
* Note that this algorithm is not numerically stable; i.e. it can produce
|
46
|
+
* intersection points which lie outside the envelope of the line segments
|
47
|
+
* themselves. In order to increase the precision of the calculation input
|
48
|
+
* points should be normalized before passing them to this routine.
|
49
|
+
*
|
50
|
+
* @param {jsts.geom.Coordinate}
|
51
|
+
* p1 first coordinate for the first line.
|
52
|
+
* @param {jsts.geom.Coordinate}
|
53
|
+
* p2 second coordinate for the first line.
|
54
|
+
* @param {jsts.geom.Coordinate}
|
55
|
+
* q1 first coordinate for the second line.
|
56
|
+
* @param {jsts.geom.Coordinate}
|
57
|
+
* q2 second coordinate for the second line.
|
58
|
+
* @return {jsts.geom.Coordinate} The coordinate of the intersection.
|
59
|
+
*/
|
60
|
+
jsts.algorithm.HCoordinate.intersection = function(p1, p2, q1, q2) {
|
61
|
+
var px, py, pw, qx, qy, qw, x, y, w, xInt, yInt;
|
62
|
+
|
63
|
+
// unrolled computation
|
64
|
+
px = p1.y - p2.y;
|
65
|
+
py = p2.x - p1.x;
|
66
|
+
pw = p1.x * p2.y - p2.x * p1.y;
|
67
|
+
|
68
|
+
qx = q1.y - q2.y;
|
69
|
+
qy = q2.x - q1.x;
|
70
|
+
qw = q1.x * q2.y - q2.x * q1.y;
|
71
|
+
|
72
|
+
x = py * qw - qy * pw;
|
73
|
+
y = qx * pw - px * qw;
|
74
|
+
w = px * qy - qx * py;
|
75
|
+
|
76
|
+
xInt = x / w;
|
77
|
+
yInt = y / w;
|
78
|
+
|
79
|
+
if (!isFinite(xInt) || !isFinite(yInt)) {
|
80
|
+
throw new jsts.error.NotRepresentableError();
|
81
|
+
}
|
82
|
+
|
83
|
+
return new jsts.geom.Coordinate(xInt, yInt);
|
84
|
+
};
|
85
|
+
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Initializes a new HCoordinate from 1 Coordinate
|
89
|
+
*
|
90
|
+
* @param {jsts.geom.Coordinate}
|
91
|
+
* p the coordinate.
|
92
|
+
*/
|
93
|
+
jsts.algorithm.HCoordinate.prototype.initFrom1Coordinate = function(p) {
|
94
|
+
this.x = p.x;
|
95
|
+
this.y = p.y;
|
96
|
+
this.w = 1.0;
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Constructs a homogeneous coordinate which is the intersection of the lines
|
102
|
+
* define by the homogenous coordinates represented by two {@link Coordinate}s.
|
103
|
+
*
|
104
|
+
* @param {jsts.geom.Coordinate}
|
105
|
+
* p1 the first coordinate.
|
106
|
+
* @param {jsts.geom.Coordinate}
|
107
|
+
* p2 the second coordinate.
|
108
|
+
*/
|
109
|
+
jsts.algorithm.HCoordinate.prototype.initFrom2Coordinates = function(p1, p2) {
|
110
|
+
// optimization when it is known that w = 1
|
111
|
+
this.x = p1.y - p2.y;
|
112
|
+
this.y = p2.x - p1.x;
|
113
|
+
this.w = p1.x * p2.y - p2.x * p1.y;
|
114
|
+
};
|
115
|
+
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Initializes from 2 HCoordinates
|
119
|
+
*
|
120
|
+
* @param {jsts.algorithm.HCoordinate}
|
121
|
+
* p1 the first HCoordinate.
|
122
|
+
* @param {jsts.algorithm.HCoordinate}
|
123
|
+
* p2 the second HCoordinate.
|
124
|
+
*/
|
125
|
+
jsts.algorithm.HCoordinate.prototype.initFrom2HCoordinates = function(p1, p2) {
|
126
|
+
this.x = p1.y * p2.w - p2.y * p1.w;
|
127
|
+
this.y = p2.x * p1.w - p1.x * p2.w;
|
128
|
+
this.w = p1.x * p2.y - p2.x * p1.y;
|
129
|
+
};
|
130
|
+
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Initializes from x,y,w
|
134
|
+
*
|
135
|
+
* @param {Number}
|
136
|
+
* x the x-value.
|
137
|
+
* @param {Number}
|
138
|
+
* y the y-value.
|
139
|
+
* @param {Number}
|
140
|
+
* w the w-value.
|
141
|
+
*/
|
142
|
+
jsts.algorithm.HCoordinate.prototype.initFromXYW = function(x, y, w) {
|
143
|
+
this.x = x;
|
144
|
+
this.y = y;
|
145
|
+
this.w = w;
|
146
|
+
};
|
147
|
+
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Initializes from x,y
|
151
|
+
*
|
152
|
+
* @param {Number}
|
153
|
+
* x the x-value.
|
154
|
+
* @param {Number}
|
155
|
+
* y the y-value.
|
156
|
+
*/
|
157
|
+
jsts.algorithm.HCoordinate.prototype.initFromXY = function(x, y) {
|
158
|
+
this.x = x;
|
159
|
+
this.y = y;
|
160
|
+
this.w = 1.0;
|
161
|
+
};
|
162
|
+
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Initializes from 4 Coordinates
|
166
|
+
*
|
167
|
+
* @param {jsts.geom.Coordinate}
|
168
|
+
* p1 the first coordinate.
|
169
|
+
* @param {jsts.geom.Coordinate}
|
170
|
+
* p2 the second coordinate.
|
171
|
+
* @param {jsts.geom.Coordinate}
|
172
|
+
* q1 the first coordinate.
|
173
|
+
* @param {jsts.geom.Coordinate}
|
174
|
+
* q2 the second coordinate.
|
175
|
+
*/
|
176
|
+
jsts.algorithm.HCoordinate.prototype.initFrom4Coordinates = function(p1, p2,
|
177
|
+
q1, q2) {
|
178
|
+
var px, py, pw, qx, qy, qw;
|
179
|
+
// unrolled computation
|
180
|
+
px = p1.y - p2.y;
|
181
|
+
py = p2.x - p1.x;
|
182
|
+
pw = p1.x * p2.y - p2.x * p1.y;
|
183
|
+
|
184
|
+
qx = q1.y - q2.y;
|
185
|
+
qy = q2.x - q1.x;
|
186
|
+
qw = q1.x * q2.y - q2.x * q1.y;
|
187
|
+
|
188
|
+
this.x = py * qw - qy * pw;
|
189
|
+
this.y = qx * pw - px * qw;
|
190
|
+
this.w = px * qy - qx * py;
|
191
|
+
};
|
192
|
+
|
193
|
+
|
194
|
+
/**
|
195
|
+
* Gets x/w
|
196
|
+
*
|
197
|
+
* @return {Number} x/w.
|
198
|
+
*/
|
199
|
+
jsts.algorithm.HCoordinate.prototype.getX = function() {
|
200
|
+
var a = this.x / this.w;
|
201
|
+
|
202
|
+
if (!isFinite(a)) {
|
203
|
+
throw new jsts.error.NotRepresentableError();
|
204
|
+
}
|
205
|
+
return a;
|
206
|
+
};
|
207
|
+
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Gets y/w
|
211
|
+
*
|
212
|
+
* @return {Number} y/w.
|
213
|
+
*/
|
214
|
+
jsts.algorithm.HCoordinate.prototype.getY = function() {
|
215
|
+
var a = this.y / this.w;
|
216
|
+
|
217
|
+
if (!isFinite(a)) {
|
218
|
+
throw new jsts.error.NotRepresentableError();
|
219
|
+
}
|
220
|
+
return a;
|
221
|
+
};
|
222
|
+
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Gets a coordinate represented by this HCoordinate
|
226
|
+
*
|
227
|
+
* @return {jst.geom.Coordinate} The coordinate.
|
228
|
+
*/
|
229
|
+
jsts.algorithm.HCoordinate.prototype.getCoordinate = function() {
|
230
|
+
var p = new jsts.geom.Coordinate();
|
231
|
+
p.x = this.getX();
|
232
|
+
p.y = this.getY();
|
233
|
+
return p;
|
234
|
+
};
|