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,230 @@
|
|
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/Geometry.js
|
11
|
+
*/
|
12
|
+
|
13
|
+
var Geometry = jsts.geom.Geometry;
|
14
|
+
var TreeSet = javascript.util.TreeSet;
|
15
|
+
var Arrays = javascript.util.Arrays;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @constructor
|
19
|
+
* @extends jsts.geom.Geometry
|
20
|
+
*/
|
21
|
+
jsts.geom.GeometryCollection = function(geometries, factory) {
|
22
|
+
this.geometries = geometries || [];
|
23
|
+
this.factory = factory;
|
24
|
+
};
|
25
|
+
|
26
|
+
jsts.geom.GeometryCollection.prototype = new Geometry();
|
27
|
+
jsts.geom.GeometryCollection.constructor = jsts.geom.GeometryCollection;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @return {boolean}
|
31
|
+
*/
|
32
|
+
jsts.geom.GeometryCollection.prototype.isEmpty = function() {
|
33
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
34
|
+
var geometry = this.getGeometryN(i);
|
35
|
+
|
36
|
+
if (!geometry.isEmpty()) {
|
37
|
+
return false;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return true;
|
41
|
+
};
|
42
|
+
|
43
|
+
jsts.geom.Geometry.prototype.getArea = function() {
|
44
|
+
var area = 0.0;
|
45
|
+
|
46
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
47
|
+
area += this.getGeometryN(i).getArea();
|
48
|
+
}
|
49
|
+
|
50
|
+
return area;
|
51
|
+
};
|
52
|
+
|
53
|
+
jsts.geom.Geometry.prototype.getLength = function() {
|
54
|
+
var length = 0.0;
|
55
|
+
|
56
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
57
|
+
length += this.getGeometryN(i).getLength();
|
58
|
+
}
|
59
|
+
|
60
|
+
return length;
|
61
|
+
};
|
62
|
+
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @return {Coordinate}
|
66
|
+
*/
|
67
|
+
jsts.geom.GeometryCollection.prototype.getCoordinate = function() {
|
68
|
+
if (this.isEmpty())
|
69
|
+
return null;
|
70
|
+
|
71
|
+
return this.getGeometryN(0).getCoordinate();
|
72
|
+
};
|
73
|
+
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Collects all coordinates of all subgeometries into an Array.
|
77
|
+
*
|
78
|
+
* Note that while changes to the coordinate objects themselves may modify the
|
79
|
+
* Geometries in place, the returned Array as such is only a temporary
|
80
|
+
* container which is not synchronized back.
|
81
|
+
*
|
82
|
+
* @return {Coordinate[]} the collected coordinates.
|
83
|
+
*/
|
84
|
+
jsts.geom.GeometryCollection.prototype.getCoordinates = function() {
|
85
|
+
var coordinates = [];
|
86
|
+
var k = -1;
|
87
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
88
|
+
var geometry = this.getGeometryN(i);
|
89
|
+
|
90
|
+
var childCoordinates = geometry.getCoordinates();
|
91
|
+
for (var j = 0; j < childCoordinates.length; j++) {
|
92
|
+
k++;
|
93
|
+
coordinates[k] = childCoordinates[j];
|
94
|
+
}
|
95
|
+
}
|
96
|
+
return coordinates;
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
/**
|
101
|
+
* @return {int}
|
102
|
+
*/
|
103
|
+
jsts.geom.GeometryCollection.prototype.getNumGeometries = function() {
|
104
|
+
return this.geometries.length;
|
105
|
+
};
|
106
|
+
|
107
|
+
|
108
|
+
/**
|
109
|
+
* @param {int}
|
110
|
+
* n
|
111
|
+
* @return {Geometry}
|
112
|
+
*/
|
113
|
+
jsts.geom.GeometryCollection.prototype.getGeometryN = function(n) {
|
114
|
+
var geometry = this.geometries[n];
|
115
|
+
if (geometry instanceof jsts.geom.Coordinate) {
|
116
|
+
geometry = new jsts.geom.Point(geometry);
|
117
|
+
}
|
118
|
+
return geometry;
|
119
|
+
};
|
120
|
+
|
121
|
+
|
122
|
+
/**
|
123
|
+
* @param {Geometry}
|
124
|
+
* other
|
125
|
+
* @param {double}
|
126
|
+
* tolerance
|
127
|
+
* @return {boolean}
|
128
|
+
*/
|
129
|
+
jsts.geom.GeometryCollection.prototype.equalsExact = function(other,
|
130
|
+
tolerance) {
|
131
|
+
if (!this.isEquivalentClass(other)) {
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
if (this.geometries.length !== other.geometries.length) {
|
135
|
+
return false;
|
136
|
+
}
|
137
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
138
|
+
var geometry = this.getGeometryN(i);
|
139
|
+
|
140
|
+
if (!geometry.equalsExact(other.getGeometryN(i), tolerance)) {
|
141
|
+
return false;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
return true;
|
145
|
+
};
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Creates and returns a full copy of this {@link GeometryCollection} object.
|
149
|
+
* (including all coordinates contained by it).
|
150
|
+
*
|
151
|
+
* @return a clone of this instance.
|
152
|
+
*/
|
153
|
+
jsts.geom.GeometryCollection.prototype.clone = function() {
|
154
|
+
var geometries = [];
|
155
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
156
|
+
geometries.push(this.geometries[i].clone());
|
157
|
+
}
|
158
|
+
return this.factory.createGeometryCollection(geometries);
|
159
|
+
};
|
160
|
+
|
161
|
+
jsts.geom.GeometryCollection.prototype.normalize = function() {
|
162
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
163
|
+
this.getGeometryN(i).normalize();
|
164
|
+
}
|
165
|
+
// TODO: might need to supply comparison function
|
166
|
+
this.geometries.sort();
|
167
|
+
};
|
168
|
+
|
169
|
+
jsts.geom.GeometryCollection.prototype.compareToSameClass = function(o) {
|
170
|
+
var theseElements = new TreeSet(Arrays.asList(this.geometries));
|
171
|
+
var otherElements = new TreeSet(Arrays.asList(o.geometries));
|
172
|
+
return this.compare(theseElements, otherElements);
|
173
|
+
};
|
174
|
+
|
175
|
+
jsts.geom.GeometryCollection.prototype.apply = function(filter) {
|
176
|
+
if (filter instanceof jsts.geom.GeometryFilter ||
|
177
|
+
filter instanceof jsts.geom.GeometryComponentFilter) {
|
178
|
+
filter.filter(this);
|
179
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
180
|
+
this.getGeometryN(i).apply(filter);
|
181
|
+
}
|
182
|
+
} else if (filter instanceof jsts.geom.CoordinateFilter) {
|
183
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
184
|
+
this.getGeometryN(i).apply(filter);
|
185
|
+
}
|
186
|
+
} else if (filter instanceof jsts.geom.CoordinateSequenceFilter) {
|
187
|
+
this.apply2.apply(this, arguments);
|
188
|
+
}
|
189
|
+
};
|
190
|
+
|
191
|
+
jsts.geom.GeometryCollection.prototype.apply2 = function(filter) {
|
192
|
+
if (this.geometries.length == 0)
|
193
|
+
return;
|
194
|
+
for (var i = 0; i < this.geometries.length; i++) {
|
195
|
+
this.geometries[i].apply(filter);
|
196
|
+
if (filter.isDone()) {
|
197
|
+
break;
|
198
|
+
}
|
199
|
+
}
|
200
|
+
if (filter.isGeometryChanged()) {
|
201
|
+
// TODO: call this.geometryChanged(); when ported
|
202
|
+
}
|
203
|
+
};
|
204
|
+
|
205
|
+
jsts.geom.GeometryCollection.prototype.getDimension = function() {
|
206
|
+
var dimension = jsts.geom.Dimension.FALSE;
|
207
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
208
|
+
var geometry = this.getGeometryN(i);
|
209
|
+
dimension = Math.max(dimension, geometry.getDimension());
|
210
|
+
}
|
211
|
+
return dimension;
|
212
|
+
};
|
213
|
+
|
214
|
+
/**
|
215
|
+
* @protected
|
216
|
+
*/
|
217
|
+
jsts.geom.GeometryCollection.prototype.computeEnvelopeInternal = function() {
|
218
|
+
var envelope = new jsts.geom.Envelope();
|
219
|
+
for (var i = 0, len = this.geometries.length; i < len; i++) {
|
220
|
+
var geometry = this.getGeometryN(i);
|
221
|
+
envelope.expandToInclude(geometry.getEnvelopeInternal());
|
222
|
+
}
|
223
|
+
return envelope;
|
224
|
+
};
|
225
|
+
|
226
|
+
jsts.geom.GeometryCollection.prototype.CLASS_NAME = 'jsts.geom.GeometryCollection';
|
227
|
+
|
228
|
+
})();
|
229
|
+
|
230
|
+
// TODO: port rest
|
@@ -0,0 +1,36 @@
|
|
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
|
+
* <code>Geometry</code> classes support the concept of applying a
|
10
|
+
* <code>GeometryComponentFilter</code> filter to the <code>Geometry</code>.
|
11
|
+
* The filter is applied to every component of the <code>Geometry</code> which
|
12
|
+
* is itself a <code>Geometry</code> and which does not itself contain any
|
13
|
+
* components. (For instance, all the {@link LinearRing}s in {@link Polygon}s
|
14
|
+
* are visited, but in a {@link MultiPolygon} the {@link Polygon}s themselves
|
15
|
+
* are not visited.) Thus the only classes of Geometry which must be handled as
|
16
|
+
* arguments to {@link #filter} are {@link LineString}s, {@link LinearRing}s
|
17
|
+
* and {@link Point}s.
|
18
|
+
* <p>
|
19
|
+
* A <code>GeometryComponentFilter</code> filter can either record information
|
20
|
+
* about the <code>Geometry</code> or change the <code>Geometry</code> in
|
21
|
+
* some way. <code>GeometryComponentFilter</code> is an example of the
|
22
|
+
* Gang-of-Four Visitor pattern.
|
23
|
+
*/
|
24
|
+
jsts.geom.GeometryComponentFilter = function() {
|
25
|
+
};
|
26
|
+
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Performs an operation with or on <code>geom</code>.
|
30
|
+
*
|
31
|
+
* @param {Geometry}
|
32
|
+
* geom a <code>Geometry</code> to which the filter is applied.
|
33
|
+
*/
|
34
|
+
jsts.geom.GeometryComponentFilter.prototype.filter = function(geom) {
|
35
|
+
throw new jsts.error.AbstractMethodInvocationError();
|
36
|
+
};
|
@@ -0,0 +1,263 @@
|
|
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
|
+
* Supplies a set of utility methods for building Geometry objects from lists
|
9
|
+
* of Coordinates.
|
10
|
+
*
|
11
|
+
* Note that the factory constructor methods do <b>not</b> change the input
|
12
|
+
* coordinates in any way.
|
13
|
+
*
|
14
|
+
* In particular, they are not rounded to the supplied <tt>PrecisionModel</tt>.
|
15
|
+
* It is assumed that input Coordinates meet the given precision.
|
16
|
+
*/
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @requires jsts/geom/PrecisionModel.js
|
20
|
+
*/
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Constructs a GeometryFactory that generates Geometries having a floating
|
24
|
+
* PrecisionModel and a spatial-reference ID of 0.
|
25
|
+
*
|
26
|
+
* @constructor
|
27
|
+
*/
|
28
|
+
jsts.geom.GeometryFactory = function(precisionModel) {
|
29
|
+
this.precisionModel = precisionModel || new jsts.geom.PrecisionModel();
|
30
|
+
};
|
31
|
+
|
32
|
+
jsts.geom.GeometryFactory.prototype.precisionModel = null;
|
33
|
+
|
34
|
+
jsts.geom.GeometryFactory.prototype.getPrecisionModel = function() {
|
35
|
+
return this.precisionModel;
|
36
|
+
};
|
37
|
+
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Creates a Point using the given Coordinate; a null Coordinate will create an
|
41
|
+
* empty Geometry.
|
42
|
+
*
|
43
|
+
* @param {Coordinate}
|
44
|
+
* coordinate Coordinate to base this Point on.
|
45
|
+
* @return {Point} A new Point.
|
46
|
+
*/
|
47
|
+
jsts.geom.GeometryFactory.prototype.createPoint = function(coordinate) {
|
48
|
+
var point = new jsts.geom.Point(coordinate, this);
|
49
|
+
|
50
|
+
return point;
|
51
|
+
};
|
52
|
+
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Creates a LineString using the given Coordinates; a null or empty array will
|
56
|
+
* create an empty LineString. Consecutive points must not be equal.
|
57
|
+
*
|
58
|
+
* @param {Coordinate[]}
|
59
|
+
* coordinates an array without null elements, or an empty array, or
|
60
|
+
* null.
|
61
|
+
* @return {LineString} A new LineString.
|
62
|
+
*/
|
63
|
+
jsts.geom.GeometryFactory.prototype.createLineString = function(coordinates) {
|
64
|
+
var lineString = new jsts.geom.LineString(coordinates, this);
|
65
|
+
|
66
|
+
return lineString;
|
67
|
+
};
|
68
|
+
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Creates a LinearRing using the given Coordinates; a null or empty array will
|
72
|
+
* create an empty LinearRing. The points must form a closed and simple
|
73
|
+
* linestring. Consecutive points must not be equal.
|
74
|
+
*
|
75
|
+
* @param {Coordinate[]}
|
76
|
+
* coordinates an array without null elements, or an empty array, or
|
77
|
+
* null.
|
78
|
+
* @return {LinearRing} A new LinearRing.
|
79
|
+
*/
|
80
|
+
jsts.geom.GeometryFactory.prototype.createLinearRing = function(coordinates) {
|
81
|
+
var linearRing = new jsts.geom.LinearRing(coordinates, this);
|
82
|
+
|
83
|
+
return linearRing;
|
84
|
+
};
|
85
|
+
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Constructs a <code>Polygon</code> with the given exterior boundary and
|
89
|
+
* interior boundaries.
|
90
|
+
*
|
91
|
+
* @param {LinearRing}
|
92
|
+
* shell the outer boundary of the new <code>Polygon</code>, or
|
93
|
+
* <code>null</code> or an empty <code>LinearRing</code> if the
|
94
|
+
* empty geometry is to be created.
|
95
|
+
* @param {LinearRing[]}
|
96
|
+
* holes the inner boundaries of the new <code>Polygon</code>, or
|
97
|
+
* <code>null</code> or empty <code>LinearRing</code> s if the
|
98
|
+
* empty geometry is to be created.
|
99
|
+
* @return {Polygon} A new Polygon.
|
100
|
+
*/
|
101
|
+
jsts.geom.GeometryFactory.prototype.createPolygon = function(shell, holes) {
|
102
|
+
var polygon = new jsts.geom.Polygon(shell, holes, this);
|
103
|
+
|
104
|
+
return polygon;
|
105
|
+
};
|
106
|
+
|
107
|
+
|
108
|
+
jsts.geom.GeometryFactory.prototype.createMultiPoint = function(points) {
|
109
|
+
if (points && points[0] instanceof jsts.geom.Coordinate) {
|
110
|
+
var converted = [];
|
111
|
+
var i;
|
112
|
+
for (i = 0; i < points.length; i++) {
|
113
|
+
converted.push(this.createPoint(points[i]));
|
114
|
+
}
|
115
|
+
points = converted;
|
116
|
+
}
|
117
|
+
|
118
|
+
return new jsts.geom.MultiPoint(points, this);
|
119
|
+
};
|
120
|
+
|
121
|
+
jsts.geom.GeometryFactory.prototype.createMultiLineString = function(
|
122
|
+
lineStrings) {
|
123
|
+
return new jsts.geom.MultiLineString(lineStrings, this);
|
124
|
+
};
|
125
|
+
|
126
|
+
jsts.geom.GeometryFactory.prototype.createMultiPolygon = function(polygons) {
|
127
|
+
return new jsts.geom.MultiPolygon(polygons, this);
|
128
|
+
};
|
129
|
+
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Build an appropriate <code>Geometry</code>, <code>MultiGeometry</code>,
|
133
|
+
* or <code>GeometryCollection</code> to contain the <code>Geometry</code>s
|
134
|
+
* in it. For example:<br>
|
135
|
+
*
|
136
|
+
* <ul>
|
137
|
+
* <li> If <code>geomList</code> contains a single <code>Polygon</code>,
|
138
|
+
* the <code>Polygon</code> is returned.
|
139
|
+
* <li> If <code>geomList</code> contains several <code>Polygon</code>s, a
|
140
|
+
* <code>MultiPolygon</code> is returned.
|
141
|
+
* <li> If <code>geomList</code> contains some <code>Polygon</code>s and
|
142
|
+
* some <code>LineString</code>s, a <code>GeometryCollection</code> is
|
143
|
+
* returned.
|
144
|
+
* <li> If <code>geomList</code> is empty, an empty
|
145
|
+
* <code>GeometryCollection</code> is returned
|
146
|
+
* </ul>
|
147
|
+
*
|
148
|
+
* Note that this method does not "flatten" Geometries in the input, and hence
|
149
|
+
* if any MultiGeometries are contained in the input a GeometryCollection
|
150
|
+
* containing them will be returned.
|
151
|
+
*
|
152
|
+
* @param geomList
|
153
|
+
* the <code>Geometry</code>s to combine.
|
154
|
+
* @return {Geometry} a <code>Geometry</code> of the "smallest", "most
|
155
|
+
* type-specific" class that can contain the elements of
|
156
|
+
* <code>geomList</code> .
|
157
|
+
*/
|
158
|
+
jsts.geom.GeometryFactory.prototype.buildGeometry = function(geomList) {
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Determine some facts about the geometries in the list
|
162
|
+
*/
|
163
|
+
var geomClass = null;
|
164
|
+
var isHeterogeneous = false;
|
165
|
+
var hasGeometryCollection = false;
|
166
|
+
for (var i = geomList.iterator(); i.hasNext();) {
|
167
|
+
var geom = i.next();
|
168
|
+
|
169
|
+
var partClass = geom.CLASS_NAME;
|
170
|
+
|
171
|
+
if (geomClass === null) {
|
172
|
+
geomClass = partClass;
|
173
|
+
}
|
174
|
+
if (!(partClass === geomClass)) {
|
175
|
+
isHeterogeneous = true;
|
176
|
+
}
|
177
|
+
if (geom.isGeometryCollectionBase())
|
178
|
+
hasGeometryCollection = true;
|
179
|
+
}
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Now construct an appropriate geometry to return
|
183
|
+
*/
|
184
|
+
// for the empty geometry, return an empty GeometryCollection
|
185
|
+
if (geomClass === null) {
|
186
|
+
return this.createGeometryCollection(null);
|
187
|
+
}
|
188
|
+
if (isHeterogeneous || hasGeometryCollection) {
|
189
|
+
return this.createGeometryCollection(geomList.toArray());
|
190
|
+
}
|
191
|
+
// at this point we know the collection is hetereogenous.
|
192
|
+
// Determine the type of the result from the first Geometry in the list
|
193
|
+
// this should always return a geometry, since otherwise an empty collection
|
194
|
+
// would have already been returned
|
195
|
+
var geom0 = geomList.get(0);
|
196
|
+
var isCollection = geomList.size() > 1;
|
197
|
+
if (isCollection) {
|
198
|
+
if (geom0 instanceof jsts.geom.Polygon) {
|
199
|
+
return this.createMultiPolygon(geomList.toArray());
|
200
|
+
} else if (geom0 instanceof jsts.geom.LineString) {
|
201
|
+
return this.createMultiLineString(geomList.toArray());
|
202
|
+
} else if (geom0 instanceof jsts.geom.Point) {
|
203
|
+
return this.createMultiPoint(geomList.toArray());
|
204
|
+
}
|
205
|
+
jsts.util.Assert.shouldNeverReachHere('Unhandled class: ' + geom0);
|
206
|
+
}
|
207
|
+
return geom0;
|
208
|
+
};
|
209
|
+
|
210
|
+
jsts.geom.GeometryFactory.prototype.createGeometryCollection = function(
|
211
|
+
geometries) {
|
212
|
+
return new jsts.geom.GeometryCollection(geometries, this);
|
213
|
+
};
|
214
|
+
|
215
|
+
/**
|
216
|
+
* Creates a {@link Geometry} with the same extent as the given envelope. The
|
217
|
+
* Geometry returned is guaranteed to be valid. To provide this behaviour, the
|
218
|
+
* following cases occur:
|
219
|
+
* <p>
|
220
|
+
* If the <code>Envelope</code> is:
|
221
|
+
* <ul>
|
222
|
+
* <li>null : returns an empty {@link Point}
|
223
|
+
* <li>a point : returns a non-empty {@link Point}
|
224
|
+
* <li>a line : returns a two-point {@link LineString}
|
225
|
+
* <li>a rectangle : returns a {@link Polygon}> whose points are (minx, miny),
|
226
|
+
* (minx, maxy), (maxx, maxy), (maxx, miny), (minx, miny).
|
227
|
+
* </ul>
|
228
|
+
*
|
229
|
+
* @param {jsts.geom.Envelope}
|
230
|
+
* envelope the <code>Envelope</code> to convert.
|
231
|
+
* @return {jsts.geom.Geometry} an empty <code>Point</code> (for null
|
232
|
+
* <code>Envelope</code>s), a <code>Point</code> (when min x = max
|
233
|
+
* x and min y = max y) or a <code>Polygon</code> (in all other cases).
|
234
|
+
*/
|
235
|
+
jsts.geom.GeometryFactory.prototype.toGeometry = function(envelope) {
|
236
|
+
// null envelope - return empty point geometry
|
237
|
+
if (envelope.isNull()) {
|
238
|
+
return this.createPoint(null);
|
239
|
+
}
|
240
|
+
|
241
|
+
// point?
|
242
|
+
if (envelope.getMinX() === envelope.getMaxX() &&
|
243
|
+
envelope.getMinY() === envelope.getMaxY()) {
|
244
|
+
return this.createPoint(new jsts.geom.Coordinate(envelope.getMinX(),
|
245
|
+
envelope.getMinY()));
|
246
|
+
}
|
247
|
+
|
248
|
+
// vertical or horizontal line?
|
249
|
+
if (envelope.getMinX() === envelope.getMaxX() ||
|
250
|
+
envelope.getMinY() === envelope.getMaxY()) {
|
251
|
+
return this.createLineString([
|
252
|
+
new jsts.geom.Coordinate(envelope.getMinX(), envelope.getMinY()),
|
253
|
+
new jsts.geom.Coordinate(envelope.getMaxX(), envelope.getMaxY())]);
|
254
|
+
}
|
255
|
+
|
256
|
+
// create a CW ring for the polygon
|
257
|
+
return this.createPolygon(this.createLinearRing([
|
258
|
+
new jsts.geom.Coordinate(envelope.getMinX(), envelope.getMinY()),
|
259
|
+
new jsts.geom.Coordinate(envelope.getMinX(), envelope.getMaxY()),
|
260
|
+
new jsts.geom.Coordinate(envelope.getMaxX(), envelope.getMaxY()),
|
261
|
+
new jsts.geom.Coordinate(envelope.getMaxX(), envelope.getMinY()),
|
262
|
+
new jsts.geom.Coordinate(envelope.getMinX(), envelope.getMinY())]), null);
|
263
|
+
};
|