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,78 @@
|
|
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
|
+
* Implements a robust method of comparing the relative position of two points
|
9
|
+
* along the same segment. The coordinates are assumed to lie "near" the
|
10
|
+
* segment. This means that this algorithm will only return correct results if
|
11
|
+
* the input coordinates have the same precision and correspond to rounded
|
12
|
+
* values of exact coordinates lying on the segment.
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
jsts.noding.SegmentPointComparator = function() {
|
16
|
+
};
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Compares two {@link Coordinate}s for their relative position along a segment
|
20
|
+
* lying in the specified {@link Octant}.
|
21
|
+
*
|
22
|
+
* @return -1 node0 occurs first.
|
23
|
+
* @return 0 the two nodes are equal.
|
24
|
+
* @return 1 node1 occurs first.
|
25
|
+
*/
|
26
|
+
jsts.noding.SegmentPointComparator.compare = function(octant, p0, p1) {
|
27
|
+
// nodes can only be equal if their coordinates are equal
|
28
|
+
if (p0.equals2D(p1))
|
29
|
+
return 0;
|
30
|
+
|
31
|
+
var xSign = jsts.noding.SegmentPointComparator.relativeSign(p0.x, p1.x);
|
32
|
+
var ySign = jsts.noding.SegmentPointComparator.relativeSign(p0.y, p1.y);
|
33
|
+
|
34
|
+
switch (octant) {
|
35
|
+
case 0:
|
36
|
+
return jsts.noding.SegmentPointComparator.compareValue(xSign, ySign);
|
37
|
+
case 1:
|
38
|
+
return jsts.noding.SegmentPointComparator.compareValue(ySign, xSign);
|
39
|
+
case 2:
|
40
|
+
return jsts.noding.SegmentPointComparator.compareValue(ySign, -xSign);
|
41
|
+
case 3:
|
42
|
+
return jsts.noding.SegmentPointComparator.compareValue(-xSign, ySign);
|
43
|
+
case 4:
|
44
|
+
return jsts.noding.SegmentPointComparator.compareValue(-xSign, -ySign);
|
45
|
+
case 5:
|
46
|
+
return jsts.noding.SegmentPointComparator.compareValue(-ySign, -xSign);
|
47
|
+
case 6:
|
48
|
+
return jsts.noding.SegmentPointComparator.compareValue(-ySign, xSign);
|
49
|
+
case 7:
|
50
|
+
return jsts.noding.SegmentPointComparator.compareValue(xSign, -ySign);
|
51
|
+
}
|
52
|
+
// TODO: Assert.shouldNeverReachHere("invalid octant value");
|
53
|
+
return 0;
|
54
|
+
};
|
55
|
+
jsts.noding.SegmentPointComparator.relativeSign = function(x0, x1) {
|
56
|
+
if (x0 < x1)
|
57
|
+
return -1;
|
58
|
+
if (x0 > x1)
|
59
|
+
return 1;
|
60
|
+
return 0;
|
61
|
+
};
|
62
|
+
|
63
|
+
/**
|
64
|
+
* @private
|
65
|
+
*/
|
66
|
+
jsts.noding.SegmentPointComparator.compareValue = function(compareSign0,
|
67
|
+
compareSign1) {
|
68
|
+
if (compareSign0 < 0)
|
69
|
+
return -1;
|
70
|
+
if (compareSign0 > 0)
|
71
|
+
return 1;
|
72
|
+
if (compareSign1 < 0)
|
73
|
+
return -1;
|
74
|
+
if (compareSign1 > 0)
|
75
|
+
return 1;
|
76
|
+
return 0;
|
77
|
+
|
78
|
+
};
|
@@ -0,0 +1,61 @@
|
|
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
|
+
* An interface for classes which represent a sequence of contiguous line
|
11
|
+
* segments. SegmentStrings can carry a context object, which is useful for
|
12
|
+
* preserving topological or parentage information.
|
13
|
+
*
|
14
|
+
* @interface
|
15
|
+
*/
|
16
|
+
jsts.noding.SegmentString = function() {
|
17
|
+
|
18
|
+
};
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Gets the user-defined data for this segment string.
|
23
|
+
*
|
24
|
+
* @return {Object} the user-defined data.
|
25
|
+
*/
|
26
|
+
jsts.noding.SegmentString.prototype.getData = jsts.abstractFunc;
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Sets the user-defined data for this segment string.
|
31
|
+
*
|
32
|
+
* @param {Object}
|
33
|
+
* data an Object containing user-defined data.
|
34
|
+
*/
|
35
|
+
jsts.noding.SegmentString.prototype.setData = jsts.abstractFunc;
|
36
|
+
|
37
|
+
|
38
|
+
/**
|
39
|
+
* @return {number}
|
40
|
+
*/
|
41
|
+
jsts.noding.SegmentString.prototype.size = jsts.abstractFunc;
|
42
|
+
|
43
|
+
|
44
|
+
/**
|
45
|
+
* @param {number}
|
46
|
+
* i
|
47
|
+
* @return {jsts.geom.Coordinate}
|
48
|
+
*/
|
49
|
+
jsts.noding.SegmentString.prototype.getCoordinate = jsts.abstractFunc;
|
50
|
+
|
51
|
+
|
52
|
+
/**
|
53
|
+
* @return {Array.<jsts.geom.Coordinate>}
|
54
|
+
*/
|
55
|
+
jsts.noding.SegmentString.prototype.getCoordinates = jsts.abstractFunc;
|
56
|
+
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @return {boolean}
|
60
|
+
*/
|
61
|
+
jsts.noding.SegmentString.prototype.isClosed = jsts.abstractFunc;
|
@@ -0,0 +1,51 @@
|
|
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/noding/Noder.js
|
11
|
+
*/
|
12
|
+
|
13
|
+
var Noder = jsts.noding.Noder;
|
14
|
+
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Base class for {@link Noder}s which make a single pass to find
|
18
|
+
* intersections. This allows using a custom {@link SegmentIntersector} (which
|
19
|
+
* for instance may simply identify intersections, rather than insert them).
|
20
|
+
*
|
21
|
+
* @interface
|
22
|
+
*/
|
23
|
+
jsts.noding.SinglePassNoder = function() {
|
24
|
+
|
25
|
+
};
|
26
|
+
|
27
|
+
|
28
|
+
jsts.noding.SinglePassNoder.prototype = new Noder();
|
29
|
+
jsts.noding.SinglePassNoder.constructor = jsts.noding.SinglePassNoder;
|
30
|
+
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @type {SegmentIntersector}
|
34
|
+
* @protected
|
35
|
+
*/
|
36
|
+
jsts.noding.SinglePassNoder.prototype.segInt = null;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Sets the SegmentIntersector to use with this noder. A SegmentIntersector
|
40
|
+
* will normally add intersection nodes to the input segment strings, but it
|
41
|
+
* may not - it may simply record the presence of intersections. However, some
|
42
|
+
* Noders may require that intersections be added.
|
43
|
+
*
|
44
|
+
* @param {SegmentIntersector}
|
45
|
+
* segInt
|
46
|
+
*/
|
47
|
+
jsts.noding.SinglePassNoder.prototype.setSegmentIntersector = function(segInt) {
|
48
|
+
this.segInt = segInt;
|
49
|
+
};
|
50
|
+
|
51
|
+
})();
|
@@ -0,0 +1,271 @@
|
|
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/HotPixel.java
|
10
|
+
* Revision: 143
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Implements a "hot pixel" as used in the Snap Rounding algorithm.
|
15
|
+
* A hot pixel contains the interior of the tolerance square and
|
16
|
+
* the boundary
|
17
|
+
* <b>minus</b> the top and right segments.
|
18
|
+
* <p>
|
19
|
+
* The hot pixel operations are all computed in the integer domain
|
20
|
+
* to avoid rounding problems.
|
21
|
+
*/
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Creates a new hot pixel.
|
25
|
+
*
|
26
|
+
* @param pt
|
27
|
+
* the coordinate at the centre of the pixel.
|
28
|
+
* @param scaleFactor
|
29
|
+
* the scaleFactor determining the pixel size.
|
30
|
+
* @param li
|
31
|
+
* the intersector to use for testing intersection with line segments.
|
32
|
+
*/
|
33
|
+
jsts.noding.snapround.HotPixel = function(pt, scaleFactor, li) {
|
34
|
+
this.corner = [];
|
35
|
+
|
36
|
+
this.originalPt = pt;
|
37
|
+
this.pt = pt;
|
38
|
+
this.scaleFactor = scaleFactor;
|
39
|
+
this.li = li;
|
40
|
+
if (this.scaleFactor !== 1.0) {
|
41
|
+
this.pt = new jsts.geom.Coordinate(this.scale(pt.x), this.scale(pt.y));
|
42
|
+
this.p0Scaled = new jsts.geom.Coordinate();
|
43
|
+
this.p1Scaled = new jsts.geom.Coordinate();
|
44
|
+
}
|
45
|
+
this.initCorners(this.pt);
|
46
|
+
};
|
47
|
+
|
48
|
+
jsts.noding.snapround.HotPixel.prototype.li = null;
|
49
|
+
|
50
|
+
jsts.noding.snapround.HotPixel.prototype.pt = null;
|
51
|
+
jsts.noding.snapround.HotPixel.prototype.originalPt = null;
|
52
|
+
jsts.noding.snapround.HotPixel.prototype.ptScaled = null;
|
53
|
+
|
54
|
+
jsts.noding.snapround.HotPixel.prototype.p0Scaled = null;
|
55
|
+
jsts.noding.snapround.HotPixel.prototype.p1Scaled = null;
|
56
|
+
|
57
|
+
jsts.noding.snapround.HotPixel.prototype.scaleFactor = undefined;
|
58
|
+
|
59
|
+
jsts.noding.snapround.HotPixel.prototype.minx = undefined;
|
60
|
+
jsts.noding.snapround.HotPixel.prototype.maxx = undefined;
|
61
|
+
jsts.noding.snapround.HotPixel.prototype.miny = undefined;
|
62
|
+
jsts.noding.snapround.HotPixel.prototype.maxy = undefined;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* The corners of the hot pixel, in the order: 10 23
|
66
|
+
*/
|
67
|
+
jsts.noding.snapround.HotPixel.prototype.corner = null;
|
68
|
+
|
69
|
+
jsts.noding.snapround.HotPixel.prototype.safeEnv = null;
|
70
|
+
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Gets the coordinate this hot pixel is based at.
|
74
|
+
*
|
75
|
+
* @return the coordinate of the pixel.
|
76
|
+
*/
|
77
|
+
jsts.noding.snapround.HotPixel.prototype.getCoordinate = function() {
|
78
|
+
return this.originalPt;
|
79
|
+
};
|
80
|
+
|
81
|
+
jsts.noding.snapround.HotPixel.SAFE_ENV_EXPANSION_FACTOR = 0.75;
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Returns a "safe" envelope that is guaranteed to contain the hot pixel. The
|
85
|
+
* envelope returned will be larger than the exact envelope of the pixel.
|
86
|
+
*
|
87
|
+
* @return an envelope which contains the hot pixel.
|
88
|
+
*/
|
89
|
+
jsts.noding.snapround.HotPixel.prototype.getSafeEnvelope = function() {
|
90
|
+
if (this.safeEnv === null) {
|
91
|
+
var safeTolerance = jsts.noding.snapround.HotPixel.SAFE_ENV_EXPANSION_FACTOR /
|
92
|
+
this.scaleFactor;
|
93
|
+
this.safeEnv = new jsts.geom.Envelope(this.originalPt.x - safeTolerance,
|
94
|
+
this.originalPt.x + safeTolerance, this.originalPt.y - safeTolerance,
|
95
|
+
this.originalPt.y + safeTolerance);
|
96
|
+
}
|
97
|
+
return this.safeEnv;
|
98
|
+
};
|
99
|
+
|
100
|
+
jsts.noding.snapround.HotPixel.prototype.initCorners = function(pt) {
|
101
|
+
var tolerance = 0.5;
|
102
|
+
this.minx = pt.x - tolerance;
|
103
|
+
this.maxx = pt.x + tolerance;
|
104
|
+
this.miny = pt.y - tolerance;
|
105
|
+
this.maxy = pt.y + tolerance;
|
106
|
+
|
107
|
+
this.corner[0] = new jsts.geom.Coordinate(this.maxx, this.maxy);
|
108
|
+
this.corner[1] = new jsts.geom.Coordinate(this.minx, this.maxy);
|
109
|
+
this.corner[2] = new jsts.geom.Coordinate(this.minx, this.miny);
|
110
|
+
this.corner[3] = new jsts.geom.Coordinate(this.maxx, this.miny);
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* @private
|
115
|
+
*/
|
116
|
+
jsts.noding.snapround.HotPixel.prototype.scale = function(val) {
|
117
|
+
return Math.round(val * this.scaleFactor);
|
118
|
+
};
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Tests whether the line segment (p0-p1) intersects this hot pixel.
|
122
|
+
*
|
123
|
+
* @param p0
|
124
|
+
* the first coordinate of the line segment to test.
|
125
|
+
* @param p1
|
126
|
+
* the second coordinate of the line segment to test.
|
127
|
+
* @return true if the line segment intersects this hot pixel.
|
128
|
+
*/
|
129
|
+
jsts.noding.snapround.HotPixel.prototype.intersects = function(p0, p1) {
|
130
|
+
if (this.scaleFactor === 1.0)
|
131
|
+
return this.intersectsScaled(p0, p1);
|
132
|
+
|
133
|
+
this.copyScaled(p0, this.p0Scaled);
|
134
|
+
this.copyScaled(p1, this.p1Scaled);
|
135
|
+
return this.intersectsScaled(this.p0Scaled, this.p1Scaled);
|
136
|
+
};
|
137
|
+
|
138
|
+
/**
|
139
|
+
* @private
|
140
|
+
*/
|
141
|
+
jsts.noding.snapround.HotPixel.prototype.copyScaled = function(p, pScaled) {
|
142
|
+
pScaled.x = this.scale(p.x);
|
143
|
+
pScaled.y = this.scale(p.y);
|
144
|
+
};
|
145
|
+
|
146
|
+
/**
|
147
|
+
* @private
|
148
|
+
*/
|
149
|
+
jsts.noding.snapround.HotPixel.prototype.intersectsScaled = function(p0, p1) {
|
150
|
+
var segMinx = Math.min(p0.x, p1.x);
|
151
|
+
var segMaxx = Math.max(p0.x, p1.x);
|
152
|
+
var segMiny = Math.min(p0.y, p1.y);
|
153
|
+
var segMaxy = Math.max(p0.y, p1.y);
|
154
|
+
|
155
|
+
var isOutsidePixelEnv = this.maxx < segMinx || this.minx > segMaxx ||
|
156
|
+
this.maxy < segMiny || this.miny > segMaxy;
|
157
|
+
if (isOutsidePixelEnv)
|
158
|
+
return false;
|
159
|
+
var intersects = this.intersectsToleranceSquare(p0, p1);
|
160
|
+
|
161
|
+
jsts.util.Assert.isTrue(!(isOutsidePixelEnv && intersects),
|
162
|
+
'Found bad envelope test');
|
163
|
+
|
164
|
+
return intersects;
|
165
|
+
};
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Tests whether the segment p0-p1 intersects the hot pixel tolerance square.
|
169
|
+
* Because the tolerance square point set is partially open (along the top and
|
170
|
+
* right) the test needs to be more sophisticated than simply checking for any
|
171
|
+
* intersection. However, it can take advantage of the fact that because the hot
|
172
|
+
* pixel edges do not lie on the coordinate grid. It is sufficient to check if
|
173
|
+
* there is at least one of:
|
174
|
+
* <ul>
|
175
|
+
* <li>a proper intersection with the segment and any hot pixel edge
|
176
|
+
* <li>an intersection between the segment and both the left and bottom edges
|
177
|
+
* <li>an intersection between a segment endpoint and the hot pixel coordinate
|
178
|
+
* </ul>
|
179
|
+
*
|
180
|
+
* @param p0
|
181
|
+
* @param p1
|
182
|
+
* @return
|
183
|
+
* @private
|
184
|
+
*/
|
185
|
+
jsts.noding.snapround.HotPixel.prototype.intersectsToleranceSquare = function(
|
186
|
+
p0, p1) {
|
187
|
+
var intersectsLeft = false;
|
188
|
+
var intersectsBottom = false;
|
189
|
+
|
190
|
+
this.li.computeIntersection(p0, p1, this.corner[0], this.corner[1]);
|
191
|
+
if (this.li.isProper())
|
192
|
+
return true;
|
193
|
+
|
194
|
+
this.li.computeIntersection(p0, p1, this.corner[1], this.corner[2]);
|
195
|
+
if (this.li.isProper())
|
196
|
+
return true;
|
197
|
+
if (this.li.hasIntersection())
|
198
|
+
intersectsLeft = true;
|
199
|
+
|
200
|
+
this.li.computeIntersection(p0, p1, this.corner[2], this.corner[3]);
|
201
|
+
if (this.li.isProper())
|
202
|
+
return true;
|
203
|
+
if (this.li.hasIntersection())
|
204
|
+
intersectsBottom = true;
|
205
|
+
|
206
|
+
this.li.computeIntersection(p0, p1, this.corner[3], this.corner[0]);
|
207
|
+
if (this.li.isProper())
|
208
|
+
return true;
|
209
|
+
|
210
|
+
if (intersectsLeft && intersectsBottom)
|
211
|
+
return true;
|
212
|
+
|
213
|
+
if (p0.equals(this.pt))
|
214
|
+
return true;
|
215
|
+
if (p1.equals(this.pt))
|
216
|
+
return true;
|
217
|
+
|
218
|
+
return false;
|
219
|
+
};
|
220
|
+
/**
|
221
|
+
* Test whether the given segment intersects the closure of this hot pixel. This
|
222
|
+
* is NOT the test used in the standard snap-rounding algorithm, which uses the
|
223
|
+
* partially closed tolerance square instead. This routine is provided for
|
224
|
+
* testing purposes only.
|
225
|
+
*
|
226
|
+
* @param p0
|
227
|
+
* the start point of a line segment.
|
228
|
+
* @param p1
|
229
|
+
* the end point of a line segment.
|
230
|
+
* @return <code>true</code> if the segment intersects the closure of the
|
231
|
+
* pixel's tolerance square.
|
232
|
+
* @private
|
233
|
+
*/
|
234
|
+
jsts.noding.snapround.HotPixel.prototype.intersectsPixelClosure = function(p0,
|
235
|
+
p1) {
|
236
|
+
this.li.computeIntersection(p0, p1, this.corner[0], this.corner[1]);
|
237
|
+
if (this.li.hasIntersection())
|
238
|
+
return true;
|
239
|
+
this.li.computeIntersection(p0, p1, this.corner[1], this.corner[2]);
|
240
|
+
if (this.li.hasIntersection())
|
241
|
+
return true;
|
242
|
+
this.li.computeIntersection(p0, p1, this.corner[2], this.corner[3]);
|
243
|
+
if (this.li.hasIntersection())
|
244
|
+
return true;
|
245
|
+
this.li.computeIntersection(p0, p1, this.corner[3], this.corner[0]);
|
246
|
+
if (this.li.hasIntersection())
|
247
|
+
return true;
|
248
|
+
|
249
|
+
return false;
|
250
|
+
};
|
251
|
+
|
252
|
+
/**
|
253
|
+
* Adds a new node (equal to the snap pt) to the specified segment if the
|
254
|
+
* segment passes through the hot pixel
|
255
|
+
*
|
256
|
+
* @param segStr
|
257
|
+
* @param segIndex
|
258
|
+
* @return true if a node was added to the segment.
|
259
|
+
*/
|
260
|
+
jsts.noding.snapround.HotPixel.prototype.addSnappedNode = function(segStr,
|
261
|
+
segIndex) {
|
262
|
+
var p0 = segStr.getCoordinate(segIndex);
|
263
|
+
var p1 = segStr.getCoordinate(segIndex + 1);
|
264
|
+
|
265
|
+
if (this.intersects(p0, p1)) {
|
266
|
+
segStr.addIntersection(this.getCoordinate(), segIndex);
|
267
|
+
|
268
|
+
return true;
|
269
|
+
}
|
270
|
+
return false;
|
271
|
+
};
|