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,207 @@
|
|
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
|
+
* @requires jsts/geom/GeometryComponentFilter.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Extracts all the 1-dimensional ({@link LineString}) components from a
|
15
|
+
* {@link Geometry}.
|
16
|
+
*
|
17
|
+
* @extends {jsts.geom.GeometryComponentFilter}
|
18
|
+
* @constructor
|
19
|
+
*/
|
20
|
+
jsts.geom.util.LinearComponentExtracter = function(lines, isForcedToLineString) {
|
21
|
+
this.lines = lines;
|
22
|
+
this.isForcedToLineString = isForcedToLineString;
|
23
|
+
};
|
24
|
+
|
25
|
+
jsts.geom.util.LinearComponentExtracter.prototype = new jsts.geom.GeometryComponentFilter();
|
26
|
+
|
27
|
+
|
28
|
+
/**
|
29
|
+
* @private
|
30
|
+
*/
|
31
|
+
jsts.geom.util.LinearComponentExtracter.prototype.lines = null;
|
32
|
+
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @private
|
36
|
+
*/
|
37
|
+
jsts.geom.util.LinearComponentExtracter.prototype.isForcedToLineString = false;
|
38
|
+
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Extracts the linear components from a single {@link Geometry} and adds them
|
42
|
+
* to the provided {@link Collection}.
|
43
|
+
*
|
44
|
+
* NOTE: will call "overloaded" function depending on args.
|
45
|
+
*
|
46
|
+
* @param {[]}
|
47
|
+
* geoms the collection of geometries from which to extract linear
|
48
|
+
* components.
|
49
|
+
* @param {[]}
|
50
|
+
* lines the collection to add the extracted linear components to.
|
51
|
+
* @return {[]} the collection of linear components (LineStrings or
|
52
|
+
* LinearRings).
|
53
|
+
*/
|
54
|
+
jsts.geom.util.LinearComponentExtracter.getLines = function(geoms, lines) {
|
55
|
+
if (arguments.length == 1) {
|
56
|
+
return jsts.geom.util.LinearComponentExtracter.getLines5.apply(this, arguments);
|
57
|
+
}
|
58
|
+
else if (arguments.length == 2 && typeof lines === 'boolean') {
|
59
|
+
return jsts.geom.util.LinearComponentExtracter.getLines6.apply(this, arguments);
|
60
|
+
}
|
61
|
+
else if (arguments.length == 2 && geoms instanceof jsts.geom.Geometry) {
|
62
|
+
return jsts.geom.util.LinearComponentExtracter.getLines3.apply(this, arguments);
|
63
|
+
}
|
64
|
+
else if (arguments.length == 3 && geoms instanceof jsts.geom.Geometry) {
|
65
|
+
return jsts.geom.util.LinearComponentExtracter.getLines4.apply(this, arguments);
|
66
|
+
}
|
67
|
+
else if (arguments.length == 3) {
|
68
|
+
return jsts.geom.util.LinearComponentExtracter.getLines2.apply(this, arguments);
|
69
|
+
}
|
70
|
+
|
71
|
+
for (var i = 0; i < geoms.length; i++) {
|
72
|
+
var g = geoms[i];
|
73
|
+
jsts.geom.util.LinearComponentExtracter.getLines3(g, lines);
|
74
|
+
}
|
75
|
+
return lines;
|
76
|
+
};
|
77
|
+
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Extracts the linear components from a single {@link Geometry} and adds them
|
81
|
+
* to the provided {@link Collection}.
|
82
|
+
*
|
83
|
+
* @param {[]}
|
84
|
+
* geoms the Collection of geometries from which to extract linear
|
85
|
+
* components.
|
86
|
+
* @param {[]}
|
87
|
+
* lines the collection to add the extracted linear components to.
|
88
|
+
* @param {boolean}
|
89
|
+
* forceToLineString true if LinearRings should be converted to
|
90
|
+
* LineStrings.
|
91
|
+
* @return {[]} the collection of linear components (LineStrings or
|
92
|
+
* LinearRings).
|
93
|
+
*/
|
94
|
+
jsts.geom.util.LinearComponentExtracter.getLines2 = function(geoms, lines,
|
95
|
+
forceToLineString) {
|
96
|
+
for (var i = 0; i < geoms.length; i++) {
|
97
|
+
var g = geoms[i];
|
98
|
+
jsts.geom.util.LinearComponentExtracter.getLines4(g, lines,
|
99
|
+
forceToLineString);
|
100
|
+
}
|
101
|
+
return lines;
|
102
|
+
};
|
103
|
+
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Extracts the linear components from a single {@link Geometry} and adds them
|
107
|
+
* to the provided {@link Collection}.
|
108
|
+
*
|
109
|
+
* @param {Geometry}
|
110
|
+
* geom the geometry from which to extract linear components.
|
111
|
+
* @param {[]}
|
112
|
+
* lines the Collection to add the extracted linear components to.
|
113
|
+
* @return {[]} the Collection of linear components (LineStrings or
|
114
|
+
* LinearRings).
|
115
|
+
*/
|
116
|
+
jsts.geom.util.LinearComponentExtracter.getLines3 = function(geom, lines) {
|
117
|
+
if (geom instanceof LineString) {
|
118
|
+
lines.add(geom);
|
119
|
+
} else {
|
120
|
+
geom.apply(new jsts.geom.util.LinearComponentExtracter(lines));
|
121
|
+
}
|
122
|
+
return lines;
|
123
|
+
};
|
124
|
+
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Extracts the linear components from a single {@link Geometry} and adds them
|
128
|
+
* to the provided {@link Collection}.
|
129
|
+
*
|
130
|
+
* @param {Geometry}
|
131
|
+
* geom the geometry from which to extract linear components.
|
132
|
+
* @param {[]}
|
133
|
+
* lines the Collection to add the extracted linear components to.
|
134
|
+
* @param {boolean}
|
135
|
+
* forceToLineString true if LinearRings should be converted to
|
136
|
+
* LineStrings.
|
137
|
+
* @return {[]} the Collection of linear components (LineStrings or
|
138
|
+
* LinearRings).
|
139
|
+
*/
|
140
|
+
jsts.geom.util.LinearComponentExtracter.getLines4 = function(geom, lines,
|
141
|
+
forceToLineString) {
|
142
|
+
geom.apply(new jsts.geom.util.LinearComponentExtracter(lines,
|
143
|
+
forceToLineString));
|
144
|
+
return lines;
|
145
|
+
};
|
146
|
+
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Extracts the linear components from a single geometry. If more than one
|
150
|
+
* geometry is to be processed, it is more efficient to create a single
|
151
|
+
* {@link LinearComponentExtracter} instance and pass it to multiple geometries.
|
152
|
+
*
|
153
|
+
* @param {Geometry}
|
154
|
+
* geom the geometry from which to extract linear components.
|
155
|
+
* @return {[]} the list of linear components.
|
156
|
+
*/
|
157
|
+
jsts.geom.util.LinearComponentExtracter.getLines5 = function(geom) {
|
158
|
+
return jsts.geom.util.LinearComponentExtracter.getLines6(geom, false);
|
159
|
+
};
|
160
|
+
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Extracts the linear components from a single geometry. If more than one
|
164
|
+
* geometry is to be processed, it is more efficient to create a single
|
165
|
+
* {@link LinearComponentExtracter} instance and pass it to multiple geometries.
|
166
|
+
*
|
167
|
+
* @param {Geometry}
|
168
|
+
* geom the geometry from which to extract linear components.
|
169
|
+
* @param {boolean}
|
170
|
+
* forceToLineString true if LinearRings should be converted to
|
171
|
+
* LineStrings.
|
172
|
+
* @return {[] the list of linear components.}
|
173
|
+
*/
|
174
|
+
jsts.geom.util.LinearComponentExtracter.getLines6 = function(geom,
|
175
|
+
forceToLineString) {
|
176
|
+
var lines = [];
|
177
|
+
geom.apply(new jsts.geom.util.LinearComponentExtracter(lines,
|
178
|
+
forceToLineString));
|
179
|
+
return lines;
|
180
|
+
};
|
181
|
+
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Indicates that LinearRing components should be converted to pure LineStrings.
|
185
|
+
*
|
186
|
+
* @param {boolean}
|
187
|
+
* isForcedToLineString true if LinearRings should be converted to
|
188
|
+
* LineStrings.
|
189
|
+
*/
|
190
|
+
jsts.geom.util.LinearComponentExtracter.prototype.setForceToLineString = function(
|
191
|
+
isForcedToLineString) {
|
192
|
+
this.isForcedToLineString = isForcedToLineString;
|
193
|
+
};
|
194
|
+
|
195
|
+
jsts.geom.util.LinearComponentExtracter.prototype.filter = function(geom) {
|
196
|
+
if (this.isForcedToLineString && geom instanceof jsts.geom.LinearRing) {
|
197
|
+
var line = geom.getFactory().createLineString(geom.getCoordinateSequence());
|
198
|
+
this.lines.push(line);
|
199
|
+
return;
|
200
|
+
}
|
201
|
+
// if not being forced, and this is a linear component
|
202
|
+
// NOTE: inheritance will not show LinearRing to be of LineString heritance...
|
203
|
+
if (geom instanceof jsts.geom.LineString || geom instanceof jsts.geom.LinearRing)
|
204
|
+
this.lines.push(geom);
|
205
|
+
|
206
|
+
// else this is not a linear component, so skip it
|
207
|
+
};
|
@@ -0,0 +1,67 @@
|
|
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
|
+
* @requires jsts/geom/GeometryFilter.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Extracts all the 0-dimensional ({@link Point}) components from a
|
15
|
+
* {@link Geometry}.
|
16
|
+
*
|
17
|
+
* Constructs a PointExtracterFilter with a list in which to store Points found.
|
18
|
+
*
|
19
|
+
* @extends {jsts.geom.GeometryFilter}
|
20
|
+
* @see GeometryExtracter
|
21
|
+
* @constructor
|
22
|
+
*/
|
23
|
+
jsts.geom.util.PointExtracter = function(pts) {
|
24
|
+
this.pts = pts;
|
25
|
+
};
|
26
|
+
|
27
|
+
jsts.geom.util.PointExtracter.prototype = new jsts.geom.GeometryFilter();
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* @private
|
32
|
+
*/
|
33
|
+
jsts.geom.util.PointExtracter.prototype.pts = null;
|
34
|
+
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Extracts the {@link Point} elements from a single {@link Geometry} and adds
|
38
|
+
* them to the provided {@link List}.
|
39
|
+
*
|
40
|
+
* @param {Geometry}
|
41
|
+
* geom the geometry from which to extract.
|
42
|
+
* @param {[]}
|
43
|
+
* list the list to add the extracted elements to.
|
44
|
+
* @return {[]}
|
45
|
+
*/
|
46
|
+
jsts.geom.util.PointExtracter.getPoints = function(geom, list) {
|
47
|
+
if (list === undefined) {
|
48
|
+
list = [];
|
49
|
+
}
|
50
|
+
|
51
|
+
if (geom instanceof jsts.geom.Point) {
|
52
|
+
list.push(geom);
|
53
|
+
} else if (geom instanceof jsts.geom.GeometryCollection ||
|
54
|
+
geom instanceof jsts.geom.MultiPoint ||
|
55
|
+
geom instanceof jsts.geom.MultiLineString ||
|
56
|
+
geom instanceof jsts.geom.MultiPolygon) {
|
57
|
+
geom.apply(new jsts.geom.util.PointExtracter(list));
|
58
|
+
}
|
59
|
+
// skip non-Polygonal elemental geometries
|
60
|
+
|
61
|
+
return list;
|
62
|
+
};
|
63
|
+
|
64
|
+
jsts.geom.util.PointExtracter.prototype.filter = function(geom) {
|
65
|
+
if (geom instanceof jsts.geom.Point)
|
66
|
+
this.pts.push(geom);
|
67
|
+
};
|
@@ -0,0 +1,71 @@
|
|
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
|
+
* @requires jsts/geom/GeometryFilter.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Extracts all the {@link Polygon} elements from a {@link Geometry}.
|
15
|
+
*
|
16
|
+
* Constructs a PolygonExtracterFilter with a list in which to store Polygons
|
17
|
+
* found.
|
18
|
+
*
|
19
|
+
* @param {Array}
|
20
|
+
* comps
|
21
|
+
* @extends {jsts.geom.GeometryFilter}
|
22
|
+
* @see GeometryExtracter
|
23
|
+
* @constructor
|
24
|
+
*/
|
25
|
+
jsts.geom.util.PolygonExtracter = function(comps) {
|
26
|
+
this.comps = comps;
|
27
|
+
};
|
28
|
+
|
29
|
+
jsts.geom.util.PolygonExtracter.prototype = new jsts.geom.GeometryFilter();
|
30
|
+
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @private
|
34
|
+
*/
|
35
|
+
jsts.geom.util.PolygonExtracter.prototype.comps = null;
|
36
|
+
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Extracts the {@link Polygon} elements from a single {@link Geometry} and adds
|
40
|
+
* them to the provided {@link List}.
|
41
|
+
*
|
42
|
+
* @param {jsts.geom.Geometry}
|
43
|
+
* geom the geometry from which to extract.
|
44
|
+
* @param {Array}
|
45
|
+
* list the list to add the extracted elements to.
|
46
|
+
* @return {Array}
|
47
|
+
*/
|
48
|
+
jsts.geom.util.PolygonExtracter.getPolygons = function(geom, list) {
|
49
|
+
if (list === undefined) {
|
50
|
+
list = [];
|
51
|
+
}
|
52
|
+
|
53
|
+
if (geom instanceof jsts.geom.Polygon) {
|
54
|
+
list.push(geom);
|
55
|
+
} else if (geom instanceof jsts.geom.GeometryCollection) {
|
56
|
+
geom.apply(new jsts.geom.util.PolygonExtracter(list));
|
57
|
+
}
|
58
|
+
// skip non-Polygonal elemental geometries
|
59
|
+
|
60
|
+
return list;
|
61
|
+
};
|
62
|
+
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @param {jsts.geom.Geometry}
|
66
|
+
* geom
|
67
|
+
*/
|
68
|
+
jsts.geom.util.PolygonExtracter.prototype.filter = function(geom) {
|
69
|
+
if (geom instanceof jsts.geom.Polygon)
|
70
|
+
this.comps.push(geom);
|
71
|
+
};
|
@@ -0,0 +1,145 @@
|
|
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/geom/Location.js
|
11
|
+
* @requires jsts/geomgraph/Position.js
|
12
|
+
*/
|
13
|
+
|
14
|
+
var Location = jsts.geom.Location;
|
15
|
+
var Position = jsts.geomgraph.Position;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* A Depth object records the topological depth of the sides of an Edge for up
|
19
|
+
* to two Geometries.
|
20
|
+
*
|
21
|
+
* @constructor
|
22
|
+
*/
|
23
|
+
jsts.geomgraph.Depth = function() {
|
24
|
+
// initialize depth array to a sentinel value
|
25
|
+
this.depth = [[], []];
|
26
|
+
for (var i = 0; i < 2; i++) {
|
27
|
+
for (var j = 0; j < 3; j++) {
|
28
|
+
this.depth[i][j] = jsts.geomgraph.Depth.NULL_VALUE;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
jsts.geomgraph.Depth.NULL_VALUE = -1;
|
34
|
+
|
35
|
+
jsts.geomgraph.Depth.depthAtLocation = function(location) {
|
36
|
+
if (location === Location.EXTERIOR)
|
37
|
+
return 0;
|
38
|
+
if (location === Location.INTERIOR)
|
39
|
+
return 1;
|
40
|
+
return jsts.geomgraph.Depth.NULL_VALUE;
|
41
|
+
};
|
42
|
+
|
43
|
+
jsts.geomgraph.Depth.prototype.depth = null;
|
44
|
+
|
45
|
+
|
46
|
+
jsts.geomgraph.Depth.prototype.getDepth = function(geomIndex, posIndex) {
|
47
|
+
return this.depth[geomIndex][posIndex];
|
48
|
+
};
|
49
|
+
|
50
|
+
jsts.geomgraph.Depth.prototype.setDepth = function(geomIndex, posIndex,
|
51
|
+
depthValue) {
|
52
|
+
this.depth[geomIndex][posIndex] = depthValue;
|
53
|
+
};
|
54
|
+
|
55
|
+
jsts.geomgraph.Depth.prototype.getLocation = function(geomIndex, posIndex) {
|
56
|
+
if (this.depth[geomIndex][posIndex] <= 0)
|
57
|
+
return Location.EXTERIOR;
|
58
|
+
return Location.INTERIOR;
|
59
|
+
};
|
60
|
+
|
61
|
+
jsts.geomgraph.Depth.prototype.add = function(geomIndex, posIndex, location) {
|
62
|
+
if (location === Location.INTERIOR)
|
63
|
+
this.depth[geomIndex][posIndex]++;
|
64
|
+
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* A Depth object is null (has never been initialized) if all depths are null.
|
68
|
+
*/
|
69
|
+
jsts.geomgraph.Depth.prototype.isNull = function() {
|
70
|
+
if (arguments.length > 0) {
|
71
|
+
return this.isNull2.apply(this, arguments);
|
72
|
+
}
|
73
|
+
|
74
|
+
for (var i = 0; i < 2; i++) {
|
75
|
+
for (var j = 0; j < 3; j++) {
|
76
|
+
if (this.depth[i][j] !== jsts.geomgraph.Depth.NULL_VALUE)
|
77
|
+
return false;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
return true;
|
81
|
+
};
|
82
|
+
|
83
|
+
jsts.geomgraph.Depth.prototype.isNull2 = function(geomIndex) {
|
84
|
+
if (arguments.length > 1) {
|
85
|
+
return this.isNull3.apply(this, arguments);
|
86
|
+
}
|
87
|
+
|
88
|
+
return this.depth[geomIndex][1] == jsts.geomgraph.Depth.NULL_VALUE;
|
89
|
+
};
|
90
|
+
|
91
|
+
jsts.geomgraph.Depth.prototype.isNull3 = function(geomIndex, posIndex) {
|
92
|
+
return this.depth[geomIndex][posIndex] == jsts.geomgraph.Depth.NULL_VALUE;
|
93
|
+
};
|
94
|
+
|
95
|
+
jsts.geomgraph.Depth.prototype.add = function(lbl) {
|
96
|
+
for (var i = 0; i < 2; i++) {
|
97
|
+
for (var j = 1; j < 3; j++) {
|
98
|
+
var loc = lbl.getLocation(i, j);
|
99
|
+
if (loc === Location.EXTERIOR || loc === Location.INTERIOR) {
|
100
|
+
// initialize depth if it is null, otherwise add this location value
|
101
|
+
if (this.isNull(i, j)) {
|
102
|
+
this.depth[i][j] = jsts.geomgraph.Depth.depthAtLocation(loc);
|
103
|
+
} else
|
104
|
+
this.depth[i][j] += jsts.geomgraph.Depth.depthAtLocation(loc);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
};
|
109
|
+
|
110
|
+
jsts.geomgraph.Depth.prototype.getDelta = function(geomIndex) {
|
111
|
+
return this.depth[geomIndex][Position.RIGHT] -
|
112
|
+
this.depth[geomIndex][Position.LEFT];
|
113
|
+
};
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Normalize the depths for each geometry, if they are non-null. A normalized
|
117
|
+
* depth has depth values in the set { 0, 1 }. Normalizing the depths involves
|
118
|
+
* reducing the depths by the same amount so that at least one of them is 0.
|
119
|
+
* If the remaining value is > 0, it is set to 1.
|
120
|
+
*/
|
121
|
+
jsts.geomgraph.Depth.prototype.normalize = function() {
|
122
|
+
for (var i = 0; i < 2; i++) {
|
123
|
+
if (!this.isNull(i)) {
|
124
|
+
var minDepth = this.depth[i][1];
|
125
|
+
if (this.depth[i][2] < minDepth)
|
126
|
+
minDepth = this.depth[i][2];
|
127
|
+
|
128
|
+
if (minDepth < 0)
|
129
|
+
minDepth = 0;
|
130
|
+
for (var j = 1; j < 3; j++) {
|
131
|
+
var newValue = 0;
|
132
|
+
if (this.depth[i][j] > minDepth)
|
133
|
+
newValue = 1;
|
134
|
+
this.depth[i][j] = newValue;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
};
|
139
|
+
|
140
|
+
jsts.geomgraph.Depth.prototype.toString = function() {
|
141
|
+
return 'A: ' + this.depth[0][1] + ',' + this.depth[0][2] + ' B: ' +
|
142
|
+
this.depth[1][1] + ',' + this.depth[1][2];
|
143
|
+
};
|
144
|
+
|
145
|
+
})();
|