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,96 @@
|
|
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/noding/snapround/MCIndexPointSnapper.java
|
10
|
+
* Revision: 486
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @requires jsts/index/chain/MonotoneChainSelectAction.js
|
15
|
+
*/
|
16
|
+
|
17
|
+
(function() {
|
18
|
+
|
19
|
+
var HotPixelSnapAction = function(hotPixel, parentEdge, vertexIndex) {
|
20
|
+
this.hotPixel = hotPixel;
|
21
|
+
this.parentEdge = parentEdge;
|
22
|
+
this.vertexIndex = vertexIndex;
|
23
|
+
};
|
24
|
+
|
25
|
+
HotPixelSnapAction.prototype = new jsts.index.chain.MonotoneChainSelectAction();
|
26
|
+
HotPixelSnapAction.constructor = HotPixelSnapAction;
|
27
|
+
|
28
|
+
HotPixelSnapAction.prototype.hotPixel = null;
|
29
|
+
HotPixelSnapAction.prototype.parentEdge = null;
|
30
|
+
HotPixelSnapAction.prototype.vertexIndex = null;
|
31
|
+
HotPixelSnapAction.prototype._isNodeAdded = false;
|
32
|
+
|
33
|
+
HotPixelSnapAction.prototype.isNodeAdded = function() {
|
34
|
+
return this._isNodeAdded;
|
35
|
+
};
|
36
|
+
|
37
|
+
HotPixelSnapAction.prototype.select = function(mc, startIndex) {
|
38
|
+
var ss = mc.getContext();
|
39
|
+
// don't snap a vertex to itself
|
40
|
+
if (this.parentEdge !== null) {
|
41
|
+
if (ss === this.parentEdge && startIndex === this.vertexIndex)
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
// isNodeAdded = SimpleSnapRounder.addSnappedNode(hotPixel, ss, startIndex);
|
45
|
+
this._isNodeAdded = this.hotPixel.addSnappedNode(ss, startIndex);
|
46
|
+
};
|
47
|
+
|
48
|
+
|
49
|
+
/**
|
50
|
+
* "Snaps" all {@link SegmentString}s in a {@link SpatialIndex} containing
|
51
|
+
* {@link MonotoneChain}s to a given {@link HotPixel}.
|
52
|
+
*/
|
53
|
+
jsts.noding.snapround.MCIndexPointSnapper = function(index) {
|
54
|
+
this.index = index;
|
55
|
+
};
|
56
|
+
|
57
|
+
jsts.noding.snapround.MCIndexPointSnapper.prototype.index = null;
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Snaps (nodes) all interacting segments to this hot pixel. The hot pixel may
|
61
|
+
* represent a vertex of an edge, in which case this routine uses the
|
62
|
+
* optimization of not noding the vertex itself
|
63
|
+
*
|
64
|
+
* @param hotPixel
|
65
|
+
* the hot pixel to snap to.
|
66
|
+
* @param parentEdge
|
67
|
+
* the edge containing the vertex, if applicable, or
|
68
|
+
* <code>null.</code>
|
69
|
+
* @param vertexIndex
|
70
|
+
* the index of the vertex, if applicable, or -1.
|
71
|
+
* @return <code>true</code> if a node was added for this pixel.
|
72
|
+
*/
|
73
|
+
jsts.noding.snapround.MCIndexPointSnapper.prototype.snap = function(hotPixel,
|
74
|
+
parentEdge, vertexIndex) {
|
75
|
+
if (arguments.length === 1) {
|
76
|
+
this.snap2.apply(this, arguments);
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
|
80
|
+
var pixelEnv = hotPixel.getSafeEnvelope();
|
81
|
+
var hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge,
|
82
|
+
vertexIndex);
|
83
|
+
|
84
|
+
this.index.query(pixelEnv, {
|
85
|
+
visitItem: function(testChain) {
|
86
|
+
testChain.select(pixelEnv, hotPixelSnapAction);
|
87
|
+
}
|
88
|
+
});
|
89
|
+
return hotPixelSnapAction.isNodeAdded();
|
90
|
+
};
|
91
|
+
|
92
|
+
jsts.noding.snapround.MCIndexPointSnapper.prototype.snap2 = function(hotPixel) {
|
93
|
+
return this.snap(hotPixel, null, -1);
|
94
|
+
};
|
95
|
+
|
96
|
+
})();
|
@@ -0,0 +1,147 @@
|
|
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/noding/snapround/MCIndexSnapRounder.java
|
9
|
+
* Revision: 486
|
10
|
+
*/
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @requires jsts/algorithm/RobustLineIntersector.js
|
14
|
+
* @requires jsts/noding/Noder.js
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Uses Snap Rounding to compute a rounded, fully noded arrangement from a set
|
19
|
+
* of {@link SegmentString}s. Implements the Snap Rounding technique described
|
20
|
+
* in papers by Hobby, Guibas & Marimont, and Goodrich et al. Snap Rounding
|
21
|
+
* assumes that all vertices lie on a uniform grid; hence the precision model of
|
22
|
+
* the input must be fixed precision, and all the input vertices must be rounded
|
23
|
+
* to that precision.
|
24
|
+
* <p>
|
25
|
+
* This implementation uses a monotone chains and a spatial index to speed up
|
26
|
+
* the intersection tests.
|
27
|
+
* <p>
|
28
|
+
* This implementation appears to be fully robust using an integer precision
|
29
|
+
* model. It will function with non-integer precision models, but the results
|
30
|
+
* are not 100% guaranteed to be correctly noded.
|
31
|
+
*/
|
32
|
+
jsts.noding.snapround.MCIndexSnapRounder = function(pm) {
|
33
|
+
this.pm = pm;
|
34
|
+
this.li = new jsts.algorithm.RobustLineIntersector();
|
35
|
+
this.li.setPrecisionModel(pm);
|
36
|
+
this.scaleFactor = pm.getScale();
|
37
|
+
};
|
38
|
+
|
39
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype = new jsts.noding.Noder();
|
40
|
+
jsts.noding.snapround.MCIndexSnapRounder.constructor = jsts.noding.snapround.MCIndexSnapRounder;
|
41
|
+
|
42
|
+
|
43
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.pm = null;
|
44
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.li = null;
|
45
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.scaleFactor = null;
|
46
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.noder = null;
|
47
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.pointSnapper = null;
|
48
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.nodedSegStrings = null;
|
49
|
+
|
50
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.getNodedSubstrings = function() {
|
51
|
+
return jsts.noding.NodedSegmentString
|
52
|
+
.getNodedSubstrings(this.nodedSegStrings);
|
53
|
+
};
|
54
|
+
|
55
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.computeNodes = function(
|
56
|
+
inputSegmentStrings) {
|
57
|
+
this.nodedSegStrings = inputSegmentStrings;
|
58
|
+
this.noder = new jsts.noding.MCIndexNoder();
|
59
|
+
this.pointSnapper = new jsts.noding.snapround.MCIndexPointSnapper(this.noder
|
60
|
+
.getIndex());
|
61
|
+
this.snapRound(inputSegmentStrings, this.li);
|
62
|
+
};
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @private
|
66
|
+
*/
|
67
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.snapRound = function(
|
68
|
+
segStrings, li) {
|
69
|
+
var intersections = this.findInteriorIntersections(segStrings, li);
|
70
|
+
this.computeIntersectionSnaps(intersections);
|
71
|
+
this.computeVertexSnaps(segStrings);
|
72
|
+
};
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Computes all interior intersections in the collection of
|
76
|
+
* {@link SegmentString}s, and returns their
|
77
|
+
*
|
78
|
+
* @link Coordinate}s.
|
79
|
+
*
|
80
|
+
* Does NOT node the segStrings.
|
81
|
+
*
|
82
|
+
* @return a list of Coordinates for the intersections.
|
83
|
+
* @private
|
84
|
+
*/
|
85
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.findInteriorIntersections = function(
|
86
|
+
segStrings, li) {
|
87
|
+
var intFinderAdder = new jsts.noding.IntersectionFinderAdder(li);
|
88
|
+
this.noder.setSegmentIntersector(intFinderAdder);
|
89
|
+
this.noder.computeNodes(segStrings);
|
90
|
+
return intFinderAdder.getInteriorIntersections();
|
91
|
+
};
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Computes nodes introduced as a result of snapping segments to snap points
|
95
|
+
* (hot pixels)
|
96
|
+
*
|
97
|
+
* @private
|
98
|
+
*/
|
99
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.computeIntersectionSnaps = function(
|
100
|
+
snapPts) {
|
101
|
+
for (var it = snapPts.iterator(); it.hasNext();) {
|
102
|
+
var snapPt = it.next();
|
103
|
+
var hotPixel = new jsts.noding.snapround.HotPixel(snapPt, this.scaleFactor,
|
104
|
+
this.li);
|
105
|
+
this.pointSnapper.snap(hotPixel);
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Computes nodes introduced as a result of snapping segments to vertices of
|
111
|
+
* other segments
|
112
|
+
*
|
113
|
+
* @param edges
|
114
|
+
* the list of segment strings to snap together.
|
115
|
+
*/
|
116
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.computeVertexSnaps = function(
|
117
|
+
edges) {
|
118
|
+
if (edges instanceof jsts.noding.NodedSegmentString) {
|
119
|
+
this.computeVertexSnaps2.apply(this, arguments);
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
|
123
|
+
for (var i0 = edges.iterator(); i0.hasNext();) {
|
124
|
+
var edge0 = i0.next();
|
125
|
+
this.computeVertexSnaps(edge0);
|
126
|
+
}
|
127
|
+
};
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Performs a brute-force comparison of every segment in each
|
131
|
+
* {@link SegmentString}. This has n^2 performance.
|
132
|
+
*
|
133
|
+
* @private
|
134
|
+
*/
|
135
|
+
jsts.noding.snapround.MCIndexSnapRounder.prototype.computeVertexSnaps2 = function(
|
136
|
+
e) {
|
137
|
+
var pts0 = e.getCoordinates();
|
138
|
+
for (var i = 0; i < pts0.length - 1; i++) {
|
139
|
+
var hotPixel = new jsts.noding.snapround.HotPixel(pts0[i],
|
140
|
+
this.scaleFactor, this.li);
|
141
|
+
var isNodeAdded = this.pointSnapper.snap(hotPixel, e, i);
|
142
|
+
// if a node is created for a vertex, that vertex must be noded too
|
143
|
+
if (isNodeAdded) {
|
144
|
+
e.addIntersection(pts0[i], i);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
};
|
@@ -0,0 +1,166 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Computes the boundary of a {@link Geometry}.
|
5
|
+
* Allows specifying the {@link BoundaryNodeRule} to be used.
|
6
|
+
* This operation will always return a {@link Geometry} of the appropriate
|
7
|
+
* dimension for the boundary (even if the input geometry is empty).
|
8
|
+
* The boundary of zero-dimensional geometries (Points) is
|
9
|
+
* always the empty {@link GeometryCollection}.
|
10
|
+
*
|
11
|
+
* @author Martin Davis
|
12
|
+
* @version 1.7
|
13
|
+
*/
|
14
|
+
|
15
|
+
jsts.operation.BoundaryOp = function(geom, bnRule) {
|
16
|
+
this.geom = geom;
|
17
|
+
this.geomFact = geom.getFactory();
|
18
|
+
this.bnRule = bnRule || jsts.algorithm.BoundaryNodeRule.MOD2_BOUNDARY_RULE;
|
19
|
+
};
|
20
|
+
|
21
|
+
|
22
|
+
/**
|
23
|
+
* @type {Geometry}
|
24
|
+
* @private
|
25
|
+
*/
|
26
|
+
jsts.operation.BoundaryOp.prototype.geom = null;
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @type {GeometryFactory}
|
31
|
+
* @private
|
32
|
+
*/
|
33
|
+
jsts.operation.BoundaryOp.prototype.geomFact = null;
|
34
|
+
|
35
|
+
|
36
|
+
/**
|
37
|
+
* @type {BoundaryNodeRule}
|
38
|
+
* @private
|
39
|
+
*/
|
40
|
+
jsts.operation.BoundaryOp.prototype.bnRule = null;
|
41
|
+
|
42
|
+
|
43
|
+
/**
|
44
|
+
* @return {Geometry}
|
45
|
+
*/
|
46
|
+
jsts.operation.BoundaryOp.prototype.getBoundary = function() {
|
47
|
+
if (this.geom instanceof jsts.geom.LineString) return this.boundaryLineString(this.geom);
|
48
|
+
if (this.geom instanceof jsts.geom.MultiLineString) return this.boundaryMultiLineString(this.geom);
|
49
|
+
return this.geom.getBoundary();
|
50
|
+
};
|
51
|
+
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @return {MultiPoint}
|
55
|
+
* @private
|
56
|
+
*/
|
57
|
+
jsts.operation.BoundaryOp.prototype.getEmptyMultiPoint = function() {
|
58
|
+
return this.geomFact.createMultiPoint(null);
|
59
|
+
};
|
60
|
+
|
61
|
+
|
62
|
+
/**
|
63
|
+
* @param {MultiLineString} mLine
|
64
|
+
* @return {Geometry}
|
65
|
+
* @private
|
66
|
+
*/
|
67
|
+
jsts.operation.BoundaryOp.prototype.boundaryMultiLineString = function(mLine) {
|
68
|
+
if (this.geom.isEmpty()) {
|
69
|
+
return this.getEmptyMultiPoint();
|
70
|
+
}
|
71
|
+
|
72
|
+
var bdyPts = this.computeBoundaryCoordinates(mLine);
|
73
|
+
|
74
|
+
// return Point or MultiPoint
|
75
|
+
if (bdyPts.length == 1) {
|
76
|
+
return this.geomFact.createPoint(bdyPts[0]);
|
77
|
+
}
|
78
|
+
// this handles 0 points case as well
|
79
|
+
return this.geomFact.createMultiPoint(bdyPts);
|
80
|
+
};
|
81
|
+
|
82
|
+
|
83
|
+
/**
|
84
|
+
* @type {Array}
|
85
|
+
* @private
|
86
|
+
*/
|
87
|
+
jsts.operation.BoundaryOp.prototype.endpoints = null;
|
88
|
+
|
89
|
+
|
90
|
+
/**
|
91
|
+
* @param {MultiLineString} mLine
|
92
|
+
* @return {Array.<Coordinate>}
|
93
|
+
* @private
|
94
|
+
*/
|
95
|
+
jsts.operation.BoundaryOp.prototype.computeBoundaryCoordinates = function(mLine) {
|
96
|
+
var i, line, endpoint, bdyPts = [];
|
97
|
+
|
98
|
+
this.endpoints = [];
|
99
|
+
for (i = 0; i < mLine.getNumGeometries(); i++) {
|
100
|
+
line = mLine.getGeometryN(i);
|
101
|
+
if (line.getNumPoints() == 0)
|
102
|
+
continue;
|
103
|
+
this.addEndpoint(line.getCoordinateN(0));
|
104
|
+
this.addEndpoint(line.getCoordinateN(line.getNumPoints() - 1));
|
105
|
+
}
|
106
|
+
|
107
|
+
for (i = 0; i < this.endpoints.length; i++) {
|
108
|
+
endpoint = this.endpoints[i];
|
109
|
+
if (this.bnRule.isInBoundary(endpoint.count)) {
|
110
|
+
bdyPts.push(endpoint.coordinate);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
return bdyPts;
|
115
|
+
};
|
116
|
+
|
117
|
+
|
118
|
+
/**
|
119
|
+
* @param {Coordinate} pt
|
120
|
+
* @private
|
121
|
+
*/
|
122
|
+
jsts.operation.BoundaryOp.prototype.addEndpoint = function(pt) {
|
123
|
+
var i, endpoint, found = false;
|
124
|
+
for (i = 0; i < this.endpoints.length; i++) {
|
125
|
+
endpoint = this.endpoints[i];
|
126
|
+
if (endpoint.coordinate.equals(pt)) {
|
127
|
+
found = true;
|
128
|
+
break;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
if (!found) {
|
133
|
+
endpoint = {};
|
134
|
+
endpoint.coordinate = pt;
|
135
|
+
endpoint.count = 0;
|
136
|
+
this.endpoints.push(endpoint);
|
137
|
+
}
|
138
|
+
|
139
|
+
endpoint.count++;
|
140
|
+
};
|
141
|
+
|
142
|
+
|
143
|
+
/**
|
144
|
+
* @param {LineString} line
|
145
|
+
* @return {Geometry}
|
146
|
+
* @private
|
147
|
+
*/
|
148
|
+
jsts.operation.BoundaryOp.prototype.boundaryLineString = function(line) {
|
149
|
+
if (this.geom.isEmpty()) {
|
150
|
+
return this.getEmptyMultiPoint();
|
151
|
+
}
|
152
|
+
|
153
|
+
if (line.isClosed()) {
|
154
|
+
// check whether endpoints of valence 2 are on the boundary or not
|
155
|
+
var closedEndpointOnBoundary = this.bnRule.isInBoundary(2);
|
156
|
+
if (closedEndpointOnBoundary) {
|
157
|
+
return line.getStartPoint();
|
158
|
+
}
|
159
|
+
else {
|
160
|
+
return this.geomFact.createMultiPoint(null);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
return this.geomFact.createMultiPoint([line.getStartPoint(),
|
164
|
+
line.getEndPoint()]
|
165
|
+
);
|
166
|
+
};
|
@@ -0,0 +1,90 @@
|
|
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
|
+
* The base class for operations that require {@link GeometryGraph}s.
|
11
|
+
*
|
12
|
+
* @param {Geometry}
|
13
|
+
* g0
|
14
|
+
* @param {Geometry}
|
15
|
+
* g1
|
16
|
+
* @param {BoundaryNodeRule}
|
17
|
+
* boundaryNodeRule
|
18
|
+
* @constructor
|
19
|
+
*/
|
20
|
+
jsts.operation.GeometryGraphOperation = function(g0, g1, boundaryNodeRule) {
|
21
|
+
this.li = new jsts.algorithm.RobustLineIntersector();
|
22
|
+
this.arg = [];
|
23
|
+
|
24
|
+
if (g0 === undefined) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
|
28
|
+
if (g1 === undefined) {
|
29
|
+
this.setComputationPrecision(g0.getPrecisionModel());
|
30
|
+
|
31
|
+
this.arg[0] = new jsts.geomgraph.GeometryGraph(0, g0);
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
boundaryNodeRule = boundaryNodeRule ||
|
36
|
+
jsts.algorithm.BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
|
37
|
+
|
38
|
+
// use the most precise model for the result
|
39
|
+
if (g0.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0)
|
40
|
+
this.setComputationPrecision(g0.getPrecisionModel());
|
41
|
+
else
|
42
|
+
this.setComputationPrecision(g1.getPrecisionModel());
|
43
|
+
|
44
|
+
this.arg[0] = new jsts.geomgraph.GeometryGraph(0, g0, boundaryNodeRule);
|
45
|
+
this.arg[1] = new jsts.geomgraph.GeometryGraph(1, g1, boundaryNodeRule);
|
46
|
+
};
|
47
|
+
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @type {LineIntersector}
|
51
|
+
* @protected
|
52
|
+
*/
|
53
|
+
jsts.operation.GeometryGraphOperation.prototype.li = null;
|
54
|
+
|
55
|
+
|
56
|
+
/**
|
57
|
+
* @type {PrecisionModel}
|
58
|
+
* @protected
|
59
|
+
*/
|
60
|
+
jsts.operation.GeometryGraphOperation.prototype.resultPrecisionModel = null;
|
61
|
+
|
62
|
+
|
63
|
+
/**
|
64
|
+
* The operation args into an array so they can be accessed by index
|
65
|
+
*
|
66
|
+
* @type {GeometryGraph[]}
|
67
|
+
* @protected
|
68
|
+
*/
|
69
|
+
jsts.operation.GeometryGraphOperation.prototype.arg = null;
|
70
|
+
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @param {int}
|
74
|
+
* i
|
75
|
+
* @return {Geometry}
|
76
|
+
*/
|
77
|
+
jsts.operation.GeometryGraphOperation.prototype.getArgGeometry = function(i) {
|
78
|
+
return arg[i].getGeometry();
|
79
|
+
};
|
80
|
+
|
81
|
+
|
82
|
+
/**
|
83
|
+
* @param {PrecisionModel}
|
84
|
+
* pm
|
85
|
+
* @protected
|
86
|
+
*/
|
87
|
+
jsts.operation.GeometryGraphOperation.prototype.setComputationPrecision = function(pm) {
|
88
|
+
this.resultPrecisionModel = pm;
|
89
|
+
this.li.setPrecisionModel(this.resultPrecisionModel);
|
90
|
+
};
|