├── bin ├── test.bat ├── test_robust.bat ├── test_stmlf.bat ├── testbuilder.bat ├── testrunner.bat └── testrunner.properties ├── debian ├── README.Debian-source ├── build.xml ├── changelog ├── compat ├── control ├── copyright ├── libjts-java-doc.docs ├── libjts-java.dirs ├── rules └── source │ └── format ├── jtsio ├── doc │ └── javadoc │ │ ├── allclasses-frame.html │ │ ├── allclasses-noframe.html │ │ ├── com │ │ └── vividsolutions │ │ │ └── jts │ │ │ └── io │ │ │ ├── gml2 │ │ │ ├── GMLHandler.html │ │ │ ├── GMLReader.html │ │ │ ├── GMLWriter.html │ │ │ ├── GeometryStrategies.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ └── package-tree.html │ │ │ └── oracle │ │ │ ├── OraReader.html │ │ │ ├── OraWriter.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ └── package-tree.html │ │ ├── constant-values.html │ │ ├── deprecated-list.html │ │ ├── help-doc.html │ │ ├── index-all.html │ │ ├── index.html │ │ ├── overview-frame.html │ │ ├── overview-summary.html │ │ ├── overview-tree.html │ │ ├── package-list │ │ ├── packages.html │ │ ├── resources │ │ └── inherit.gif │ │ └── stylesheet.css ├── src │ └── com │ │ └── vividsolutions │ │ └── jts │ │ └── io │ │ ├── gml2 │ │ ├── GMLConstants.java │ │ ├── GMLHandler.java │ │ ├── GMLReader.java │ │ ├── GMLWriter.java │ │ ├── GeometryStrategies.java │ │ └── package.html │ │ └── oracle │ │ ├── Constants.java │ │ ├── OraReader.java │ │ ├── OraWriter.java │ │ └── package.html └── test │ ├── com │ └── vividsolutions │ │ └── jts │ │ ├── generator │ │ ├── GeometryGenerator.java │ │ ├── GridGenerator.java │ │ ├── LineStringGenerator.java │ │ ├── MultiGenerator.java │ │ ├── PointGenerator.java │ │ └── PolygonGenerator.java │ │ └── io │ │ ├── gml2 │ │ ├── GMLReaderTestCase.java │ │ ├── StaticLineStringTest.java │ │ ├── StaticMultiLineStringTest.java │ │ ├── StaticMultiPointTest.java │ │ ├── StaticMultiPolygonTest.java │ │ ├── StaticPointTest.java │ │ ├── StaticPolygonTest.java │ │ ├── WritingTestCase.java │ │ └── geometry.xsd │ │ └── oracle │ │ ├── ConnectedTestCase.java │ │ ├── StaticLineStringTest.java │ │ ├── StaticMultiLineStringTest.java │ │ ├── StaticMultiPointTest.java │ │ ├── StaticMultiPolygonTest.java │ │ ├── StaticPointTest.java │ │ ├── StaticPolygonTest.java │ │ └── connection.properties │ ├── data │ ├── linestrings.xml │ ├── multilinestrings.xml │ ├── multipoints.xml │ ├── multipolygons.xml │ ├── points.xml │ └── polygons.xml │ └── readme ├── src ├── MANIFEST.MF └── com │ └── vividsolutions │ ├── jts │ ├── JTSVersion.java │ ├── algorithm │ │ ├── Angle.java │ │ ├── BoundaryNodeRule.java │ │ ├── CGAlgorithms.java │ │ ├── CentralEndpointIntersector.java │ │ ├── CentroidArea.java │ │ ├── CentroidLine.java │ │ ├── CentroidPoint.java │ │ ├── ConvexHull.java │ │ ├── HCoordinate.java │ │ ├── InteriorPointArea.java │ │ ├── InteriorPointLine.java │ │ ├── InteriorPointPoint.java │ │ ├── LineIntersector.java │ │ ├── MCPointInRing.java │ │ ├── MinimumDiameter.java │ │ ├── NonRobustCGAlgorithms.java │ │ ├── NonRobustLineIntersector.java │ │ ├── NotRepresentableException.java │ │ ├── PointInRing.java │ │ ├── PointLocator.java │ │ ├── RobustCGAlgorithms.java │ │ ├── RobustDeterminant.java │ │ ├── RobustLineIntersector.java │ │ ├── SIRtreePointInRing.java │ │ ├── SimplePointInAreaLocator.java │ │ ├── SimplePointInRing.java │ │ └── package.html │ ├── geom │ │ ├── Coordinate.java │ │ ├── CoordinateArrays.java │ │ ├── CoordinateFilter.java │ │ ├── CoordinateList.java │ │ ├── CoordinateSequence.java │ │ ├── CoordinateSequenceComparator.java │ │ ├── CoordinateSequenceFactory.java │ │ ├── CoordinateSequenceFilter.java │ │ ├── CoordinateSequences.java │ │ ├── DefaultCoordinateSequence.java │ │ ├── DefaultCoordinateSequenceFactory.java │ │ ├── Dimension.java │ │ ├── Envelope.java │ │ ├── Geometry.java │ │ ├── GeometryCollection.java │ │ ├── GeometryCollectionIterator.java │ │ ├── GeometryComponentFilter.java │ │ ├── GeometryFactory.java │ │ ├── GeometryFilter.java │ │ ├── IntersectionMatrix.java │ │ ├── LineSegment.java │ │ ├── LineString.java │ │ ├── LinearRing.java │ │ ├── Location.java │ │ ├── MultiLineString.java │ │ ├── MultiPoint.java │ │ ├── MultiPolygon.java │ │ ├── Point.java │ │ ├── Polygon.java │ │ ├── PrecisionModel.java │ │ ├── TopologyException.java │ │ ├── Triangle.java │ │ ├── impl │ │ │ ├── CoordinateArraySequence.java │ │ │ ├── CoordinateArraySequenceFactory.java │ │ │ ├── PackedCoordinateSequence.java │ │ │ └── PackedCoordinateSequenceFactory.java │ │ ├── package.html │ │ └── util │ │ │ ├── AffineTransformation.java │ │ │ ├── AffineTransformationBuilder.java │ │ │ ├── GeometryEditor.java │ │ │ ├── GeometryTransformer.java │ │ │ ├── LinearComponentExtracter.java │ │ │ ├── Matrix.java │ │ │ ├── NoninvertibleTransformationException.java │ │ │ ├── PointExtracter.java │ │ │ ├── PolygonExtracter.java │ │ │ ├── ShortCircuitedGeometryVisitor.java │ │ │ └── package.html │ ├── geomgraph │ │ ├── Depth.java │ │ ├── DirectedEdge.java │ │ ├── DirectedEdgeStar.java │ │ ├── Edge.java │ │ ├── EdgeEnd.java │ │ ├── EdgeEndStar.java │ │ ├── EdgeIntersection.java │ │ ├── EdgeIntersectionList.java │ │ ├── EdgeList.java │ │ ├── EdgeNodingValidator.java │ │ ├── EdgeRing.java │ │ ├── GeometryGraph.java │ │ ├── GraphComponent.java │ │ ├── Label.java │ │ ├── Node.java │ │ ├── NodeFactory.java │ │ ├── NodeMap.java │ │ ├── PlanarGraph.java │ │ ├── Position.java │ │ ├── Quadrant.java │ │ ├── TopologyLocation.java │ │ ├── index │ │ │ ├── EdgeSetIntersector.java │ │ │ ├── MonotoneChain.java │ │ │ ├── MonotoneChainEdge.java │ │ │ ├── MonotoneChainIndexer.java │ │ │ ├── SegmentIntersector.java │ │ │ ├── SimpleEdgeSetIntersector.java │ │ │ ├── SimpleMCSweepLineIntersector.java │ │ │ ├── SimpleSweepLineIntersector.java │ │ │ ├── SweepLineEvent.java │ │ │ ├── SweepLineSegment.java │ │ │ └── package.html │ │ └── package.html │ ├── index │ │ ├── ArrayListVisitor.java │ │ ├── ItemVisitor.java │ │ ├── SpatialIndex.java │ │ ├── bintree │ │ │ ├── Bintree.java │ │ │ ├── Interval.java │ │ │ ├── Key.java │ │ │ ├── Node.java │ │ │ ├── NodeBase.java │ │ │ ├── Root.java │ │ │ └── package.html │ │ ├── chain │ │ │ ├── MonotoneChain.java │ │ │ ├── MonotoneChainBuilder.java │ │ │ ├── MonotoneChainOverlapAction.java │ │ │ ├── MonotoneChainSelectAction.java │ │ │ └── package.html │ │ ├── package.html │ │ ├── quadtree │ │ │ ├── DoubleBits.java │ │ │ ├── IntervalSize.java │ │ │ ├── Key.java │ │ │ ├── Node.java │ │ │ ├── NodeBase.java │ │ │ ├── Quadtree.java │ │ │ ├── Root.java │ │ │ └── package.html │ │ ├── strtree │ │ │ ├── AbstractNode.java │ │ │ ├── AbstractSTRtree.java │ │ │ ├── Boundable.java │ │ │ ├── Interval.java │ │ │ ├── ItemBoundable.java │ │ │ ├── SIRtree.java │ │ │ ├── STRtree.java │ │ │ └── package.html │ │ └── sweepline │ │ │ ├── SweepLineEvent.java │ │ │ ├── SweepLineIndex.java │ │ │ ├── SweepLineInterval.java │ │ │ ├── SweepLineOverlapAction.java │ │ │ └── package.html │ ├── io │ │ ├── ByteArrayInStream.java │ │ ├── ByteOrderDataInStream.java │ │ ├── ByteOrderValues.java │ │ ├── InStream.java │ │ ├── InputStreamInStream.java │ │ ├── OutStream.java │ │ ├── OutputStreamOutStream.java │ │ ├── ParseException.java │ │ ├── WKBConstants.java │ │ ├── WKBReader.java │ │ ├── WKBWriter.java │ │ ├── WKTReader.java │ │ ├── WKTWriter.java │ │ └── package.html │ ├── linearref │ │ ├── ExtractLineByLocation.java │ │ ├── LengthIndexOfPoint.java │ │ ├── LengthIndexedLine.java │ │ ├── LengthLocationMap.java │ │ ├── LinearGeometryBuilder.java │ │ ├── LinearIterator.java │ │ ├── LinearLocation.java │ │ ├── LocationIndexOfLine.java │ │ ├── LocationIndexOfPoint.java │ │ ├── LocationIndexedLine.java │ │ └── package.html │ ├── noding │ │ ├── FastNodingValidator.java │ │ ├── InteriorIntersectionFinder.java │ │ ├── IntersectionAdder.java │ │ ├── IntersectionFinderAdder.java │ │ ├── IteratedNoder.java │ │ ├── MCIndexNoder.java │ │ ├── Noder.java │ │ ├── NodingValidator.java │ │ ├── Octant.java │ │ ├── OrientedCoordinateArray.java │ │ ├── ScaledNoder.java │ │ ├── SegmentIntersector.java │ │ ├── SegmentNode.java │ │ ├── SegmentNodeList.java │ │ ├── SegmentPointComparator.java │ │ ├── SegmentString.java │ │ ├── SegmentStringDissolver.java │ │ ├── SimpleNoder.java │ │ ├── SinglePassNoder.java │ │ ├── package.html │ │ └── snapround │ │ │ ├── HotPixel.java │ │ │ ├── MCIndexPointSnapper.java │ │ │ ├── MCIndexSnapRounder.java │ │ │ ├── SimpleSnapRounder.java │ │ │ └── package.html │ ├── operation │ │ ├── BoundaryOp.java │ │ ├── GeometryGraphOperation.java │ │ ├── IsSimpleOp.java │ │ ├── buffer │ │ │ ├── BufferBuilder.java │ │ │ ├── BufferOp.java │ │ │ ├── BufferSubgraph.java │ │ │ ├── OffsetCurveBuilder.java │ │ │ ├── OffsetCurveSetBuilder.java │ │ │ ├── RightmostEdgeFinder.java │ │ │ ├── SubgraphDepthLocater.java │ │ │ └── package.html │ │ ├── distance │ │ │ ├── ConnectedElementLocationFilter.java │ │ │ ├── ConnectedElementPointFilter.java │ │ │ ├── DistanceOp.java │ │ │ ├── GeometryLocation.java │ │ │ └── package.html │ │ ├── linemerge │ │ │ ├── EdgeString.java │ │ │ ├── LineMergeDirectedEdge.java │ │ │ ├── LineMergeEdge.java │ │ │ ├── LineMergeGraph.java │ │ │ ├── LineMerger.java │ │ │ └── LineSequencer.java │ │ ├── overlay │ │ │ ├── ConsistentPolygonRingChecker.java │ │ │ ├── EdgeSetNoder.java │ │ │ ├── LineBuilder.java │ │ │ ├── MaximalEdgeRing.java │ │ │ ├── MinimalEdgeRing.java │ │ │ ├── OverlayNodeFactory.java │ │ │ ├── OverlayOp.java │ │ │ ├── PointBuilder.java │ │ │ ├── PolygonBuilder.java │ │ │ ├── package.html │ │ │ ├── snap │ │ │ │ ├── GeometrySnapper.java │ │ │ │ ├── LineStringSnapper.java │ │ │ │ ├── SnapIfNeededOverlayOp.java │ │ │ │ └── SnapOverlayOp.java │ │ │ └── validate │ │ │ │ ├── FuzzyPointLocator.java │ │ │ │ ├── OffsetPointGenerator.java │ │ │ │ └── OverlayResultValidator.java │ │ ├── package.html │ │ ├── polygonize │ │ │ ├── EdgeRing.java │ │ │ ├── PolygonizeDirectedEdge.java │ │ │ ├── PolygonizeEdge.java │ │ │ ├── PolygonizeGraph.java │ │ │ └── Polygonizer.java │ │ ├── predicate │ │ │ ├── RectangleContains.java │ │ │ ├── RectangleIntersects.java │ │ │ └── SegmentIntersectionTester.java │ │ ├── relate │ │ │ ├── EdgeEndBuilder.java │ │ │ ├── EdgeEndBundle.java │ │ │ ├── EdgeEndBundleStar.java │ │ │ ├── RelateComputer.java │ │ │ ├── RelateNode.java │ │ │ ├── RelateNodeFactory.java │ │ │ ├── RelateNodeGraph.java │ │ │ ├── RelateOp.java │ │ │ └── package.html │ │ └── valid │ │ │ ├── ConnectedInteriorTester.java │ │ │ ├── ConsistentAreaTester.java │ │ │ ├── IsValidOp.java │ │ │ ├── QuadtreeNestedRingTester.java │ │ │ ├── RepeatedPointTester.java │ │ │ ├── SimpleNestedRingTester.java │ │ │ ├── SweeplineNestedRingTester.java │ │ │ ├── TopologyValidationError.java │ │ │ └── package.html │ ├── planargraph │ │ ├── DirectedEdge.java │ │ ├── DirectedEdgeStar.java │ │ ├── Edge.java │ │ ├── GraphComponent.java │ │ ├── Node.java │ │ ├── NodeMap.java │ │ ├── PlanarGraph.java │ │ ├── Subgraph.java │ │ ├── algorithm │ │ │ └── ConnectedSubgraphFinder.java │ │ └── package.html │ ├── polygonize │ │ └── package.html │ ├── precision │ │ ├── CommonBits.java │ │ ├── CommonBitsOp.java │ │ ├── CommonBitsRemover.java │ │ ├── EnhancedPrecisionOp.java │ │ ├── SimpleGeometryPrecisionReducer.java │ │ └── package.html │ ├── simplify │ │ ├── DouglasPeuckerLineSimplifier.java │ │ ├── DouglasPeuckerSimplifier.java │ │ ├── LineSegmentIndex.java │ │ ├── TaggedLineSegment.java │ │ ├── TaggedLineString.java │ │ ├── TaggedLineStringSimplifier.java │ │ ├── TaggedLinesSimplifier.java │ │ └── TopologyPreservingSimplifier.java │ └── util │ │ ├── Assert.java │ │ ├── AssertionFailedException.java │ │ ├── CollectionUtil.java │ │ ├── CoordinateArrayFilter.java │ │ ├── CoordinateCountFilter.java │ │ ├── Debug.java │ │ ├── GeometricShapeFactory.java │ │ ├── Stopwatch.java │ │ ├── UniqueCoordinateArrayFilter.java │ │ └── package.html │ └── jtsexample │ ├── geom │ ├── BasicExample.java │ ├── ConstructionExample.java │ ├── ExtendedCoordinate.java │ ├── ExtendedCoordinateExample.java │ ├── ExtendedCoordinateSequence.java │ ├── ExtendedCoordinateSequenceFactory.java │ ├── PrecisionModelExample.java │ └── SimpleMethodsExample.java │ ├── linearref │ └── LinearRefExample.java │ ├── operation │ ├── distance │ │ └── ClosestPointExample.java │ ├── linemerge │ │ └── LineMergeExample.java │ └── polygonize │ │ └── PolygonizeExample.java │ ├── package.html │ ├── precision │ └── EnhancedPrecisionOpExample.java │ └── technique │ ├── LineStringSelfIntersections.java │ └── PolygonUnionUsingBuffer.java └── testxml ├── general ├── TestBoundary.xml ├── TestCentroid.xml ├── TestConvexHull-big.xml ├── TestConvexHull.xml ├── TestFunctionAA.xml ├── TestFunctionAAPrec.xml ├── TestFunctionLA.xml ├── TestFunctionLAPrec.xml ├── TestFunctionLL.xml ├── TestFunctionLLPrec.xml ├── TestFunctionPA.xml ├── TestFunctionPL.xml ├── TestFunctionPLPrec.xml ├── TestFunctionPP.xml ├── TestInteriorPoint.xml ├── TestRectanglePredicate.xml ├── TestRelateAA.xml ├── TestRelateAC.xml ├── TestRelateLA.xml ├── TestRelateLC.xml ├── TestRelateLL.xml ├── TestRelatePA.xml ├── TestRelatePL.xml ├── TestRelatePP.xml ├── TestSimple.xml ├── TestValid.xml ├── TestValid2-big.xml ├── TestValid2.xml └── TestWithinDistance.xml ├── robust ├── ExternalRobustness.xml ├── TestRobustOverlayFixed.xml ├── TestRobustOverlayFloat.xml └── TestRobustRelate.xml ├── stmlf ├── stmlf-cases-20061018_int.xml └── stmlf-cases-20061020_int.xml └── validate ├── TestRelateAA-big.xml ├── TestRelateAA.xml ├── TestRelateAC.xml ├── TestRelateLA.xml ├── TestRelateLC.xml ├── TestRelateLL.xml ├── TestRelatePA.xml ├── TestRelatePL.xml └── TestRelatePP.xml /bin/test.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem A batch file to run the XML test files written by Geographic Data BC. 3 | 4 | set CLASSPATH= 5 | for %%i in (..\lib\*.*) do ( 6 | set jarfile=%%i 7 | 8 | rem If we append to a variable inside the for, only the last entry will 9 | rem be kept. So append to the variable outside the for. 10 | rem See http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20561701.html. 11 | rem [Jon Aquino] 12 | 13 | call :setclass 14 | ) 15 | 16 | java com.vividsolutions.jtstest.testrunner.TopologyTestApp -Files ..\testxml\validate ..\testxml\general 17 | pause 18 | 19 | goto :eof 20 | 21 | :setclass 22 | set CLASSPATH=%jarfile%;%CLASSPATH% 23 | set jarfile= 24 | 25 | :eof -------------------------------------------------------------------------------- /bin/test_robust.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem A batch file to run a XML test files 3 | 4 | set CLASSPATH= 5 | for %%i in (..\lib\*.*) do ( 6 | set jarfile=%%i 7 | 8 | rem If we append to a variable inside the for, only the last entry will 9 | rem be kept. So append to the variable outside the for. 10 | rem See http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20561701.html. 11 | rem [Jon Aquino] 12 | 13 | call :setclass 14 | ) 15 | 16 | java com.vividsolutions.jtstest.testrunner.TopologyTestApp -Files ..\testxml\robust 17 | pause 18 | 19 | goto :eof 20 | 21 | :setclass 22 | set CLASSPATH=%jarfile%;%CLASSPATH% 23 | set jarfile= 24 | 25 | :eof -------------------------------------------------------------------------------- /bin/test_stmlf.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem A batch file to run a XML test files 3 | 4 | set CLASSPATH= 5 | for %%i in (..\lib\*.*) do ( 6 | set jarfile=%%i 7 | 8 | rem If we append to a variable inside the for, only the last entry will 9 | rem be kept. So append to the variable outside the for. 10 | rem See http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20561701.html. 11 | rem [Jon Aquino] 12 | 13 | call :setclass 14 | ) 15 | 16 | java com.vividsolutions.jtstest.testrunner.TopologyTestApp -Files ..\testxml\stmlf -geomop com.vividsolutions.jtstest.testrunner.geomop.OverlayValidatedGeometryOperation 17 | pause 18 | 19 | goto :eof 20 | 21 | :setclass 22 | set CLASSPATH=%jarfile%;%CLASSPATH% 23 | set jarfile= 24 | 25 | :eof -------------------------------------------------------------------------------- /bin/testbuilder.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem A batch file to run the JTS Test Builder 3 | 4 | set CLASSPATH= 5 | for %%i in (..\lib\*.*) do ( 6 | set jarfile=%%i 7 | 8 | rem If we append to a variable inside the for, only the last entry will 9 | rem be kept. So append to the variable outside the for. 10 | rem See http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20561701.html. 11 | rem [Jon Aquino] 12 | 13 | call :setclass 14 | ) 15 | 16 | start javaw com.vividsolutions.jtstest.testbuilder.JTSTestBuilder 17 | 18 | goto :eof 19 | 20 | :setclass 21 | set CLASSPATH=%jarfile%;%CLASSPATH% 22 | set jarfile= 23 | 24 | :eof -------------------------------------------------------------------------------- /bin/testrunner.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem A batch file to run the JTS test runner. 3 | 4 | set CLASSPATH= 5 | for %%i in (..\lib\*.*) do ( 6 | set jarfile=%%i 7 | 8 | rem If we append to a variable inside the for, only the last entry will 9 | rem be kept. So append to the variable outside the for. 10 | rem See http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20561701.html. 11 | rem [Jon Aquino] 12 | 13 | call :setclass 14 | ) 15 | 16 | start javaw com.vividsolutions.jtstest.testrunner.TopologyTestApp -Properties testrunner.properties -GUI 17 | 18 | goto :eof 19 | 20 | :setclass 21 | set CLASSPATH=%jarfile%;%CLASSPATH% 22 | set jarfile= 23 | 24 | :eof -------------------------------------------------------------------------------- /bin/testrunner.properties: -------------------------------------------------------------------------------- 1 | #Properties file for class com.vividsolutions.jtstest.testrunner.TopologyTestApp 2 | #Wed Dec 06 16:08:49 PST 2006 3 | TestFiles=\ Z\:\\proj\\jts\\robust\\tests\\unit\\cmp-5966094-2025063.xml 4 | -------------------------------------------------------------------------------- /debian/README.Debian-source: -------------------------------------------------------------------------------- 1 | jts for Debian 2 | -------------- 3 | 4 | As upstream only distributes as binary/source combination zip file 5 | I do repackaging to remove the binary parts: 6 | 7 | - unzip jts-.zip into a jts- directory 8 | - rm -Rf lib - to remove the prebuild and dependency runtime libraries 9 | - rm -Rf doc/javadoc - to remove the javadoc 10 | - build the jts_.orig.tar.gz 11 | 12 | -- Wolfgang Baer , Thu, 27 Jan 2005 10:38:29 +0100 13 | 14 | Removed PDF documentation and oracle stuff starting from 1.7 15 | 16 | -- Francesco Paolo Lovergine , Sat, 16 Jun 2007 00:31:55 +0100 17 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | jts (1.8-0sg9) UNRELEASED; urgency=low 2 | 3 | * UNRELEASED 4 | 5 | -- SimpleGeo Nerds Tue, 07 Sep 2010 16:33:07 +0000 6 | 7 | jts (1.8-0sg8) UNRELEASED; urgency=low 8 | 9 | [ Ian Eure ] 10 | * Fix source format. 11 | * Apply CoordinateList fixes from v1.9. 12 | 13 | [ SimpleGeo Nerds ] 14 | 15 | -- SimpleGeo Nerds Tue, 31 Aug 2010 00:51:16 +0000 16 | 17 | jts (1.8-0sg0) unstable; urgency=low 18 | 19 | * New upstream version. 20 | 21 | -- Ian Eure Mon, 30 Aug 2010 16:38:53 -0700 22 | 23 | jts (1.7-2) unstable; urgency=low 24 | 25 | * Added Homepage field to debian/control. 26 | * Added Vcs-* fields to debian/control. 27 | * Now using default-jdk/jre instead of kaffe. 28 | (closes: #547392) 29 | * Wolfgang removed among uploaders, because inactive since years. 30 | * Fixed lintian warning: debhelper-but-no-misc-depends. 31 | * Debhelper compatibility set to 7. 32 | * Fixed lintian error: clean-should-be-satisfied-by-build-depends. 33 | * Fixed Section for libjts-java. 34 | * Copyright fixed: JTS is released under LGPL 2.1 or later. 35 | 36 | -- Francesco Paolo Lovergine Tue, 22 Sep 2009 11:16:16 +0200 37 | 38 | jts (1.7-1) unstable; urgency=low 39 | 40 | * New upstream release 41 | (closes: #362120) 42 | * Policy bumped to 3.7.2, without changes 43 | * Debhelper compatibility set to 5. 44 | 45 | -- Francesco Paolo Lovergine Sat, 16 Jun 2007 00:27:01 +0200 46 | 47 | jts (1.6-2) unstable; urgency=low 48 | 49 | * Kaffe compiler transition. 50 | * Updated FSF address in debian/copyright 51 | 52 | -- Wolfgang Baer Sun, 15 Jan 2006 16:01:03 +0100 53 | 54 | jts (1.6-1) unstable; urgency=low 55 | 56 | * New upstream release 57 | * Upload to unstable 58 | * Adjusted copyright to include the second download location 59 | * Fixed minor lintian warnings in debian/control 60 | * Standards-Version 3.6.2 (no changes needed) 61 | * Changed libant1.6-java build-dep to ant (now in main) 62 | 63 | * Upload sponsored by Petter Reinholdtsen 64 | 65 | -- Wolfgang Baer Sun, 7 Aug 2005 14:12:35 +0200 66 | 67 | jts (1.5-1) experimental; urgency=low 68 | 69 | * Initial Release (closes: #294756) 70 | 71 | -- Wolfgang Baer Thu, 27 Jan 2005 10:38:29 +0100 72 | 73 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: jts 2 | Section: libs 3 | Priority: optional 4 | Maintainer: Debian GIS Project 5 | Uploaders: Francesco Paolo Lovergine , Ian Eure 6 | Build-Depends: debhelper (>= 7), cdbs, ant, default-jdk 7 | Standards-Version: 3.8.3 8 | Homepage: http://www.vividsolutions.com/jts/jtshome.htm 9 | Vcs-Browser: http://svn.debian.org/wsvn/pkg-grass/packages/jts/ 10 | Vcs-Svn: svn://svn.debian.org/pkg-grass/packages/jts/ 11 | 12 | Package: libjts-java 13 | Architecture: all 14 | Section: java 15 | Depends: default-jre-headless | default-jre, ${misc:Depends} 16 | Suggests: libjts-java-doc 17 | Description: Java Topology Suite 18 | JTS is a java library which provides: 19 | * an implementation of the spatial data model defined 20 | in the OGC Simple Features Specification for SQL (SFS) 21 | * a complete, consistent, implementation of fundamental 2D spatial algorithms 22 | * an explicit precision model, with algorithms that gracefully handle 23 | situations that result in dimensional collapse 24 | * robust implementations of key computational geometric operations 25 | * I/O in Well-Known Text format 26 | 27 | Package: libjts-java-doc 28 | Architecture: all 29 | Section: doc 30 | Depends: ${misc:Depends} 31 | Suggests: libjts-java 32 | Description: Documentation for the Java Topology Suite JTS 33 | Documentation for programmers: 34 | * javadoc for libjts-java 35 | * developer guide 36 | * technical Specifications etc 37 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Wolfgang Baer on 2 | Thu, 27 Jan 2005 10:38:29 +0100. 3 | 4 | It was downloaded from 5 | and is also available form 6 | 7 | Copyright: 8 | 9 | Upstream Authors: 10 | 11 | Martin Davis 12 | Jonathan Aquino 13 | David Skea 14 | Yao Cui 15 | Mark Sondheim 16 | Denis Boutin 17 | David Ash 18 | 19 | 20 | License: 21 | 22 | This package is free software; you can redistribute it and/or modify 23 | it under the terms of the GNU Lesser General Public License as published by 24 | the Free Software Foundation; version 2.1 dated February 1999 or later. 25 | 26 | This package is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | GNU Lesser General Public License for more details. 30 | You should have received a copy of the GNU Lesser General Public License 31 | along with this package; if not, write to the Free Software 32 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 33 | 34 | On Debian systems, the complete text of the GNU Lesser General 35 | Public License can be found in `/usr/share/common-licenses/LGPL'. 36 | -------------------------------------------------------------------------------- /debian/libjts-java-doc.docs: -------------------------------------------------------------------------------- 1 | doc/* 2 | target/docs/api 3 | target/docs/examples 4 | -------------------------------------------------------------------------------- /debian/libjts-java.dirs: -------------------------------------------------------------------------------- 1 | usr/share/java 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # debian/rules file for jts (uses cdbs) 3 | 4 | include /usr/share/cdbs/1/rules/debhelper.mk 5 | include /usr/share/cdbs/1/class/ant.mk 6 | 7 | export UPSTREAM_VERSION = $(shell head -1 debian/changelog | cut -f2 -d\( | cut -f1 -d\) | cut -f1 -d\-) 8 | 9 | JAVA_HOME := /usr/lib/jvm/default-java 10 | JAVA_CMD := /usr/bin/java 11 | ANT_HOME := /usr/share/ant 12 | 13 | DEB_JARS := $(ANT_HOME)/lib/ant-launcher.jar 14 | DEB_ANT_BUILDFILE := debian/build.xml 15 | DEB_ANT_BUILD_TARGET := all 16 | 17 | install/libjts-java:: 18 | install -m 644 target/jts.jar debian/libjts-java/usr/share/java/jts-$(UPSTREAM_VERSION).jar 19 | ln -s jts-$(UPSTREAM_VERSION).jar debian/libjts-java/usr/share/java/jts.jar 20 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 36 | 37 |
GMLHandler 24 |
25 | GMLReader 26 |
27 | GMLWriter 28 |
29 | GeometryStrategies 30 |
31 | OraReader 32 |
33 | OraWriter 34 |
35 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 36 | 37 |
GMLHandler 24 |
25 | GMLReader 26 |
27 | GMLWriter 28 |
29 | GeometryStrategies 30 |
31 | OraReader 32 |
33 | OraWriter 34 |
35 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/com/vividsolutions/jts/io/gml2/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.vividsolutions.jts.io.gml2 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.vividsolutions.jts.io.gml2 20 | 21 | 22 | 33 | 34 |
23 | Classes  24 | 25 |
26 | GeometryStrategies 27 |
28 | GMLHandler 29 |
30 | GMLReader 31 |
32 | GMLWriter
35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/com/vividsolutions/jts/io/oracle/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.vividsolutions.jts.io.oracle 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.vividsolutions.jts.io.oracle 20 | 21 | 22 | 29 | 30 |
23 | Classes  24 | 25 |
26 | OraReader 27 |
28 | OraWriter
31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | <H2> 18 | Frame Alert</H2> 19 | 20 | <P> 21 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 22 | <BR> 23 | Link to<A HREF="overview-summary.html">Non-frame version.</A> 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 |
22 |
25 | 26 | 27 | 28 | 38 | 39 |
All Classes 29 |

