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,143 @@
|
|
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
|
+
* Combines {@link Geometry}s
|
9
|
+
* to produce a {@link GeometryCollection} of the most appropriate type.
|
10
|
+
* Input geometries which are already collections
|
11
|
+
* will have their elements extracted first.
|
12
|
+
* No validation of the result geometry is performed.
|
13
|
+
* (The only case where invalidity is possible is where {@link Polygonal} geometries
|
14
|
+
* are combined and result in a self-intersection).
|
15
|
+
*
|
16
|
+
* @see GeometryFactory#buildGeometry
|
17
|
+
*/
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Creates a new combiner for a collection of geometries
|
23
|
+
*
|
24
|
+
* @param {Array} geoms the geometries to combine.
|
25
|
+
* @constructor
|
26
|
+
*/
|
27
|
+
jsts.geom.util.GeometryCombiner = function(geoms) {
|
28
|
+
this.geomFactory = jsts.geom.util.GeometryCombiner.extractFactory(geoms);
|
29
|
+
this.inputGeoms = geoms;
|
30
|
+
};
|
31
|
+
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Combines a collection of geometries.
|
35
|
+
*
|
36
|
+
* @param {ArrayList} geoms the geometries to combine.
|
37
|
+
* @return {Geometry} the combined geometry.
|
38
|
+
* @public
|
39
|
+
*/
|
40
|
+
jsts.geom.util.GeometryCombiner.combine = function(geoms) {
|
41
|
+
if (arguments.length>1) return this.combine2.apply(this, arguments);
|
42
|
+
var combiner = new jsts.geom.util.GeometryCombiner(geoms);
|
43
|
+
return combiner.combine();
|
44
|
+
};
|
45
|
+
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Combines two or three geometries.
|
49
|
+
*
|
50
|
+
* @param {Geometry} g0 a geometry to combine.
|
51
|
+
* @param {Geometry} g1 a geometry to combine.
|
52
|
+
* @param {Geometry=} [g2] a geometry to combine.
|
53
|
+
* @return {Geometry} the combined geometry.
|
54
|
+
* @public
|
55
|
+
*/
|
56
|
+
jsts.geom.util.GeometryCombiner.combine2 = function() {
|
57
|
+
var arrayList = new javascript.util.ArrayList();
|
58
|
+
Array.prototype.slice.call(arguments).forEach(function(a) {
|
59
|
+
arrayList.add(a);
|
60
|
+
});
|
61
|
+
var combiner = new jsts.geom.util.GeometryCombiner(arrayList);
|
62
|
+
return combiner.combine();
|
63
|
+
};
|
64
|
+
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @type {GeometryFactory}
|
68
|
+
* @private
|
69
|
+
*/
|
70
|
+
jsts.geom.util.GeometryCombiner.prototype.geomFactory = null;
|
71
|
+
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @type {boolean}
|
75
|
+
* @private
|
76
|
+
*/
|
77
|
+
jsts.geom.util.GeometryCombiner.prototype.skipEmpty = false;
|
78
|
+
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @type {Array}
|
82
|
+
* @private
|
83
|
+
*/
|
84
|
+
jsts.geom.util.GeometryCombiner.prototype.inputGeoms;
|
85
|
+
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Extracts the GeometryFactory used by the geometries in a collection
|
89
|
+
*
|
90
|
+
* @param {Array} geoms
|
91
|
+
* @return {jsts.geom.GeometryFactory} a GeometryFactory.
|
92
|
+
* @public
|
93
|
+
*/
|
94
|
+
jsts.geom.util.GeometryCombiner.extractFactory = function(geoms) {
|
95
|
+
if (geoms.isEmpty()) return null;
|
96
|
+
return geoms.iterator().next().getFactory();
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Computes the combination of the input geometries
|
102
|
+
* to produce the most appropriate {@link Geometry} or {@link GeometryCollection}
|
103
|
+
*
|
104
|
+
* @return {jsts.geom.Geometry} a Geometry which is the combination of the inputs.
|
105
|
+
* @public
|
106
|
+
*/
|
107
|
+
jsts.geom.util.GeometryCombiner.prototype.combine = function() {
|
108
|
+
var elems = new javascript.util.ArrayList(), i;
|
109
|
+
for (i = this.inputGeoms.iterator(); i.hasNext(); ) {
|
110
|
+
var g = i.next();
|
111
|
+
this.extractElements(g, elems);
|
112
|
+
}
|
113
|
+
|
114
|
+
if (elems.size() === 0) {
|
115
|
+
if (this.geomFactory !== null) {
|
116
|
+
// return an empty GC
|
117
|
+
return geomFactory.createGeometryCollection(null);
|
118
|
+
}
|
119
|
+
return null;
|
120
|
+
}
|
121
|
+
// return the "simplest possible" geometry
|
122
|
+
return this.geomFactory.buildGeometry(elems);
|
123
|
+
};
|
124
|
+
|
125
|
+
|
126
|
+
/**
|
127
|
+
* @param {jsts.geom.Geometry} geom
|
128
|
+
* @param {Array} elems
|
129
|
+
* @private
|
130
|
+
*/
|
131
|
+
jsts.geom.util.GeometryCombiner.prototype.extractElements = function(geom, elems) {
|
132
|
+
if (geom === null) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
for (var i = 0; i < geom.getNumGeometries(); i++) {
|
137
|
+
var elemGeom = geom.getGeometryN(i);
|
138
|
+
if (this.skipEmpty && elemGeom.isEmpty()) {
|
139
|
+
continue;
|
140
|
+
}
|
141
|
+
elems.add(elemGeom);
|
142
|
+
}
|
143
|
+
};
|
@@ -0,0 +1,76 @@
|
|
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
|
+
* Constructs a filter with a list in which to store the elements found.
|
15
|
+
*
|
16
|
+
* @param clz the class of the components to extract (null means all types).
|
17
|
+
* @param {[]} comps the list to extract into.
|
18
|
+
* @extends {jsts.geom.GeometryFilter}
|
19
|
+
* @constructor
|
20
|
+
*/
|
21
|
+
jsts.geom.util.GeometryExtracter = function(clz, comps) {
|
22
|
+
this.clz = clz;
|
23
|
+
this.comps = comps;
|
24
|
+
};
|
25
|
+
|
26
|
+
jsts.geom.util.GeometryExtracter.prototype = new jsts.geom.GeometryFilter();
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @private
|
31
|
+
*/
|
32
|
+
jsts.geom.util.GeometryExtracter.prototype.clz = null;
|
33
|
+
|
34
|
+
|
35
|
+
/**
|
36
|
+
* @private
|
37
|
+
* @type {javascript.util.List}
|
38
|
+
*/
|
39
|
+
jsts.geom.util.GeometryExtracter.prototype.comps = null;
|
40
|
+
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Extracts the components of type <tt>clz</tt> from a {@link Geometry}
|
44
|
+
* and adds them to the provided {@link List} if provided.
|
45
|
+
*
|
46
|
+
* @param {Geometry} geom the geometry from which to extract.
|
47
|
+
* @param {Object} clz
|
48
|
+
* @param {javascript.util.ArrayList} [list] the list to add the extracted elements to.
|
49
|
+
*
|
50
|
+
* @return {javascript.util.ArrayList}
|
51
|
+
*/
|
52
|
+
jsts.geom.util.GeometryExtracter.extract = function(geom, clz, list) {
|
53
|
+
list = list || new javascript.util.ArrayList();
|
54
|
+
if (geom instanceof clz) {
|
55
|
+
list.add(geom);
|
56
|
+
}
|
57
|
+
else if (geom instanceof jsts.geom.GeometryCollection ||
|
58
|
+
geom instanceof jsts.geom.MultiPoint ||
|
59
|
+
geom instanceof jsts.geom.MultiLineString ||
|
60
|
+
geom instanceof jsts.geom.MultiPolygon) {
|
61
|
+
geom.apply(new jsts.geom.util.GeometryExtracter(clz, list));
|
62
|
+
}
|
63
|
+
//skip non-LineString elemental geometries
|
64
|
+
|
65
|
+
return list;
|
66
|
+
};
|
67
|
+
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @param {Geometry} geom
|
71
|
+
*/
|
72
|
+
jsts.geom.util.GeometryExtracter.prototype.filter = function(geom) {
|
73
|
+
if (this.clz === null || geom instanceof this.clz) {
|
74
|
+
this.comps.add(geom);
|
75
|
+
}
|
76
|
+
};
|
@@ -0,0 +1,295 @@
|
|
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/geom/util/GeometryTransformer.java
|
10
|
+
* Revision: 381
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* A framework for processes which transform an input {@link Geometry} into an
|
15
|
+
* output {@link Geometry}, possibly changing its structure and type(s). This
|
16
|
+
* class is a framework for implementing subclasses which perform
|
17
|
+
* transformations on various different Geometry subclasses. It provides an easy
|
18
|
+
* way of applying specific transformations to given geometry types, while
|
19
|
+
* allowing unhandled types to be simply copied. Also, the framework ensures
|
20
|
+
* that if subcomponents change type the parent geometries types change
|
21
|
+
* appropriately to maintain valid structure. Subclasses will override whichever
|
22
|
+
* <code>transformX</code> methods they need to to handle particular Geometry
|
23
|
+
* types.
|
24
|
+
* <p>
|
25
|
+
* A typically usage would be a transformation class that transforms
|
26
|
+
* <tt>Polygons</tt> into <tt>Polygons</tt>, <tt>LineStrings</tt> or
|
27
|
+
* <tt>Points</tt>, depending on the geometry of the input (For instance, a
|
28
|
+
* simplification operation). This class would likely need to override the
|
29
|
+
* {@link #transformMultiPolygon(MultiPolygon, Geometry)transformMultiPolygon}
|
30
|
+
* method to ensure that if input Polygons change type the result is a
|
31
|
+
* <tt>GeometryCollection</tt>, not a <tt>MultiPolygon</tt>.
|
32
|
+
* <p>
|
33
|
+
* The default behaviour of this class is simply to recursively transform each
|
34
|
+
* Geometry component into an identical object by deep copying down to the level
|
35
|
+
* of, but not including, coordinates.
|
36
|
+
* <p>
|
37
|
+
* All <code>transformX</code> methods may return <code>null</code>, to
|
38
|
+
* avoid creating empty or invalid geometry objects. This will be handled
|
39
|
+
* correctly by the transformer. <code>transform<i>XXX</i></code> methods
|
40
|
+
* should always return valid geometry - if they cannot do this they should
|
41
|
+
* return <code>null</code> (for instance, it may not be possible for a
|
42
|
+
* transformLineString implementation to return at least two points - in this
|
43
|
+
* case, it should return <code>null</code>). The
|
44
|
+
* {@link #transform(Geometry)transform} method itself will always return a
|
45
|
+
* non-null Geometry object (but this may be empty).
|
46
|
+
*
|
47
|
+
* @see GeometryEditor
|
48
|
+
*/
|
49
|
+
|
50
|
+
(function() {
|
51
|
+
|
52
|
+
var ArrayList = javascript.util.ArrayList;
|
53
|
+
|
54
|
+
var GeometryTransformer = function() {
|
55
|
+
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
GeometryTransformer.prototype.inputGeom = null;
|
60
|
+
|
61
|
+
GeometryTransformer.prototype.factory = null;
|
62
|
+
|
63
|
+
// these could eventually be exposed to clients
|
64
|
+
/**
|
65
|
+
* <code>true</code> if empty geometries should not be included in the
|
66
|
+
* result
|
67
|
+
*/
|
68
|
+
GeometryTransformer.prototype.pruneEmptyGeometry = true;
|
69
|
+
|
70
|
+
/**
|
71
|
+
* <code>true</code> if a homogenous collection result from a
|
72
|
+
* {@link GeometryCollection} should still be a general GeometryCollection
|
73
|
+
*/
|
74
|
+
GeometryTransformer.prototype.preserveGeometryCollectionType = true;
|
75
|
+
|
76
|
+
/**
|
77
|
+
* <code>true</code> if the output from a collection argument should still
|
78
|
+
* be a collection
|
79
|
+
*/
|
80
|
+
GeometryTransformer.prototype.preserveCollections = false;
|
81
|
+
|
82
|
+
/**
|
83
|
+
* <code>true</code> if the type of the input should be preserved
|
84
|
+
*/
|
85
|
+
GeometryTransformer.prototype.reserveType = false;
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Utility function to make input geometry available
|
89
|
+
*
|
90
|
+
* @return the input geometry.
|
91
|
+
*/
|
92
|
+
GeometryTransformer.prototype.getInputGeometry = function() {
|
93
|
+
return this.inputGeom;
|
94
|
+
};
|
95
|
+
|
96
|
+
GeometryTransformer.prototype.transform = function(inputGeom) {
|
97
|
+
this.inputGeom = inputGeom;
|
98
|
+
this.factory = inputGeom.getFactory();
|
99
|
+
|
100
|
+
if (inputGeom instanceof jsts.geom.Point)
|
101
|
+
return this.transformPoint(inputGeom, null);
|
102
|
+
if (inputGeom instanceof jsts.geom.MultiPoint)
|
103
|
+
return this.transformMultiPoint(inputGeom, null);
|
104
|
+
if (inputGeom instanceof jsts.geom.LinearRing)
|
105
|
+
return this.transformLinearRing(inputGeom, null);
|
106
|
+
if (inputGeom instanceof jsts.geom.LineString)
|
107
|
+
return this.transformLineString(inputGeom, null);
|
108
|
+
if (inputGeom instanceof jsts.geom.MultiLineString)
|
109
|
+
return this.transformMultiLineString(inputGeom, null);
|
110
|
+
if (inputGeom instanceof jsts.geom.Polygon)
|
111
|
+
return this.transformPolygon(inputGeom, null);
|
112
|
+
if (inputGeom instanceof jsts.geom.MultiPolygon)
|
113
|
+
return this.transformMultiPolygon(inputGeom, null);
|
114
|
+
if (inputGeom instanceof jsts.geom.GeometryCollection)
|
115
|
+
return this.transformGeometryCollection(inputGeom, null);
|
116
|
+
|
117
|
+
throw new jsts.error.IllegalArgumentException('Unknown Geometry subtype: ' +
|
118
|
+
inputGeom.getClass().getName());
|
119
|
+
};
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Convenience method which provides standard way of creating a
|
123
|
+
* {@link CoordinateSequence}
|
124
|
+
*
|
125
|
+
* @param coords
|
126
|
+
* the coordinate array to copy.
|
127
|
+
* @return a coordinate sequence for the array.
|
128
|
+
*/
|
129
|
+
GeometryTransformer.prototype.createCoordinateSequence = function(coords) {
|
130
|
+
return this.factory.getCoordinateSequenceFactory().create(coords);
|
131
|
+
};
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Convenience method which provides statndard way of copying
|
135
|
+
* {@link CoordinateSequence}s
|
136
|
+
*
|
137
|
+
* @param seq
|
138
|
+
* the sequence to copy.
|
139
|
+
* @return a deep copy of the sequence.
|
140
|
+
*/
|
141
|
+
GeometryTransformer.prototype.copy = function(seq) {
|
142
|
+
return seq.clone();
|
143
|
+
};
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Transforms a {@link CoordinateSequence}. This method should always return
|
147
|
+
* a valid coordinate list for the desired result type. (E.g. a coordinate
|
148
|
+
* list for a LineString must have 0 or at least 2 points). If this is not
|
149
|
+
* possible, return an empty sequence - this will be pruned out.
|
150
|
+
*
|
151
|
+
* @param coords
|
152
|
+
* the coordinates to transform.
|
153
|
+
* @param parent
|
154
|
+
* the parent geometry.
|
155
|
+
* @return the transformed coordinates.
|
156
|
+
*/
|
157
|
+
GeometryTransformer.prototype.transformCoordinates = function(coords, parent) {
|
158
|
+
return this.copy(coords);
|
159
|
+
};
|
160
|
+
|
161
|
+
GeometryTransformer.prototype.transformPoint = function(geom, parent) {
|
162
|
+
return this.factory.createPoint(this.transformCoordinates(geom
|
163
|
+
.getCoordinateSequence(), geom));
|
164
|
+
};
|
165
|
+
|
166
|
+
GeometryTransformer.prototype.transformMultiPoint = function(geom, parent) {
|
167
|
+
var transGeomList = new ArrayList();
|
168
|
+
for (var i = 0; i < geom.getNumGeometries(); i++) {
|
169
|
+
var transformGeom = this.transformPoint(geom.getGeometryN(i), geom);
|
170
|
+
if (transformGeom == null)
|
171
|
+
continue;
|
172
|
+
if (transformGeom.isEmpty())
|
173
|
+
continue;
|
174
|
+
transGeomList.add(transformGeom);
|
175
|
+
}
|
176
|
+
return this.factory.buildGeometry(transGeomList);
|
177
|
+
};
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Transforms a LinearRing. The transformation of a LinearRing may result in a
|
181
|
+
* coordinate sequence which does not form a structurally valid ring (i.e. a
|
182
|
+
* degnerate ring of 3 or fewer points). In this case a LineString is
|
183
|
+
* returned. Subclasses may wish to override this method and check for this
|
184
|
+
* situation (e.g. a subclass may choose to eliminate degenerate linear rings)
|
185
|
+
*
|
186
|
+
* @param geom
|
187
|
+
* the ring to simplify.
|
188
|
+
* @param parent
|
189
|
+
* the parent geometry.
|
190
|
+
* @return a LinearRing if the transformation resulted in a structurally valid
|
191
|
+
* ring.
|
192
|
+
* @return a LineString if the transformation caused the LinearRing to
|
193
|
+
* collapse to 3 or fewer points.
|
194
|
+
*/
|
195
|
+
GeometryTransformer.prototype.transformLinearRing = function(geom, parent) {
|
196
|
+
var seq = this.transformCoordinates(geom.getCoordinateSequence(), geom);
|
197
|
+
var seqSize = seq.length;
|
198
|
+
// ensure a valid LinearRing
|
199
|
+
if (seqSize > 0 && seqSize < 4 && !this.preserveType)
|
200
|
+
return this.factory.createLineString(seq);
|
201
|
+
return this.factory.createLinearRing(seq);
|
202
|
+
|
203
|
+
};
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Transforms a {@link LineString} geometry.
|
207
|
+
*
|
208
|
+
* @param geom
|
209
|
+
* @param parent
|
210
|
+
* @return
|
211
|
+
*/
|
212
|
+
GeometryTransformer.prototype.transformLineString = function(geom, parent) {
|
213
|
+
// should check for 1-point sequences and downgrade them to points
|
214
|
+
return this.factory.createLineString(this.transformCoordinates(geom
|
215
|
+
.getCoordinateSequence(), geom));
|
216
|
+
};
|
217
|
+
|
218
|
+
GeometryTransformer.prototype.transformMultiLineString = function(geom,
|
219
|
+
parent) {
|
220
|
+
var transGeomList = new ArrayList();
|
221
|
+
for (var i = 0; i < geom.getNumGeometries(); i++) {
|
222
|
+
var transformGeom = this.transformLineString(geom.getGeometryN(i), geom);
|
223
|
+
if (transformGeom == null)
|
224
|
+
continue;
|
225
|
+
if (transformGeom.isEmpty())
|
226
|
+
continue;
|
227
|
+
transGeomList.add(transformGeom);
|
228
|
+
}
|
229
|
+
return this.factory.buildGeometry(transGeomList);
|
230
|
+
};
|
231
|
+
|
232
|
+
GeometryTransformer.prototype.transformPolygon = function(geom, parent) {
|
233
|
+
var isAllValidLinearRings = true;
|
234
|
+
var shell = this.transformLinearRing(geom.getExteriorRing(), geom);
|
235
|
+
|
236
|
+
if (shell == null || !(shell instanceof jsts.geom.LinearRing) ||
|
237
|
+
shell.isEmpty())
|
238
|
+
isAllValidLinearRings = false;
|
239
|
+
|
240
|
+
var holes = new ArrayList();
|
241
|
+
for (var i = 0; i < geom.getNumInteriorRing(); i++) {
|
242
|
+
var hole = this.transformLinearRing(geom.getInteriorRingN(i), geom);
|
243
|
+
if (hole == null || hole.isEmpty()) {
|
244
|
+
continue;
|
245
|
+
}
|
246
|
+
if (!(hole instanceof jsts.geom.LinearRing))
|
247
|
+
isAllValidLinearRings = false;
|
248
|
+
|
249
|
+
holes.add(hole);
|
250
|
+
}
|
251
|
+
|
252
|
+
if (isAllValidLinearRings)
|
253
|
+
return this.factory.createPolygon(shell, holes.toArray());
|
254
|
+
else {
|
255
|
+
var components = new ArrayList();
|
256
|
+
if (shell != null)
|
257
|
+
components.add(shell);
|
258
|
+
components.addAll(holes);
|
259
|
+
return this.factory.buildGeometry(components);
|
260
|
+
}
|
261
|
+
};
|
262
|
+
|
263
|
+
GeometryTransformer.prototype.transformMultiPolygon = function(geom, parent) {
|
264
|
+
var transGeomList = new ArrayList();
|
265
|
+
for (var i = 0; i < geom.getNumGeometries(); i++) {
|
266
|
+
var transformGeom = this.transformPolygon(geom.getGeometryN(i), geom);
|
267
|
+
if (transformGeom == null)
|
268
|
+
continue;
|
269
|
+
if (transformGeom.isEmpty())
|
270
|
+
continue;
|
271
|
+
transGeomList.add(transformGeom);
|
272
|
+
}
|
273
|
+
return this.factory.buildGeometry(transGeomList);
|
274
|
+
};
|
275
|
+
|
276
|
+
GeometryTransformer.prototype.transformGeometryCollection = function(geom,
|
277
|
+
parent) {
|
278
|
+
var transGeomList = new ArrayList();
|
279
|
+
for (var i = 0; i < geom.getNumGeometries(); i++) {
|
280
|
+
var transformGeom = this.transform(geom.getGeometryN(i));
|
281
|
+
if (transformGeom == null)
|
282
|
+
continue;
|
283
|
+
if (this.pruneEmptyGeometry && transformGeom.isEmpty())
|
284
|
+
continue;
|
285
|
+
transGeomList.add(transformGeom);
|
286
|
+
}
|
287
|
+
if (this.preserveGeometryCollectionType)
|
288
|
+
return this.factory.createGeometryCollection(GeometryFactory
|
289
|
+
.toGeometryArray(transGeomList));
|
290
|
+
return this.factory.buildGeometry(transGeomList);
|
291
|
+
};
|
292
|
+
|
293
|
+
jsts.geom.util.GeometryTransformer = GeometryTransformer;
|
294
|
+
|
295
|
+
})();
|