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,63 @@
|
|
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
|
+
(function() {
|
9
|
+
|
10
|
+
/**
|
11
|
+
* A Position indicates the position of a Location relative to a graph
|
12
|
+
* component (Node, Edge, or Area).
|
13
|
+
*
|
14
|
+
* @constructor
|
15
|
+
*/
|
16
|
+
jsts.geomgraph.Position = function() {
|
17
|
+
|
18
|
+
};
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* An indicator that a Location is <i>on</i> a GraphComponent
|
23
|
+
*
|
24
|
+
* @type {int}
|
25
|
+
*/
|
26
|
+
jsts.geomgraph.Position.ON = 0;
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* An indicator that a Location is to the <i>left</i> of a GraphComponent
|
31
|
+
*
|
32
|
+
* @type {int}
|
33
|
+
*/
|
34
|
+
jsts.geomgraph.Position.LEFT = 1;
|
35
|
+
|
36
|
+
|
37
|
+
/**
|
38
|
+
* An indicator that a Location is to the <i>right</i> of a GraphComponent
|
39
|
+
*
|
40
|
+
* @type {int}
|
41
|
+
*/
|
42
|
+
jsts.geomgraph.Position.RIGHT = 2;
|
43
|
+
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Returns LEFT if the position is RIGHT, RIGHT if the position is LEFT, or
|
47
|
+
* the position otherwise.
|
48
|
+
*
|
49
|
+
* @param {int}
|
50
|
+
* position
|
51
|
+
* @return {int}
|
52
|
+
*/
|
53
|
+
jsts.geomgraph.Position.opposite = function(position) {
|
54
|
+
if (position === jsts.geomgraph.Position.LEFT) {
|
55
|
+
return jsts.geomgraph.Position.RIGHT;
|
56
|
+
}
|
57
|
+
if (position === jsts.geomgraph.Position.RIGHT) {
|
58
|
+
return jsts.geomgraph.Position.LEFT;
|
59
|
+
}
|
60
|
+
return position;
|
61
|
+
};
|
62
|
+
|
63
|
+
})();
|
@@ -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
|
+
|
9
|
+
/**
|
10
|
+
* Utility functions for working with quadrants, which are numbered as follows:
|
11
|
+
*
|
12
|
+
* <pre>
|
13
|
+
* 1 | 0
|
14
|
+
* --+--
|
15
|
+
* 2 | 3
|
16
|
+
* <pre>
|
17
|
+
* @constructor
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
jsts.geomgraph.Quadrant = function() {
|
21
|
+
|
22
|
+
};
|
23
|
+
|
24
|
+
jsts.geomgraph.Quadrant.NE = 0;
|
25
|
+
jsts.geomgraph.Quadrant.NW = 1;
|
26
|
+
jsts.geomgraph.Quadrant.SW = 2;
|
27
|
+
jsts.geomgraph.Quadrant.SE = 3;
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Returns the quadrant of a directed line segment (specified as x and y
|
32
|
+
* displacements, which cannot both be 0).
|
33
|
+
*
|
34
|
+
* @throws IllegalArgumentException
|
35
|
+
* if the displacements are both 0
|
36
|
+
*/
|
37
|
+
jsts.geomgraph.Quadrant.quadrant = function(dx, dy) {
|
38
|
+
if (dx instanceof jsts.geom.Coordinate) {
|
39
|
+
return jsts.geomgraph.Quadrant.quadrant2.apply(this, arguments);
|
40
|
+
}
|
41
|
+
|
42
|
+
if (dx === 0.0 && dy === 0.0)
|
43
|
+
throw new jsts.error.IllegalArgumentError(
|
44
|
+
'Cannot compute the quadrant for point ( ' + dx + ', ' + dy + ' )');
|
45
|
+
if (dx >= 0.0) {
|
46
|
+
if (dy >= 0.0)
|
47
|
+
return jsts.geomgraph.Quadrant.NE;
|
48
|
+
else
|
49
|
+
return jsts.geomgraph.Quadrant.SE;
|
50
|
+
} else {
|
51
|
+
if (dy >= 0.0)
|
52
|
+
return jsts.geomgraph.Quadrant.NW;
|
53
|
+
else
|
54
|
+
return jsts.geomgraph.Quadrant.SW;
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Returns the quadrant of a directed line segment from p0 to p1.
|
61
|
+
*
|
62
|
+
* @throws IllegalArgumentException
|
63
|
+
* if the points are equal
|
64
|
+
*/
|
65
|
+
jsts.geomgraph.Quadrant.quadrant2 = function(p0, p1) {
|
66
|
+
if (p1.x === p0.x && p1.y === p0.y)
|
67
|
+
throw new jsts.error.IllegalArgumentError(
|
68
|
+
'Cannot compute the quadrant for two identical points ' + p0);
|
69
|
+
|
70
|
+
if (p1.x >= p0.x) {
|
71
|
+
if (p1.y >= p0.y)
|
72
|
+
return jsts.geomgraph.Quadrant.NE;
|
73
|
+
else
|
74
|
+
return jsts.geomgraph.Quadrant.SE;
|
75
|
+
} else {
|
76
|
+
if (p1.y >= p0.y)
|
77
|
+
return jsts.geomgraph.Quadrant.NW;
|
78
|
+
else
|
79
|
+
return jsts.geomgraph.Quadrant.SW;
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Returns true if the quadrants are 1 and 3, or 2 and 4
|
86
|
+
*/
|
87
|
+
jsts.geomgraph.Quadrant.isOpposite = function(quad1, quad2) {
|
88
|
+
if (quad1 === quad2)
|
89
|
+
return false;
|
90
|
+
var diff = (quad1 - quad2 + 4) % 4;
|
91
|
+
// if quadrants are not adjacent, they are opposite
|
92
|
+
if (diff === 2)
|
93
|
+
return true;
|
94
|
+
return false;
|
95
|
+
};
|
96
|
+
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Returns the right-hand quadrant of the halfplane defined by the two
|
100
|
+
* quadrants, or -1 if the quadrants are opposite, or the quadrant if they are
|
101
|
+
* identical.
|
102
|
+
*/
|
103
|
+
jsts.geomgraph.Quadrant.commonHalfPlane = function(quad1, quad2) {
|
104
|
+
// if quadrants are the same they do not determine a unique common halfplane.
|
105
|
+
// Simply return one of the two possibilities
|
106
|
+
if (quad1 === quad2)
|
107
|
+
return quad1;
|
108
|
+
var diff = (quad1 - quad2 + 4) % 4;
|
109
|
+
// if quadrants are not adjacent, they do not share a common halfplane
|
110
|
+
if (diff === 2)
|
111
|
+
return -1;
|
112
|
+
//
|
113
|
+
var min = (quad1 < quad2) ? quad1 : quad2;
|
114
|
+
var max = (quad1 > quad2) ? quad1 : quad2;
|
115
|
+
// for this one case, the righthand plane is NOT the minimum index;
|
116
|
+
if (min === 0 && max === 3)
|
117
|
+
return 3;
|
118
|
+
// in general, the halfplane index is the minimum of the two adjacent
|
119
|
+
// quadrants
|
120
|
+
return min;
|
121
|
+
};
|
122
|
+
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Returns whether the given quadrant lies within the given halfplane (specified
|
126
|
+
* by its right-hand quadrant).
|
127
|
+
*/
|
128
|
+
jsts.geomgraph.Quadrant.isInHalfPlane = function(quad, halfPlane) {
|
129
|
+
if (halfPlane === jsts.geomgraph.Quadrant.SE) {
|
130
|
+
return quad === jsts.geomgraph.Quadrant.SE ||
|
131
|
+
quad === jsts.geomgraph.Quadrant.SW;
|
132
|
+
}
|
133
|
+
return quad === halfPlane || quad === halfPlane + 1;
|
134
|
+
};
|
135
|
+
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Returns true if the given quadrant is 0 or 1.
|
139
|
+
*/
|
140
|
+
jsts.geomgraph.Quadrant.isNorthern = function(quad) {
|
141
|
+
return quad === jsts.geomgraph.Quadrant.NE ||
|
142
|
+
quad === jsts.geomgraph.Quadrant.NW;
|
143
|
+
};
|
@@ -0,0 +1,251 @@
|
|
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/geomgraph/Position.js
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* A TopologyLocation is the labelling of a GraphComponent's topological
|
13
|
+
* relationship to a single Geometry.
|
14
|
+
* <p>
|
15
|
+
* If the parent component is an area edge, each side and the edge itself have a
|
16
|
+
* topological location. These locations are named
|
17
|
+
* <ul>
|
18
|
+
* <li> ON: on the edge
|
19
|
+
* <li> LEFT: left-hand side of the edge
|
20
|
+
* <li> RIGHT: right-hand side
|
21
|
+
* </ul>
|
22
|
+
* If the parent component is a line edge or node, there is a single topological
|
23
|
+
* relationship attribute, ON.
|
24
|
+
* <p>
|
25
|
+
* The possible values of a topological location are {Location.NONE,
|
26
|
+
* Location.EXTERIOR, Location.BOUNDARY, Location.INTERIOR}
|
27
|
+
* <p>
|
28
|
+
* The labelling is stored in an array location[j] where where j has the values
|
29
|
+
* ON, LEFT, RIGHT
|
30
|
+
*
|
31
|
+
* @constructor
|
32
|
+
*/
|
33
|
+
jsts.geomgraph.TopologyLocation = function() {
|
34
|
+
this.location = [];
|
35
|
+
|
36
|
+
if (arguments.length === 3) {
|
37
|
+
var on = arguments[0];
|
38
|
+
var left = arguments[1];
|
39
|
+
var right = arguments[2];
|
40
|
+
this.init(3);
|
41
|
+
this.location[jsts.geomgraph.Position.ON] = on;
|
42
|
+
this.location[jsts.geomgraph.Position.LEFT] = left;
|
43
|
+
this.location[jsts.geomgraph.Position.RIGHT] = right;
|
44
|
+
} else if (arguments[0] instanceof jsts.geomgraph.TopologyLocation) {
|
45
|
+
var gl = arguments[0];
|
46
|
+
this.init(gl.location.length);
|
47
|
+
if (gl != null) {
|
48
|
+
for (var i = 0; i < this.location.length; i++) {
|
49
|
+
this.location[i] = gl.location[i];
|
50
|
+
}
|
51
|
+
}
|
52
|
+
} else if (typeof arguments[0] === 'number') {
|
53
|
+
var on = arguments[0];
|
54
|
+
this.init(1);
|
55
|
+
this.location[jsts.geomgraph.Position.ON] = on;
|
56
|
+
} else if (arguments[0] instanceof Array) {
|
57
|
+
var location = arguments[0];
|
58
|
+
this.init(location.length);
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
|
63
|
+
/**
|
64
|
+
* @private
|
65
|
+
*/
|
66
|
+
jsts.geomgraph.TopologyLocation.prototype.location = null;
|
67
|
+
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @param {int}
|
71
|
+
* size
|
72
|
+
* @private
|
73
|
+
*/
|
74
|
+
jsts.geomgraph.TopologyLocation.prototype.init = function(size) {
|
75
|
+
this.location[size - 1] = null;
|
76
|
+
this.setAllLocations(jsts.geom.Location.NONE);
|
77
|
+
};
|
78
|
+
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @param {int}
|
82
|
+
* posIndex
|
83
|
+
* @return {int}
|
84
|
+
*/
|
85
|
+
jsts.geomgraph.TopologyLocation.prototype.get = function(posIndex) {
|
86
|
+
if (posIndex < this.location.length)
|
87
|
+
return this.location[posIndex];
|
88
|
+
return jsts.geom.Location.NONE;
|
89
|
+
};
|
90
|
+
|
91
|
+
|
92
|
+
/**
|
93
|
+
* @return {boolean} true if all locations are NULL.
|
94
|
+
*/
|
95
|
+
jsts.geomgraph.TopologyLocation.prototype.isNull = function() {
|
96
|
+
for (var i = 0; i < this.location.length; i++) {
|
97
|
+
if (this.location[i] !== jsts.geom.Location.NONE)
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
return true;
|
101
|
+
};
|
102
|
+
|
103
|
+
|
104
|
+
/**
|
105
|
+
* @return {boolean} true if any locations are NULL.
|
106
|
+
*/
|
107
|
+
jsts.geomgraph.TopologyLocation.prototype.isAnyNull = function() {
|
108
|
+
for (var i = 0; i < this.location.length; i++) {
|
109
|
+
if (this.location[i] === jsts.geom.Location.NONE)
|
110
|
+
return true;
|
111
|
+
}
|
112
|
+
return false;
|
113
|
+
};
|
114
|
+
|
115
|
+
|
116
|
+
/**
|
117
|
+
* @param {TopologyLocation}
|
118
|
+
* le
|
119
|
+
* @param {int}
|
120
|
+
* locIndex
|
121
|
+
* @return {boolean}
|
122
|
+
*/
|
123
|
+
jsts.geomgraph.TopologyLocation.prototype.isEqualOnSide = function(le, locIndex) {
|
124
|
+
return this.location[locIndex] == le.location[locIndex];
|
125
|
+
};
|
126
|
+
|
127
|
+
|
128
|
+
/**
|
129
|
+
* @return {boolean}
|
130
|
+
*/
|
131
|
+
jsts.geomgraph.TopologyLocation.prototype.isArea = function() {
|
132
|
+
return this.location.length > 1;
|
133
|
+
};
|
134
|
+
|
135
|
+
|
136
|
+
/**
|
137
|
+
* @return {boolean}
|
138
|
+
*/
|
139
|
+
jsts.geomgraph.TopologyLocation.prototype.isLine = function() {
|
140
|
+
return this.location.length === 1;
|
141
|
+
};
|
142
|
+
|
143
|
+
jsts.geomgraph.TopologyLocation.prototype.flip = function() {
|
144
|
+
if (this.location.length <= 1)
|
145
|
+
return;
|
146
|
+
var temp = this.location[jsts.geomgraph.Position.LEFT];
|
147
|
+
this.location[jsts.geomgraph.Position.LEFT] = this.location[jsts.geomgraph.Position.RIGHT];
|
148
|
+
this.location[jsts.geomgraph.Position.RIGHT] = temp;
|
149
|
+
};
|
150
|
+
|
151
|
+
|
152
|
+
/**
|
153
|
+
* @param {int}
|
154
|
+
* locValue
|
155
|
+
*/
|
156
|
+
jsts.geomgraph.TopologyLocation.prototype.setAllLocations = function(locValue) {
|
157
|
+
for (var i = 0; i < this.location.length; i++) {
|
158
|
+
this.location[i] = locValue;
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
|
163
|
+
/**
|
164
|
+
* @param {int}
|
165
|
+
* locValue
|
166
|
+
*/
|
167
|
+
jsts.geomgraph.TopologyLocation.prototype.setAllLocationsIfNull = function(
|
168
|
+
locValue) {
|
169
|
+
for (var i = 0; i < this.location.length; i++) {
|
170
|
+
if (this.location[i] === jsts.geom.Location.NONE)
|
171
|
+
this.location[i] = locValue;
|
172
|
+
}
|
173
|
+
};
|
174
|
+
|
175
|
+
|
176
|
+
/**
|
177
|
+
* @param {int}
|
178
|
+
* locIndex
|
179
|
+
* @param {int}
|
180
|
+
* locValue
|
181
|
+
*/
|
182
|
+
jsts.geomgraph.TopologyLocation.prototype.setLocation = function(locIndex,
|
183
|
+
locValue) {
|
184
|
+
if (locValue !== undefined) {
|
185
|
+
this.location[locIndex] = locValue;
|
186
|
+
} else {
|
187
|
+
this.setLocation(jsts.geomgraph.Position.ON, locIndex);
|
188
|
+
}
|
189
|
+
};
|
190
|
+
|
191
|
+
|
192
|
+
/**
|
193
|
+
* @return {int[]}
|
194
|
+
*/
|
195
|
+
jsts.geomgraph.TopologyLocation.prototype.getLocations = function() {
|
196
|
+
return location;
|
197
|
+
};
|
198
|
+
|
199
|
+
|
200
|
+
/**
|
201
|
+
* @param {int}
|
202
|
+
* on
|
203
|
+
* @param {int}
|
204
|
+
* left
|
205
|
+
* @param {int}
|
206
|
+
* right
|
207
|
+
*/
|
208
|
+
jsts.geomgraph.TopologyLocation.prototype.setLocations = function(on, left,
|
209
|
+
right) {
|
210
|
+
this.location[jsts.geomgraph.Position.ON] = on;
|
211
|
+
this.location[jsts.geomgraph.Position.LEFT] = left;
|
212
|
+
this.location[jsts.geomgraph.Position.RIGHT] = right;
|
213
|
+
};
|
214
|
+
|
215
|
+
|
216
|
+
/**
|
217
|
+
* @param {int}
|
218
|
+
* loc
|
219
|
+
* @return {boolean}
|
220
|
+
*/
|
221
|
+
jsts.geomgraph.TopologyLocation.prototype.allPositionsEqual = function(loc) {
|
222
|
+
for (var i = 0; i < this.location.length; i++) {
|
223
|
+
if (this.location[i] !== loc)
|
224
|
+
return false;
|
225
|
+
}
|
226
|
+
return true;
|
227
|
+
};
|
228
|
+
|
229
|
+
|
230
|
+
/**
|
231
|
+
* merge updates only the NULL attributes of this object with the attributes of
|
232
|
+
* another.
|
233
|
+
*
|
234
|
+
* @param {TopologyLocation}
|
235
|
+
* gl
|
236
|
+
*/
|
237
|
+
jsts.geomgraph.TopologyLocation.prototype.merge = function(gl) {
|
238
|
+
// if the src is an Area label & and the dest is not, increase the dest to be
|
239
|
+
// an Area
|
240
|
+
if (gl.location.length > this.location.length) {
|
241
|
+
var newLoc = [];
|
242
|
+
newLoc[jsts.geomgraph.Position.ON] = this.location[jsts.geomgraph.Position.ON];
|
243
|
+
newLoc[jsts.geomgraph.Position.LEFT] = jsts.geom.Location.NONE;
|
244
|
+
newLoc[jsts.geomgraph.Position.RIGHT] = jsts.geom.Location.NONE;
|
245
|
+
this.location = newLoc;
|
246
|
+
}
|
247
|
+
for (var i = 0; i < this.location.length; i++) {
|
248
|
+
if (this.location[i] === jsts.geom.Location.NONE && i < gl.location.length)
|
249
|
+
this.location[i] = gl.location[i];
|
250
|
+
}
|
251
|
+
};
|