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,228 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Port source:
|
9
|
+
* /jts/jts/java/src/com/vividsolutions/jts/algorithm/distance/DiscreteHausdorffDistance.java
|
10
|
+
* Revision: 6
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/geom/CoordinateFilter.js
|
15
|
+
* @requires jsts/geom/CoordinateSequenceFilter.js
|
16
|
+
* @requires jsts/algorithm/distance/PointPairDistance.js
|
17
|
+
* @requires jsts/algorithm/distance/DistanceToPoint.js
|
18
|
+
*/
|
19
|
+
|
20
|
+
(function() {
|
21
|
+
|
22
|
+
var PointPairDistance = jsts.algorithm.distance.PointPairDistance;
|
23
|
+
var DistanceToPoint = jsts.algorithm.distance.DistanceToPoint;
|
24
|
+
|
25
|
+
var MaxPointDistanceFilter = function(geom) {
|
26
|
+
this.maxPtDist = new PointPairDistance();
|
27
|
+
this.minPtDist = new PointPairDistance();
|
28
|
+
this.euclideanDist = new DistanceToPoint();
|
29
|
+
|
30
|
+
this.geom = geom;
|
31
|
+
};
|
32
|
+
|
33
|
+
MaxPointDistanceFilter.prototype = new jsts.geom.CoordinateFilter();
|
34
|
+
|
35
|
+
MaxPointDistanceFilter.prototype.maxPtDist = new PointPairDistance();
|
36
|
+
MaxPointDistanceFilter.prototype.minPtDist = new PointPairDistance();
|
37
|
+
MaxPointDistanceFilter.prototype.euclideanDist = new DistanceToPoint();
|
38
|
+
MaxPointDistanceFilter.prototype.geom;
|
39
|
+
|
40
|
+
MaxPointDistanceFilter.prototype.filter = function(pt) {
|
41
|
+
this.minPtDist.initialize();
|
42
|
+
DistanceToPoint.computeDistance(this.geom, pt, this.minPtDist);
|
43
|
+
this.maxPtDist.setMaximum(this.minPtDist);
|
44
|
+
};
|
45
|
+
|
46
|
+
MaxPointDistanceFilter.prototype.getMaxPointDistance = function() {
|
47
|
+
return this.maxPtDist;
|
48
|
+
};
|
49
|
+
|
50
|
+
|
51
|
+
var MaxDensifiedByFractionDistanceFilter = function(geom, fraction) {
|
52
|
+
this.maxPtDist = new PointPairDistance();
|
53
|
+
this.minPtDist = new PointPairDistance();
|
54
|
+
|
55
|
+
this.geom = geom;
|
56
|
+
// NOTE: Math.rint in JTS changed to Math.round
|
57
|
+
this.numSubSegs = Math.round(1.0 / fraction);
|
58
|
+
};
|
59
|
+
|
60
|
+
MaxDensifiedByFractionDistanceFilter.prototype = new jsts.geom.CoordinateSequenceFilter();
|
61
|
+
|
62
|
+
MaxDensifiedByFractionDistanceFilter.prototype.maxPtDist = new PointPairDistance();
|
63
|
+
MaxDensifiedByFractionDistanceFilter.prototype.minPtDist = new PointPairDistance();
|
64
|
+
MaxDensifiedByFractionDistanceFilter.prototype.geom;
|
65
|
+
MaxDensifiedByFractionDistanceFilter.prototype.numSubSegs = 0;
|
66
|
+
|
67
|
+
MaxDensifiedByFractionDistanceFilter.prototype.filter = function(seq, index) {
|
68
|
+
/**
|
69
|
+
* This logic also handles skipping Point geometries
|
70
|
+
*/
|
71
|
+
if (index == 0)
|
72
|
+
return;
|
73
|
+
|
74
|
+
var p0 = seq[index - 1];
|
75
|
+
var p1 = seq[index];
|
76
|
+
|
77
|
+
var delx = (p1.x - p0.x) / this.numSubSegs;
|
78
|
+
var dely = (p1.y - p0.y) / this.numSubSegs;
|
79
|
+
|
80
|
+
for (var i = 0; i < this.numSubSegs; i++) {
|
81
|
+
var x = p0.x + i * delx;
|
82
|
+
var y = p0.y + i * dely;
|
83
|
+
var pt = new jsts.geom.Coordinate(x, y);
|
84
|
+
this.minPtDist.initialize();
|
85
|
+
DistanceToPoint.computeDistance(this.geom, pt, this.minPtDist);
|
86
|
+
this.maxPtDist.setMaximum(this.minPtDist);
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
MaxDensifiedByFractionDistanceFilter.prototype.isGeometryChanged = function() {
|
91
|
+
return false;
|
92
|
+
};
|
93
|
+
|
94
|
+
MaxDensifiedByFractionDistanceFilter.prototype.isDone = function() {
|
95
|
+
return false;
|
96
|
+
};
|
97
|
+
|
98
|
+
MaxDensifiedByFractionDistanceFilter.prototype.getMaxPointDistance = function() {
|
99
|
+
return this.maxPtDist;
|
100
|
+
};
|
101
|
+
|
102
|
+
/**
|
103
|
+
* An algorithm for computing a distance metric which is an approximation to
|
104
|
+
* the Hausdorff Distance based on a discretization of the input
|
105
|
+
* {@link Geometry}. The algorithm computes the Hausdorff distance restricted
|
106
|
+
* to discrete points for one of the geometries. The points can be either the
|
107
|
+
* vertices of the geometries (the default), or the geometries with line
|
108
|
+
* segments densified by a given fraction. Also determines two points of the
|
109
|
+
* Geometries which are separated by the computed distance.
|
110
|
+
* <p>
|
111
|
+
* This algorithm is an approximation to the standard Hausdorff distance.
|
112
|
+
* Specifically,
|
113
|
+
*
|
114
|
+
* <pre>
|
115
|
+
* for all geometries a, b: DHD(a, b) <= HD(a, b)
|
116
|
+
* </pre>
|
117
|
+
*
|
118
|
+
* The approximation can be made as close as needed by densifying the input
|
119
|
+
* geometries. In the limit, this value will approach the true Hausdorff
|
120
|
+
* distance:
|
121
|
+
*
|
122
|
+
* <pre>
|
123
|
+
* DHD(A, B, densifyFactor) -> HD(A, B) as densifyFactor -> 0.0
|
124
|
+
* </pre>
|
125
|
+
*
|
126
|
+
* The default approximation is exact or close enough for a large subset of
|
127
|
+
* useful cases. Examples of these are:
|
128
|
+
* <ul>
|
129
|
+
* <li>computing distance between Linestrings that are roughly parallel to
|
130
|
+
* each other, and roughly equal in length. This occurs in matching linear
|
131
|
+
* networks.
|
132
|
+
* <li>Testing similarity of geometries.
|
133
|
+
* </ul>
|
134
|
+
* An example where the default approximation is not close is:
|
135
|
+
*
|
136
|
+
* <pre>
|
137
|
+
* A = LINESTRING (0 0, 100 0, 10 100, 10 100)
|
138
|
+
* B = LINESTRING (0 100, 0 10, 80 10)
|
139
|
+
*
|
140
|
+
* DHD(A, B) = 22.360679774997898
|
141
|
+
* HD(A, B) ˜= 47.8
|
142
|
+
* </pre>
|
143
|
+
*/
|
144
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance = function(g0, g1) {
|
145
|
+
this.g0 = g0;
|
146
|
+
this.g1 = g1;
|
147
|
+
|
148
|
+
this.ptDist = new jsts.algorithm.distance.PointPairDistance();
|
149
|
+
};
|
150
|
+
|
151
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.g0 = null;
|
152
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.g1 = null;
|
153
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.ptDist = null;
|
154
|
+
/**
|
155
|
+
* Value of 0.0 indicates that no densification should take place
|
156
|
+
*/
|
157
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.densifyFrac = 0.0;
|
158
|
+
|
159
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.distance = function(g0, g1,
|
160
|
+
densifyFrac) {
|
161
|
+
var dist = new jsts.algorithm.distance.DiscreteHausdorffDistance(g0, g1);
|
162
|
+
if (densifyFrac !== undefined)
|
163
|
+
dist.setDensifyFraction(densifyFrac);
|
164
|
+
return dist.distance();
|
165
|
+
};
|
166
|
+
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Sets the fraction by which to densify each segment. Each segment will be
|
170
|
+
* (virtually) split into a number of equal-length subsegments, whose fraction
|
171
|
+
* of the total length is closest to the given fraction.
|
172
|
+
*
|
173
|
+
* @param densifyPercent
|
174
|
+
*/
|
175
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.setDensifyFraction = function(
|
176
|
+
densifyFrac) {
|
177
|
+
if (densifyFrac > 1.0 || densifyFrac <= 0.0)
|
178
|
+
throw new jsts.error.IllegalArgumentError(
|
179
|
+
'Fraction is not in range (0.0 - 1.0]');
|
180
|
+
|
181
|
+
this.densifyFrac = densifyFrac;
|
182
|
+
};
|
183
|
+
|
184
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.distance = function() {
|
185
|
+
this.compute(this.g0, this.g1);
|
186
|
+
return ptDist.getDistance();
|
187
|
+
};
|
188
|
+
|
189
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.orientedDistance = function() {
|
190
|
+
this.computeOrientedDistance(this.g0, this.g1, this.ptDist);
|
191
|
+
return this.ptDist.getDistance();
|
192
|
+
};
|
193
|
+
|
194
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.getCoordinates = function() {
|
195
|
+
return ptDist.getCoordinates();
|
196
|
+
};
|
197
|
+
|
198
|
+
/**
|
199
|
+
*
|
200
|
+
* @private
|
201
|
+
*/
|
202
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.compute = function(
|
203
|
+
g0, g1) {
|
204
|
+
this.computeOrientedDistance(g0, g1, this.ptDist);
|
205
|
+
this.computeOrientedDistance(g1, g0, this.ptDist);
|
206
|
+
};
|
207
|
+
|
208
|
+
/**
|
209
|
+
*
|
210
|
+
* @private
|
211
|
+
*/
|
212
|
+
jsts.algorithm.distance.DiscreteHausdorffDistance.prototype.computeOrientedDistance = function(
|
213
|
+
discreteGeom, geom, ptDist) {
|
214
|
+
var distFilter = new MaxPointDistanceFilter(geom);
|
215
|
+
discreteGeom.apply(distFilter);
|
216
|
+
ptDist.setMaximum(distFilter.getMaxPointDistance());
|
217
|
+
|
218
|
+
if (this.densifyFrac > 0) {
|
219
|
+
var fracFilter = new MaxDensifiedByFractionDistanceFilter(geom,
|
220
|
+
this.densifyFrac);
|
221
|
+
discreteGeom.apply(fracFilter);
|
222
|
+
ptDist.setMaximum(fracFilter.getMaxPointDistance());
|
223
|
+
|
224
|
+
}
|
225
|
+
};
|
226
|
+
|
227
|
+
|
228
|
+
})();
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Port source: /jts/jts/java/src/com/vividsolutions/jts/algorithm/distance/DistanceToPoint.java
|
9
|
+
* Revision: 6
|
10
|
+
*/
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @requires jsts/geom/Polygon.js
|
14
|
+
*/
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Computes the Euclidean distance (L2 metric) from a Point to a Geometry. Also
|
18
|
+
* computes two points which are separated by the distance.
|
19
|
+
*/
|
20
|
+
jsts.algorithm.distance.DistanceToPoint = function() {
|
21
|
+
|
22
|
+
};
|
23
|
+
|
24
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance = function(geom, pt,
|
25
|
+
ptDist) {
|
26
|
+
if (geom instanceof jsts.geom.LineString) {
|
27
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance2(geom, pt, ptDist);
|
28
|
+
} else if (geom instanceof jsts.geom.Polygon) {
|
29
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance4(geom, pt, ptDist);
|
30
|
+
} else if (geom instanceof jsts.geom.GeometryCollection) {
|
31
|
+
var gc = geom;
|
32
|
+
for (var i = 0; i < gc.getNumGeometries(); i++) {
|
33
|
+
var g = gc.getGeometryN(i);
|
34
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance(g, pt, ptDist);
|
35
|
+
}
|
36
|
+
} else { // assume geom is Point
|
37
|
+
ptDist.setMinimum(geom.getCoordinate(), pt);
|
38
|
+
}
|
39
|
+
};
|
40
|
+
|
41
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance2 = function(line, pt,
|
42
|
+
ptDist) {
|
43
|
+
var tempSegment = new jsts.geom.LineSegment();
|
44
|
+
|
45
|
+
var coords = line.getCoordinates();
|
46
|
+
for (var i = 0; i < coords.length - 1; i++) {
|
47
|
+
tempSegment.setCoordinates(coords[i], coords[i + 1]);
|
48
|
+
// this is somewhat inefficient - could do better
|
49
|
+
var closestPt = tempSegment.closestPoint(pt);
|
50
|
+
ptDist.setMinimum(closestPt, pt);
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance3 = function(segment,
|
55
|
+
pt, ptDist) {
|
56
|
+
var closestPt = segment.closestPoint(pt);
|
57
|
+
ptDist.setMinimum(closestPt, pt);
|
58
|
+
};
|
59
|
+
|
60
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance4 = function(poly, pt,
|
61
|
+
ptDist) {
|
62
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance2(poly
|
63
|
+
.getExteriorRing(), pt, ptDist);
|
64
|
+
for (var i = 0; i < poly.getNumInteriorRing(); i++) {
|
65
|
+
jsts.algorithm.distance.DistanceToPoint.computeDistance2(poly
|
66
|
+
.getInteriorRingN(i), pt, ptDist);
|
67
|
+
}
|
68
|
+
};
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Port source: /jts/jts/java/src/com/vividsolutions/jts/algorithm/distance/PointPairDistance.java
|
9
|
+
* Revision: 6
|
10
|
+
*/
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @requires jsts/geom/Coordinate.js
|
14
|
+
*/
|
15
|
+
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Contains a pair of points and the distance between them. Provides methods to
|
19
|
+
* update with a new point pair with either maximum or minimum distance.
|
20
|
+
*/
|
21
|
+
jsts.algorithm.distance.PointPairDistance = function() {
|
22
|
+
this.pt = [new jsts.geom.Coordinate(), new jsts.geom.Coordinate()];
|
23
|
+
};
|
24
|
+
|
25
|
+
jsts.algorithm.distance.PointPairDistance.prototype.pt = null;
|
26
|
+
jsts.algorithm.distance.PointPairDistance.prototype.distance = NaN;
|
27
|
+
jsts.algorithm.distance.PointPairDistance.prototype.isNull = true;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Initializes the points, avoiding recomputing the distance.
|
31
|
+
*
|
32
|
+
* @param p0
|
33
|
+
* @param p1
|
34
|
+
* @param distance
|
35
|
+
* the distance between p0 and p1.
|
36
|
+
*/
|
37
|
+
jsts.algorithm.distance.PointPairDistance.prototype.initialize = function(p0,
|
38
|
+
p1, distance) {
|
39
|
+
if (p0 === undefined) {
|
40
|
+
this.isNull = true;
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
|
44
|
+
this.pt[0].setCoordinate(p0);
|
45
|
+
this.pt[1].setCoordinate(p1);
|
46
|
+
this.distance = distance !== undefined ? distance : p0.distance(p1);
|
47
|
+
this.isNull = false;
|
48
|
+
};
|
49
|
+
|
50
|
+
jsts.algorithm.distance.PointPairDistance.prototype.getDistance = function() {
|
51
|
+
return this.distance;
|
52
|
+
};
|
53
|
+
|
54
|
+
jsts.algorithm.distance.PointPairDistance.prototype.getCoordinates = function() {
|
55
|
+
return this.pt;
|
56
|
+
};
|
57
|
+
|
58
|
+
jsts.algorithm.distance.PointPairDistance.prototype.getCoordinate = function(i) {
|
59
|
+
return this.pt[i];
|
60
|
+
};
|
61
|
+
|
62
|
+
jsts.algorithm.distance.PointPairDistance.prototype.setMaximum = function(
|
63
|
+
ptDist) {
|
64
|
+
if (arguments.length === 2) {
|
65
|
+
this.setMaximum2.apply(this, arguments);
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
|
69
|
+
this.setMaximum(ptDist.pt[0], ptDist.pt[1]);
|
70
|
+
};
|
71
|
+
|
72
|
+
jsts.algorithm.distance.PointPairDistance.prototype.setMaximum2 = function(p0,
|
73
|
+
p1) {
|
74
|
+
if (this.isNull) {
|
75
|
+
this.initialize(p0, p1);
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
var dist = p0.distance(p1);
|
79
|
+
if (dist > this.distance)
|
80
|
+
this.initialize(p0, p1, dist);
|
81
|
+
};
|
82
|
+
|
83
|
+
jsts.algorithm.distance.PointPairDistance.prototype.setMinimum = function(
|
84
|
+
ptDist) {
|
85
|
+
if (arguments.length === 2) {
|
86
|
+
this.setMinimum2.apply(this, arguments);
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
|
90
|
+
this.setMinimum(ptDist.pt[0], ptDist.pt[1]);
|
91
|
+
};
|
92
|
+
|
93
|
+
jsts.algorithm.distance.PointPairDistance.prototype.setMinimum2 = function(p0,
|
94
|
+
p1) {
|
95
|
+
if (this.isNull) {
|
96
|
+
this.initialize(p0, p1);
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
var dist = p0.distance(p1);
|
100
|
+
if (dist < this.distance)
|
101
|
+
this.initialize(p0, p1, dist);
|
102
|
+
};
|
103
|
+
|
104
|
+
// NOTE: toString not ported
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Computes the location of points relative to a {@link Polygonal}
|
11
|
+
* {@link Geometry}, using a simple O(n) algorithm. This algorithm is suitable
|
12
|
+
* for use in cases where only one or a few points will be tested against a
|
13
|
+
* given area.
|
14
|
+
* <p>
|
15
|
+
* The algorithm used is only guaranteed to return correct results for points
|
16
|
+
* which are <b>not</b> on the boundary of the Geometry.
|
17
|
+
*
|
18
|
+
* @constructor
|
19
|
+
* @augments {PointOnGeometryLocator}
|
20
|
+
*/
|
21
|
+
jsts.algorithm.locate.SimplePointInAreaLocator = function(geom) {
|
22
|
+
this.geom = geom;
|
23
|
+
};
|
24
|
+
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Determines the {@link Location} of a point in an areal {@link Geometry}.
|
28
|
+
* Currently this will never return a value of BOUNDARY.
|
29
|
+
*
|
30
|
+
* @param p
|
31
|
+
* the point to test.
|
32
|
+
* @param geom
|
33
|
+
* the areal geometry to test.
|
34
|
+
* @return the Location of the point in the geometry.
|
35
|
+
*/
|
36
|
+
jsts.algorithm.locate.SimplePointInAreaLocator.locate = function(p, geom) {
|
37
|
+
if (geom.isEmpty())
|
38
|
+
return jsts.geom.Location.EXTERIOR;
|
39
|
+
|
40
|
+
if (jsts.algorithm.locate.SimplePointInAreaLocator.containsPoint(p, geom))
|
41
|
+
return jsts.geom.Location.INTERIOR;
|
42
|
+
return jsts.geom.Location.EXTERIOR;
|
43
|
+
};
|
44
|
+
|
45
|
+
jsts.algorithm.locate.SimplePointInAreaLocator.containsPoint = function(p, geom) {
|
46
|
+
if (geom instanceof jsts.geom.Polygon) {
|
47
|
+
return jsts.algorithm.locate.SimplePointInAreaLocator
|
48
|
+
.containsPointInPolygon(p, geom);
|
49
|
+
} else if (geom instanceof jsts.geom.GeometryCollection ||
|
50
|
+
geom instanceof jsts.geom.MultiPoint ||
|
51
|
+
geom instanceof jsts.geom.MultiLineString ||
|
52
|
+
geom instanceof jsts.geom.MultiPolygon) {
|
53
|
+
for (var i = 0; i < geom.geometries.length; i++) {
|
54
|
+
var g2 = geom.geometries[i];
|
55
|
+
if (g2 !== geom)
|
56
|
+
if (jsts.algorithm.locate.SimplePointInAreaLocator.containsPoint(p, g2))
|
57
|
+
return true;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
return false;
|
61
|
+
};
|
62
|
+
|
63
|
+
jsts.algorithm.locate.SimplePointInAreaLocator.containsPointInPolygon = function(
|
64
|
+
p, poly) {
|
65
|
+
if (poly.isEmpty())
|
66
|
+
return false;
|
67
|
+
var shell = poly.getExteriorRing();
|
68
|
+
if (!jsts.algorithm.locate.SimplePointInAreaLocator.isPointInRing(p, shell))
|
69
|
+
return false;
|
70
|
+
// now test if the point lies in or on the holes
|
71
|
+
for (var i = 0; i < poly.getNumInteriorRing(); i++) {
|
72
|
+
var hole = poly.getInteriorRingN(i);
|
73
|
+
if (jsts.algorithm.locate.SimplePointInAreaLocator.isPointInRing(p, hole))
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
return true;
|
77
|
+
};
|
78
|
+
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Determines whether a point lies in a LinearRing, using the ring envelope to
|
82
|
+
* short-circuit if possible.
|
83
|
+
*
|
84
|
+
* @param p
|
85
|
+
* the point to test.
|
86
|
+
* @param ring
|
87
|
+
* a linear ring.
|
88
|
+
* @return true if the point lies inside the ring.
|
89
|
+
*/
|
90
|
+
jsts.algorithm.locate.SimplePointInAreaLocator.isPointInRing = function(p, ring) {
|
91
|
+
// short-circuit if point is not in ring envelope
|
92
|
+
if (!ring.getEnvelopeInternal().intersects(p))
|
93
|
+
return false;
|
94
|
+
return jsts.algorithm.CGAlgorithms.isPointInRing(p, ring.getCoordinates());
|
95
|
+
};
|
96
|
+
|
97
|
+
jsts.algorithm.locate.SimplePointInAreaLocator.prototype.geom = null;
|
98
|
+
|
99
|
+
|
100
|
+
jsts.algorithm.locate.SimplePointInAreaLocator.prototype.locate = function(p) {
|
101
|
+
return jsts.algorithm.locate.SimplePointInAreaLocator.locate(p, geom);
|
102
|
+
};
|