30 | 31 | Packages 32 |
33 | com.vividsolutions.jts.io.gml2 34 |
35 | com.vividsolutions.jts.io.oracle 36 |
37 |

40 | 41 |

42 |   43 | 44 | 45 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/package-list: -------------------------------------------------------------------------------- 1 | com.vividsolutions.jts.io.gml2 2 | com.vividsolutions.jts.io.oracle 3 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/packages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 | 22 |
23 |

24 | The front page has been relocated.Please see: 25 |
26 |           Frame version 27 |
28 |           Non-frame version.
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /jtsio/doc/javadoc/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simplegeo/jts/3a4c9a9c3a7d3274e16bdd2f341df7d3e113d81b/jtsio/doc/javadoc/resources/inherit.gif -------------------------------------------------------------------------------- /jtsio/doc/javadoc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 29 | 30 | -------------------------------------------------------------------------------- /jtsio/src/com/vividsolutions/jts/io/gml2/package.html: -------------------------------------------------------------------------------- 1 | 2 | JTS IO: Java Topology Suite IO Library 3 | 4 | Classes to read and write the GML2 geometry format. 5 | 6 | -------------------------------------------------------------------------------- /jtsio/src/com/vividsolutions/jts/io/oracle/package.html: -------------------------------------------------------------------------------- 1 | 2 | JTS IO: Java Topology Suite IO Library 3 | 4 | Classes to read and write Oracle SDO_GEOMETRY object structures. 5 | 6 | -------------------------------------------------------------------------------- /jtsio/test/com/vividsolutions/jts/generator/PointGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.generator; 34 | 35 | import com.vividsolutions.jts.geom.Geometry; 36 | import com.vividsolutions.jts.geom.Point; 37 | 38 | /** 39 | * 40 | * Creates a point based on the bounding box. 41 | * 42 | * This implementation returns the centroid. 43 | * 44 | * @author David Zwiers, Vivid Solutions. 45 | */ 46 | public class PointGenerator extends GeometryGenerator { 47 | 48 | /** 49 | * @see com.vividsolutions.jts.generator.GeometryGenerator#create() 50 | * @throws NullPointerException when either the Geometry Factory, or the Bounding Box are undefined. 51 | */ 52 | public Geometry create() { 53 | if(geometryFactory == null){ 54 | throw new NullPointerException("GeometryFactory is not declared"); 55 | } 56 | if(boundingBox == null || boundingBox.isNull()){ 57 | throw new NullPointerException("Bounding Box is not declared"); 58 | } 59 | 60 | Point p = geometryFactory.toGeometry(boundingBox).getCentroid(); 61 | geometryFactory.getPrecisionModel().makePrecise(p.getCoordinate()); 62 | return p; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /jtsio/test/com/vividsolutions/jts/io/gml2/WritingTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.io.gml2; 34 | 35 | import java.io.*; 36 | 37 | import com.vividsolutions.jts.geom.GeometryFactory; 38 | import com.vividsolutions.jts.geom.PrecisionModel; 39 | 40 | import junit.framework.TestCase; 41 | 42 | /** 43 | * 44 | * Abstract Test Case. Intended to provide some IO operations for the middle of a test. 45 | * 46 | * 47 | * @author David Zwiers, Vivid Solutions. 48 | */ 49 | public class WritingTestCase extends TestCase { 50 | 51 | /** 52 | * @param arg 53 | */ 54 | public WritingTestCase(String arg){ 55 | super(arg); 56 | } 57 | 58 | protected StringWriter sw = null; 59 | protected Writer getWriter(){ 60 | sw = new StringWriter(); 61 | sw.write("\n"); 62 | return sw; 63 | } 64 | protected Reader getReader() throws IOException{ 65 | sw.flush(); 66 | sw.close(); 67 | String s = sw.toString(); 68 | 69 | // System.out.println(s); 70 | 71 | return new StringReader(s); 72 | } 73 | 74 | protected static PrecisionModel precisionModel = new PrecisionModel(1000); 75 | protected static GeometryFactory geometryFactory = new GeometryFactory(precisionModel); 76 | 77 | } 78 | -------------------------------------------------------------------------------- /jtsio/test/com/vividsolutions/jts/io/oracle/connection.properties: -------------------------------------------------------------------------------- 1 | test.server=Neptune 2 | test.port=1521 3 | test.sid=LRDW 4 | test.user=inventory 5 | test.pwd=password -------------------------------------------------------------------------------- /jtsio/test/data/points.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 24000.0,36000.0 7 | 8 | 9 | 10 | 32000.0,36000.0 11 | 12 | 13 | 14 | 40000.0,36000.0 15 | 16 | 17 | 18 | 48000.0,36000.0 19 | 20 | 21 | 22 | 56000.0,36000.0 23 | 24 | 25 | 26 | 24000.0,48000.0 27 | 28 | 29 | 30 | 32000.0,48000.0 31 | 32 | 33 | 34 | 40000.0,48000.0 35 | 36 | 37 | 38 | 48000.0,48000.0 39 | 40 | 41 | 42 | 56000.0,48000.0 43 | 44 | 45 | 46 | 24000.0,60000.0 47 | 48 | 49 | 50 | 32000.0,60000.0 51 | 52 | 53 | 54 | 40000.0,60000.0 55 | 56 | 57 | 58 | 48000.0,60000.0 59 | 60 | 61 | 62 | 56000.0,60000.0 63 | 64 | 65 | 66 | 24000.0,72000.0 67 | 68 | 69 | 70 | 32000.0,72000.0 71 | 72 | 73 | 74 | 40000.0,72000.0 75 | 76 | 77 | 78 | 48000.0,72000.0 79 | 80 | 81 | 82 | 56000.0,72000.0 83 | 84 | 85 | 86 | 24000.0,84000.0 87 | 88 | 89 | 90 | 32000.0,84000.0 91 | 92 | 93 | 94 | 40000.0,84000.0 95 | 96 | 97 | 98 | 48000.0,84000.0 99 | 100 | 101 | 102 | 56000.0,84000.0 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /jtsio/test/readme: -------------------------------------------------------------------------------- 1 | Set of tests and testing utilities which require the same jar set as the src directory, with the exception of the junit jar. -------------------------------------------------------------------------------- /src/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-version: 1.0 2 | Implementation-Title: Java Topology Suite 3 | Implementation-Version: 1.7 4 | Implementation-Vendor: Vivid Solutions 5 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/JTSVersion.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts; 2 | 3 | /** 4 | * JTS API version information. 5 | *

6 | * Versions consist of a 3-part version number: major.minor.patch 7 | * An optional release status string may be present in the string version of 8 | * the version. 9 | * 10 | * @version 1.7 11 | */ 12 | public class JTSVersion { 13 | 14 | /** 15 | * The current version number of the JTS API. 16 | */ 17 | public static final JTSVersion CURRENT_VERSION = new JTSVersion(); 18 | 19 | /** 20 | * The major version number. 21 | */ 22 | public static final int MAJOR = 1; 23 | 24 | /** 25 | * The minor version number. 26 | */ 27 | public static final int MINOR = 8; 28 | 29 | /** 30 | * The patch version number. 31 | */ 32 | public static final int PATCH = 0; 33 | 34 | /** 35 | * An optional string providing further release info (such as "alpha 1"); 36 | */ 37 | private static final String releaseInfo = ""; 38 | 39 | /** 40 | * Prints the current JTS version to stdout. 41 | * 42 | * @param args the command-line arguments (none are required). 43 | */ 44 | public static void main(String[] args) 45 | { 46 | System.out.println(CURRENT_VERSION); 47 | } 48 | 49 | private JTSVersion() { 50 | } 51 | 52 | /** 53 | * Gets the major number of the release version. 54 | * 55 | * @return the major number of the release version. 56 | */ 57 | public int getMajor() { return MAJOR; } 58 | 59 | /** 60 | * Gets the minor number of the release version. 61 | * 62 | * @return the minor number of the release version. 63 | */ 64 | public int getMinor() { return MINOR; } 65 | 66 | /** 67 | * Gets the patch number of the release version. 68 | * 69 | * @return the patch number of the release version. 70 | */ 71 | public int getPatch() { return PATCH; } 72 | 73 | /** 74 | * Gets the full version number, suitable for display. 75 | * 76 | * @return the full version number, suitable for display. 77 | */ 78 | public String toString() 79 | { 80 | String ver = MAJOR + "." + MINOR + "." + PATCH; 81 | if (releaseInfo != null && releaseInfo.length() > 0) 82 | return ver + " " + releaseInfo; 83 | return ver; 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/algorithm/NotRepresentableException.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* 5 | * The JTS Topology Suite is a collection of Java classes that 6 | * implement the fundamental operations required to validate a given 7 | * geo-spatial data set to a known topological specification. 8 | * 9 | * Copyright (C) 2001 Vivid Solutions 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For more information, contact: 26 | * 27 | * Vivid Solutions 28 | * Suite #1A 29 | * 2328 Government Street 30 | * Victoria BC V8T 5G5 31 | * Canada 32 | * 33 | * (250)385-6040 34 | * www.vividsolutions.com 35 | */ 36 | package com.vividsolutions.jts.algorithm; 37 | 38 | /** 39 | * Indicates that a {@link HCoordinate} has been computed which is 40 | * not representable on the Cartesian plane. 41 | * 42 | * @version 1.7 43 | * @see HCoordinate 44 | */ 45 | public class NotRepresentableException extends Exception { 46 | 47 | public NotRepresentableException() { 48 | super("Projective point not representable on the Cartesian plane."); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/algorithm/PointInRing.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.algorithm; 35 | 36 | import com.vividsolutions.jts.geom.Coordinate; 37 | 38 | /** 39 | * An interface for classes which test whether a {@link Coordinate} lies inside 40 | * a ring. 41 | * 42 | * @version 1.7 43 | */ 44 | public interface PointInRing { 45 | 46 | boolean isInside(Coordinate pt); 47 | } 48 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/algorithm/RobustCGAlgorithms.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.algorithm; 36 | 37 | import com.vividsolutions.jts.geom.*; 38 | 39 | /** 40 | * Stub version of RobustCGAlgorithms for backwards compatibility. 41 | * Will be deprecated in next release - use CGAlgorithms instead. 42 | * 43 | * @version 1.7 44 | * 45 | */ 46 | public class RobustCGAlgorithms extends CGAlgorithms { 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/algorithm/SimplePointInRing.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.algorithm; 35 | 36 | import com.vividsolutions.jts.geom.*; 37 | 38 | /** 39 | * Tests whether a {@link Coordinate} lies inside 40 | * a ring, using a linear-time algorithm. 41 | * 42 | * @version 1.7 43 | */ 44 | public class SimplePointInRing 45 | implements PointInRing 46 | { 47 | 48 | private Coordinate[] pts; 49 | 50 | public SimplePointInRing(LinearRing ring) 51 | { 52 | pts = ring.getCoordinates(); 53 | } 54 | 55 | public boolean isInside(Coordinate pt) 56 | { 57 | return CGAlgorithms.isPointInRing(pt, pts); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/algorithm/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes and interfaces implementing fundamental computational geometry algorithms. 11 | 12 |

Robustness

13 | 14 | Geometrical algorithms involve a combination of combinatorial and numerical computation. As with 15 | all numerical computation using finite-precision numbers, the algorithms chosen are susceptible to 16 | problems of robustness. A robustness problem occurs when a numerical calculation produces an 17 | incorrect answer for some inputs due to round-off errors. Robustness problems are especially 18 | serious in geometric computation, since they can result in errors during topology building. 19 |

20 | There are many approaches to dealing with the problem of robustness in geometrical computation. 21 | Not surprisingly, most robust algorithms are substantially more complex and less performant than 22 | the non-robust versions. Fortunately, JTS is sensitive to robustness problems in only a few key 23 | functions (such as line intersection and the point-in-polygon test). There are efficient robust 24 | algorithms available for these functions, and these algorithms are implemented in JTS. 25 | 26 |

Computational Performance

27 | 28 | Runtime performance is an important consideration for a production-quality implementation of 29 | geometric algorithms. The most computationally intensive algorithm used in JTS is intersection 30 | detection. JTS methods need to determine both all intersection between the line segments in a 31 | single Geometry (self-intersection) and all intersections between the line segments of two different 32 | Geometries. 33 |

34 | The obvious naive algorithm for intersection detection (comparing every segment with every other) 35 | has unacceptably slow performance. There is a large literature of faster algorithms for intersection 36 | detection. Unfortunately, many of them involve substantial code complexity. JTS tries to balance code 37 | simplicity with performance gains. It uses some simple techniques to produce substantial performance 38 | gains for common types of input data. 39 | 40 | 41 |

Package Specification

42 | 43 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/CoordinateFilter.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.geom; 36 | 37 | 38 | /** 39 | * Geometry classes support the concept of applying a 40 | * coordinate filter to every coordinate in the Geometry. A 41 | * coordinate filter can either record information about each coordinate or 42 | * change the coordinate in some way. Coordinate filters implement the 43 | * interface CoordinateFilter. (CoordinateFilter is 44 | * an example of the Gang-of-Four Visitor pattern). Coordinate filters can be 45 | * used to implement such things as coordinate transformations, centroid and 46 | * envelope computation, and many other functions. 47 | * 48 | *@version 1.7 49 | */ 50 | public interface CoordinateFilter { 51 | 52 | /** 53 | * Performs an operation with or on coord. 54 | * 55 | *@param coord a Coordinate to which the filter is applied. 56 | */ 57 | void filter(Coordinate coord); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/CoordinateSequences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.geom; 34 | 35 | import java.util.*; 36 | 37 | /** 38 | * Utility functions for manipulating {@link CoordinateSequence}s 39 | * 40 | * @version 1.7 41 | */ 42 | public class CoordinateSequences { 43 | 44 | /** 45 | * Reverses the coordinates in a sequence in-place. 46 | */ 47 | public static void reverse(CoordinateSequence seq) 48 | { 49 | int last = seq.size() - 1; 50 | int mid = last / 2; 51 | for (int i = 0; i <= mid; i++) { 52 | swap(seq, i, last - i); 53 | } 54 | } 55 | 56 | /** 57 | * Swaps two coordinates in a sequence. 58 | * 59 | * @param seq 60 | * @param i 61 | * @param j 62 | */ 63 | public static void swap(CoordinateSequence seq, int i, int j) 64 | { 65 | if (i == j) return; 66 | for (int dim = 0; dim < seq.getDimension(); dim++) { 67 | double tmp = seq.getOrdinate(i, dim); 68 | seq.setOrdinate(i, dim, seq.getOrdinate(j, dim)); 69 | seq.setOrdinate(j, dim, tmp); 70 | } 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/GeometryComponentFilter.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.geom; 36 | 37 | 38 | /** 39 | * Geometry classes support the concept of applying 40 | * a GeometryComponentFilter 41 | * filter to the Geometry. 42 | * The filter is applied to every component of the Geometry 43 | * which is itself a Geometry. 44 | * (For instance, all the LinearRings in Polygons are visited.) 45 | *

46 | * A GeometryComponentFilter filter can either 47 | * record information about the Geometry 48 | * or change the Geometry in some way. 49 | * GeometryComponentFilter 50 | * is an example of the Gang-of-Four Visitor pattern. 51 | * 52 | *@version 1.7 53 | */ 54 | public interface GeometryComponentFilter { 55 | 56 | /** 57 | * Performs an operation with or on geom. 58 | * 59 | *@param geom a Geometry to which the filter is applied. 60 | */ 61 | void filter(Geometry geom); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/GeometryFilter.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.geom; 36 | 37 | 38 | /** 39 | * GeometryCollection classes support the concept of 40 | * applying a GeometryFilter to the Geometry. 41 | * The filter is applied to every element Geometry. 42 | * A GeometryFilter can either record information about the Geometry 43 | * or change the Geometry in some way. 44 | * GeometryFilter 45 | * is an example of the Gang-of-Four Visitor pattern. 46 | * 47 | *@version 1.7 48 | */ 49 | public interface GeometryFilter { 50 | 51 | /** 52 | * Performs an operation with or on geom. 53 | * 54 | *@param geom a Geometry to which the filter is applied. 55 | */ 56 | void filter(Geometry geom); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/TopologyException.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* 5 | * The JTS Topology Suite is a collection of Java classes that 6 | * implement the fundamental operations required to validate a given 7 | * geo-spatial data set to a known topological specification. 8 | * 9 | * Copyright (C) 2001 Vivid Solutions 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For more information, contact: 26 | * 27 | * Vivid Solutions 28 | * Suite #1A 29 | * 2328 Government Street 30 | * Victoria BC V8T 5G5 31 | * Canada 32 | * 33 | * (250)385-6040 34 | * www.vividsolutions.com 35 | */ 36 | package com.vividsolutions.jts.geom; 37 | 38 | /** 39 | * Indicates an invalid or inconsistent topological situation encountered during processing 40 | * 41 | * @version 1.7 42 | */ 43 | public class TopologyException 44 | extends RuntimeException 45 | { 46 | private static String msgWithCoord(String msg, Coordinate pt) 47 | { 48 | if (pt != null) 49 | return msg + " [ " + pt + " ]"; 50 | return msg; 51 | } 52 | 53 | private Coordinate pt = null; 54 | 55 | public TopologyException(String msg) 56 | { 57 | super(msg); 58 | } 59 | 60 | public TopologyException(String msg, Coordinate pt) 61 | { 62 | super(msgWithCoord(msg, pt)); 63 | this.pt = new Coordinate(pt); 64 | } 65 | 66 | public Coordinate getCoordinate() { return pt; } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains the Geometry interface hierarchy and supporting classes. 11 |

12 | The Java Topology Suite (JTS) is a Java API that implements a core set of spatial data operations using an explicit precision model and robust geometric algorithms. JTS is intended to be used in the development of applications that support the validation, cleaning, integration and querying of spatial datasets. 13 |

14 | JTS attempts to implement the OpenGIS Simple Features Specification (SFS) as accurately as possible. In some cases the SFS is unclear or omits a specification; in this case JTS attempts to choose a reasonable and consistent alternative. Differences from and elaborations of the SFS are documented in this specification. 15 | 16 |

Package Specification

17 | 18 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/util/LinearComponentExtracter.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.geom.util; 35 | 36 | import java.util.*; 37 | import com.vividsolutions.jts.geom.*; 38 | 39 | /** 40 | * Extracts all the 1-dimensional ({@link LineString}) components from a {@link Geometry}. 41 | * 42 | * @version 1.7 43 | */ 44 | public class LinearComponentExtracter 45 | implements GeometryComponentFilter 46 | { 47 | 48 | /** 49 | * Extracts the linear components from a single geometry. 50 | * If more than one geometry is to be processed, it is more 51 | * efficient to create a single {@link LineExtracterFilter} instance 52 | * and pass it to multiple geometries. 53 | * 54 | * @param geom the geometry from which to extract linear components 55 | * @return the list of linear components 56 | */ 57 | public static List getLines(Geometry geom) 58 | { 59 | List lines = new ArrayList(); 60 | geom.apply(new LinearComponentExtracter(lines)); 61 | return lines; 62 | } 63 | 64 | private List lines; 65 | 66 | /** 67 | * Constructs a LineExtracterFilter with a list in which to store LineStrings found. 68 | */ 69 | public LinearComponentExtracter(List lines) 70 | { 71 | this.lines = lines; 72 | } 73 | 74 | public void filter(Geometry geom) 75 | { 76 | if (geom instanceof LineString) lines.add(geom); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/util/NoninvertibleTransformationException.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.geom.util; 2 | 3 | /** 4 | * Indicates that an {@link AffineTransformation} 5 | * is non-invertible. 6 | * 7 | * @author Martin Davis 8 | */ 9 | public class NoninvertibleTransformationException 10 | extends Exception 11 | { 12 | public NoninvertibleTransformationException() 13 | { 14 | super(); 15 | } 16 | public NoninvertibleTransformationException(String msg) 17 | { 18 | super(msg); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/util/PointExtracter.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.geom.util; 35 | 36 | import java.util.*; 37 | import com.vividsolutions.jts.geom.*; 38 | 39 | /** 40 | * Extracts all the 0-dimensional ({@link Point}) components from a {@link Geometry}. 41 | * 42 | * @version 1.7 43 | */ 44 | public class PointExtracter 45 | implements GeometryFilter 46 | { 47 | /** 48 | * Returns the Point components from a single geometry. 49 | * If more than one geometry is to be processed, it is more 50 | * efficient to create a single {@link PointExtracterFilter} instance 51 | * and pass it to multiple geometries. 52 | */ 53 | public static List getPoints(Geometry geom) 54 | { 55 | List pts = new ArrayList(); 56 | geom.apply(new PointExtracter(pts)); 57 | return pts; 58 | } 59 | 60 | private List pts; 61 | /** 62 | * Constructs a PointExtracterFilter with a list in which to store Points found. 63 | */ 64 | public PointExtracter(List pts) 65 | { 66 | this.pts = pts; 67 | } 68 | 69 | public void filter(Geometry geom) 70 | { 71 | if (geom instanceof Point) pts.add(geom); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/util/PolygonExtracter.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.geom.util; 35 | 36 | import java.util.*; 37 | import com.vividsolutions.jts.geom.*; 38 | 39 | /** 40 | * Extracts all the 2-dimensional ({@link Polygon}) components from a {@link Geometry}. 41 | * 42 | * @version 1.7 43 | */ 44 | public class PolygonExtracter 45 | implements GeometryFilter 46 | { 47 | /** 48 | * Returns the Polygon components from a single geometry. 49 | * If more than one geometry is to be processed, it is more 50 | * efficient to create a single {@link PolygonExtracterFilter} instance 51 | * and pass it to multiple geometries. 52 | */ 53 | public static List getPolygons(Geometry geom) 54 | { 55 | List comps = new ArrayList(); 56 | geom.apply(new PolygonExtracter(comps)); 57 | return comps; 58 | } 59 | 60 | private List comps; 61 | /** 62 | * Constructs a PolygonExtracterFilter with a list in which to store Polygons found. 63 | */ 64 | public PolygonExtracter(List comps) 65 | { 66 | this.comps = comps; 67 | } 68 | 69 | public void filter(Geometry geom) 70 | { 71 | if (geom instanceof Polygon) comps.add(geom); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/util/ShortCircuitedGeometryVisitor.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.geom.util; 2 | 3 | import com.vividsolutions.jts.geom.*; 4 | 5 | /** 6 | * A visitor to {@link Geometry} elements which can 7 | * be short-circuited by a given condition 8 | * 9 | * @version 1.7 10 | */ 11 | public abstract class ShortCircuitedGeometryVisitor 12 | { 13 | private boolean isDone = false; 14 | 15 | public ShortCircuitedGeometryVisitor() { 16 | } 17 | 18 | public void applyTo(Geometry geom) { 19 | for (int i = 0; i < geom.getNumGeometries() && ! isDone; i++) { 20 | Geometry element = geom.getGeometryN(i); 21 | if (! (element instanceof GeometryCollection)) { 22 | visit(element); 23 | if (isDone()) { 24 | isDone = true; 25 | return; 26 | } 27 | } 28 | else 29 | applyTo(element); 30 | } 31 | } 32 | 33 | protected abstract void visit(Geometry element); 34 | 35 | protected abstract boolean isDone(); 36 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geom/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Provides classes that parse and modify Geometry objects. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geomgraph/EdgeNodingValidator.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.geomgraph; 35 | 36 | import java.util.*; 37 | import com.vividsolutions.jts.algorithm.*; 38 | import com.vividsolutions.jts.geom.*; 39 | import com.vividsolutions.jts.noding.*; 40 | 41 | /** 42 | * Validates that a collection of {@link Edge}s is correctly noded. 43 | * Throws an appropriate exception if an noding error is found. 44 | * 45 | * @version 1.7 46 | */ 47 | public class EdgeNodingValidator 48 | { 49 | 50 | private static Collection toSegmentStrings(Collection edges) 51 | { 52 | // convert Edges to SegmentStrings 53 | Collection segStrings = new ArrayList(); 54 | for (Iterator i = edges.iterator(); i.hasNext(); ) { 55 | Edge e = (Edge) i.next(); 56 | segStrings.add(new SegmentString(e.getCoordinates(), e)); 57 | } 58 | return segStrings; 59 | } 60 | 61 | private NodingValidator nv; 62 | 63 | /** 64 | * Creates a new validator for the given collection of {@link Edge}s. 65 | * 66 | * @param edges a collection of Edges. 67 | */ 68 | public EdgeNodingValidator(Collection edges) 69 | { 70 | nv = new NodingValidator(toSegmentStrings(edges)); 71 | } 72 | 73 | /** 74 | * Checks whether the supplied edges 75 | * are correctly noded. Throws an exception if they are not. 76 | * 77 | * @throws RuntimeException if the SegmentStrings are not correctly noded 78 | */ 79 | public void checkValid() 80 | { 81 | nv.checkValid(); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geomgraph/NodeFactory.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.geomgraph; 35 | 36 | import com.vividsolutions.jts.geom.Coordinate; 37 | 38 | 39 | /** 40 | * @version 1.7 41 | */ 42 | public class NodeFactory { 43 | /** 44 | * The basic node constructor does not allow for incident edges 45 | */ 46 | public Node createNode(Coordinate coord) 47 | { 48 | return new Node(coord, null); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geomgraph/Position.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* 5 | * The JTS Topology Suite is a collection of Java classes that 6 | * implement the fundamental operations required to validate a given 7 | * geo-spatial data set to a known topological specification. 8 | * 9 | * Copyright (C) 2001 Vivid Solutions 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For more information, contact: 26 | * 27 | * Vivid Solutions 28 | * Suite #1A 29 | * 2328 Government Street 30 | * Victoria BC V8T 5G5 31 | * Canada 32 | * 33 | * (250)385-6040 34 | * www.vividsolutions.com 35 | */ 36 | package com.vividsolutions.jts.geomgraph; 37 | 38 | /** 39 | * A Position indicates the position of a Location relative to a graph component 40 | * (Node, Edge, or Area). 41 | * @version 1.7 42 | */ 43 | public class Position { 44 | 45 | /** An indicator that a Location is on a GraphComponent */ 46 | public static final int ON = 0; 47 | /** An indicator that a Location is to the left of a GraphComponent */ 48 | public static final int LEFT = 1; 49 | /** An indicator that a Location is to the right of a GraphComponent */ 50 | public static final int RIGHT = 2; 51 | /** 52 | * Returns LEFT if the position is RIGHT, RIGHT if the position is LEFT, or the position 53 | * otherwise. 54 | */ 55 | public static final int opposite(int position) 56 | { 57 | if (position == LEFT) return RIGHT; 58 | if (position == RIGHT) return LEFT; 59 | return position; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geomgraph/index/MonotoneChain.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* 5 | * The JTS Topology Suite is a collection of Java classes that 6 | * implement the fundamental operations required to validate a given 7 | * geo-spatial data set to a known topological specification. 8 | * 9 | * Copyright (C) 2001 Vivid Solutions 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For more information, contact: 26 | * 27 | * Vivid Solutions 28 | * Suite #1A 29 | * 2328 Government Street 30 | * Victoria BC V8T 5G5 31 | * Canada 32 | * 33 | * (250)385-6040 34 | * www.vividsolutions.com 35 | */ 36 | package com.vividsolutions.jts.geomgraph.index; 37 | 38 | /** 39 | * @version 1.7 40 | */ 41 | public class MonotoneChain { 42 | 43 | MonotoneChainEdge mce; 44 | int chainIndex; 45 | 46 | public MonotoneChain(MonotoneChainEdge mce, int chainIndex) { 47 | this.mce = mce; 48 | this.chainIndex = chainIndex; 49 | } 50 | 51 | public void computeIntersections(MonotoneChain mc, SegmentIntersector si) 52 | { 53 | this.mce.computeIntersectsForChain(chainIndex, mc.mce, mc.chainIndex, si); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geomgraph/index/SweepLineSegment.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* 5 | * The JTS Topology Suite is a collection of Java classes that 6 | * implement the fundamental operations required to validate a given 7 | * geo-spatial data set to a known topological specification. 8 | * 9 | * Copyright (C) 2001 Vivid Solutions 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For more information, contact: 26 | * 27 | * Vivid Solutions 28 | * Suite #1A 29 | * 2328 Government Street 30 | * Victoria BC V8T 5G5 31 | * Canada 32 | * 33 | * (250)385-6040 34 | * www.vividsolutions.com 35 | */ 36 | package com.vividsolutions.jts.geomgraph.index; 37 | 38 | import com.vividsolutions.jts.geom.Coordinate; 39 | import com.vividsolutions.jts.geomgraph.*; 40 | 41 | 42 | /** 43 | * @version 1.7 44 | */ 45 | public class SweepLineSegment { 46 | 47 | Edge edge; 48 | Coordinate[] pts; 49 | int ptIndex; 50 | 51 | public SweepLineSegment(Edge edge, int ptIndex) { 52 | this.edge = edge; 53 | this.ptIndex = ptIndex; 54 | pts = edge.getCoordinates(); 55 | } 56 | 57 | public double getMinX() 58 | { 59 | double x1 = pts[ptIndex].x; 60 | double x2 = pts[ptIndex + 1].x; 61 | return x1 < x2 ? x1 : x2; 62 | } 63 | public double getMaxX() 64 | { 65 | double x1 = pts[ptIndex].x; 66 | double x2 = pts[ptIndex + 1].x; 67 | return x1 > x2 ? x1 : x2; 68 | } 69 | public void computeIntersections(SweepLineSegment ss, SegmentIntersector si) 70 | { 71 | si.addIntersections(edge, ptIndex, ss.edge, ss.ptIndex); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geomgraph/index/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes that implement indexes for performing noding on geometry graph edges. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/geomgraph/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes that implement topology graphs. 11 |

12 | The Java Topology Suite (JTS) is a Java API that implements a core set of spatial data operations using an explicit precision model and robust geometric algorithms. JTS is intended to be used in the development of applications that support the validation, cleaning, integration and querying of spatial datasets. 13 |

14 | JTS attempts to implement the OpenGIS Simple Features Specification (SFS) as accurately as possible. In some cases the SFS is unclear or omits a specification; in this case JTS attempts to choose a reasonable and consistent alternative. Differences from and elaborations of the SFS are documented in this specification. 15 | 16 |

Package Specification

17 | 18 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/ArrayListVisitor.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.index; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.index.ItemVisitor; 5 | 6 | /** 7 | * @version 1.7 8 | */ 9 | public class ArrayListVisitor 10 | implements ItemVisitor 11 | { 12 | 13 | private ArrayList items = new ArrayList(); 14 | public ArrayListVisitor() { 15 | } 16 | 17 | public void visitItem(Object item) 18 | { 19 | items.add(item); 20 | } 21 | 22 | public ArrayList getItems() { return items; } 23 | 24 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/ItemVisitor.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.index; 2 | 3 | /** 4 | * A visitor for items in an index. 5 | * 6 | * @version 1.7 7 | */ 8 | 9 | public interface ItemVisitor 10 | { 11 | void visitItem(Object item); 12 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/bintree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes that implement a Binary Interval Tree index 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/chain/MonotoneChainOverlapAction.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.index.chain; 36 | 37 | import com.vividsolutions.jts.geom.*; 38 | 39 | /** 40 | * The action for the internal iterator for performing 41 | * overlap queries on a MonotoneChain 42 | * 43 | * @version 1.7 44 | */ 45 | public class MonotoneChainOverlapAction 46 | { 47 | // these envelopes are used during the MonotoneChain search process 48 | Envelope tempEnv1 = new Envelope(); 49 | Envelope tempEnv2 = new Envelope(); 50 | 51 | protected LineSegment overlapSeg1 = new LineSegment(); 52 | protected LineSegment overlapSeg2 = new LineSegment(); 53 | 54 | /** 55 | * This function can be overridden if the original chains are needed 56 | * 57 | * @param start1 the index of the start of the overlapping segment from mc1 58 | * @param start2 the index of the start of the overlapping segment from mc2 59 | */ 60 | public void overlap(MonotoneChain mc1, int start1, MonotoneChain mc2, int start2) 61 | { 62 | mc1.getLineSegment(start1, overlapSeg1); 63 | mc2.getLineSegment(start2, overlapSeg2); 64 | overlap(overlapSeg1, overlapSeg2); 65 | } 66 | 67 | /** 68 | * This is a convenience function which can be overridden to obtain the actual 69 | * line segments which overlap 70 | * @param seg1 71 | * @param seg2 72 | */ 73 | public void overlap(LineSegment seg1, LineSegment seg2) 74 | { 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/chain/MonotoneChainSelectAction.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.index.chain; 36 | 37 | import com.vividsolutions.jts.geom.*; 38 | /** 39 | * The action for the internal iterator for performing 40 | * envelope select queries on a MonotoneChain 41 | * 42 | * @version 1.7 43 | */ 44 | public class MonotoneChainSelectAction 45 | { 46 | // these envelopes are used during the MonotoneChain search process 47 | Envelope tempEnv1 = new Envelope(); 48 | 49 | LineSegment selectedSegment = new LineSegment(); 50 | 51 | /** 52 | * This function can be overridden if the original chain is needed 53 | */ 54 | public void select(MonotoneChain mc, int start) 55 | { 56 | mc.getLineSegment(start, selectedSegment); 57 | select(selectedSegment); 58 | } 59 | 60 | /** 61 | * This is a convenience function which can be overridden to obtain the actual 62 | * line segment which is selected 63 | * @param seg 64 | */ 65 | public void select(LineSegment seg) 66 | { 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/chain/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes that implement Monotone Chains 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Provides classes for various kinds of spatial indexes. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/quadtree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes that implement a Quadtree spatial index 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/strtree/Boundable.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.index.strtree; 35 | 36 | /** 37 | * A spatial object in an AbstractSTRtree. 38 | * 39 | * @version 1.7 40 | */ 41 | public interface Boundable { 42 | /** 43 | * Returns a representation of space that encloses this Boundable, preferably 44 | * not much bigger than this Boundable's boundary yet fast to test for intersection 45 | * with the bounds of other Boundables. The class of object returned depends 46 | * on the subclass of AbstractSTRtree. 47 | * @return an Envelope (for STRtrees), an Interval (for SIRtrees), or other object 48 | * (for other subclasses of AbstractSTRtree) 49 | * @see AbstractSTRtree.IntersectsOp 50 | */ 51 | Object getBounds(); 52 | } 53 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/strtree/Interval.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.index.strtree; 35 | 36 | import com.vividsolutions.jts.util.*; 37 | 38 | /** 39 | * A contiguous portion of 1D-space. Used internally by SIRtree. 40 | * @see SIRtree 41 | * 42 | * @version 1.7 43 | */ 44 | public class Interval { 45 | 46 | public Interval(Interval other) { 47 | this(other.min, other.max); 48 | } 49 | 50 | public Interval(double min, double max) { 51 | Assert.isTrue(min <= max); 52 | this.min = min; 53 | this.max = max; 54 | } 55 | 56 | private double min; 57 | private double max; 58 | 59 | public double getCentre() { return (min+max)/2; } 60 | 61 | /** 62 | * @return this 63 | */ 64 | public Interval expandToInclude(Interval other) { 65 | max = Math.max(max, other.max); 66 | min = Math.min(min, other.min); 67 | return this; 68 | } 69 | 70 | public boolean intersects(Interval other) { 71 | return !(other.min > max || other.max < min); 72 | } 73 | public boolean equals(Object o) { 74 | if (! (o instanceof Interval)) { return false; } 75 | Interval other = (Interval) o; 76 | return min == other.min && max == other.max; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/strtree/ItemBoundable.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.index.strtree; 35 | 36 | /** 37 | * Boundable wrapper for a non-Boundable spatial object. Used internally by 38 | * AbstractSTRtree. 39 | * 40 | * @version 1.7 41 | */ 42 | public class ItemBoundable implements Boundable { 43 | private Object bounds; 44 | private Object item; 45 | 46 | public ItemBoundable(Object bounds, Object item) { 47 | this.bounds = bounds; 48 | this.item = item; 49 | } 50 | 51 | public Object getBounds() { 52 | return bounds; 53 | } 54 | 55 | public Object getItem() { return item; } 56 | } 57 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/strtree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Contains 2-D and 1-D versions of the Sort-Tile-Recursive (STR) tree, a query-only R-tree. 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/sweepline/SweepLineInterval.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.index.sweepline; 36 | 37 | /** 38 | * @version 1.7 39 | */ 40 | public class SweepLineInterval { 41 | 42 | private double min, max; 43 | private Object item; 44 | 45 | public SweepLineInterval(double min, double max) 46 | { 47 | this(min, max, null); 48 | } 49 | 50 | public SweepLineInterval(double min, double max, Object item) 51 | { 52 | this.min = min < max ? min : max; 53 | this.max = max > min ? max : min; 54 | this.item = item; 55 | } 56 | 57 | public double getMin() { return min; } 58 | public double getMax() { return max; } 59 | public Object getItem() { return item; } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/sweepline/SweepLineOverlapAction.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.index.sweepline; 36 | 37 | /** 38 | * An action taken when a {@link SweepLineIndex} detects that two 39 | * {@link SweepLineInterval}s overlap 40 | * 41 | * @version 1.7 42 | */ 43 | public interface SweepLineOverlapAction { 44 | 45 | void overlap(SweepLineInterval s0, SweepLineInterval s1); 46 | } 47 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/index/sweepline/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes which implement a sweepline algorithm for scanning geometric data structures. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/ByteArrayInStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.io; 34 | 35 | import java.io.*; 36 | 37 | /** 38 | * Allows an array of bytes to be used as an {@link InStream}. 39 | * To optimize memory usage, instances can be reused 40 | * with different byte arrays. 41 | */ 42 | public class ByteArrayInStream 43 | implements InStream 44 | { 45 | private byte[] byteBuffer; 46 | private ByteArrayInputStream bis; 47 | 48 | public ByteArrayInStream(byte[] byteBuffer) 49 | { 50 | setBuffer(byteBuffer); 51 | } 52 | 53 | public void setBuffer(byte[] byteBuffer) 54 | { 55 | this.byteBuffer = byteBuffer; 56 | // for now - could be replaced with optimized custom code 57 | bis = new ByteArrayInputStream(byteBuffer); 58 | } 59 | 60 | public void read(byte[] buf) 61 | throws IOException 62 | { 63 | bis.read(buf); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/InStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.io; 34 | 35 | import java.io.IOException; 36 | 37 | /** 38 | * A interface for classes providing an input stream of bytes. 39 | * This interface is similar to the Java {@link InputStream}, 40 | * but with a narrower interface to make it easier to implement. 41 | * 42 | */ 43 | public interface InStream 44 | { 45 | /** 46 | * Reads buf.length bytes from the input stream 47 | * and stores them in the supplied buffer. 48 | * 49 | * @param buf the buffer to receive the bytes 50 | * 51 | * @throws IOException if an I/O error occurs 52 | */ 53 | void read(byte[] buf) throws IOException; 54 | } 55 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/InputStreamInStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.io; 34 | 35 | import java.io.*; 36 | 37 | /** 38 | * An adapter to allow an {@link InputStream} to be used as an {@link InStream} 39 | */ 40 | public class InputStreamInStream 41 | implements InStream 42 | { 43 | private InputStream is; 44 | 45 | public InputStreamInStream(InputStream is) 46 | { 47 | this.is = is; 48 | } 49 | 50 | public void read(byte[] buf) throws IOException 51 | { 52 | is.read(buf); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/OutStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.io; 34 | 35 | import java.io.IOException; 36 | 37 | /** 38 | * A interface for classes providing an output stream of bytes. 39 | * This interface is similar to the Java {@link OutputStream}, 40 | * but with a narrower interface to make it easier to implement. 41 | */ 42 | public interface OutStream 43 | { 44 | void write(byte[] buf, int len) throws IOException; 45 | } 46 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/OutputStreamOutStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.io; 34 | 35 | import java.io.IOException; 36 | import java.io.OutputStream; 37 | 38 | /** 39 | * An adapter to allow an {@link OutputStream} to be used as an {@link OutStream} 40 | */ 41 | public class OutputStreamOutStream 42 | implements OutStream 43 | { 44 | private OutputStream os; 45 | 46 | public OutputStreamOutStream(OutputStream os) 47 | { 48 | this.os = os; 49 | } 50 | public void write(byte[] buf, int len) throws IOException 51 | { 52 | os.write(buf, 0, len); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/ParseException.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.io; 36 | 37 | /** 38 | * Thrown by a WKTReader when a parsing problem occurs. 39 | * 40 | *@version 1.7 41 | */ 42 | public class ParseException extends Exception { 43 | 44 | /** 45 | * Creates a ParseException with the given detail message. 46 | * 47 | *@param message a description of this ParseException 48 | */ 49 | public ParseException(String message) { 50 | super(message); 51 | } 52 | 53 | /** 54 | * Creates a ParseException with es detail message. 55 | * 56 | *@param e an exception that occurred while a WKTReader was 57 | * parsing a Well-known Text string 58 | */ 59 | public ParseException(Exception e) { 60 | this(e.toString()); 61 | } 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/WKBConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The JTS Topology Suite is a collection of Java classes that 3 | * implement the fundamental operations required to validate a given 4 | * geo-spatial data set to a known topological specification. 5 | * 6 | * Copyright (C) 2001 Vivid Solutions 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | * 22 | * For more information, contact: 23 | * 24 | * Vivid Solutions 25 | * Suite #1A 26 | * 2328 Government Street 27 | * Victoria BC V8T 5G5 28 | * Canada 29 | * 30 | * (250)385-6040 31 | * www.vividsolutions.com 32 | */ 33 | package com.vividsolutions.jts.io; 34 | 35 | /** 36 | * Constant values used by the WKB format 37 | */ 38 | public interface WKBConstants { 39 | int wkbXDR = 0; 40 | int wkbNDR = 1; 41 | 42 | int wkbPoint = 1; 43 | int wkbLineString = 2; 44 | int wkbPolygon = 3; 45 | int wkbMultiPoint = 4; 46 | int wkbMultiLineString = 5; 47 | int wkbMultiPolygon = 6; 48 | int wkbGeometryCollection = 7; 49 | } 50 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/io/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains the interfaces for converting JTS objects to and from other formats. 11 |

12 | The Java Topology Suite (JTS) is a Java API that implements a core set of spatial data operations using an explicit precision model and robust geometric algorithms. JTS is intended to be used in the development of applications that support the validation, cleaning, integration and querying of spatial datasets. 13 |

14 | JTS attempts to implement the OpenGIS Simple Features Specification (SFS) as accurately as possible. In some cases the SFS is unclear or omits a specification; in this case JTS attempts to choose a reasonable and consistent alternative. Differences from and elaborations of the SFS are documented in this specification. 15 | 16 |

Package Specification

17 | 18 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/linearref/LocationIndexOfLine.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.linearref; 2 | 3 | import com.vividsolutions.jts.geom.*; 4 | 5 | /** 6 | * Determines the location of a subline along a linear {@link Geometry}. 7 | * The location is reported as a pair of {@link LinearLocation}s. 8 | *

9 | * Note: Currently this algorithm is not guaranteed to 10 | * return the correct substring in some situations where 11 | * an endpoint of the test line occurs more than once in the input line. 12 | * (However, the common case of a ring is always handled correctly). 13 | */ 14 | class LocationIndexOfLine 15 | { 16 | /** 17 | * MD - this algorithm has been extracted into a class 18 | * because it is intended to validate that the subline truly is a subline, 19 | * and also to use the internal vertex information to unambiguously locate the subline. 20 | */ 21 | public static LinearLocation[] indicesOf(Geometry linearGeom, Geometry subLine) 22 | { 23 | LocationIndexOfLine locater = new LocationIndexOfLine(linearGeom); 24 | return locater.indicesOf(subLine); 25 | } 26 | 27 | private Geometry linearGeom; 28 | 29 | public LocationIndexOfLine(Geometry linearGeom) { 30 | this.linearGeom = linearGeom; 31 | } 32 | 33 | public LinearLocation[] indicesOf(Geometry subLine) 34 | { 35 | Coordinate startPt = ((LineString) subLine.getGeometryN(0)).getCoordinateN(0); 36 | LineString lastLine = (LineString) subLine.getGeometryN(subLine.getNumGeometries() - 1); 37 | Coordinate endPt = lastLine.getCoordinateN(lastLine.getNumPoints() - 1); 38 | 39 | LocationIndexOfPoint locPt = new LocationIndexOfPoint(linearGeom); 40 | LinearLocation[] subLineLoc = new LinearLocation[2]; 41 | subLineLoc[0] = locPt.indexOf(startPt); 42 | 43 | // check for case where subline is zero length 44 | if (subLine.getLength() == 0.0) { 45 | subLineLoc[1] = (LinearLocation) subLineLoc[0].clone(); 46 | } 47 | else { 48 | subLineLoc[1] = locPt.indexOfAfter(endPt, subLineLoc[0]); 49 | } 50 | return subLineLoc; 51 | } 52 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/linearref/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes and interfaces implementing linear referencing on linear geometries 11 | 12 |

Linear Referencing

13 | 14 | Linear Referencing is a way of defining positions along linear geometries 15 | (LineStrings and MultiLineStrings). 16 | It is used extensively in linear network systems. 17 | There are numerous possible Linear Referencing Methods which 18 | can be used to define positions along linear geometry. 19 | This package supports two: 20 |
    21 |
  • Linear Location - a linear location is a triple 22 | (component index, segment index, segment fraction) 23 | which precisely specifies a point on a linear geometry. 24 | It allows for efficient mapping of the index value to actual coordinate values. 25 |
  • Length - the natural concept of using the length along 26 | the geometry to specify a position. 27 | 28 |

    Package Specification

    29 | 30 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/noding/IntersectionFinderAdder.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.noding; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.geom.*; 5 | import com.vividsolutions.jts.algorithm.LineIntersector; 6 | import com.vividsolutions.jts.util.Debug; 7 | 8 | /** 9 | * Finds proper and interior intersections in a set of SegmentStrings, 10 | * and adds them as nodes. 11 | * 12 | * @version 1.7 13 | */ 14 | public class IntersectionFinderAdder 15 | implements SegmentIntersector 16 | { 17 | private LineIntersector li; 18 | private final List interiorIntersections; 19 | 20 | 21 | /** 22 | * Creates an intersection finder which finds all proper intersections 23 | * 24 | * @param li the LineIntersector to use 25 | */ 26 | public IntersectionFinderAdder(LineIntersector li) 27 | { 28 | this.li = li; 29 | interiorIntersections = new ArrayList(); 30 | } 31 | 32 | public List getInteriorIntersections() { return interiorIntersections; } 33 | 34 | /** 35 | * This method is called by clients 36 | * of the {@link SegmentIntersector} class to process 37 | * intersections for two segments of the {@link SegmentStrings} being intersected. 38 | * Note that some clients (such as {@link MonotoneChain}s) may optimize away 39 | * this call for segment pairs which they have determined do not intersect 40 | * (e.g. by an disjoint envelope test). 41 | */ 42 | public void processIntersections( 43 | SegmentString e0, int segIndex0, 44 | SegmentString e1, int segIndex1 45 | ) 46 | { 47 | // don't bother intersecting a segment with itself 48 | if (e0 == e1 && segIndex0 == segIndex1) return; 49 | 50 | Coordinate p00 = e0.getCoordinates()[segIndex0]; 51 | Coordinate p01 = e0.getCoordinates()[segIndex0 + 1]; 52 | Coordinate p10 = e1.getCoordinates()[segIndex1]; 53 | Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; 54 | 55 | li.computeIntersection(p00, p01, p10, p11); 56 | //if (li.hasIntersection() && li.isProper()) Debug.println(li); 57 | 58 | if (li.hasIntersection()) { 59 | if (li.isInteriorIntersection()) { 60 | for (int intIndex = 0; intIndex < li.getIntersectionNum(); intIndex++) { 61 | interiorIntersections.add(li.getIntersection(intIndex)); 62 | } 63 | e0.addIntersections(li, segIndex0, 0); 64 | e1.addIntersections(li, segIndex1, 1); 65 | } 66 | } 67 | } 68 | 69 | /** 70 | * Always process all intersections 71 | * 72 | * @return false always 73 | */ 74 | public boolean isDone() { return false; } 75 | 76 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/noding/Noder.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jts.noding; 35 | 36 | import java.util.*; 37 | 38 | /** 39 | * Computes all intersections between segments in a set of {@link SegmentString}s. 40 | * Intersections found are represented as {@link SegmentNode}s and added to the 41 | * {@link SegmentString}s in which they occur. 42 | * As a final step in the noding a new set of segment strings split 43 | * at the nodes may be returned. 44 | * 45 | * @version 1.7 46 | */ 47 | public interface Noder 48 | { 49 | 50 | /** 51 | * Computes the noding for a collection of {@link SegmentString}s. 52 | * Some Noders may add all these nodes to the input SegmentStrings; 53 | * others may only add some or none at all. 54 | * 55 | * @param segStrings a collection of {@link SegmentString}s to node 56 | */ 57 | void computeNodes(Collection segStrings); 58 | 59 | /** 60 | * Returns a {@link Collection} of fully noded {@link SegmentStrings}. 61 | * The SegmentStrings have the same context as their parent. 62 | * 63 | * @return a Collection of SegmentStrings 64 | */ 65 | Collection getNodedSubstrings(); 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/noding/Octant.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.noding; 2 | 3 | import com.vividsolutions.jts.geom.Coordinate; 4 | /** 5 | * Methods for computing and working with octants of the Cartesian plane 6 | * Octants are numbered as follows: 7 | *
     8 |  *  \2|1/
     9 |  * 3 \|/ 0
    10 |  * ---+--
    11 |  * 4 /|\ 7
    12 |  *  /5|6\
    13 |  * 
    14 |  * If line segments lie along a coordinate axis, the octant is the lower of the two
    15 |  * possible values.
    16 |  *
    17 |  * @version 1.7
    18 |  */
    19 | public class Octant {
    20 | 
    21 |   /**
    22 |    * Returns the octant of a directed line segment (specified as x and y
    23 |    * displacements, which cannot both be 0).
    24 |    */
    25 |   public static int octant(double dx, double dy)
    26 |   {
    27 |     if (dx == 0.0 && dy == 0.0)
    28 |       throw new IllegalArgumentException("Cannot compute the octant for point ( "+ dx + ", " + dy + " )" );
    29 | 
    30 |     double adx = Math.abs(dx);
    31 |     double ady = Math.abs(dy);
    32 | 
    33 |     if (dx >= 0) {
    34 |       if (dy >= 0) {
    35 |         if (adx >= ady)
    36 |           return 0;
    37 |         else
    38 |           return 1;
    39 |       }
    40 |       else { // dy < 0
    41 |         if (adx >= ady)
    42 |           return 7;
    43 |         else
    44 |           return 6;
    45 |       }
    46 |     }
    47 |     else { // dx < 0
    48 |       if (dy >= 0) {
    49 |         if (adx >= ady)
    50 |           return 3;
    51 |         else
    52 |           return 2;
    53 |       }
    54 |       else { // dy < 0
    55 |         if (adx >= ady)
    56 |           return 4;
    57 |         else
    58 |           return 5;
    59 |       }
    60 |     }
    61 |   }
    62 | 
    63 |   /**
    64 |    * Returns the octant of a directed line segment from p0 to p1.
    65 |    */
    66 |   public static int octant(Coordinate p0, Coordinate p1)
    67 |   {
    68 |     double dx = p1.x - p0.x;
    69 |     double dy = p1.y - p0.y;
    70 |     if (dx == 0.0 && dy == 0.0)
    71 |       throw new IllegalArgumentException("Cannot compute the octant for two identical points " + p0);
    72 |     return octant(dx, dy);
    73 |   }
    74 | 
    75 |   private Octant() {
    76 |   }
    77 | }
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/noding/SegmentIntersector.java:
    --------------------------------------------------------------------------------
     1 | /*
     2 |  * The JTS Topology Suite is a collection of Java classes that
     3 |  * implement the fundamental operations required to validate a given
     4 |  * geo-spatial data set to a known topological specification.
     5 |  *
     6 |  * Copyright (C) 2001 Vivid Solutions
     7 |  *
     8 |  * This library is free software; you can redistribute it and/or
     9 |  * modify it under the terms of the GNU Lesser General Public
    10 |  * License as published by the Free Software Foundation; either
    11 |  * version 2.1 of the License, or (at your option) any later version.
    12 |  *
    13 |  * This library is distributed in the hope that it will be useful,
    14 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    16 |  * Lesser General Public License for more details.
    17 |  *
    18 |  * You should have received a copy of the GNU Lesser General Public
    19 |  * License along with this library; if not, write to the Free Software
    20 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    21 |  *
    22 |  * For more information, contact:
    23 |  *
    24 |  *     Vivid Solutions
    25 |  *     Suite #1A
    26 |  *     2328 Government Street
    27 |  *     Victoria BC  V8T 5G5
    28 |  *     Canada
    29 |  *
    30 |  *     (250)385-6040
    31 |  *     www.vividsolutions.com
    32 |  */
    33 | package com.vividsolutions.jts.noding;
    34 | 
    35 | import java.util.*;
    36 | import com.vividsolutions.jts.geom.*;
    37 | import com.vividsolutions.jts.algorithm.LineIntersector;
    38 | import com.vividsolutions.jts.util.Debug;
    39 | 
    40 | /**
    41 |  * Computes the intersections between two line segments in {@link SegmentString}s
    42 |  * and adds them to each string.
    43 |  * The {@link SegmentIntersector} is passed to a {@link Noder}.
    44 |  * The {@link addIntersections} method is called whenever the {@link Noder}
    45 |  * detects that two SegmentStrings might intersect.
    46 |  * This class is an example of the Strategy pattern.
    47 |  *
    48 |  * @version 1.7
    49 |  */
    50 | 
    51 | public interface SegmentIntersector
    52 | {
    53 |   /**
    54 |    * This method is called by clients
    55 |    * of the {@link SegmentIntersector} interface to process
    56 |    * intersections for two segments of the {@link SegmentStrings} being intersected.
    57 |    */
    58 |   void processIntersections(
    59 |     SegmentString e0,  int segIndex0,
    60 |     SegmentString e1,  int segIndex1
    61 |      );
    62 | }
    63 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/noding/SegmentPointComparator.java:
    --------------------------------------------------------------------------------
     1 | package com.vividsolutions.jts.noding;
     2 | 
     3 | import com.vividsolutions.jts.geom.Coordinate;
     4 | import com.vividsolutions.jts.util.Assert;
     5 | 
     6 | /**
     7 |  * Implements a robust method of comparing the relative position of two
     8 |  * points along the same segment.
     9 |  * The coordinates are assumed to lie "near" the segment.
    10 |  * This means that this algorithm will only return correct results
    11 |  * if the input coordinates
    12 |  * have the same precision and correspond to rounded values
    13 |  * of exact coordinates lying on the segment.
    14 |  *
    15 |  * @version 1.7
    16 |  */
    17 | public class SegmentPointComparator {
    18 | 
    19 |   /**
    20 |    * Compares two {@link Coordinate}s for their relative position along a segment
    21 |    * lying in the specified {@link Octant}.
    22 |    *
    23 |    * @return -1 node0 occurs first
    24 |    * @return 0 the two nodes are equal
    25 |    * @return 1 node1 occurs first
    26 |    */
    27 |   public static int compare(int octant, Coordinate p0, Coordinate p1)
    28 |   {
    29 |     // nodes can only be equal if their coordinates are equal
    30 |     if (p0.equals2D(p1)) return 0;
    31 | 
    32 |     int xSign = relativeSign(p0.x, p1.x);
    33 |     int ySign = relativeSign(p0.y, p1.y);
    34 | 
    35 |     switch (octant) {
    36 |       case 0: return compareValue(xSign, ySign);
    37 |       case 1: return compareValue(ySign, xSign);
    38 |       case 2: return compareValue(ySign, -xSign);
    39 |       case 3: return compareValue(-xSign, ySign);
    40 |       case 4: return compareValue(-xSign, -ySign);
    41 |       case 5: return compareValue(-ySign, -xSign);
    42 |       case 6: return compareValue(-ySign, xSign);
    43 |       case 7: return compareValue(xSign, -ySign);
    44 |     }
    45 |     Assert.shouldNeverReachHere("invalid octant value");
    46 |     return 0;
    47 |   }
    48 | 
    49 |   public static int relativeSign(double x0, double x1)
    50 |   {
    51 |     if (x0 < x1) return -1;
    52 |     if (x0 > x1) return 1;
    53 |     return 0;
    54 |   }
    55 | 
    56 |   private static int compareValue(int compareSign0, int compareSign1)
    57 |   {
    58 |     if (compareSign0 < 0) return -1;
    59 |     if (compareSign0 > 0) return 1;
    60 |     if (compareSign1 < 0) return -1;
    61 |     if (compareSign1 > 0) return 1;
    62 |     return 0;
    63 | 
    64 |   }
    65 | }
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/noding/package.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | 
     4 | 
     7 | 
     8 | 
     9 | 
    10 | Classes to compute nodings for arrangements of line segments and line segment sequences.
    11 | 
    12 | 
    13 | 
    14 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/noding/snapround/package.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | 
     4 | 
     7 | 
     8 | 
     9 | 
    10 | Contains classes to implement the Snap Rounding algorithm for noding linestrings.
    11 | 
    12 | 
    13 | 
    14 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/buffer/package.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | 
     4 | 
     7 | 
     8 | 
     9 | 
    10 | Provides classes for computing buffers of geometries
    11 | 
    12 | 
    13 | 
    14 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/distance/ConnectedElementPointFilter.java:
    --------------------------------------------------------------------------------
     1 | 
     2 | /*
     3 |  * The JTS Topology Suite is a collection of Java classes that
     4 |  * implement the fundamental operations required to validate a given
     5 |  * geo-spatial data set to a known topological specification.
     6 |  *
     7 |  * Copyright (C) 2001 Vivid Solutions
     8 |  *
     9 |  * This library is free software; you can redistribute it and/or
    10 |  * modify it under the terms of the GNU Lesser General Public
    11 |  * License as published by the Free Software Foundation; either
    12 |  * version 2.1 of the License, or (at your option) any later version.
    13 |  *
    14 |  * This library is distributed in the hope that it will be useful,
    15 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    17 |  * Lesser General Public License for more details.
    18 |  *
    19 |  * You should have received a copy of the GNU Lesser General Public
    20 |  * License along with this library; if not, write to the Free Software
    21 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22 |  *
    23 |  * For more information, contact:
    24 |  *
    25 |  *     Vivid Solutions
    26 |  *     Suite #1A
    27 |  *     2328 Government Street
    28 |  *     Victoria BC  V8T 5G5
    29 |  *     Canada
    30 |  *
    31 |  *     (250)385-6040
    32 |  *     www.vividsolutions.com
    33 |  */
    34 | package com.vividsolutions.jts.operation.distance;
    35 | 
    36 | import java.util.*;
    37 | import com.vividsolutions.jts.geom.*;
    38 | 
    39 | /**
    40 |  * Extracts a single point
    41 |  * from each connected element in a Geometry
    42 |  * (e.g. a polygon, linestring or point)
    43 |  * and returns them in a list
    44 |  *
    45 |  * @version 1.7
    46 |  */
    47 | public class ConnectedElementPointFilter
    48 |   implements GeometryFilter
    49 | {
    50 | 
    51 |   /**
    52 |    * Returns a list containing a Coordinate from each Polygon, LineString, and Point
    53 |    * found inside the specified geometry. Thus, if the specified geometry is
    54 |    * not a GeometryCollection, an empty list will be returned.
    55 |    */
    56 |   public static List getCoordinates(Geometry geom)
    57 |   {
    58 |     List pts = new ArrayList();
    59 |     geom.apply(new ConnectedElementPointFilter(pts));
    60 |     return pts;
    61 |   }
    62 | 
    63 |   private List pts;
    64 | 
    65 |   ConnectedElementPointFilter(List pts)
    66 |   {
    67 |     this.pts = pts;
    68 |   }
    69 | 
    70 |   public void filter(Geometry geom)
    71 |   {
    72 |     if (geom instanceof Point
    73 |       || geom instanceof LineString
    74 |       || geom instanceof Polygon )
    75 |       pts.add(geom.getCoordinate());
    76 |   }
    77 | 
    78 | }
    79 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/distance/package.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | 
     4 | 
     7 | 
     8 | 
     9 | 
    10 | Provides classes for computing the distance between geometries
    11 | 
    12 | 
    13 | 
    14 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/linemerge/LineMergeEdge.java:
    --------------------------------------------------------------------------------
     1 | 
     2 | /*
     3 |  * The JTS Topology Suite is a collection of Java classes that
     4 |  * implement the fundamental operations required to validate a given
     5 |  * geo-spatial data set to a known topological specification.
     6 |  *
     7 |  * Copyright (C) 2001 Vivid Solutions
     8 |  *
     9 |  * This library is free software; you can redistribute it and/or
    10 |  * modify it under the terms of the GNU Lesser General Public
    11 |  * License as published by the Free Software Foundation; either
    12 |  * version 2.1 of the License, or (at your option) any later version.
    13 |  *
    14 |  * This library is distributed in the hope that it will be useful,
    15 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    17 |  * Lesser General Public License for more details.
    18 |  *
    19 |  * You should have received a copy of the GNU Lesser General Public
    20 |  * License along with this library; if not, write to the Free Software
    21 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22 |  *
    23 |  * For more information, contact:
    24 |  *
    25 |  *     Vivid Solutions
    26 |  *     Suite #1A
    27 |  *     2328 Government Street
    28 |  *     Victoria BC  V8T 5G5
    29 |  *     Canada
    30 |  *
    31 |  *     (250)385-6040
    32 |  *     www.vividsolutions.com
    33 |  */
    34 | package com.vividsolutions.jts.operation.linemerge;
    35 | 
    36 | import com.vividsolutions.jts.geom.LineString;
    37 | import com.vividsolutions.jts.planargraph.Edge;
    38 | 
    39 | /**
    40 |  * An edge of a {@link LineMergeGraph}. The marked field indicates
    41 |  * whether this Edge has been logically deleted from the graph.
    42 |  *
    43 |  * @version 1.7
    44 |  */
    45 | public class LineMergeEdge extends Edge {
    46 |   private LineString line;
    47 |   /**
    48 |    * Constructs a LineMergeEdge with vertices given by the specified LineString.
    49 |    */
    50 |   public LineMergeEdge(LineString line) {
    51 |     this.line = line;
    52 |   }
    53 |   /**
    54 |    * Returns the LineString specifying the vertices of this edge.
    55 |    */
    56 |   public LineString getLine() {
    57 |     return line;
    58 |   }
    59 | }
    60 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/overlay/EdgeSetNoder.java:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | /*
     4 |  * The JTS Topology Suite is a collection of Java classes that
     5 |  * implement the fundamental operations required to validate a given
     6 |  * geo-spatial data set to a known topological specification.
     7 |  *
     8 |  * Copyright (C) 2001 Vivid Solutions
     9 |  *
    10 |  * This library is free software; you can redistribute it and/or
    11 |  * modify it under the terms of the GNU Lesser General Public
    12 |  * License as published by the Free Software Foundation; either
    13 |  * version 2.1 of the License, or (at your option) any later version.
    14 |  *
    15 |  * This library is distributed in the hope that it will be useful,
    16 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    18 |  * Lesser General Public License for more details.
    19 |  *
    20 |  * You should have received a copy of the GNU Lesser General Public
    21 |  * License along with this library; if not, write to the Free Software
    22 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 |  *
    24 |  * For more information, contact:
    25 |  *
    26 |  *     Vivid Solutions
    27 |  *     Suite #1A
    28 |  *     2328 Government Street
    29 |  *     Victoria BC  V8T 5G5
    30 |  *     Canada
    31 |  *
    32 |  *     (250)385-6040
    33 |  *     www.vividsolutions.com
    34 |  */
    35 | package com.vividsolutions.jts.operation.overlay;
    36 | 
    37 | import java.util.*;
    38 | import com.vividsolutions.jts.algorithm.LineIntersector;
    39 | import com.vividsolutions.jts.geomgraph.*;
    40 | import com.vividsolutions.jts.geomgraph.index.*;
    41 | import com.vividsolutions.jts.util.*;
    42 | 
    43 | /**
    44 |  * Nodes a set of edges.
    45 |  * Takes one or more sets of edges and constructs a
    46 |  * new set of edges consisting of all the split edges created by
    47 |  * noding the input edges together
    48 |  * @version 1.7
    49 |  */
    50 | public class EdgeSetNoder {
    51 | 
    52 |   private LineIntersector li;
    53 |   private List inputEdges = new ArrayList();
    54 | 
    55 |   public EdgeSetNoder(LineIntersector li) {
    56 |     this.li = li;
    57 |   }
    58 | 
    59 |   public void addEdges(List edges)
    60 |   {
    61 |     inputEdges.addAll(edges);
    62 |   }
    63 | 
    64 |   public List getNodedEdges()
    65 |   {
    66 |     EdgeSetIntersector esi = new SimpleMCSweepLineIntersector();
    67 |     SegmentIntersector si = new SegmentIntersector(li, true, false);
    68 |     esi.computeIntersections(inputEdges, si, true);
    69 | //Debug.println("has proper int = " + si.hasProperIntersection());
    70 | 
    71 |     List splitEdges = new ArrayList();
    72 |     for (Iterator i = inputEdges.iterator(); i.hasNext(); ) {
    73 |       Edge e = (Edge) i.next();
    74 |       e.getEdgeIntersectionList().addSplitEdges(splitEdges);
    75 |     }
    76 |     return splitEdges;
    77 |   }
    78 | }
    79 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/overlay/MinimalEdgeRing.java:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | /*
     4 |  * The JTS Topology Suite is a collection of Java classes that
     5 |  * implement the fundamental operations required to validate a given
     6 |  * geo-spatial data set to a known topological specification.
     7 |  *
     8 |  * Copyright (C) 2001 Vivid Solutions
     9 |  *
    10 |  * This library is free software; you can redistribute it and/or
    11 |  * modify it under the terms of the GNU Lesser General Public
    12 |  * License as published by the Free Software Foundation; either
    13 |  * version 2.1 of the License, or (at your option) any later version.
    14 |  *
    15 |  * This library is distributed in the hope that it will be useful,
    16 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    18 |  * Lesser General Public License for more details.
    19 |  *
    20 |  * You should have received a copy of the GNU Lesser General Public
    21 |  * License along with this library; if not, write to the Free Software
    22 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 |  *
    24 |  * For more information, contact:
    25 |  *
    26 |  *     Vivid Solutions
    27 |  *     Suite #1A
    28 |  *     2328 Government Street
    29 |  *     Victoria BC  V8T 5G5
    30 |  *     Canada
    31 |  *
    32 |  *     (250)385-6040
    33 |  *     www.vividsolutions.com
    34 |  */
    35 | package com.vividsolutions.jts.operation.overlay;
    36 | 
    37 | import com.vividsolutions.jts.geom.*;
    38 | import com.vividsolutions.jts.algorithm.*;
    39 | import com.vividsolutions.jts.geomgraph.*;
    40 | 
    41 | /**
    42 |  * A ring of {@link Edge}s with the property that no node
    43 |  * has degree greater than 2.  These are the form of rings required
    44 |  * to represent polygons under the OGC SFS spatial data model.
    45 |  *
    46 |  * @version 1.7
    47 |  * @see com.vividsolutions.jts.operation.overlay.MaximalEdgeRing
    48 |  */
    49 | public class MinimalEdgeRing
    50 |   extends EdgeRing
    51 | {
    52 | 
    53 |   public MinimalEdgeRing(DirectedEdge start, GeometryFactory geometryFactory, CGAlgorithms cga) {
    54 |     super(start, geometryFactory, cga);
    55 |   }
    56 | 
    57 |   public DirectedEdge getNext(DirectedEdge de)
    58 |   {
    59 |     return de.getNextMin();
    60 |   }
    61 |   public void setEdgeRing(DirectedEdge de, EdgeRing er)
    62 |   {
    63 |     de.setMinEdgeRing(er);
    64 |   }
    65 | 
    66 | }
    67 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/overlay/OverlayNodeFactory.java:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | /*
     4 |  * The JTS Topology Suite is a collection of Java classes that
     5 |  * implement the fundamental operations required to validate a given
     6 |  * geo-spatial data set to a known topological specification.
     7 |  *
     8 |  * Copyright (C) 2001 Vivid Solutions
     9 |  *
    10 |  * This library is free software; you can redistribute it and/or
    11 |  * modify it under the terms of the GNU Lesser General Public
    12 |  * License as published by the Free Software Foundation; either
    13 |  * version 2.1 of the License, or (at your option) any later version.
    14 |  *
    15 |  * This library is distributed in the hope that it will be useful,
    16 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    18 |  * Lesser General Public License for more details.
    19 |  *
    20 |  * You should have received a copy of the GNU Lesser General Public
    21 |  * License along with this library; if not, write to the Free Software
    22 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 |  *
    24 |  * For more information, contact:
    25 |  *
    26 |  *     Vivid Solutions
    27 |  *     Suite #1A
    28 |  *     2328 Government Street
    29 |  *     Victoria BC  V8T 5G5
    30 |  *     Canada
    31 |  *
    32 |  *     (250)385-6040
    33 |  *     www.vividsolutions.com
    34 |  */
    35 | package com.vividsolutions.jts.operation.overlay;
    36 | 
    37 | /**
    38 |  * @version 1.7
    39 |  */
    40 | import com.vividsolutions.jts.geom.Coordinate;
    41 | import com.vividsolutions.jts.geomgraph.*;
    42 | 
    43 | /**
    44 |  * Creates nodes for use in the {@link PlanarGraph}s constructed during
    45 |  * overlay operations.
    46 |  *
    47 |  * @version 1.7
    48 |  */
    49 | public class OverlayNodeFactory
    50 |   extends NodeFactory
    51 | {
    52 |   public Node createNode(Coordinate coord)
    53 |   {
    54 |     return new Node(coord, new DirectedEdgeStar());
    55 |   }
    56 | }
    57 | 
    
    
    --------------------------------------------------------------------------------
    /src/com/vividsolutions/jts/operation/overlay/package.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | 
     4 | 
     7 | 
     8 | 
     9 | 
    10 | Contains classes that perform a topological overlay to compute boolean spatial functions.
    11 | 

    12 | The Overlay Algorithm is used in spatial analysis methods for computing set-theoretic 13 | operations (boolean combinations) of input {@link Geometry}s. The algorithm for 14 | computing the overlay uses the intersection operations supported by topology graphs. 15 | To compute an overlay it is necessary to explicitly compute the resultant graph formed 16 | by the computed intersections. 17 |

    18 | The algorithm to compute a set-theoretic spatial analysis method has the following steps: 19 |

      20 |
    • Build topology graphs of the two input geometries. For each geometry all 21 | self-intersection nodes are computed and added to the graph. 22 |
    • Compute nodes for all intersections between edges and nodes of the graphs. 23 |
    • Compute the labeling for the computed nodes by merging the labels from the input graphs. 24 |
    • Compute new edges between the compute intersection nodes. Label the edges appropriately. 25 |
    • Build the resultant graph from the new nodes and edges. 26 |
    • Compute the labeling for isolated components of the graph. Add the 27 | isolated components to the resultant graph. 28 |
    • Compute the result of the boolean combination by selecting the node and edges 29 | with the appropriate labels. Polygonize areas and sew linear geometries together. 30 |
    31 | 32 |

    Package Specification

    33 | 34 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/overlay/snap/SnapIfNeededOverlayOp.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.operation.overlay.snap; 2 | 3 | import com.vividsolutions.jts.geom.*; 4 | import com.vividsolutions.jts.operation.overlay.OverlayOp; 5 | import com.vividsolutions.jts.operation.overlay.validate.OverlayResultValidator; 6 | 7 | 8 | /** 9 | * Performs an overlay operation using snapping and enhanced precision 10 | * to improve the robustness of the result. 11 | * This class only uses snapping 12 | * if an error is detected when running the standard JTS overlay code. 13 | * Errors detected include thrown exceptions 14 | * (in particular, {@link TopologyException}) 15 | * and invalid overlay computations. 16 | * 17 | * @author Martin Davis 18 | * @version 1.7 19 | */ 20 | public class SnapIfNeededOverlayOp 21 | { 22 | public static Geometry overlayOp(Geometry g0, Geometry g1, int opCode) 23 | { 24 | SnapIfNeededOverlayOp op = new SnapIfNeededOverlayOp(g0, g1); 25 | return op.getResultGeometry(opCode); 26 | } 27 | 28 | public static Geometry intersection(Geometry g0, Geometry g1) 29 | { 30 | return overlayOp(g0, g1, OverlayOp.INTERSECTION); 31 | } 32 | 33 | public static Geometry union(Geometry g0, Geometry g1) 34 | { 35 | return overlayOp(g0, g1, OverlayOp.UNION); 36 | } 37 | 38 | public static Geometry difference(Geometry g0, Geometry g1) 39 | { 40 | return overlayOp(g0, g1, OverlayOp.DIFFERENCE); 41 | } 42 | 43 | public static Geometry symDifference(Geometry g0, Geometry g1) 44 | { 45 | return overlayOp(g0, g1, OverlayOp.SYMDIFFERENCE); 46 | } 47 | 48 | private Geometry[] geom = new Geometry[2]; 49 | 50 | public SnapIfNeededOverlayOp(Geometry g1, Geometry g2) 51 | { 52 | geom[0] = g1; 53 | geom[1] = g2; 54 | } 55 | 56 | public Geometry getResultGeometry(int opCode) 57 | { 58 | Geometry result = null; 59 | boolean isSuccess = false; 60 | try { 61 | result = OverlayOp.overlayOp(geom[0], geom[1], opCode); 62 | boolean isValid = true; 63 | // not needed if noding validation is used 64 | // boolean isValid = OverlayResultValidator.isValid(geom[0], geom[1], OverlayOp.INTERSECTION, result); 65 | if (isValid) 66 | isSuccess = true; 67 | 68 | } 69 | catch (Exception ex) { 70 | // ignore this exception, since the operation will be rerun 71 | // System.out.println(ex.getMessage()); 72 | // ex.printStackTrace(); 73 | } 74 | if (! isSuccess) { 75 | // this may still throw an exception - just let it go if it does 76 | result = SnapOverlayOp.overlayOp(geom[0], geom[1], opCode); 77 | } 78 | return result; 79 | } 80 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/overlay/validate/OffsetPointGenerator.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.operation.overlay.validate; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.geom.*; 5 | import com.vividsolutions.jts.geom.util.*; 6 | 7 | /** 8 | * Generates points offset by a given distance 9 | * from both sides of the midpoint of 10 | * all segments in a {@link Geometry}. 11 | * Can be used to generate probe points for 12 | * determining whether a polygonal overlay result 13 | * is incorrect. 14 | * 15 | * @author Martin Davis 16 | * @version 1.7 17 | */ 18 | public class OffsetPointGenerator 19 | { 20 | private double offsetDistance; 21 | private Geometry g; 22 | private List offsetPts; 23 | 24 | public OffsetPointGenerator(Geometry g, double offsetDistance) 25 | { 26 | this.g = g; 27 | this.offsetDistance = offsetDistance; 28 | } 29 | 30 | /** 31 | * Gets the computed offset points. 32 | * 33 | * @return List 34 | */ 35 | public List getPoints() 36 | { 37 | offsetPts = new ArrayList(); 38 | List lines = LinearComponentExtracter.getLines(g); 39 | for (Iterator i = lines.iterator(); i.hasNext(); ) { 40 | LineString line = (LineString) i.next(); 41 | extractPoints(line); 42 | } 43 | //System.out.println(toMultiPoint(offsetPts)); 44 | return offsetPts; 45 | } 46 | 47 | private void extractPoints(LineString line) 48 | { 49 | Coordinate[] pts = line.getCoordinates(); 50 | for (int i = 0; i < pts.length - 1; i++) { 51 | computeOffsetPoints(pts[i], pts[i + 1]); 52 | } 53 | } 54 | 55 | /** 56 | * Generates the two points which are offset from the 57 | * midpoint of the segment (p0, p1) by the 58 | * offsetDistance. 59 | * 60 | * @param p0 the first point of the segment to offset from 61 | * @param p1 the second point of the segment to offset from 62 | */ 63 | private void computeOffsetPoints(Coordinate p0, Coordinate p1) 64 | { 65 | double dx = p1.x - p0.x; 66 | double dy = p1.y - p0.y; 67 | double len = Math.sqrt(dx * dx + dy * dy); 68 | // u is the vector that is the length of the offset, in the direction of the segment 69 | double ux = offsetDistance * dx / len; 70 | double uy = offsetDistance * dy / len; 71 | 72 | double midX = (p1.x + p0.x) / 2; 73 | double midY = (p1.y + p0.y) / 2; 74 | 75 | Coordinate offsetLeft = new Coordinate(midX - uy, midY + ux); 76 | Coordinate offsetRight = new Coordinate(midX + uy, midY - ux); 77 | 78 | offsetPts.add(offsetLeft); 79 | offsetPts.add(offsetRight); 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Provides classes for implementing operations on geometries 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/polygonize/PolygonizeEdge.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | 35 | 36 | package com.vividsolutions.jts.operation.polygonize; 37 | 38 | import com.vividsolutions.jts.geom.*; 39 | import com.vividsolutions.jts.planargraph.*; 40 | 41 | /** 42 | * An edge of a polygonization graph. 43 | * 44 | * @version 1.7 45 | */ 46 | class PolygonizeEdge 47 | extends Edge 48 | { 49 | private LineString line; 50 | 51 | public PolygonizeEdge(LineString line) 52 | { 53 | this.line = line; 54 | } 55 | public LineString getLine() { return line; } 56 | } 57 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/predicate/SegmentIntersectionTester.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.operation.predicate; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.algorithm.*; 5 | import com.vividsolutions.jts.geom.*; 6 | 7 | /** 8 | * Tests if any line segments in two sets of CoordinateSequences intersect. 9 | * Optimized for small geometry size. 10 | * Short-circuited to return as soon an intersection is found. 11 | * 12 | * @version 1.7 13 | */ 14 | public class SegmentIntersectionTester { 15 | 16 | // for purposes of intersection testing, don't need to set precision model 17 | private LineIntersector li = new RobustLineIntersector(); 18 | 19 | private boolean hasIntersection = false; 20 | private Coordinate pt00 = new Coordinate(); 21 | private Coordinate pt01 = new Coordinate(); 22 | private Coordinate pt10 = new Coordinate(); 23 | private Coordinate pt11 = new Coordinate(); 24 | 25 | public SegmentIntersectionTester() { 26 | } 27 | 28 | public boolean hasIntersectionWithLineStrings(CoordinateSequence seq, List lines) 29 | { 30 | for (Iterator i = lines.iterator(); i.hasNext(); ) { 31 | LineString line = (LineString) i.next(); 32 | hasIntersection(seq, line.getCoordinateSequence()); 33 | if (hasIntersection) 34 | break; 35 | } 36 | return hasIntersection; 37 | } 38 | 39 | public boolean hasIntersection(CoordinateSequence seq0, CoordinateSequence seq1) { 40 | for (int i = 1; i < seq0.size() && ! hasIntersection; i++) { 41 | seq0.getCoordinate(i - 1, pt00); 42 | seq0.getCoordinate(i, pt01); 43 | for (int j = 1; j < seq1.size() && ! hasIntersection; j++) { 44 | seq1.getCoordinate(j - 1, pt10); 45 | seq1.getCoordinate(j, pt11); 46 | 47 | li.computeIntersection(pt00, pt01, pt10, pt11); 48 | if (li.hasIntersection()) 49 | hasIntersection = true; 50 | } 51 | } 52 | return hasIntersection; 53 | } 54 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/relate/RelateNode.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* 5 | * The JTS Topology Suite is a collection of Java classes that 6 | * implement the fundamental operations required to validate a given 7 | * geo-spatial data set to a known topological specification. 8 | * 9 | * Copyright (C) 2001 Vivid Solutions 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * For more information, contact: 26 | * 27 | * Vivid Solutions 28 | * Suite #1A 29 | * 2328 Government Street 30 | * Victoria BC V8T 5G5 31 | * Canada 32 | * 33 | * (250)385-6040 34 | * www.vividsolutions.com 35 | */ 36 | package com.vividsolutions.jts.operation.relate; 37 | 38 | /** 39 | * A RelateNode is a Node that maintains a list of EdgeStubs 40 | * for the edges that are incident on it. 41 | * 42 | * @version 1.7 43 | */ 44 | 45 | import java.io.PrintStream; 46 | import java.util.*; 47 | import com.vividsolutions.jts.geom.*; 48 | import com.vividsolutions.jts.util.*; 49 | import com.vividsolutions.jts.geomgraph.*; 50 | 51 | /** 52 | * Represents a node in the topological graph used to compute spatial relationships. 53 | * 54 | * @version 1.7 55 | */ 56 | public class RelateNode 57 | extends Node 58 | { 59 | 60 | public RelateNode(Coordinate coord, EdgeEndStar edges) 61 | { 62 | super(coord, edges); 63 | } 64 | 65 | /** 66 | * Update the IM with the contribution for this component. 67 | * A component only contributes if it has a labelling for both parent geometries 68 | */ 69 | protected void computeIM(IntersectionMatrix im) 70 | { 71 | im.setAtLeastIfValid(label.getLocation(0), label.getLocation(1), 0); 72 | } 73 | /** 74 | * Update the IM with the contribution for the EdgeEnds incident on this node. 75 | */ 76 | void updateIMFromEdges(IntersectionMatrix im) 77 | { 78 | ((EdgeEndBundleStar) edges).updateIM(im); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/relate/RelateNodeFactory.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.operation.relate; 36 | 37 | import com.vividsolutions.jts.geom.Coordinate; 38 | import com.vividsolutions.jts.geomgraph.*; 39 | 40 | /** 41 | * Used by the {@link NodeMap} in a {@link RelateNodeGraph} to create {@link RelateNode}s. 42 | * 43 | * @version 1.7 44 | */ 45 | public class RelateNodeFactory 46 | extends NodeFactory 47 | { 48 | public Node createNode(Coordinate coord) 49 | { 50 | return new RelateNode(coord, new EdgeEndBundleStar()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/relate/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes to implement the computation of the spatial relationships of Geometrys. 11 |

    12 | The relate algorithm computes the IntersectionMatrix describing the 13 | relationship of two Geometrys. The algorithm for computing relate 14 | uses the intersection operations supported by topology graphs. Although the relate 15 | result depends on the resultant graph formed by the computed intersections, there is 16 | no need to explicitly compute the entire graph. 17 | It is sufficient to compute the local structure of the graph 18 | at each intersection node. 19 |

    20 | The algorithm to compute relate has the following steps: 21 |

      22 |
    • Build topology graphs of the two input geometries. For each geometry 23 | all self-intersection nodes are computed and added to the graph. 24 |
    • Compute nodes for all intersections between edges and nodes of the graphs. 25 |
    • Compute the labeling for the computed nodes by merging the labels from the input graphs. 26 |
    • Compute the labeling for isolated components of the graph (see below) 27 |
    • Compute the IntersectionMatrix from the labels on the nodes and edges. 28 |
    29 | 30 |

    Labeling isolated components

    31 | 32 | Isolated components are components (edges or nodes) of an input Geometry which 33 | do not contain any intersections with the other input Geometry. The 34 | topological relationship of these components to the other input Geometry 35 | must be computed in order to determine the complete labeling of the component. This can 36 | be done by testing whether the component lies in the interior or exterior of the other 37 | Geometry. If the other Geometry is 1-dimensional, the isolated 38 | component must lie in the exterior (since otherwise it would have an intersection with an 39 | edge of the Geometry). If the other Geometry is 2-dimensional, 40 | a Point-In-Polygon test can be used to determine whether the isolated component is in the 41 | interior or exterior. 42 | 43 |

    Package Specification

    44 | 45 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/operation/valid/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Provides classes for testing the validity of geometries. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/planargraph/algorithm/ConnectedSubgraphFinder.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.planargraph.algorithm; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.planargraph.*; 5 | 6 | /** 7 | * Finds all connected {@link Subgraph}s of a {@link PlanarGraph}. 8 | *

    9 | * Note: uses the isVisited flag on the nodes. 10 | */ 11 | public class ConnectedSubgraphFinder 12 | { 13 | 14 | private PlanarGraph graph; 15 | 16 | public ConnectedSubgraphFinder(PlanarGraph graph) { 17 | this.graph = graph; 18 | } 19 | 20 | public List getConnectedSubgraphs() 21 | { 22 | List subgraphs = new ArrayList(); 23 | 24 | GraphComponent.setVisited(graph.nodeIterator(), false); 25 | for (Iterator i = graph.edgeIterator(); i.hasNext(); ) { 26 | Edge e = (Edge) i.next(); 27 | Node node = e.getDirEdge(0).getFromNode(); 28 | if (! node.isVisited()) { 29 | subgraphs.add(findSubgraph(node)); 30 | } 31 | } 32 | return subgraphs; 33 | } 34 | 35 | private Subgraph findSubgraph(Node node) 36 | { 37 | Subgraph subgraph = new Subgraph(graph); 38 | addReachable(node, subgraph); 39 | return subgraph; 40 | } 41 | 42 | /** 43 | * Adds all nodes and edges reachable from this node to the subgraph. 44 | * Uses an explicit stack to avoid a large depth of recursion. 45 | * 46 | * @param node a node known to be in the subgraph 47 | */ 48 | private void addReachable(Node startNode, Subgraph subgraph) 49 | { 50 | Stack nodeStack = new Stack(); 51 | nodeStack.add(startNode); 52 | while (! nodeStack.empty()) { 53 | Node node = (Node) nodeStack.pop(); 54 | addEdges(node, nodeStack, subgraph); 55 | } 56 | } 57 | 58 | /** 59 | * Adds the argument node and all its out edges to the subgraph. 60 | * @param node the node to add 61 | * @param nodeStack the current set of nodes being traversed 62 | */ 63 | private void addEdges(Node node, Stack nodeStack, Subgraph subgraph) 64 | { 65 | node.setVisited(true); 66 | for (Iterator i = ((DirectedEdgeStar) node.getOutEdges()).iterator(); i.hasNext(); ) { 67 | DirectedEdge de = (DirectedEdge) i.next(); 68 | subgraph.add(de.getEdge()); 69 | Node toNode = de.getToNode(); 70 | if (! toNode.isVisited()) nodeStack.push(toNode); 71 | } 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/planargraph/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes to implement a planar graph data structure. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/polygonize/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes to implement a polygonization algorithm. 11 | This package can be used to create polygons from fully noded linework. 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/precision/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Provides classes for manipulating the precision model of Geometries 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/simplify/DouglasPeuckerLineSimplifier.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.simplify; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.geom.*; 5 | 6 | /** 7 | * Simplifies a linestring (sequence of points) using 8 | * the standard Douglas-Peucker algorithm. 9 | * 10 | * @version 1.7 11 | */ 12 | public class DouglasPeuckerLineSimplifier 13 | { 14 | public static Coordinate[] simplify(Coordinate[] pts, double distanceTolerance) 15 | { 16 | DouglasPeuckerLineSimplifier simp = new DouglasPeuckerLineSimplifier(pts); 17 | simp.setDistanceTolerance(distanceTolerance); 18 | return simp.simplify(); 19 | } 20 | 21 | private Coordinate[] pts; 22 | private boolean[] usePt; 23 | private double distanceTolerance; 24 | 25 | public DouglasPeuckerLineSimplifier(Coordinate[] pts) 26 | { 27 | this.pts = pts; 28 | } 29 | /** 30 | * Sets the distance tolerance for the simplification. 31 | * All vertices in the simplified linestring will be within this 32 | * distance of the original linestring. 33 | * 34 | * @param distanceTolerance the approximation tolerance to use 35 | */ 36 | public void setDistanceTolerance(double distanceTolerance) { 37 | this.distanceTolerance = distanceTolerance; 38 | } 39 | 40 | public Coordinate[] simplify() 41 | { 42 | usePt = new boolean[pts.length]; 43 | for (int i = 0; i < pts.length; i++) { 44 | usePt[i] = true; 45 | } 46 | simplifySection(0, pts.length - 1); 47 | CoordinateList coordList = new CoordinateList(); 48 | for (int i = 0; i < pts.length; i++) { 49 | if (usePt[i]) 50 | coordList.add(new Coordinate(pts[i])); 51 | } 52 | return coordList.toCoordinateArray(); 53 | } 54 | 55 | private LineSegment seg = new LineSegment(); 56 | 57 | private void simplifySection(int i, int j) 58 | { 59 | if((i+1) == j) { 60 | return; 61 | } 62 | seg.p0 = pts[i]; 63 | seg.p1 = pts[j]; 64 | double maxDistance = -1.0; 65 | int maxIndex = i; 66 | for (int k = i + 1; k < j; k++) { 67 | double distance = seg.distance(pts[k]); 68 | if (distance > maxDistance) { 69 | maxDistance = distance; 70 | maxIndex = k; 71 | } 72 | } 73 | if (maxDistance <= distanceTolerance) { 74 | for(int k = i + 1; k < j; k++) { 75 | usePt[k] = false; 76 | } 77 | } 78 | else { 79 | simplifySection(i, maxIndex); 80 | simplifySection(maxIndex, j); 81 | } 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/simplify/LineSegmentIndex.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.simplify; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.geom.*; 5 | import com.vividsolutions.jts.index.*; 6 | import com.vividsolutions.jts.index.quadtree.Quadtree; 7 | 8 | /** 9 | * An spatial index on a set of {@link LineSegment}s. 10 | * Supports adding and removing items. 11 | * 12 | * @author Martin Davis 13 | */ 14 | public class LineSegmentIndex 15 | { 16 | private Quadtree index = new Quadtree(); 17 | 18 | public LineSegmentIndex() 19 | { 20 | } 21 | 22 | public void add(TaggedLineString line) { 23 | TaggedLineSegment[] segs = line.getSegments(); 24 | for (int i = 0; i < segs.length - 1; i++) { 25 | TaggedLineSegment seg = segs[i]; 26 | add(seg); 27 | } 28 | } 29 | 30 | public void add(LineSegment seg) 31 | { 32 | index.insert(new Envelope(seg.p0, seg.p1), seg); 33 | } 34 | 35 | public void remove(LineSegment seg) 36 | { 37 | index.remove(new Envelope(seg.p0, seg.p1), seg); 38 | } 39 | 40 | public List query(LineSegment querySeg) 41 | { 42 | Envelope env = new Envelope(querySeg.p0, querySeg.p1); 43 | 44 | LineSegmentVisitor visitor = new LineSegmentVisitor(querySeg); 45 | index.query(env, visitor); 46 | List itemsFound = visitor.getItems(); 47 | 48 | // List listQueryItems = index.query(env); 49 | // System.out.println("visitor size = " + itemsFound.size() 50 | // + " query size = " + listQueryItems.size()); 51 | // List itemsFound = index.query(env); 52 | 53 | return itemsFound; 54 | } 55 | } 56 | 57 | /** 58 | * ItemVisitor subclass to reduce volume of query results. 59 | */ 60 | class LineSegmentVisitor 61 | implements ItemVisitor 62 | { 63 | // MD - only seems to make about a 10% difference in overall time. 64 | 65 | private LineSegment querySeg; 66 | private ArrayList items = new ArrayList(); 67 | 68 | public LineSegmentVisitor(LineSegment querySeg) { 69 | this.querySeg = querySeg; 70 | } 71 | 72 | public void visitItem(Object item) 73 | { 74 | LineSegment seg = (LineSegment) item; 75 | if (Envelope.intersects(seg.p0, seg.p1, querySeg.p0, querySeg.p1)) 76 | items.add(item); 77 | } 78 | 79 | public ArrayList getItems() { return items; } 80 | } 81 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/simplify/TaggedLineSegment.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.simplify; 2 | 3 | import com.vividsolutions.jts.geom.*; 4 | 5 | /** 6 | * A {@link LineSegment} which is tagged with its location in a parent {@link Geometry}. 7 | * Used to index the segments in a geometry and recover the segment locations 8 | * from the index. 9 | */ 10 | public class TaggedLineSegment 11 | extends LineSegment 12 | { 13 | private Geometry parent; 14 | private int index; 15 | 16 | public TaggedLineSegment(Coordinate p0, Coordinate p1, Geometry parent, int index) { 17 | super(p0, p1); 18 | this.parent = parent; 19 | this.index = index; 20 | } 21 | 22 | public TaggedLineSegment(Coordinate p0, Coordinate p1) { 23 | this(p0, p1, null, -1); 24 | } 25 | 26 | public Geometry getParent() { return parent; } 27 | public int getIndex() { return index; } 28 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/simplify/TaggedLineString.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.simplify; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.geom.*; 5 | 6 | /** 7 | * @version 1.7 8 | */ 9 | public class TaggedLineString 10 | { 11 | 12 | private LineString parentLine; 13 | private TaggedLineSegment[] segs; 14 | private List resultSegs = new ArrayList(); 15 | private int minimumSize; 16 | 17 | public TaggedLineString(LineString parentLine) { 18 | this(parentLine, 2); 19 | } 20 | 21 | public TaggedLineString(LineString parentLine, int minimumSize) { 22 | this.parentLine = parentLine; 23 | this.minimumSize = minimumSize; 24 | init(); 25 | } 26 | 27 | public int getMinimumSize() { return minimumSize; } 28 | public LineString getParent() { return parentLine; } 29 | public Coordinate[] getParentCoordinates() { return parentLine.getCoordinates(); } 30 | public Coordinate[] getResultCoordinates() { return extractCoordinates(resultSegs); } 31 | 32 | public int getResultSize() 33 | { 34 | int resultSegsSize = resultSegs.size(); 35 | return resultSegsSize == 0 ? 0 : resultSegsSize + 1; 36 | } 37 | 38 | public TaggedLineSegment getSegment(int i) { return segs[i]; } 39 | 40 | private void init() 41 | { 42 | Coordinate[] pts = parentLine.getCoordinates(); 43 | segs = new TaggedLineSegment[pts.length - 1]; 44 | for (int i = 0; i < pts.length - 1; i++) { 45 | TaggedLineSegment seg 46 | = new TaggedLineSegment(pts[i], pts[i + 1], parentLine, i); 47 | segs[i] = seg; 48 | } 49 | } 50 | 51 | public TaggedLineSegment[] getSegments() { return segs; } 52 | 53 | public void addToResult(LineSegment seg) 54 | { 55 | resultSegs.add(seg); 56 | } 57 | 58 | public LineString asLineString() 59 | { 60 | return parentLine.getFactory().createLineString(extractCoordinates(resultSegs)); 61 | } 62 | 63 | public LinearRing asLinearRing() { 64 | return parentLine.getFactory().createLinearRing(extractCoordinates(resultSegs)); 65 | } 66 | 67 | private static Coordinate[] extractCoordinates(List segs) 68 | { 69 | Coordinate[] pts = new Coordinate[segs.size() + 1]; 70 | LineSegment seg = null; 71 | for (int i = 0; i < segs.size(); i++) { 72 | seg = (LineSegment) segs.get(i); 73 | pts[i] = seg.p0; 74 | } 75 | // add last point 76 | pts[pts.length - 1] = seg.p1; 77 | return pts; 78 | } 79 | 80 | 81 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/simplify/TaggedLinesSimplifier.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.simplify; 2 | 3 | import java.util.*; 4 | import com.vividsolutions.jts.algorithm.*; 5 | 6 | /** 7 | * Simplifies a collection of {@link TaggedLineString}s, preserving topology 8 | * (in the sense that no new intersections are introduced). 9 | * This class is essentially just a container for the common 10 | * indexes used by {@link TaggedLineStringSimplifier}. 11 | */ 12 | public class TaggedLinesSimplifier 13 | { 14 | private LineSegmentIndex inputIndex = new LineSegmentIndex(); 15 | private LineSegmentIndex outputIndex = new LineSegmentIndex(); 16 | private double distanceTolerance = 0.0; 17 | 18 | public TaggedLinesSimplifier() 19 | { 20 | 21 | } 22 | 23 | /** 24 | * Sets the distance tolerance for the simplification. 25 | * All vertices in the simplified geometry will be within this 26 | * distance of the original geometry. 27 | * 28 | * @param distanceTolerance the approximation tolerance to use 29 | */ 30 | public void setDistanceTolerance(double distanceTolerance) { 31 | this.distanceTolerance = distanceTolerance; 32 | } 33 | 34 | /** 35 | * Simplify a collection of {@link TaggedLineString}s 36 | * 37 | * @param taggedLines the collection of lines to simplify 38 | */ 39 | public void simplify(Collection taggedLines) { 40 | for (Iterator i = taggedLines.iterator(); i.hasNext(); ) { 41 | inputIndex.add((TaggedLineString) i.next()); 42 | } 43 | for (Iterator i = taggedLines.iterator(); i.hasNext(); ) { 44 | TaggedLineStringSimplifier tlss 45 | = new TaggedLineStringSimplifier(inputIndex, outputIndex); 46 | tlss.setDistanceTolerance(distanceTolerance); 47 | tlss.simplify((TaggedLineString) i.next()); 48 | } 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/util/AssertionFailedException.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.util; 36 | 37 | /** 38 | * Thrown when the application is in an inconsistent state. Indicates a problem 39 | * with the code. 40 | * 41 | *@version 1.7 42 | */ 43 | public class AssertionFailedException extends RuntimeException { 44 | 45 | /** 46 | * Creates an AssertionFailedException. 47 | */ 48 | public AssertionFailedException() { 49 | super(); 50 | } 51 | 52 | /** 53 | * Creates a AssertionFailedException with the given detail 54 | * message. 55 | * 56 | *@param message a description of the assertion 57 | */ 58 | public AssertionFailedException(String message) { 59 | super(message); 60 | } 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/util/CollectionUtil.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jts.util; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Executes a transformation function on each element of a collection 7 | * and returns the results in a new List. 8 | * 9 | * @version 1.7 10 | */ 11 | public class CollectionUtil { 12 | 13 | public interface Function { 14 | Object execute(Object obj); 15 | } 16 | 17 | /** 18 | * Executes a function on each item in a {@link Collection} 19 | * and returns the results in a new {@link List} 20 | * 21 | * @param coll the collection to process 22 | * @param func the Function to execute 23 | */ 24 | public static List transform(Collection coll, Function func) 25 | { 26 | List result = new ArrayList(); 27 | for (Iterator i = coll.iterator(); i.hasNext(); ) { 28 | result.add(func.execute(i.next())); 29 | } 30 | return result; 31 | } 32 | 33 | /** 34 | * Executes a function on each item in a Collection but does 35 | * not accumulate the result 36 | * 37 | * @param coll the collection to process 38 | * @param func the Function to execute 39 | */ 40 | public static void apply(Collection coll, Function func) 41 | { 42 | for (Iterator i = coll.iterator(); i.hasNext(); ) { 43 | func.execute(i.next()); 44 | } 45 | } 46 | 47 | /** 48 | * Executes a function on each item in a Collection 49 | * and collects all the entries for which the result 50 | * of the function is equal to {@link Boolean}.TRUE. 51 | * 52 | * @param collection the collection to process 53 | * @param func the Function to execute 54 | */ 55 | public static List select(Collection collection, Function func) { 56 | List result = new ArrayList(); 57 | for (Iterator i = collection.iterator(); i.hasNext();) { 58 | Object item = i.next(); 59 | if (Boolean.TRUE.equals(func.execute(item))) { 60 | result.add(item); 61 | } 62 | } 63 | return result; 64 | } 65 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/util/CoordinateArrayFilter.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.util; 36 | 37 | import com.vividsolutions.jts.geom.*; 38 | 39 | /** 40 | * A {@link CoordinateFilter} that creates an array containing every 41 | * coordinate in a {@link Geometry}. 42 | * 43 | *@version 1.7 44 | */ 45 | public class CoordinateArrayFilter implements CoordinateFilter { 46 | Coordinate[] pts = null; 47 | int n = 0; 48 | 49 | /** 50 | * Constructs a CoordinateArrayFilter. 51 | * 52 | *@param size the number of points that the CoordinateArrayFilter 53 | * will collect 54 | */ 55 | public CoordinateArrayFilter(int size) { 56 | pts = new Coordinate[size]; 57 | } 58 | 59 | /** 60 | * Returns the gathered Coordinates. 61 | * 62 | *@return the Coordinates collected by this CoordinateArrayFilter 63 | */ 64 | public Coordinate[] getCoordinates() { 65 | return pts; 66 | } 67 | 68 | public void filter(Coordinate coord) { 69 | pts[n++] = coord; 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/util/CoordinateCountFilter.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.util; 36 | 37 | import com.vividsolutions.jts.geom.*; 38 | 39 | /** 40 | * A {@link CoordinateFilter} that counts the total number of coordinates 41 | * in a Geometry. 42 | * 43 | *@version 1.7 44 | */ 45 | public class CoordinateCountFilter implements CoordinateFilter { 46 | private int n = 0; 47 | 48 | public CoordinateCountFilter() { } 49 | 50 | /** 51 | * Returns the result of the filtering. 52 | * 53 | *@return the number of points found by this CoordinateCountFilter 54 | */ 55 | public int getCount() { 56 | return n; 57 | } 58 | 59 | public void filter(Coordinate coord) { 60 | n++; 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/util/UniqueCoordinateArrayFilter.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * The JTS Topology Suite is a collection of Java classes that 5 | * implement the fundamental operations required to validate a given 6 | * geo-spatial data set to a known topological specification. 7 | * 8 | * Copyright (C) 2001 Vivid Solutions 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * For more information, contact: 25 | * 26 | * Vivid Solutions 27 | * Suite #1A 28 | * 2328 Government Street 29 | * Victoria BC V8T 5G5 30 | * Canada 31 | * 32 | * (250)385-6040 33 | * www.vividsolutions.com 34 | */ 35 | package com.vividsolutions.jts.util; 36 | 37 | import java.util.ArrayList; 38 | import java.util.TreeSet; 39 | 40 | import com.vividsolutions.jts.geom.Coordinate; 41 | import com.vividsolutions.jts.geom.CoordinateFilter; 42 | 43 | /** 44 | * A {@link CoordinateFilter} that builds a set of Coordinates. 45 | * The set of coordinates contains no duplicate points. 46 | * 47 | *@version 1.7 48 | */ 49 | public class UniqueCoordinateArrayFilter implements CoordinateFilter { 50 | TreeSet treeSet = new TreeSet(); 51 | ArrayList list = new ArrayList(); 52 | 53 | public UniqueCoordinateArrayFilter() { } 54 | 55 | /** 56 | * Returns the gathered Coordinates. 57 | * 58 | *@return the Coordinates collected by this CoordinateArrayFilter 59 | */ 60 | public Coordinate[] getCoordinates() { 61 | Coordinate[] coordinates = new Coordinate[list.size()]; 62 | return (Coordinate[]) list.toArray(coordinates); 63 | } 64 | 65 | public void filter(Coordinate coord) { 66 | if (!treeSet.contains(coord)) { 67 | list.add(coord); 68 | treeSet.add(coord); 69 | } 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jts/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Contains support classes for the Java Topology Suite. 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jtsexample/geom/BasicExample.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jtsexample.geom; 35 | 36 | import com.vividsolutions.jts.geom.Coordinate; 37 | import com.vividsolutions.jts.geom.Geometry; 38 | import com.vividsolutions.jts.geom.GeometryFactory; 39 | import com.vividsolutions.jts.io.WKTReader; 40 | 41 | /** 42 | * Shows basic ways of creating and operating on geometries 43 | * 44 | * @version 1.7 45 | */ 46 | public class BasicExample 47 | { 48 | public static void main(String[] args) 49 | throws Exception 50 | { 51 | // read a geometry from a WKT string (using the default geometry factory) 52 | Geometry g1 = new WKTReader().read("LINESTRING (0 0, 10 10, 20 20)"); 53 | System.out.println("Geometry 1: " + g1); 54 | 55 | // create a geometry by specifying the coordinates directly 56 | Coordinate[] coordinates = new Coordinate[]{new Coordinate(0, 0), 57 | new Coordinate(10, 10), new Coordinate(20, 20)}; 58 | // use the default factory, which gives full double-precision 59 | Geometry g2 = new GeometryFactory().createLineString(coordinates); 60 | System.out.println("Geometry 2: " + g2); 61 | 62 | // compute the intersection of the two geometries 63 | Geometry g3 = g1.intersection(g2); 64 | System.out.println("G1 intersection G2: " + g3); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jtsexample/geom/ConstructionExample.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jtsexample.geom; 2 | 3 | import com.vividsolutions.jts.geom.*; 4 | 5 | /** 6 | * Examples of constructing Geometries programmatically. 7 | *

    8 | * The Best Practice moral here is: 9 | * 10 | * Use the GeometryFactory to construct Geometries whenever possible. 11 | * 12 | * This has several advantages: 13 | *

      14 | *
    1. Simplifies your code 15 | *
    2. allows you to take advantage of convenience methods provided by GeometryFactory 16 | *
    3. Insulates your code from changes in the signature of JTS constructors 17 | *
    18 | * 19 | * @version 1.7 20 | */ 21 | public class ConstructionExample 22 | { 23 | 24 | public static void main(String[] args) 25 | throws Exception 26 | { 27 | // create a factory using default values (e.g. floating precision) 28 | GeometryFactory fact = new GeometryFactory(); 29 | 30 | Point p1 = fact.createPoint(new Coordinate(0,0)); 31 | System.out.println(p1); 32 | 33 | Point p2 = fact.createPoint(new Coordinate(1,1)); 34 | System.out.println(p1); 35 | 36 | MultiPoint mpt = fact.createMultiPoint(new Coordinate[] { new Coordinate(0,0), new Coordinate(1,1) } ); 37 | System.out.println(mpt); 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jtsexample/geom/ExtendedCoordinate.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * The JTS Topology Suite is a collection of Java classes that 4 | * implement the fundamental operations required to validate a given 5 | * geo-spatial data set to a known topological specification. 6 | * 7 | * Copyright (C) 2001 Vivid Solutions 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | * For more information, contact: 24 | * 25 | * Vivid Solutions 26 | * Suite #1A 27 | * 2328 Government Street 28 | * Victoria BC V8T 5G5 29 | * Canada 30 | * 31 | * (250)385-6040 32 | * www.vividsolutions.com 33 | */ 34 | package com.vividsolutions.jtsexample.geom; 35 | 36 | import com.vividsolutions.jts.geom.*; 37 | 38 | 39 | /** 40 | * @version 1.7 41 | */ 42 | public class ExtendedCoordinate 43 | extends Coordinate 44 | { 45 | private static final long serialVersionUID = 8527484784733305576L; 46 | // A Coordinate subclass should provide all of these methods 47 | 48 | /** 49 | * Default constructor 50 | */ 51 | public ExtendedCoordinate() 52 | { 53 | super(); 54 | this.m = 0.0; 55 | } 56 | 57 | public ExtendedCoordinate(double x, double y, double z, double m) 58 | { 59 | super(x, y, z); 60 | this.m = m; 61 | } 62 | 63 | public ExtendedCoordinate(Coordinate coord) 64 | { 65 | super(coord); 66 | if (coord instanceof ExtendedCoordinate) 67 | m = ((ExtendedCoordinate) coord).m; 68 | else 69 | m = Double.NaN; 70 | } 71 | 72 | public ExtendedCoordinate(ExtendedCoordinate coord) 73 | { 74 | super(coord); 75 | m = coord.m; 76 | } 77 | 78 | /** 79 | * An example of extended data. 80 | * The m variable holds a measure value for linear referencing 81 | */ 82 | 83 | private double m; 84 | 85 | public double getM() { return m; } 86 | public void setM(double m) { this.m = m; } 87 | 88 | public String toString() 89 | { 90 | String stringRep = x + " " + y + " m=" + m; 91 | return stringRep; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jtsexample/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | Contains classes with examples of using the JTS API. 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/com/vividsolutions/jtsexample/technique/LineStringSelfIntersections.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jtsexample.technique; 2 | 3 | import com.vividsolutions.jts.geom.*; 4 | import com.vividsolutions.jts.io.WKTReader; 5 | import java.util.*; 6 | 7 | /** 8 | * Shows a technique for identifying the location of self-intersections 9 | * in a non-simple LineString. 10 | * 11 | * @version 1.7 12 | */ 13 | 14 | public class LineStringSelfIntersections { 15 | 16 | public static void main(String[] args) 17 | throws Exception 18 | { 19 | WKTReader rdr = new WKTReader(); 20 | 21 | LineString line1 = (LineString) (rdr.read("LINESTRING (0 0, 10 10, 20 20)")); 22 | showSelfIntersections(line1); 23 | LineString line2 = (LineString) (rdr.read("LINESTRING (0 40, 60 40, 60 0, 20 0, 20 60)")); 24 | showSelfIntersections(line2); 25 | 26 | } 27 | 28 | public static void showSelfIntersections(LineString line) 29 | { 30 | System.out.println("Line: " + line); 31 | System.out.println("Self Intersections: " + lineStringSelfIntersections(line)); 32 | } 33 | 34 | public static Geometry lineStringSelfIntersections(LineString line) 35 | { 36 | Geometry lineEndPts = getEndPoints(line); 37 | Geometry nodedLine = line.union(lineEndPts); 38 | Geometry nodedEndPts = getEndPoints(nodedLine); 39 | Geometry selfIntersections = nodedEndPts.difference(lineEndPts); 40 | return selfIntersections; 41 | } 42 | 43 | public static Geometry getEndPoints(Geometry g) 44 | { 45 | List endPtList = new ArrayList(); 46 | if (g instanceof LineString) { 47 | LineString line = (LineString) g; 48 | 49 | endPtList.add(line.getCoordinateN(0)); 50 | endPtList.add(line.getCoordinateN(line.getNumPoints() - 1)); 51 | } 52 | else if (g instanceof MultiLineString) { 53 | MultiLineString mls = (MultiLineString) g; 54 | for (int i = 0; i < mls.getNumGeometries(); i++) { 55 | LineString line = (LineString) mls.getGeometryN(i); 56 | endPtList.add(line.getCoordinateN(0)); 57 | endPtList.add(line.getCoordinateN(line.getNumPoints() - 1)); 58 | } 59 | } 60 | Coordinate[] endPts = CoordinateArrays.toCoordinateArray(endPtList); 61 | return (new GeometryFactory()).createMultiPoint(endPts); 62 | } 63 | 64 | 65 | } -------------------------------------------------------------------------------- /src/com/vividsolutions/jtsexample/technique/PolygonUnionUsingBuffer.java: -------------------------------------------------------------------------------- 1 | package com.vividsolutions.jtsexample.technique; 2 | 3 | import com.vividsolutions.jts.geom.*; 4 | import com.vividsolutions.jts.io.WKTReader; 5 | import java.util.*; 6 | 7 | /** 8 | * Shows a technique for using a zero-width buffer to compute 9 | * the union of a collection of polygonal geometrys. 10 | * The advantages of this technique are: 11 | *
      12 | *
    • can avoid robustness issues 13 | *
    • faster for large numbers of input geometries 14 | *
    • handles GeometryCollections as input (although only the polygons will be buffered) 15 | *
    16 | * Disadvantages are: 17 | *
      18 | *
    • may not preserve input coordinate precision in some cases 19 | *
    • only works for polygons 20 | *
    21 | * 22 | * @version 1.7 23 | */ 24 | 25 | public class PolygonUnionUsingBuffer { 26 | 27 | public static void main(String[] args) 28 | throws Exception 29 | { 30 | WKTReader rdr = new WKTReader(); 31 | 32 | Geometry[] geom = new Geometry[3]; 33 | geom[0] = rdr.read("POLYGON (( 100 180, 100 260, 180 260, 180 180, 100 180 ))"); 34 | geom[1] = rdr.read("POLYGON (( 80 140, 80 200, 200 200, 200 140, 80 140 ))"); 35 | geom[2] = rdr.read("POLYGON (( 160 160, 160 240, 240 240, 240 160, 160 160 ))"); 36 | unionUsingBuffer(geom); 37 | 38 | } 39 | 40 | public static void unionUsingBuffer(Geometry[] geom) 41 | { 42 | GeometryFactory fact = geom[0].getFactory(); 43 | Geometry geomColl = fact.createGeometryCollection(geom); 44 | Geometry union = geomColl.buffer(0.0); 45 | System.out.println(union); 46 | } 47 | 48 | 49 | 50 | } -------------------------------------------------------------------------------- /testxml/general/TestConvexHull-big.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Big convex hull 6 | 7 | MULTIPOINT(-1000000000000000000000000 -1000000000000000000000000, 1000000000000000000000000 -1000000000000000000000000, 1000000000000000000000000 1000000000000000000000000, -1000000000000000000000000 1000000000000000000000000, 0 0) 8 | 9 | 10 | 11 | POLYGON( 12 | (-1000000000000000000000000 -1000000000000000000000000, -1000000000000000000000000 1000000000000000000000000, 1000000000000000000000000 1000000000000000000000000, 1000000000000000000000000 -1000000000000000000000000, -1000000000000000000000000 -1000000000000000000000000)) 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /testxml/general/TestFunctionLAPrec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LA - line and sliver intersecting, dimensional collapse 6 | 7 | POLYGON( 8 | (95 9, 81 414, 87 414, 95 9)) 9 | 10 | 11 | LINESTRING(93 13, 96 13) 12 | 13 | 14 | 15 | LINESTRING(95 9, 81 414, 87 414, 95 9) 16 | 17 | 18 | 19 | 20 | POLYGON( 21 | (95 9, 81 414, 87 414, 95 9)) 22 | 23 | 24 | 25 | 26 | POINT(95 13) 27 | 28 | 29 | 30 | 31 | GEOMETRYCOLLECTION( 32 | LINESTRING(95 9, 95 13), 33 | POLYGON( 34 | (95 13, 81 414, 87 414, 95 13)), 35 | LINESTRING(93 13, 95 13), 36 | LINESTRING(95 13, 96 13)) 37 | 38 | 39 | 40 | 41 | GEOMETRYCOLLECTION( 42 | LINESTRING(95 9, 95 13), 43 | POLYGON( 44 | (95 13, 81 414, 87 414, 95 13))) 45 | 46 | 47 | 48 | 49 | GEOMETRYCOLLECTION( 50 | LINESTRING(95 9, 95 13), 51 | POLYGON( 52 | (95 13, 81 414, 87 414, 95 13)), 53 | LINESTRING(93 13, 95 13), 54 | LINESTRING(95 13, 96 13)) 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /testxml/general/TestFunctionLLPrec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LL - narrow V 6 | 7 | LINESTRING(0 10, 620 10, 0 11) 8 | 9 | 10 | LINESTRING(400 60, 400 10) 11 | 12 | 13 | 14 | POINT(400 10) 15 | 16 | 17 | 18 | 19 | MULTILINESTRING( 20 | (0 10, 400 10), 21 | (400 10, 620 10, 400 10), 22 | (400 10, 0 11), 23 | (400 60, 400 10)) 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /testxml/general/TestFunctionPLPrec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PP - Point just off line. Causes non-robust algorithms to fail. 6 | 7 | LINESTRING(-123456789 -40, 381039468754763 123456789) 8 | 9 | 10 | POINT(0 0) 11 | 12 | 13 | 14 | false 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /testxml/general/TestInteriorPoint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | P - single point 6 | POINT(10 10) 7 | POINT(10 10) 8 | 9 | 10 | 11 | P - single point 12 | MULTIPOINT (60 300, 200 200, 240 240, 200 300, 40 140, 80 240, 140 240, 100 160, 140 200, 60 200) 13 | 14 | POINT (140 240) 15 | 16 | 17 | 18 | L - linestring with single segment 19 | LINESTRING (0 0, 7 14) 20 | 21 | POINT (7 14) 22 | 23 | 24 | 25 | L - linestring with multiple segments 26 | LINESTRING (0 0, 3 15, 6 2, 11 14, 16 5, 16 18, 2 22) 27 | 28 | POINT (11 14) 29 | 30 | 31 | 32 | mL - complex linestrings 33 | MULTILINESTRING ((60 240, 140 300, 180 200, 40 140, 100 100, 120 220), 34 | (240 80, 260 160, 200 240, 180 340, 280 340, 240 180, 180 140, 40 200, 140 260)) 35 | 36 | POINT (180 200) 37 | 38 | 39 | 40 | A - box 41 | POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0)) 42 | 43 | POINT (5 5) 44 | 45 | 46 | 47 | mA - polygons with holes 48 | MULTIPOLYGON (((60 320, 240 340, 260 100, 20 60, 120 180, 60 320), 49 | (200 280, 140 260, 180 160, 240 140, 200 280)), 50 | ((380 280, 300 260, 340 100, 440 80, 380 280), 51 | (380 220, 340 200, 400 100, 380 220))) 52 | 53 | POINT (138 200) 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /testxml/general/TestRelateAC.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AC A-shells overlapping B-shell at A-vertex 6 | 7 | POLYGON( 8 | (100 60, 140 100, 100 140, 60 100, 100 60)) 9 | 10 | 11 | MULTIPOLYGON( 12 | ( 13 | (80 40, 120 40, 120 80, 80 80, 80 40)), 14 | ( 15 | (120 80, 160 80, 160 120, 120 120, 120 80)), 16 | ( 17 | (80 120, 120 120, 120 160, 80 160, 80 120)), 18 | ( 19 | (40 80, 80 80, 80 120, 40 120, 40 80))) 20 | 21 | 22 | 23 | true 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /testxml/general/TestRelateLC.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LC - topographically equal with no boundary 6 | 7 | LINESTRING(0 0, 0 50, 50 50, 50 0, 0 0) 8 | 9 | 10 | MULTILINESTRING( 11 | (0 0, 0 50), 12 | (0 50, 50 50), 13 | (50 50, 50 0), 14 | (50 0, 0 0)) 15 | 16 | 17 | 18 | true 19 | 20 | 21 | 22 | 23 | 24 | LC - intersection (containment) along mod-2 A-Int line segment 25 | 26 | LINESTRING(40 180, 140 180) 27 | 28 | 29 | MULTIPOLYGON( 30 | ( 31 | (20 320, 180 320, 180 180, 20 180, 20 320)), 32 | ( 33 | (20 180, 20 80, 180 80, 180 180, 20 180))) 34 | 35 | 36 | 37 | true 38 | 39 | 40 | 41 | 42 | 43 | LC - intersection (overlap) along mod-2 A-Int line segment 44 | 45 | LINESTRING(40 180, 140 180) 46 | 47 | 48 | MULTIPOLYGON( 49 | ( 50 | (20 320, 180 320, 180 180, 20 180, 20 320)), 51 | ( 52 | (60 180, 60 80, 180 80, 180 180, 60 180))) 53 | 54 | 55 | 56 | true 57 | 58 | 59 | 60 | 61 | 62 | LC - equal with boundary intersection 63 | 64 | LINESTRING(0 0, 60 0, 60 60, 60 0, 120 0) 65 | 66 | 67 | MULTILINESTRING( 68 | (0 0, 60 0), 69 | (60 0, 120 0), 70 | (60 0, 60 60)) 71 | 72 | 73 | 74 | true 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /testxml/general/TestRelatePA.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PA - disjoint 6 | 7 | POINT(20 20) 8 | 9 | 10 | POLYGON( 11 | (60 120, 60 40, 160 40, 160 120, 60 120)) 12 | 13 | 14 | 15 | true 16 | 17 | 18 | 19 | 20 | 21 | mPA - points in B: E, I 22 | 23 | MULTIPOINT(0 20, 40 20) 24 | 25 | 26 | POLYGON( 27 | (20 40, 20 0, 60 0, 60 40, 20 40)) 28 | 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | 37 | mPA - points in B: E, B 38 | 39 | MULTIPOINT(0 20, 20 20) 40 | 41 | 42 | POLYGON( 43 | (20 40, 20 0, 60 0, 60 40, 20 40)) 44 | 45 | 46 | 47 | true 48 | 49 | 50 | 51 | 52 | 53 | mPA - points in B: B, I 54 | 55 | MULTIPOINT(20 20, 40 20) 56 | 57 | 58 | POLYGON( 59 | (20 40, 20 0, 60 0, 60 40, 20 40)) 60 | 61 | 62 | 63 | true 64 | 65 | 66 | 67 | 68 | 69 | mPA - points in B: I, B, E 70 | 71 | MULTIPOINT(80 260, 140 260, 180 260) 72 | 73 | 74 | POLYGON( 75 | (40 320, 140 320, 140 200, 40 200, 40 320)) 76 | 77 | 78 | 79 | true 80 | 81 | 82 | 83 | 84 | 85 | PmA - point in B: mod-2 I 86 | 87 | POINT(40 40) 88 | 89 | 90 | MULTIPOLYGON( 91 | ( 92 | (0 40, 0 0, 40 0, 40 40, 0 40)), 93 | ( 94 | (40 80, 40 40, 80 40, 80 80, 40 80))) 95 | 96 | 97 | 98 | true 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /testxml/general/TestRelatePL.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PL - disjoint 6 | 7 | POINT(60 120) 8 | 9 | 10 | LINESTRING(40 40, 120 120, 200 120) 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | PL - touches Bdy 21 | 22 | POINT(40 40) 23 | 24 | 25 | LINESTRING(40 40, 100 100, 160 100) 26 | 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | PL - touches non-vertex 36 | 37 | POINT(60 60) 38 | 39 | 40 | LINESTRING(40 40, 100 100) 41 | 42 | 43 | 44 | true 45 | 46 | 47 | 48 | 49 | 50 | mPL - touches Bdy and Ext 51 | 52 | MULTIPOINT(40 40, 100 40) 53 | 54 | 55 | LINESTRING(40 40, 80 80) 56 | 57 | 58 | 59 | true 60 | 61 | 62 | 63 | 64 | 65 | mPL - touches Int and Bdy 66 | 67 | MULTIPOINT(40 40, 60 60) 68 | 69 | 70 | LINESTRING(40 40, 80 80) 71 | 72 | 73 | 74 | true 75 | 76 | 77 | 78 | 79 | 80 | mPL - touches Int and Ext 81 | 82 | MULTIPOINT(60 60, 100 100) 83 | 84 | 85 | LINESTRING(40 40, 80 80) 86 | 87 | 88 | 89 | true 90 | 91 | 92 | 93 | 94 | 95 | mPL - touches IntNV and Ext 96 | 97 | MULTIPOINT(60 60, 100 100) 98 | 99 | 100 | LINESTRING(40 40, 80 80) 101 | 102 | 103 | 104 | true 105 | 106 | 107 | 108 | 109 | 110 | mPL - touches IntV and Ext 111 | 112 | MULTIPOINT(60 60, 100 100) 113 | 114 | 115 | LINESTRING(40 40, 60 60, 80 80) 116 | 117 | 118 | 119 | true 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /testxml/general/TestRelatePP.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | same point 6 | 7 | POINT(20 20) 8 | 9 | 10 | POINT(20 20) 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | different point 21 | 22 | POINT(20 20) 23 | 24 | 25 | POINT(20 30) 26 | 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | some same, some different points 36 | 37 | MULTIPOINT(40 40, 80 60, 40 100) 38 | 39 | 40 | MULTIPOINT(40 40, 80 60, 120 100) 41 | 42 | 43 | 44 | true 45 | 46 | 47 | 48 | 49 | 50 | same points 51 | 52 | MULTIPOINT(40 40, 80 60, 120 100) 53 | 54 | 55 | MULTIPOINT(40 40, 80 60, 120 100) 56 | 57 | 58 | 59 | true 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /testxml/general/TestValid2-big.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test 92 5 | 6 | POLYGON ((100 100, 1000000000000000 110, 1000000000000000 100, 100 100)) 7 | 8 | true 9 | 10 | 11 | Test 558 12 | 13 | MULTIPOINT (-1000000000000000000000000 -1000000000000000000000000, 1000000000000000000000000 -1000000000000000000000000, 1000000000000000000000000 1000000000000000000000000, -1000000000000000000000000 1000000000000000000000000, 0 0) 14 | 15 | true 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /testxml/robust/TestRobustOverlayFixed.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AA 6 | 7 | POLYGON ((545 317, 617 379, 581 321, 545 317)) 8 | 9 | 10 | POLYGON ((484 290, 558 359, 543 309, 484 290)) 11 | 12 | 13 | 14 | POINT (545 317) 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /testxml/robust/TestRobustRelate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PP - Point is not on line. Non-robust algorithms fail by erroneously reporting intersects=true. 6 | 7 | LINESTRING(-123456789 -40, 381039468754763 123456789) 8 | 9 | 10 | POINT(0 0) 11 | 12 | 13 | 14 | false 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /testxml/validate/TestRelateAA-big.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A/A-6-18: a polygon overlapping a very skinny polygon [dim(2){A.A.Int = B.A.Int}, dim(1){A.A.Bdy.V-EP = B.A.Bdy.NV-EP}, dim(0){A.A.Bdy.CP = B.A.Bdy.CP}, dim(0){A.A.Bdy.NV = B.A.Bdy.NV}] 6 | 7 | POLYGON( 8 | (100 100, 100 200, 200 200, 200 100, 100 100)) 9 | 10 | 11 | POLYGON( 12 | (100 100, 1000000000000000 110, 1000000000000000 100, 100 100)) 13 | 14 | 15 | true 16 | 17 | 18 | 19 | 20 | A/A-6-24: a polygon overlapping a very skinny polygon [dim(2){A.A.Int = B.A.Int}, dim(1){A.A.Bdy.V-EP = B.A.Bdy.NV-NV}, dim(0){A.A.Bdy.NV = B.A.Bdy.NV}] 21 | 22 | POLYGON( 23 | (120 100, 120 200, 200 200, 200 100, 120 100)) 24 | 25 | 26 | POLYGON( 27 | (100 100, 1000000000000000 110, 1000000000000000 100, 100 100)) 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /testxml/validate/TestRelateAC.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AC A-shells overlapping B-shell at A-vertex 6 | 7 | POLYGON( 8 | (100 60, 140 100, 100 140, 60 100, 100 60)) 9 | 10 | 11 | MULTIPOLYGON( 12 | ( 13 | (80 40, 120 40, 120 80, 80 80, 80 40)), 14 | ( 15 | (120 80, 160 80, 160 120, 120 120, 120 80)), 16 | ( 17 | (80 120, 120 120, 120 160, 80 160, 80 120)), 18 | ( 19 | (40 80, 80 80, 80 120, 40 120, 40 80))) 20 | 21 | 22 | true 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /testxml/validate/TestRelateLC.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LC - topographically equal with no boundary 6 | 7 | LINESTRING(0 0, 0 50, 50 50, 50 0, 0 0) 8 | 9 | 10 | MULTILINESTRING( 11 | (0 0, 0 50), 12 | (0 50, 50 50), 13 | (50 50, 50 0), 14 | (50 0, 0 0)) 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | LC - intersection (containment) along mod-2 A-Int line segment 23 | 24 | LINESTRING(40 180, 140 180) 25 | 26 | 27 | MULTIPOLYGON( 28 | ( 29 | (20 320, 180 320, 180 180, 20 180, 20 320)), 30 | ( 31 | (20 180, 20 80, 180 80, 180 180, 20 180))) 32 | 33 | 34 | true 35 | 36 | 37 | 38 | 39 | LC - intersection (overlap) along mod-2 A-Int line segment 40 | 41 | LINESTRING(40 180, 140 180) 42 | 43 | 44 | MULTIPOLYGON( 45 | ( 46 | (20 320, 180 320, 180 180, 20 180, 20 320)), 47 | ( 48 | (60 180, 60 80, 180 80, 180 180, 60 180))) 49 | 50 | 51 | true 52 | 53 | 54 | 55 | 56 | LC - equal with boundary intersection 57 | 58 | LINESTRING(0 0, 60 0, 60 60, 60 0, 120 0) 59 | 60 | 61 | MULTILINESTRING( 62 | (0 0, 60 0), 63 | (60 0, 120 0), 64 | (60 0, 60 60)) 65 | 66 | 67 | true 68 | 69 | 70 | 71 | 72 | --------------------------------------------------------------------------------