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,68 @@
|
|
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
|
+
* Converts a geometry in Well-Known Text format to a {@link Geometry}.
|
11
|
+
* <p>
|
12
|
+
* <code>WKTReader</code> supports extracting <code>Geometry</code> objects
|
13
|
+
* from either {@link Reader}s or {@link String}s. This allows it to function
|
14
|
+
* as a parser to read <code>Geometry</code> objects from text blocks embedded
|
15
|
+
* in other data formats (e.g. XML).
|
16
|
+
* <P>
|
17
|
+
* <p>
|
18
|
+
* A <code>WKTReader</code> is parameterized by a <code>GeometryFactory</code>,
|
19
|
+
* to allow it to create <code>Geometry</code> objects of the appropriate
|
20
|
+
* implementation. In particular, the <code>GeometryFactory</code> determines
|
21
|
+
* the <code>PrecisionModel</code> and <code>SRID</code> that is used.
|
22
|
+
* <P>
|
23
|
+
*
|
24
|
+
* @constructor
|
25
|
+
*/
|
26
|
+
jsts.io.WKTReader = function(geometryFactory) {
|
27
|
+
this.geometryFactory = geometryFactory || new jsts.geom.GeometryFactory();
|
28
|
+
this.precisionModel = this.geometryFactory.getPrecisionModel();
|
29
|
+
this.parser = new jsts.io.WKTParser(this.geometryFactory);
|
30
|
+
};
|
31
|
+
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Reads a Well-Known Text representation of a {@link Geometry}
|
35
|
+
*
|
36
|
+
* @param {string}
|
37
|
+
* wkt a <Geometry Tagged Text> string (see the OpenGIS Simple Features
|
38
|
+
* Specification).
|
39
|
+
* @return {jsts.geom.Geometry} a <code>Geometry</code> read from
|
40
|
+
* <code>string.</code>
|
41
|
+
*/
|
42
|
+
jsts.io.WKTReader.prototype.read = function(wkt) {
|
43
|
+
var geometry = this.parser.read(wkt);
|
44
|
+
|
45
|
+
// TODO: port and use GeometryPrecisionReducer, this is a hack
|
46
|
+
if (this.precisionModel.getType() === jsts.geom.PrecisionModel.FIXED) {
|
47
|
+
this.reducePrecision(geometry);
|
48
|
+
}
|
49
|
+
|
50
|
+
return geometry;
|
51
|
+
};
|
52
|
+
|
53
|
+
//NOTE: this is a hack
|
54
|
+
jsts.io.WKTReader.prototype.reducePrecision = function(geometry) {
|
55
|
+
var i, len;
|
56
|
+
|
57
|
+
if (geometry.coordinate) {
|
58
|
+
this.precisionModel.makePrecise(geometry.coordinate);
|
59
|
+
} else if (geometry.points) {
|
60
|
+
for (i = 0, len = geometry.points.length; i < len; i++) {
|
61
|
+
this.precisionModel.makePrecise(geometry.points[i]);
|
62
|
+
}
|
63
|
+
} else if (geometry.geometries) {
|
64
|
+
for (i = 0, len = geometry.geometries.length; i < len; i++) {
|
65
|
+
this.reducePrecision(geometry.geometries[i]);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Writes the Well-Known Text representation of a {@link Geometry}. The
|
11
|
+
* Well-Known Text format is defined in the <A
|
12
|
+
* HREF="http://www.opengis.org/techno/specs.htm"> OGC Simple Features
|
13
|
+
* Specification for SQL</A>.
|
14
|
+
* <p>
|
15
|
+
* The <code>WKTWriter</code> outputs coordinates rounded to the precision
|
16
|
+
* model. Only the maximum number of decimal places necessary to represent the
|
17
|
+
* ordinates to the required precision will be output.
|
18
|
+
* <p>
|
19
|
+
* The SFS WKT spec does not define a special tag for {@link LinearRing}s.
|
20
|
+
* Under the spec, rings are output as <code>LINESTRING</code>s.
|
21
|
+
*
|
22
|
+
* @see WKTReader
|
23
|
+
* @constructor
|
24
|
+
*/
|
25
|
+
jsts.io.WKTWriter = function() {
|
26
|
+
this.parser = new jsts.io.WKTParser(this.geometryFactory);
|
27
|
+
};
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Converts a <code>Geometry</code> to its Well-known Text representation.
|
32
|
+
*
|
33
|
+
* @param {jsts.geom.Geometry}
|
34
|
+
* geometry a <code>Geometry</code> to process.
|
35
|
+
* @return {string} a <Geometry Tagged Text> string (see the OpenGIS Simple
|
36
|
+
* Features Specification).
|
37
|
+
*/
|
38
|
+
jsts.io.WKTWriter.prototype.write = function(geometry) {
|
39
|
+
var wkt = this.parser.write(geometry);
|
40
|
+
|
41
|
+
return wkt;
|
42
|
+
};
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Generates the WKT for a <tt>LINESTRING</tt> specified by two
|
46
|
+
* {@link Coordinate}s.
|
47
|
+
*
|
48
|
+
* @param p0
|
49
|
+
* the first coordinate.
|
50
|
+
* @param p1
|
51
|
+
* the second coordinate.
|
52
|
+
*
|
53
|
+
* @return the WKT.
|
54
|
+
*/
|
55
|
+
jsts.io.WKTWriter.toLineString = function(p0, p1) {
|
56
|
+
if (arguments.length !== 2) {
|
57
|
+
throw new jsts.error.NotImplementedError();
|
58
|
+
}
|
59
|
+
|
60
|
+
return 'LINESTRING ( ' + p0.x + ' ' + p0.y + ', ' + p1.x + ' ' + p1.y + ' )';
|
61
|
+
};
|
@@ -0,0 +1,87 @@
|
|
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
|
+
* Represents a list of contiguous line segments, and supports noding the
|
11
|
+
* segments. The line segments are represented by an array of
|
12
|
+
* {@link Coordinate}s. Intended to optimize the noding of contiguous
|
13
|
+
* segments by reducing the number of allocated objects. SegmentStrings can
|
14
|
+
* carry a context object, which is useful for preserving topological or
|
15
|
+
* parentage information. All noded substrings are initialized with the same
|
16
|
+
* context object.
|
17
|
+
*
|
18
|
+
* Creates a new segment string from a list of vertices.
|
19
|
+
*
|
20
|
+
* @param pts
|
21
|
+
* the vertices of the segment string.
|
22
|
+
* @param data
|
23
|
+
* the user-defined data of this segment string (may be null).
|
24
|
+
* @constructor
|
25
|
+
*/
|
26
|
+
jsts.noding.BasicSegmentString = function(pts, data) {
|
27
|
+
this.pts = pts;
|
28
|
+
this.data = data;
|
29
|
+
};
|
30
|
+
jsts.noding.BasicSegmentString.prototype = new jsts.noding.SegmentString();
|
31
|
+
|
32
|
+
|
33
|
+
jsts.noding.BasicSegmentString.prototype.pts = null;
|
34
|
+
jsts.noding.BasicSegmentString.prototype.data = null;
|
35
|
+
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Gets the user-defined data for this segment string.
|
39
|
+
*
|
40
|
+
* @return the user-defined data.
|
41
|
+
*/
|
42
|
+
jsts.noding.BasicSegmentString.prototype.getData = function() {
|
43
|
+
return this.data;
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Sets the user-defined data for this segment string.
|
48
|
+
*
|
49
|
+
* @param data
|
50
|
+
* an Object containing user-defined data.
|
51
|
+
*/
|
52
|
+
jsts.noding.BasicSegmentString.prototype.setData = function(data) {
|
53
|
+
this.data = data;
|
54
|
+
};
|
55
|
+
|
56
|
+
jsts.noding.BasicSegmentString.prototype.size = function() {
|
57
|
+
return this.pts.length;
|
58
|
+
};
|
59
|
+
|
60
|
+
jsts.noding.BasicSegmentString.prototype.getCoordinate = function(i) {
|
61
|
+
return this.pts[i];
|
62
|
+
};
|
63
|
+
|
64
|
+
jsts.noding.BasicSegmentString.prototype.getCoordinates = function() {
|
65
|
+
return this.pts;
|
66
|
+
};
|
67
|
+
|
68
|
+
jsts.noding.BasicSegmentString.prototype.isClosed = function() {
|
69
|
+
return this.pts[0].equals(this.pts[this.pts.length - 1]);
|
70
|
+
};
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Gets the octant of the segment starting at vertex <code>index</code>.
|
74
|
+
*
|
75
|
+
* @param index
|
76
|
+
* the index of the vertex starting the segment. Must not be the last
|
77
|
+
* index in the vertex list.
|
78
|
+
* @return the octant of the segment at the vertex.
|
79
|
+
*/
|
80
|
+
jsts.noding.BasicSegmentString.prototype.getSegmentOctant = function(index) {
|
81
|
+
if (index == this.pts.length - 1)
|
82
|
+
return -1;
|
83
|
+
return jsts.noding.Octant.octant(this.getCoordinate(index), this
|
84
|
+
.getCoordinate(index + 1));
|
85
|
+
};
|
86
|
+
|
87
|
+
})();
|
@@ -0,0 +1,127 @@
|
|
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/algorithm/RobustLineIntersector.js
|
11
|
+
* @requires jsts/noding/InteriorIntersectionFinder.js
|
12
|
+
* @requires jsts/noding/MCIndexNoder.js
|
13
|
+
*/
|
14
|
+
|
15
|
+
var RobustLineIntersector = jsts.algorithm.RobustLineIntersector;
|
16
|
+
var InteriorIntersectionFinder = jsts.noding.InteriorIntersectionFinder;
|
17
|
+
var MCIndexNoder = jsts.noding.MCIndexNoder;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Validates that a collection of {@link SegmentString}s is correctly noded.
|
21
|
+
* Indexing is used to improve performance. In the most common use case,
|
22
|
+
* validation stops after a single non-noded intersection is detected. Does
|
23
|
+
* NOT check a-b-a collapse situations. Also does not check for
|
24
|
+
* endpoint-interior vertex intersections. This should not be a problem, since
|
25
|
+
* the noders should be able to compute intersections between vertices
|
26
|
+
* correctly.
|
27
|
+
* <p>
|
28
|
+
* The client may either test the {@link #isValid} condition, or request that
|
29
|
+
* a suitable {@link TopologyException} be thrown.
|
30
|
+
*
|
31
|
+
* Creates a new noding validator for a given set of linework.
|
32
|
+
*
|
33
|
+
* @param segStrings
|
34
|
+
* a collection of {@link SegmentString} s.
|
35
|
+
*/
|
36
|
+
jsts.noding.FastNodingValidator = function(segStrings) {
|
37
|
+
this.li = new RobustLineIntersector();
|
38
|
+
|
39
|
+
this.segStrings = segStrings;
|
40
|
+
};
|
41
|
+
|
42
|
+
jsts.noding.FastNodingValidator.prototype.li = null;
|
43
|
+
|
44
|
+
jsts.noding.FastNodingValidator.prototype.segStrings = null;
|
45
|
+
jsts.noding.FastNodingValidator.prototype.findAllIntersections = false;
|
46
|
+
jsts.noding.FastNodingValidator.prototype.segInt = null;
|
47
|
+
jsts.noding.FastNodingValidator.prototype._isValid = true;
|
48
|
+
|
49
|
+
jsts.noding.FastNodingValidator.prototype.setFindAllIntersections = function(
|
50
|
+
findAllIntersections) {
|
51
|
+
this.findAllIntersections = findAllIntersections;
|
52
|
+
};
|
53
|
+
|
54
|
+
jsts.noding.FastNodingValidator.prototype.getIntersections = function() {
|
55
|
+
return segInt.getIntersections();
|
56
|
+
};
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Checks for an intersection and reports if one is found.
|
60
|
+
*
|
61
|
+
* @return true if the arrangement contains an interior intersection.
|
62
|
+
*/
|
63
|
+
jsts.noding.FastNodingValidator.prototype.isValid = function() {
|
64
|
+
this.execute();
|
65
|
+
return this._isValid;
|
66
|
+
};
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Returns an error message indicating the segments containing the
|
70
|
+
* intersection.
|
71
|
+
*
|
72
|
+
* @return an error message documenting the intersection location.
|
73
|
+
*/
|
74
|
+
jsts.noding.FastNodingValidator.prototype.getErrorMessage = function() {
|
75
|
+
if (this._isValid)
|
76
|
+
return 'no intersections found';
|
77
|
+
|
78
|
+
var intSegs = this.segInt.getIntersectionSegments();
|
79
|
+
return 'found non-noded intersection between ' +
|
80
|
+
jsts.io.WKTWriter.toLineString(intSegs[0], intSegs[1]) + ' and ' +
|
81
|
+
jsts.io.WKTWriter.toLineString(intSegs[2], intSegs[3]);
|
82
|
+
};
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Checks for an intersection and throws a TopologyException if one is found.
|
86
|
+
*
|
87
|
+
* @throws TopologyException
|
88
|
+
* if an intersection is found
|
89
|
+
*/
|
90
|
+
jsts.noding.FastNodingValidator.prototype.checkValid = function() {
|
91
|
+
this.execute();
|
92
|
+
if (!this._isValid)
|
93
|
+
throw new jsts.error.TopologyError(this.getErrorMessage(), this.segInt
|
94
|
+
.getInteriorIntersection());
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* @private
|
99
|
+
*/
|
100
|
+
jsts.noding.FastNodingValidator.prototype.execute = function() {
|
101
|
+
if (this.segInt != null)
|
102
|
+
return;
|
103
|
+
this.checkInteriorIntersections();
|
104
|
+
};
|
105
|
+
|
106
|
+
/**
|
107
|
+
* @private
|
108
|
+
*/
|
109
|
+
jsts.noding.FastNodingValidator.prototype.checkInteriorIntersections = function() {
|
110
|
+
/**
|
111
|
+
* MD - It may even be reliable to simply check whether end segments (of
|
112
|
+
* SegmentStrings) have an interior intersection, since noding should have
|
113
|
+
* split any true interior intersections already.
|
114
|
+
*/
|
115
|
+
this._isValid = true;
|
116
|
+
this.segInt = new InteriorIntersectionFinder(this.li);
|
117
|
+
this.segInt.setFindAllIntersections(this.findAllIntersections);
|
118
|
+
var noder = new MCIndexNoder();
|
119
|
+
noder.setSegmentIntersector(this.segInt);
|
120
|
+
noder.computeNodes(this.segStrings);
|
121
|
+
if (this.segInt.hasIntersection()) {
|
122
|
+
this._isValid = false;
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
};
|
126
|
+
|
127
|
+
})();
|
@@ -0,0 +1,171 @@
|
|
1
|
+
/* Copyright (c) 2011 by The Authors.
|
2
|
+
* Published under the LGPL 2.1 license.
|
3
|
+
* See /license-notice.txt for the full text of the license notice.
|
4
|
+
* See /license.txt for the full text of the license.
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function() {
|
8
|
+
|
9
|
+
/**
|
10
|
+
* @requires jsts/noding/SegmentIntersector.js
|
11
|
+
*/
|
12
|
+
|
13
|
+
var SegmentIntersector = jsts.noding.SegmentIntersector;
|
14
|
+
var ArrayList = javascript.util.ArrayList;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Finds an interior intersection in a set of {@link SegmentString}s, if one
|
18
|
+
* exists. Only the first intersection found is reported.
|
19
|
+
*
|
20
|
+
* Creates an intersection finder which finds an interior intersection if one
|
21
|
+
* exists
|
22
|
+
*
|
23
|
+
* @param li
|
24
|
+
* the LineIntersector to use.
|
25
|
+
* @constructor
|
26
|
+
*/
|
27
|
+
jsts.noding.InteriorIntersectionFinder = function(li) {
|
28
|
+
this.li = li;
|
29
|
+
this.intersections = new ArrayList();
|
30
|
+
this.interiorIntersection = null;
|
31
|
+
};
|
32
|
+
|
33
|
+
jsts.noding.InteriorIntersectionFinder.prototype = new SegmentIntersector();
|
34
|
+
jsts.noding.InteriorIntersectionFinder.constructor = jsts.noding.InteriorIntersectionFinder;
|
35
|
+
|
36
|
+
jsts.noding.InteriorIntersectionFinder.prototype.findAllIntersections = false;
|
37
|
+
jsts.noding.InteriorIntersectionFinder.prototype.isCheckEndSegmentsOnly = false;
|
38
|
+
jsts.noding.InteriorIntersectionFinder.prototype.li = null;
|
39
|
+
jsts.noding.InteriorIntersectionFinder.prototype.interiorIntersection = null;
|
40
|
+
jsts.noding.InteriorIntersectionFinder.prototype.intSegments = null;
|
41
|
+
jsts.noding.InteriorIntersectionFinder.prototype.intersections = null;
|
42
|
+
|
43
|
+
|
44
|
+
jsts.noding.InteriorIntersectionFinder.prototype.setFindAllIntersections = function(
|
45
|
+
findAllIntersections) {
|
46
|
+
this.findAllIntersections = findAllIntersections;
|
47
|
+
};
|
48
|
+
|
49
|
+
jsts.noding.InteriorIntersectionFinder.prototype.getIntersections = function() {
|
50
|
+
return intersections;
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Sets whether only end segments should be tested for interior intersection.
|
55
|
+
* This is a performance optimization that may be used if the segments have
|
56
|
+
* been previously noded by an appropriate algorithm. It may be known that any
|
57
|
+
* potential noding failures will occur only in end segments.
|
58
|
+
*
|
59
|
+
* @param isCheckEndSegmentsOnly
|
60
|
+
* whether to test only end segments.
|
61
|
+
*/
|
62
|
+
jsts.noding.InteriorIntersectionFinder.prototype.setCheckEndSegmentsOnly = function(
|
63
|
+
isCheckEndSegmentsOnly) {
|
64
|
+
this.isCheckEndSegmentsOnly = isCheckEndSegmentsOnly;
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Tests whether an intersection was found.
|
69
|
+
*
|
70
|
+
* @return true if an intersection was found.
|
71
|
+
*/
|
72
|
+
jsts.noding.InteriorIntersectionFinder.prototype.hasIntersection = function() {
|
73
|
+
return this.interiorIntersection != null;
|
74
|
+
};
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Gets the computed location of the intersection. Due to round-off, the
|
78
|
+
* location may not be exact.
|
79
|
+
*
|
80
|
+
* @return the coordinate for the intersection location.
|
81
|
+
*/
|
82
|
+
jsts.noding.InteriorIntersectionFinder.prototype.getInteriorIntersection = function() {
|
83
|
+
return this.interiorIntersection;
|
84
|
+
};
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Gets the endpoints of the intersecting segments.
|
88
|
+
*
|
89
|
+
* @return an array of the segment endpoints (p00, p01, p10, p11).
|
90
|
+
*/
|
91
|
+
jsts.noding.InteriorIntersectionFinder.prototype.getIntersectionSegments = function() {
|
92
|
+
return this.intSegments;
|
93
|
+
};
|
94
|
+
|
95
|
+
/**
|
96
|
+
* This method is called by clients of the {@link SegmentIntersector} class to
|
97
|
+
* process intersections for two segments of the {@link SegmentString}s being
|
98
|
+
* intersected. Note that some clients (such as {@link MonotoneChain}s) may
|
99
|
+
* optimize away this call for segment pairs which they have determined do not
|
100
|
+
* intersect (e.g. by an disjoint envelope test).
|
101
|
+
*/
|
102
|
+
jsts.noding.InteriorIntersectionFinder.prototype.processIntersections = function(
|
103
|
+
e0, segIndex0, e1, segIndex1) {
|
104
|
+
// short-circuit if intersection already found
|
105
|
+
if (this.hasIntersection())
|
106
|
+
return;
|
107
|
+
|
108
|
+
// don't bother intersecting a segment with itself
|
109
|
+
if (e0 == e1 && segIndex0 == segIndex1)
|
110
|
+
return;
|
111
|
+
|
112
|
+
/**
|
113
|
+
* If enabled, only test end segments (on either segString).
|
114
|
+
*
|
115
|
+
*/
|
116
|
+
if (this.isCheckEndSegmentsOnly) {
|
117
|
+
var isEndSegPresent = this.isEndSegment(e0, segIndex0) ||
|
118
|
+
isEndSegment(e1, segIndex1);
|
119
|
+
if (!isEndSegPresent)
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
|
123
|
+
var p00 = e0.getCoordinates()[segIndex0];
|
124
|
+
var p01 = e0.getCoordinates()[segIndex0 + 1];
|
125
|
+
var p10 = e1.getCoordinates()[segIndex1];
|
126
|
+
var p11 = e1.getCoordinates()[segIndex1 + 1];
|
127
|
+
|
128
|
+
this.li.computeIntersection(p00, p01, p10, p11);
|
129
|
+
// if (li.hasIntersection() && li.isProper()) Debug.println(li);
|
130
|
+
|
131
|
+
if (this.li.hasIntersection()) {
|
132
|
+
if (this.li.isInteriorIntersection()) {
|
133
|
+
this.intSegments = [];
|
134
|
+
this.intSegments[0] = p00;
|
135
|
+
this.intSegments[1] = p01;
|
136
|
+
this.intSegments[2] = p10;
|
137
|
+
this.intSegments[3] = p11;
|
138
|
+
|
139
|
+
this.interiorIntersection = this.li.getIntersection(0);
|
140
|
+
this.intersections.add(this.interiorIntersection);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
};
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Tests whether a segment in a {@link SegmentString} is an end segment.
|
147
|
+
* (either the first or last).
|
148
|
+
*
|
149
|
+
* @param segStr
|
150
|
+
* a segment string.
|
151
|
+
* @param index
|
152
|
+
* the index of a segment in the segment string.
|
153
|
+
* @return true if the segment is an end segment.
|
154
|
+
* @private
|
155
|
+
*/
|
156
|
+
jsts.noding.InteriorIntersectionFinder.prototype.isEndSegment = function(
|
157
|
+
segStr, index) {
|
158
|
+
if (index == 0)
|
159
|
+
return true;
|
160
|
+
if (index >= segStr.size() - 2)
|
161
|
+
return true;
|
162
|
+
return false;
|
163
|
+
};
|
164
|
+
|
165
|
+
jsts.noding.InteriorIntersectionFinder.prototype.isDone = function() {
|
166
|
+
if (this.findAllIntersections)
|
167
|
+
return false;
|
168
|
+
return this.interiorIntersection != null;
|
169
|
+
};
|
170
|
+
|
171
|
+
})();
|