├── .git-blame-ignore-revs ├── tests ├── xmltester │ ├── tinyxml2 │ │ └── README │ ├── testrunner.sh │ ├── tests │ │ ├── general │ │ │ ├── MISSING │ │ │ ├── TestOverlayPLPrec.xml │ │ │ ├── TestValid2-big.xml │ │ │ ├── TestConvexHull-big.xml │ │ │ ├── TestUnaryUnionFloating.xml │ │ │ ├── TestPreparedPointPredicate.xml │ │ │ ├── TestRelatePP.xml │ │ │ ├── TestIntersectsPL.xml │ │ │ └── TestPreparedIntersectsPL.xml │ │ ├── misc │ │ │ ├── linemerge.xml │ │ │ └── Buffer-2.xml │ │ ├── issue │ │ │ ├── issue-geos-582.xml │ │ │ ├── issue-geos-1085.xml │ │ │ ├── issue-geos-1018.xml │ │ │ ├── issue-geos-990.xml │ │ │ ├── issue-geos-234.xml │ │ │ ├── issue-geos-527.xml │ │ │ ├── issue-geos-590.xml │ │ │ ├── issue-geos-188.xml │ │ │ └── issue-geos-838.xml │ │ ├── robust │ │ │ ├── TestRobustRelate.xml │ │ │ ├── TestRobustOverlayFixed.xml │ │ │ └── overlay │ │ │ │ ├── TestOverlay-geos-527.xml │ │ │ │ ├── TestOverlay-geos-234.xml │ │ │ │ ├── TestOverlay-geos-522.xml │ │ │ │ ├── TestOverlay-gisse-345341-lines.xml │ │ │ │ ├── TestOverlay-geos-459.xml │ │ │ │ ├── TestOverlay-geos-997-union-fail.xml │ │ │ │ ├── TestOverlay-geos-398.xml │ │ │ │ ├── TestOverlay-geos-586.xml │ │ │ │ └── TestOverlay-geos-838.xml │ │ ├── failure │ │ │ └── robust-TestRobustRelateFloat.xml │ │ └── validate │ │ │ ├── TestRelateAA-big.xml │ │ │ └── TestRelateAC.xml │ └── JTSXMLTester.sh ├── unit │ ├── tut │ │ ├── tut_config.hpp │ │ ├── README │ │ └── tut_reporter.hpp │ ├── index │ │ ├── strtree │ │ │ └── SIRtreeTest.cpp │ │ └── chain │ │ │ └── MonotoneChainBuilderTest.cpp │ ├── capi │ │ ├── GEOSSetSRIDTest.cpp │ │ ├── GEOSUnionCascadedTest.cpp │ │ ├── GEOSSymDifferencePrecTest.cpp │ │ ├── GEOSGeomToWKB_bufTest.cpp │ │ ├── GEOSGeom_createLineStringTest.cpp │ │ ├── GEOSDifferencePrecTest.cpp │ │ ├── GEOSGeomTypeIdTest.cpp │ │ ├── GEOSGeomTypeTest.cpp │ │ ├── GEOSisSimpleTest.cpp │ │ ├── GEOSUnaryUnionPrecTest.cpp │ │ ├── GEOSGeom_getDimensionsTest.cpp │ │ ├── GEOSSimplifyTest.cpp │ │ ├── GEOSUnionPrecTest.cpp │ │ ├── GEOSGeom_createCircularStringTest.cpp │ │ ├── GEOSBuildAreaTest.cpp │ │ ├── GEOSDisjointTest.cpp │ │ ├── GEOSSymDifferenceTest.cpp │ │ ├── GEOSRelateTest.cpp │ │ ├── GEOSGeom_cloneTest.cpp │ │ ├── GEOSConvexHullTest.cpp │ │ ├── GEOSGetNumInteriorRingsTest.cpp │ │ ├── GEOSGeom_getCoordinateDimensionTest.cpp │ │ ├── GEOSLineMergeTest.cpp │ │ ├── GEOSGetGeometryNTest.cpp │ │ ├── GEOSSegmentIntersectionTest.cpp │ │ ├── GEOSCoversTest.cpp │ │ ├── GEOSCrossesTest.cpp │ │ ├── GEOSGeomGetNumPointsTest.cpp │ │ ├── GEOSCoveredByTest.cpp │ │ ├── GEOSEnvelopeTest.cpp │ │ ├── GEOSTouchesTest.cpp │ │ └── GEOSUserDataTest.cpp │ ├── triangulate │ │ └── quadedge │ │ │ └── VertexTest.cpp │ └── geom │ │ └── Geometry │ │ └── toTextTest.cpp ├── superbuild.CMakeLists.txt ├── CMakeLists.txt └── README.md ├── CODE_OF_CONDUCT.md ├── doxygen └── README ├── .codespellrc ├── benchmarks ├── capi │ ├── memleak_mp_prep.sh │ └── memleak_mp_prep.c ├── README.md ├── operation │ ├── buffer │ │ └── CMakeLists.txt │ └── predicate │ │ └── CMakeLists.txt ├── index │ ├── CMakeLists.txt │ └── chain │ │ └── CMakeLists.txt ├── CMakeLists.txt ├── algorithm │ └── locate │ │ └── CMakeLists.txt └── geom │ └── EnvelopePerfTest.cpp ├── .gitpod.yml ├── src ├── deps │ ├── ryu │ │ ├── LICENSE │ │ ├── LICENSE-Boost │ │ └── ryu.h │ └── CMakeLists.txt ├── CMakeLists.txt ├── noding │ ├── SegmentStringUtil.cpp │ ├── BasicSegmentString.cpp │ ├── SegmentNode.cpp │ └── snap │ │ └── SnappingPointIndex.cpp ├── algorithm │ ├── locate │ │ └── PointOnGeometryLocator.cpp │ └── NotRepresentableException.cpp ├── io │ ├── ByteOrderDataInStream.cpp │ ├── Writer.cpp │ ├── CLocalizer.cpp │ └── WKBStreamReader.cpp ├── operation │ ├── overlayng │ │ ├── EdgeKey.cpp │ │ ├── EdgeSourceInfo.cpp │ │ └── IndexedPointOnLineLocator.cpp │ ├── union │ │ └── UnionStrategy.cpp │ ├── cluster │ │ └── UnionFind.cpp │ ├── buffer │ │ ├── MinimalEdgeRing.cpp │ │ └── BufferNodeFactory.cpp │ ├── polygonize │ │ └── PolygonizeEdge.cpp │ ├── grid │ │ └── FloodFill.cpp │ ├── valid │ │ └── PolygonRingTouch.cpp │ └── linemerge │ │ └── LineMergeEdge.cpp ├── geom │ ├── prep │ │ ├── PreparedGeometry.cpp │ │ ├── PreparedPoint.cpp │ │ ├── PreparedPolygonCovers.cpp │ │ └── PreparedLineStringNearestPoints.cpp │ ├── GeometryComponentFilter.cpp │ ├── util │ │ └── NoOpGeometryOperation.cpp │ ├── Location.cpp │ └── Curve.cpp ├── info.plist.in ├── index │ ├── strtree │ │ ├── Interval.cpp │ │ └── GeometryItemDistance.cpp │ ├── intervalrtree │ │ ├── IntervalRTreeLeafNode.cpp │ │ └── IntervalRTreeBranchNode.cpp │ ├── kdtree │ │ └── KdNode.cpp │ ├── sweepline │ │ └── SweepLineInterval.cpp │ └── chain │ │ ├── MonotoneChainSelectAction.cpp │ │ └── MonotoneChainOverlapAction.cpp ├── dissolve │ ├── DissolveEdgeGraph.cpp │ └── DissolveHalfEdge.cpp ├── triangulate │ └── quadedge │ │ └── LocateFailureException.cpp ├── geomgraph │ ├── NodeFactory.cpp │ └── Label.cpp ├── planargraph │ └── Subgraph.cpp └── simplify │ └── RingHullIndex.cpp ├── tools ├── codespell.ignore ├── astyle.sh ├── geos.pc.in ├── findclassfiles ├── astyle │ ├── CMakeLists.txt │ └── LICENSE.md └── build-cmake.bat ├── .gitattributes ├── .codecov.yml ├── .astylerc ├── cmake └── geos-config.cmake ├── Version.txt ├── include ├── geos │ ├── vend │ │ └── include_nlohmann_json.hpp │ ├── util │ │ ├── Machine.h │ │ ├── string.h │ │ ├── IllegalStateException.h │ │ ├── math.h │ │ ├── AssertionFailedException.h │ │ └── IllegalArgumentException.h │ ├── index │ │ ├── ItemVisitor.h │ │ ├── strtree │ │ │ ├── EnvelopeUtil.h │ │ │ └── GeometryItemDistance.h │ │ ├── sweepline │ │ │ ├── SweepLineInterval.h │ │ │ └── SweepLineOverlapAction.h │ │ ├── kdtree │ │ │ └── KdNodeVisitor.h │ │ └── intervalrtree │ │ │ └── IntervalRTreeLeafNode.h │ ├── algorithm │ │ ├── PointInRing.h │ │ └── NotRepresentableException.h │ ├── version.h.in │ ├── io │ │ ├── WKBStreamReader.h │ │ ├── WKTStreamReader.h │ │ ├── WKTFileReader.h │ │ ├── CLocalizer.h │ │ ├── Writer.h │ │ └── ParseException.h │ ├── geomgraph │ │ ├── index │ │ │ └── SweepLineEventObj.h │ │ └── NodeFactory.h │ ├── triangulate │ │ └── quadedge │ │ │ └── LocateFailureException.h │ ├── operation │ │ ├── grid │ │ │ ├── Crossing.h │ │ │ └── Side.h │ │ └── cluster │ │ │ └── EnvelopeIntersectsClusterFinder.h │ ├── simplify │ │ └── RingHullIndex.h │ └── geom │ │ └── util │ │ └── NoOpGeometryOperation.h ├── geos.h └── CMakeLists.txt ├── .mailmap ├── util ├── CMakeLists.txt └── geosop │ └── CMakeLists.txt ├── .drone-1.0.yml ├── .editorconfig ├── configure ├── .github └── workflows │ └── container.yml ├── examples └── CMakeLists.txt └── capi └── CMakeLists.txt /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | f43aa53d27b3889823365317fcf4ff45e60dc90f 2 | -------------------------------------------------------------------------------- /tests/xmltester/tinyxml2/README: -------------------------------------------------------------------------------- 1 | Code imported from https://github.com/leethomason/tinyxml2 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Code of Conduct 2 | =============== 3 | 4 | See [the GEOS Code of Conduct](https://libgeos.org/project/coc/). 5 | -------------------------------------------------------------------------------- /doxygen/README: -------------------------------------------------------------------------------- 1 | To build Doxygen documentation use: 2 | 3 | make doxygen-html 4 | 5 | Take a look at example.cpp to get started. 6 | -------------------------------------------------------------------------------- /tests/unit/tut/tut_config.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TUT_CONFIG_H_GUARD 2 | #define TUT_CONFIG_H_GUARD 3 | 4 | #define TUT_USE_RTTI 1 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | skip = ./tools/astyle,./src/deps,./web/themes,./util/geosop/cxxopts.hpp 3 | ignore-words = ./tools/codespell.ignore 4 | -------------------------------------------------------------------------------- /tests/unit/tut/README: -------------------------------------------------------------------------------- 1 | C++ Template Unit Test Framework 2 | 3 | This is a local copy of the upstream: 4 | http://mrzechonek.github.io/tut-framework 5 | -------------------------------------------------------------------------------- /benchmarks/capi/memleak_mp_prep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # tweak the number till you get a few lines of output and a segfault.. 4 | ulimit -v $((1024*18)) 5 | 6 | ./memleak_mp_prep 7 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | # see https://www.gitpod.io/docs/config-gitpod-file 2 | # for more info 3 | 4 | tasks: 5 | - init: mkdir _build && cd _build && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 6 | -------------------------------------------------------------------------------- /src/deps/ryu/LICENSE: -------------------------------------------------------------------------------- 1 | All the C code is copyrighted by Ulf Adams and contributors, and may be used freely in accordance with the Apache 2.0 license. Alternatively, it may be used freely in accordance with the Boost 1.0 license. -------------------------------------------------------------------------------- /tests/xmltester/testrunner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | runner=$1 4 | shift 5 | 6 | echo "#!/bin/sh" > ${runner} 7 | echo "./XMLTester -v $@" >> ${runner} 8 | chmod +x ${runner} 9 | 10 | echo "Runner: ${runner} created" 11 | -------------------------------------------------------------------------------- /tests/unit/tut/tut_reporter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TUT_REPORTER 2 | #define TUT_REPORTER 3 | 4 | #include 5 | 6 | namespace tut 7 | { 8 | typedef console_reporter reporter; 9 | } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /tools/codespell.ignore: -------------------------------------------------------------------------------- 1 | parms 2 | Geometrys 3 | deques 4 | extracter 5 | implementors 6 | translater 7 | thirdparty 8 | crate 9 | eiter 10 | examplar 11 | nempty 12 | ba 13 | te 14 | seh 15 | bLoc 16 | aLo 17 | Wel 18 | EMPTYY 19 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Exclude specific files at the root of the repository 3 | .gitignore export-ignore 4 | HOWTO_RELEASE export-ignore 5 | 6 | web/ export-ignore 7 | php/ export-ignore 8 | tools/ci/ export-ignore 9 | debian/ export-ignore 10 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | status: 4 | project: 5 | default: 6 | target: auto 7 | threshold: 1% 8 | 9 | ignore: 10 | - "tests/unit/tut" 11 | - "tests/xmltester/tinyxml2" 12 | 13 | comment: false 14 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/MISSING: -------------------------------------------------------------------------------- 1 | Tests found in JTS/testxml/general and not ported as of rev 3991 (Jun 30 2014) 2 | ---------------------------------------------------------------------------- 3 | 4 | TestDensify.xml 5 | - requires densify::Densifier still unported 6 | 7 | -------------------------------------------------------------------------------- /.astylerc: -------------------------------------------------------------------------------- 1 | --style=stroustrup 2 | --indent=spaces=4 3 | --max-code-length=120 4 | --lineend=linux 5 | --unpad-paren 6 | --pad-oper 7 | --align-pointer=type 8 | --align-reference=type 9 | --break-closing-braces 10 | --add-braces 11 | --break-return-type 12 | --break-after-logical 13 | -------------------------------------------------------------------------------- /benchmarks/README.md: -------------------------------------------------------------------------------- 1 | ## Benchmarks 2 | 3 | A variety of programs to execute various kinds of tests, 4 | including benchmarks, stability and robustness tests. 5 | 6 | ### Building 7 | 8 | Building the benchmark tests must be enabled using 9 | 10 | cmake -DBUILD_BENCHMARKS=ON .. 11 | -------------------------------------------------------------------------------- /tests/xmltester/tests/misc/linemerge.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Case 4 | 5 | MULTILINESTRING((0 0, 10 0), (10 0, 20 0)) 6 | 7 | 8 | 9 | GEOMETRYCOLLECTION ( LINESTRING(0 0, 10 0, 20 0) ) 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tools/astyle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DIR=`dirname $0` 4 | ${DIR}/astyle/astyle \ 5 | --style=stroustrup \ 6 | --unpad-paren \ 7 | --pad-header \ 8 | --pad-comma \ 9 | --indent=spaces=4 \ 10 | --align-pointer=type \ 11 | --max-code-length=120 \ 12 | --lineend=linux \ 13 | $@ 14 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-582.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GC - overlapping polygons 5 | 6 | MULTIPOLYGON(EMPTY,((0 0,1 0,1 1,0 1, 0 0))) 7 | 8 | POINT (0.5 0.5) 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tools/geos.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | includedir=@includedir@ 4 | libdir=@libdir@ 5 | 6 | Name: GEOS 7 | Description: Geometry Engine, Open Source - C API 8 | Requires: 9 | Version: @VERSION@ 10 | Cflags: -I${includedir} 11 | Libs: -L${libdir} -lgeos_c 12 | Libs.private: -lgeos @EXTRA_LIBS@ 13 | -------------------------------------------------------------------------------- /tests/superbuild.CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This is used in CI as a simple test of GEOS building as a subproject 2 | # within a CMake super-build context. 3 | 4 | cmake_minimum_required(VERSION 3.13) 5 | 6 | project(superbuild_example) 7 | 8 | add_subdirectory("geos") 9 | 10 | add_executable(capi_read capi_read.c) 11 | target_link_libraries(capi_read PRIVATE GEOS::geos_c) 12 | -------------------------------------------------------------------------------- /tools/findclassfiles: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test "x${1}" = "x"; then 4 | echo "Usage: $0 []" >&2 5 | exit 1 6 | fi 7 | 8 | classname="${1}" 9 | package="." 10 | 11 | if test "x${2}" != "x"; then 12 | package="${2}" 13 | fi 14 | 15 | # TODO: skip directory-only matches 16 | find . -name '*.h' -o -name '*.inl' -o -name '*.cpp' \ 17 | | grep -wi "${classname}" \ 18 | | grep -i "${package}" 19 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/TestRobustRelate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PP - Point is not on line. Non-robust algorithms fail by erroneously reporting intersects=true. 5 | 6 | LINESTRING(-123456789 -40, 381039468754763 123456789) 7 | 8 | 9 | POINT(0 0) 10 | 11 | 12 | 13 | false 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-1085.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Empty component in multilinestring 7 | See https://trac.osgeo.org/geos/ticket/1085 8 | 9 | 10 | LINESTRING(0 0, 10 0) 11 | 12 | 13 | MULTILINESTRING((0 10,10 -10),EMPTY) 14 | 15 | true 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-1018.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Difference of two geometries 6 | 7 | 8 | POLYGON((0.1 0.1, 4.0 0.1, 4.0 1.9, 0.1 1.9, 0.1 0.1)) 9 | 10 | 11 | POLYGON((0 0, 0 2, 2 2, 2 0, 0 0)) 12 | 13 | 14 | 15 | POLYGON ((2.0 1.9, 4.0 1.9, 4.0 0.1, 2.0 0.1, 2.0 1.9)) 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/xmltester/tests/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 | 15 | LINESTRING (545 317, 546 317) 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/TestOverlayPLPrec.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 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-990.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Difference of two 3D geometries 6 | 7 | 8 | LINESTRING(0 0,0 10,10 10,10 0,0 0) 9 | 10 | 11 | GEOMETRYCOLLECTION Z (GEOMETRYCOLLECTION Z (MULTILINESTRING Z ((0 0 10,10 0 20),(10 0 20,10 10 30)),LINESTRING Z (0 10 20,10 10 30)),LINESTRING Z (0 0 10,0 10 20)) 12 | 13 | 14 | 15 | LINESTRING EMPTY 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /cmake/geos-config.cmake: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | include("${CMAKE_CURRENT_LIST_DIR}/geos-targets.cmake") 12 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | add_subdirectory(unit) 12 | add_subdirectory(xmltester) 13 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-234.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | http://trac.osgeo.org/geos/ticket/234 4 | 5 | 6 | 7 | 8 | 9 | http://trac.osgeo.org/geos/ticket/234 10 | Assertion failed on intersecting collection with empty component 11 | 12 | 13 | MULTIPOLYGON (((1 1, 1 5, 5 5, 5 1, 1 1), EMPTY)) 14 | 15 | 16 | MULTIPOLYGON (((3 3, 3 4, 4 4, 4 3, 3 3))) 17 | 18 | 19 | 20 | POLYGON ((3 3, 3 4, 4 4, 4 3, 3 3)) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-527.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | .01 5 | 6 | 7 | 8 | Bogus noding 9 | http://trac.osgeo.org/geos/ticket/527 10 | 11 | 12 | LINESTRING( 13 | 1725063 4819121, 14 | 1725064.14183882 4819094.70208557, 15 | 1725064.13656044 4819094.70235069, 16 | 1725064.14210362 4819094.70227252, 17 | 1725064.13656043 4819094.70235069, 18 | 1725063 4819121 19 | ) 20 | 21 | 22 | 52.6557 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-234.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | http://trac.osgeo.org/geos/ticket/234 4 | 5 | 6 | 7 | 8 | 9 | http://trac.osgeo.org/geos/ticket/234 10 | Assertion failed on intersecting collection with empty component 11 | 12 | 13 | MULTIPOLYGON (((1 1, 1 5, 5 5, 5 1, 1 1), EMPTY)) 14 | 15 | 16 | MULTIPOLYGON (((3 3, 3 4, 4 4, 4 3, 3 3))) 17 | 18 | 19 | 20 | POLYGON ((3 3, 3 4, 4 4, 4 3, 3 3)) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Version.txt: -------------------------------------------------------------------------------- 1 | 2 | # GEOS Versions 3 | GEOS_VERSION_MAJOR=3 4 | GEOS_VERSION_MINOR=15 5 | GEOS_VERSION_PATCH=0 6 | 7 | # OPTIONS: "", "dev", "rc1" etc. 8 | GEOS_PATCH_WORD=dev 9 | 10 | # GEOS CAPI Versions 11 | # 12 | # - For a release with no interface changes just bump REVISION. 13 | # ( Even if *nothing* changed in CAPI ) 14 | # - Adding interfaces, bump CURRENT/AGE, set REVISION to 0. 15 | # - Deleting interfaces / compatibility issues - bump CURRENT, others to zero 16 | # ( THIS MUST BE CAREFULLY AVOIDED ) 17 | # 18 | CAPI_INTERFACE_CURRENT=22 19 | CAPI_INTERFACE_REVISION=0 20 | CAPI_INTERFACE_AGE=21 21 | 22 | # JTS Port 23 | JTS_PORT=1.18.0 24 | -------------------------------------------------------------------------------- /benchmarks/operation/buffer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | add_executable(perf_iterated_buffer IteratedBufferStressTest.cpp) 12 | target_link_libraries(perf_iterated_buffer PRIVATE geos) 13 | -------------------------------------------------------------------------------- /benchmarks/operation/predicate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | add_executable(perf_rectangle_intersects RectangleIntersectsPerfTest.cpp) 12 | target_link_libraries(perf_rectangle_intersects PRIVATE geos) 13 | -------------------------------------------------------------------------------- /tests/xmltester/tests/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 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | file(GLOB_RECURSE _sources ${CMAKE_CURRENT_LIST_DIR}/*.cpp CONFIGURE_DEPEND) 12 | target_sources(geos PRIVATE ${_sources}) 13 | unset(_sources) 14 | 15 | add_subdirectory(deps) 16 | 17 | -------------------------------------------------------------------------------- /src/noding/SegmentStringUtil.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | 16 | #include 17 | 18 | namespace geos { 19 | namespace noding { // geos::noding 20 | 21 | } // geos::noding 22 | } // geos 23 | -------------------------------------------------------------------------------- /tests/unit/index/strtree/SIRtreeTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | using namespace geos::index::strtree; 6 | 7 | namespace tut { 8 | // dummy data, not used 9 | struct test_sirtree_data {}; 10 | 11 | using group = test_group; 12 | using object = group::object; 13 | 14 | group test_sirtree_group("geos::index::strtree::SIRtree"); 15 | 16 | // 17 | // Test Cases 18 | // 19 | 20 | // Make sure no memory is leaked. 21 | // See https://trac.osgeo.org/geos/ticket/919 22 | template<> 23 | template<> 24 | void object::test<1> 25 | () 26 | { 27 | SIRtree t; 28 | double value = 3; 29 | t.insert(1, 5, &value); 30 | } 31 | 32 | 33 | } // namespace tut 34 | 35 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-522.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overlay fails with classic overlay, floating overlay 8 | http://trac.osgeo.org/geos/ticket/522 9 | 10 | 11 | 00000000030000000100000005C13118F40000021D4129F7E61E2399E3C13118F40000021C4129FB1EC6E992B9C13118F40000021C4129FB1C7A29E156C131188FC33F491A4129F9FEFCFEC6D8C13118F40000021D4129F7E61E2399E3 12 | 13 | 14 | 00000000030000000100000004C13118F40000021D4129FA6AECF26D05C13118F40000021C4129FAC7A2C8D1D1C13118EC265BFAD64129FABBAEFEF5C8C13118F40000021D4129FA6AECF26D05 15 | 16 | true 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/TestConvexHull-big.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Big convex hull 5 | 6 | MULTIPOINT((-1000000000000000000000000 -1000000000000000000000000), (1000000000000000000000000 -1000000000000000000000000), (1000000000000000000000000 1000000000000000000000000), (-1000000000000000000000000 1000000000000000000000000), (0 0)) 7 | 8 | 9 | 10 | POLYGON( 11 | (-1000000000000000000000000 -1000000000000000000000000, -1000000000000000000000000 1000000000000000000000000, 1000000000000000000000000 1000000000000000000000000, 1000000000000000000000000 -1000000000000000000000000, -1000000000000000000000000 -1000000000000000000000000)) 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSSetSRIDTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geossetsrid_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geossetsrid("capi::GEOSSetSRID"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1> 22 | () 23 | { 24 | int expected_srid = 1234; 25 | GEOSGeometry* input = GEOSGeomFromWKT("LINESTRING (1 2, 4 5, 9 -2)"); 26 | GEOSSetSRID(input, expected_srid); 27 | ensure_equals(GEOSGetSRID(input), expected_srid); 28 | 29 | GEOSGeom_destroy(input); 30 | } 31 | 32 | } // namespace tut 33 | 34 | -------------------------------------------------------------------------------- /include/geos/vend/include_nlohmann_json.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2021 Jared Erickson 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | #ifndef GEOS_VEND_JSON 15 | #define GEOS_VEND_JSON 16 | 17 | #ifdef nlohmann 18 | #error "GEOS modifies the nlohmann define " 19 | #endif 20 | #define nlohmann geos_nlohmann 21 | #include "geos/vend/json.hpp" 22 | #undef nlohmann 23 | 24 | #endif -------------------------------------------------------------------------------- /tools/astyle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # 3 | # Copyright (C) 2019 Paul Ramsey 4 | # 5 | # This is free software; you can redistribute and/or modify it under 6 | # the terms of the GNU Lesser General Public Licence as published 7 | # by the Free Software Foundation. 8 | # See the COPYING file for more information. 9 | # 10 | ################################################################################# 11 | 12 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 13 | file(GLOB_RECURSE astyle_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 14 | add_executable(astyle ${astyle_SOURCES}) 15 | if(MSVC) 16 | target_compile_options(astyle PRIVATE /source-charset:utf-8) 17 | endif() 18 | # message(STATUS "Enable AStyle") 19 | 20 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/TestUnaryUnionFloating.xml: -------------------------------------------------------------------------------- 1 | 2 | Tests for Geometry.union() method (unary union) with floating precision 3 | 4 | 5 | mP - showing that non-polygonal components are discarded correctly 6 | 7 | GEOMETRYCOLLECTION ( 8 | POLYGON ((-3 -2, 700 900, -6 900, -3 -2)), 9 | POLYGON((700 900, -1.6859349853697 899.55, 0.3 -0.4, 700 900)), 10 | POLYGON ((700 860, 700 899.5, -1.68593498537 899.55, 700 860)) 11 | ) 12 | 13 | 14 | 15 | POLYGON ((0.2942036115049298 2.226702215615205, -3 -2, -6 900, 700 900, 699.6114719806972 899.5000276853219, 700 899.5, 700 860, 670.2204017222961 861.6785046602191, 0.3 -0.4, 0.2942036115049298 2.226702215615205)) 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Brendan Ward 2 | Casper van der Wel 3 | Daniel Baston 4 | Daniel Baston 5 | Daniel Baston 6 | Howard Butler 7 | Martin Davis 8 | Martin Davis 9 | Mateusz Łoskot 10 | Paul Ramsey 11 | Paul Ramsey 12 | Paul van der Linden 13 | Raul Marin 14 | Regina Obe 15 | Sandro Santilli 16 | Vicky Vergara 17 | -------------------------------------------------------------------------------- /src/algorithm/locate/PointOnGeometryLocator.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | 16 | #include 17 | 18 | namespace geos { 19 | namespace algorithm { // geos::algorithm 20 | namespace locate { // geos::algorithm::locate 21 | 22 | } // geos::algorithm::locate 23 | } // geos::algorithm 24 | } // geos 25 | -------------------------------------------------------------------------------- /util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2020 Martin Davis 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | 12 | option(BUILD_GEOSOP "Build geosop command-line interface" ON) 13 | message(STATUS "GEOS: Build geosop ${BUILD_GEOSOP}") 14 | 15 | if(BUILD_GEOSOP) 16 | 17 | add_executable(orientview 18 | OrientationIndexViewer.cpp 19 | ) 20 | 21 | target_link_libraries(orientview PRIVATE geos geos_c) 22 | 23 | add_subdirectory(geosop) 24 | 25 | endif() 26 | -------------------------------------------------------------------------------- /include/geos/util/Machine.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2009 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | /** 18 | * Check endianness of current machine. 19 | * @return 0 for big_endian | xdr; 1 == little_endian | ndr 20 | */ 21 | inline int 22 | getMachineByteOrder() 23 | { 24 | static int endian_check = 1; // don't modify !! 25 | return *((char*)&endian_check); 26 | } 27 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSUnionCascadedTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosunioncascaded_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosunioncascaded("capi::GEOSUnionCascaded"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = GEOSGeomFromWKT("POINT (2 8)"); 24 | ensure(nullptr != geom1_); 25 | geom2_ = GEOSGeomFromWKT("POINT (3 9)"); 26 | ensure(nullptr != geom2_); 27 | 28 | geom3_ = GEOSUnion(geom1_, geom2_); 29 | ensure(nullptr != geom3_); 30 | 31 | ensure_equals("MULTIPOINT ((2 8), (3 9))", toWKT(geom3_)); 32 | } 33 | 34 | } // namespace tut 35 | 36 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-gisse-345341-lines.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | https://gis.stackexchange.com/questions/345341/get-location-of-postgis-geos-topology-exception 4 | Union of line fails using simple noding 5 | 6 | 7 | 8 | 9 | GISSE 345341 - Union of line fails using simple noding. 10 | 11 | 0102000020110F000003000000DC874D65FCC25EC176032C6B350C5341B336429FFEC25EC1F962BBD9480C5341FC849518FFC25EC15BE20F5F500C5341 12 | 13 | 14 | 0102000020110F000006000000FA9BBFD3FCC25EC1B978232F390C5341B336429FFEC25EC1F962BBD9480C5341A77E6BE5FEC25EC1357C21334D0C5341C3EBA27BFEC25EC11BE5A4C34A0C5341B61D8CACFCC25EC1BCF273143C0C5341FA9BBFD3FCC25EC1B978232F390C5341 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSSymDifferencePrecTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geossymdifferenceprec_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geossymdifferenceprec("capi::GEOSSymDifferencePrec"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("LINESTRING(50 100, 50 200)"); 24 | ensure(geom1_); 25 | geom2_ = fromWKT("LINESTRING(50 50, 50 150)"); 26 | ensure(geom2_); 27 | geom3_ = GEOSSymDifferencePrec(geom1_, geom2_, 15); 28 | 29 | ensure_equals("MULTILINESTRING ((45 150, 45 195), (45 45, 45 105))", toWKT(geom3_)); 30 | } 31 | 32 | } // namespace tut 33 | 34 | -------------------------------------------------------------------------------- /src/io/ByteOrderDataInStream.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: io/ByteOrderDataInStream.java rev. 1.1 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | 21 | namespace geos { 22 | namespace io { // geos::io 23 | 24 | } // namespace geos::io 25 | } // namespace geos 26 | 27 | -------------------------------------------------------------------------------- /src/operation/overlayng/EdgeKey.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | 18 | namespace geos { // geos 19 | namespace operation { // geos.operation 20 | namespace overlayng { // geos.operation.overlayng 21 | 22 | } // namespace geos.operation.overlayng 23 | } // namespace geos.operation 24 | } // namespace geos 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeomToWKB_bufTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgeomtowkb_buf_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosgeomtowkb_buf("capi::GEOSGeomToWKB_buf"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | 24 | geom1_ = fromWKT("POINT (1 2)"); 25 | ensure(nullptr != geom1_); 26 | 27 | std::size_t size{}; 28 | unsigned char* wkb = GEOSGeomToWKB_buf(geom1_, &size); 29 | geom2_ = GEOSGeomFromWKB_buf(&wkb[0], size); 30 | ensure(nullptr != geom2_); 31 | 32 | ensure_equals(toWKT(geom1_), toWKT(geom2_)); 33 | 34 | free(wkb); 35 | } 36 | 37 | } // namespace tut 38 | 39 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeom_createLineStringTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "capi_test_utils.h" 3 | 4 | namespace tut { 5 | // 6 | // Test Group 7 | // 8 | 9 | struct test_geosgeom_createlinestring_data : public capitest::utility {}; 10 | 11 | typedef test_group group; 12 | typedef group::object object; 13 | 14 | group test_geosgeom_createlinestring("capi::GEOSGeom_createLineString"); 15 | 16 | template<> 17 | template<> 18 | void object::test<1> 19 | () 20 | { 21 | GEOSCoordSequence* seq = GEOSCoordSeq_create(3, 2); 22 | GEOSCoordSeq_setXY(seq, 0, 1, 2); 23 | GEOSCoordSeq_setXY(seq, 1, 4, 5); 24 | GEOSCoordSeq_setXY(seq, 2, 9, -2); 25 | 26 | result_ = GEOSGeom_createLineString(seq); 27 | expected_ = fromWKT("LINESTRING (1 2, 4 5, 9 -2)"); 28 | 29 | ensure_geometry_equals(result_, expected_, 0); 30 | } 31 | 32 | } // namespace tut 33 | 34 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-459.xml: -------------------------------------------------------------------------------- 1 | 2 | http://trac.osgeo.org/geos/ticket/459 3 | 4 | 5 | 6 | 7 | 0102000000080000003C0AD7E32D4E3A4152B81E250A4452412085EB91284A3A417A14AE2719445241285C8F42354A3A41A4703D6A1E445241CCCCCC0C474A3A415C8FC2851E445241C4F5289C4B4A3A415C8FC2C52B445241BE08DEAE534E3A41B1B518AB1F44524100000000604E3A419A9999C9064452413C0AD7E32D4E3A4152B81E250A445241 8 | 9 | 10 | 010200000009000000B89C2EFE364A3A41DFC087291F445241545C8F42354A3A41A4703D6A1E4452418CEC6D6F354A3A41FE7E44D31D44524136C80FA4394A3A412D7F89121D445241409B06043D4A3A415860C1CC1C445241360D6849404A3A4136B46EC91C445241FC25CB4B474A3A41B72FD41F1D445241CDCCCC0C474A3A415C8FC2851E445241181E3474434A3A4116CE6F471F445241 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.drone-1.0.yml: -------------------------------------------------------------------------------- 1 | # Syntax documentation: 2 | # https://docs.drone.io/pipeline/overview/ 3 | 4 | # See https://git.osgeo.org/gitea/geos/geos-docker 5 | test-image: &test-image docker.osgeo.org/geos/build-test:alpine 6 | 7 | kind: pipeline 8 | name: default 9 | 10 | clone: 11 | image: plugins/git 12 | depth: 50 13 | recursive: false 14 | 15 | steps: 16 | - name: build 17 | image: *test-image 18 | pull: always 19 | commands: 20 | - mkdir build 21 | - cd build 22 | - cmake --version 23 | - CXXFLAGS="-O0" cmake .. 24 | - make V=0 25 | - name: check 26 | image: *test-image 27 | commands: 28 | - cd build 29 | - ctest --output-on-failure . 30 | # - name: docs 31 | # image: *test-image 32 | # commands: 33 | # - make doxygen-checked 34 | # - name: valgrindcheck 35 | # image: *test-image 36 | # commands: 37 | # - CXXFLAGS="-O0" make valgrindcheck V=0 38 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSDifferencePrecTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosdifferenceprec_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosdifferenceprec("capi::GEOSDifferencePrec"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("LINESTRING (2 8, 10 8)"); 24 | geom2_ = fromWKT("LINESTRING (3.9 8.1, 6.1 7.9)"); 25 | GEOSSetSRID(geom1_, 4326); 26 | 27 | result_ = GEOSDifferencePrec(geom1_, geom2_, 2); 28 | ensure(result_); 29 | 30 | ensure_geometry_equals(result_, "MULTILINESTRING ((6 8, 10 8), (2 8, 4 8))"); 31 | ensure_equals(GEOSGetSRID(geom1_), GEOSGetSRID(result_)); 32 | } 33 | 34 | } // namespace tut 35 | 36 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-527.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Bogus noding 8 | http://trac.osgeo.org/geos/ticket/527 9 | 10 | 11 | LINESTRING( 12 | 1725063 4819121, 13 | 1725064.14183882 4819094.70208557, 14 | 1725064.13656044 4819094.70235069, 15 | 1725064.14210362 4819094.70227252, 16 | 1725064.13656043 4819094.70235069, 17 | 1725063 4819121 18 | ) 19 | 20 | 21 | 22 | MULTILINESTRING ((1725064.13656044 4819094.70235069, 1725063 4819121), (1725063 4819121, 1725064.141830536 4819094.702276371), (1725064.13656044 4819094.70235069, 1725064.141830536 4819094.702276371), (1725064.141830536 4819094.702276371, 1725064.14183882 4819094.70208557, 1725064.13656044 4819094.70235069), (1725064.141830536 4819094.702276371, 1725064.14210362 4819094.70227252)) 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /include/geos/util/string.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2022 ISciences LLC 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace geos { 20 | namespace util { 21 | 22 | bool endsWith(const std::string & s, const std::string & suffix); 23 | bool endsWith(const std::string & s, char suffix); 24 | 25 | bool startsWith(const std::string & s, const std::string & prefix); 26 | bool startsWith(const std::string & s, char prefix); 27 | 28 | void toUpper(std::string& s); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # every file needs these 7 | [*] 8 | charset = utf-8 9 | end_of_line = lf 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | # C/C++ files want 4-space indentation 14 | [*.{h,cpp,inl,h.in,c}] 15 | indent_style = space 16 | indent_size = 4 17 | 18 | # Makefiles want tab indentation 19 | [Makefile.am] 20 | indent_style = tab 21 | indent_size = 2 22 | 23 | # YML files want space indentation 24 | [*.yml] 25 | indent_style = space 26 | indent_size = 2 27 | 28 | # appveyor.yml is meant for windows (mloskot said) 29 | [appveyor.yml] 30 | end_of_line = crlf 31 | 32 | # Visual-C files want carriage returns too 33 | [*.{vc,opt}] 34 | end_of_line = crlf 35 | 36 | # CMake configuration files 37 | [CMakeLists.txt] 38 | indent_style = space 39 | indent_size = 2 40 | 41 | # CMake modules 42 | [*.cmake] 43 | indent_style = space 44 | indent_size = 2 45 | 46 | -------------------------------------------------------------------------------- /benchmarks/index/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | 12 | add_subdirectory(chain) 13 | 14 | IF(benchmark_FOUND) 15 | add_executable(perf_spatial_index SpatialIndexPerfTest.cpp) 16 | target_include_directories(perf_spatial_index PUBLIC 17 | $ 18 | $) 19 | target_link_libraries(perf_spatial_index PRIVATE 20 | benchmark::benchmark geos) 21 | endif() 22 | -------------------------------------------------------------------------------- /src/geom/prep/PreparedGeometry.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: geom/prep/PreparedGeometry.java rev. 1.11 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | 20 | #include 21 | 22 | namespace geos { 23 | namespace geom { // geos.geom 24 | namespace prep { // geos.geom.prep 25 | 26 | } // namespace geos.geom.prep 27 | } // namespace geos.geom 28 | } // namespace geos 29 | -------------------------------------------------------------------------------- /src/info.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${MACOSX_FRAMEWORK_NAME} 9 | CFBundleGetInfoString 10 | GEOS ${VERSION} 11 | CFBundleIdentifier 12 | ${MACOSX_FRAMEWORK_IDENTIFIER} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | GEOS 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | ${MACOSX_FRAMEWORK_SHORT_VERSION_STRING} 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | ${MACOSX_FRAMEWORK_BUNDLE_VERSION} 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeomTypeIdTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgeomtypeid_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosgeomtypeid("capi::GEOSGeomTypeId"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("POINT (1 2)"); 24 | ensure(nullptr != geom1_); 25 | geom2_ = fromWKT("LINESTRING (1 2, 3 4)"); 26 | ensure(nullptr != geom2_); 27 | geom3_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 28 | ensure(nullptr != geom3_); 29 | 30 | ensure_equals(GEOS_POINT, GEOSGeomTypeId(geom1_)); 31 | ensure_equals(GEOS_LINESTRING, GEOSGeomTypeId(geom2_)); 32 | ensure_equals(GEOS_CIRCULARSTRING, GEOSGeomTypeId(geom3_)); 33 | } 34 | 35 | } // namespace tut 36 | 37 | -------------------------------------------------------------------------------- /src/index/strtree/Interval.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #include 17 | //#include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | 25 | namespace geos { 26 | namespace index { // geos.index 27 | namespace strtree { // geos.index.strtree 28 | 29 | } // namespace geos.index.strtree 30 | } // namespace geos.index 31 | } // namespace geos 32 | 33 | -------------------------------------------------------------------------------- /src/operation/union/UnionStrategy.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2021 Daniel Baston 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | #include 17 | 18 | namespace geos { 19 | namespace operation { 20 | namespace geounion { 21 | 22 | std::unique_ptr UnionStrategy::Union(std::unique_ptr && g0, std::unique_ptr && g1) { 23 | // Default implementation just copies the inputs. 24 | return Union(g0.get(), g1.get()); 25 | } 26 | 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /benchmarks/capi/memleak_mp_prep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "geos_c.h" 4 | 5 | int main(void) { 6 | GEOSWKTReader *reader; 7 | GEOSGeometry *mp; 8 | GEOSGeometry *p; 9 | const GEOSPreparedGeometry *prep_mp; 10 | unsigned long int i; 11 | unsigned long int count = 1000000; 12 | 13 | initGEOS(NULL, NULL); 14 | 15 | reader = GEOSWKTReader_create(); 16 | 17 | mp = GEOSWKTReader_read(reader, 18 | "MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))"); 19 | 20 | p = GEOSWKTReader_read(reader, 21 | "POLYGON((2 2, 6 2, 6 6, 2 6, 2 2))"); 22 | 23 | assert(GEOSisValid(mp)); 24 | assert(GEOSisValid(p)); 25 | 26 | prep_mp = GEOSPrepare(mp); 27 | 28 | for (i=0; i 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | file(GLOB_RECURSE _sources ${CMAKE_CURRENT_LIST_DIR}/*.c CONFIGURE_DEPEND) 12 | add_library(ryu OBJECT ${_sources}) 13 | target_include_directories(ryu PUBLIC ${CMAKE_CURRENT_LIST_DIR}) 14 | set_target_properties(ryu PROPERTIES 15 | POSITION_INDEPENDENT_CODE ON 16 | C_STANDARD 99 17 | ) 18 | unset(_sources) 19 | 20 | target_include_directories(geos 21 | PUBLIC 22 | $ 23 | $) 24 | 25 | -------------------------------------------------------------------------------- /benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | 12 | find_package(benchmark QUIET) 13 | 14 | add_executable(perf_class_sizes ClassSizes.cpp) 15 | target_include_directories(perf_class_sizes PRIVATE 16 | $ 17 | $) 18 | target_link_libraries(perf_class_sizes PRIVATE geos_cxx_flags) 19 | 20 | add_subdirectory(capi) 21 | 22 | add_subdirectory(algorithm) 23 | add_subdirectory(geom) 24 | add_subdirectory(index) 25 | add_subdirectory(operation) 26 | -------------------------------------------------------------------------------- /benchmarks/algorithm/locate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | # 3 | # CMake configuration for GEOS benchmarks/operation/predicate tests 4 | # 5 | # Copyright (C) 2017 Mateusz Loskot 6 | # 7 | # This is free software; you can redistribute and/or modify it under 8 | # the terms of the GNU Lesser General Public Licence as published 9 | # by the Free Software Foundation. 10 | # See the COPYING file for more information. 11 | # 12 | ################################################################################# 13 | 14 | if (benchmark_FOUND) 15 | add_executable(perf_point_locator PointLocatorPerfTest.cpp) 16 | target_include_directories(perf_point_locator PUBLIC 17 | $ 18 | $ 19 | $) 20 | target_link_libraries(perf_point_locator PRIVATE 21 | benchmark::benchmark geos) 22 | endif() 23 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeomTypeTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgeomtype_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosgeomtype("capi::GEOSGeomType"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("POINT (1 2)"); 24 | char* type1 = GEOSGeomType(geom1_); 25 | ensure_equals(std::string(type1), "Point"); 26 | GEOSFree(type1); 27 | 28 | geom2_ = fromWKT("LINESTRING (1 2, 3 4)"); 29 | char* type2 = GEOSGeomType(geom2_); 30 | ensure_equals(std::string(type2), "LineString"); 31 | GEOSFree(type2); 32 | 33 | geom3_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 2)"); 34 | char* type3 = GEOSGeomType(geom3_); 35 | ensure_equals(std::string(type3), "CircularString"); 36 | GEOSFree(type3); 37 | } 38 | 39 | } // namespace tut 40 | 41 | -------------------------------------------------------------------------------- /tests/xmltester/tests/failure/robust-TestRobustRelateFloat.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | A/P - Point is on boundary of polygon. 7 | Orientation algorithms (including CGAlgorithmsDD) fail by incorrectly reporting the point to not be on the boundary. 8 | See https://trac.osgeo.org/geos/ticket/841 9 | 10 | 11 | POLYGON ((0 0, 1 0, 0 1, 0 0)) 12 | 13 | 14 | POINT (0.95 0.05) 15 | 16 | 17 | false 18 | 19 | 20 | 21 | 22 | 23 | L/L - Line A contains Line B. 24 | Fails due to imprecision of computed self-node in A. 25 | See https://trac.osgeo.org/geos/ticket/572 26 | 27 | 28 | LINESTRING (1 0, 0 2, 0 0, 2 2) 29 | 30 | 31 | LINESTRING (0 0, 2 2) 32 | 33 | 34 | true 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /include/geos/index/ItemVisitor.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | namespace geos { 21 | namespace index { 22 | 23 | /** \brief 24 | * A visitor for items in an index. 25 | * 26 | * Last port: index/ItemVisitor.java rev. 1.2 (JTS-1.7) 27 | */ 28 | class GEOS_DLL ItemVisitor { 29 | public: 30 | virtual void visitItem(void*) = 0; 31 | 32 | virtual 33 | ~ItemVisitor() {} 34 | }; 35 | 36 | } // namespace geos.index 37 | } // namespace geos 38 | 39 | -------------------------------------------------------------------------------- /src/operation/cluster/UnionFind.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020-2021 Daniel Baston 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | namespace geos { 18 | namespace operation { 19 | namespace cluster { 20 | 21 | Clusters UnionFind::getClusters() { 22 | std::vector elems(clusters.size()); 23 | std::iota(elems.begin(), elems.end(), 0); 24 | 25 | return Clusters(*this, std::move(elems), clusters.size()); 26 | } 27 | 28 | Clusters UnionFind::getClusters(std::vector elems) { 29 | return Clusters(*this, std::move(elems), clusters.size()); 30 | } 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/TestPreparedPointPredicate.xml: -------------------------------------------------------------------------------- 1 | 2 | Test cases for PreparedPoint predicates 3 | 4 | org.locationtech.jtstest.geomop.PreparedGeometryOperation 5 | 6 | 7 | P/A - point in interior of poly 8 | POINT (100 100) 9 | 10 | POLYGON ((50 130, 150 130, 100 50, 50 130)) 11 | 12 | true 13 | 14 | 15 | 16 | P/A - point on boundary of poly 17 | POINT (100 50) 18 | 19 | POLYGON ((50 130, 150 130, 100 50, 50 130)) 20 | 21 | true 22 | 23 | 24 | 25 | P/A - point outside poly 26 | POINT (200 200) 27 | 28 | POLYGON ((50 130, 150 130, 100 50, 50 130)) 29 | 30 | false 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSisSimpleTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosissimple_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosissimple("capi::GEOSisSimple"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | input_ = GEOSGeomFromWKT("LINESTRING (0 0, 1 1)"); 24 | ensure_equals(1, GEOSisSimple(input_)); 25 | } 26 | 27 | template<> 28 | template<> 29 | void object::test<2>() 30 | { 31 | input_ = GEOSGeomFromWKT("LINESTRING (0 0, 2 2, 1 2, 1 0)"); 32 | ensure_equals(0, GEOSisSimple(input_)); 33 | } 34 | 35 | template<> 36 | template<> 37 | void object::test<3>() 38 | { 39 | input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 40 | ensure(input_ != nullptr); 41 | 42 | char ret = GEOSisSimple(input_); 43 | ensure_equals("error raised on curved geometry", ret, 2); 44 | } 45 | 46 | } // namespace tut 47 | -------------------------------------------------------------------------------- /include/geos/algorithm/PointInRing.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | // Forward declarations 21 | namespace geos { 22 | namespace geom { 23 | class Coordinate; 24 | } 25 | } 26 | 27 | namespace geos { 28 | namespace algorithm { // geos::algorithm 29 | 30 | class GEOS_DLL PointInRing { 31 | public: 32 | virtual 33 | ~PointInRing() {} 34 | virtual bool isInside(const geom::Coordinate& pt) = 0; 35 | }; 36 | 37 | } // namespace geos::algorithm 38 | } // namespace geos 39 | 40 | 41 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSUnaryUnionPrecTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for C-API GEOSUnaryUnion 3 | 4 | #include 5 | // geos 6 | #include 7 | 8 | #include "capi_test_utils.h" 9 | 10 | namespace tut { 11 | // 12 | // Test Group 13 | // 14 | 15 | // Common data used in test cases. 16 | struct test_capiunaryunionprec_data : public capitest::utility { 17 | 18 | test_capiunaryunionprec_data() { 19 | } 20 | 21 | }; 22 | 23 | typedef test_group group; 24 | typedef group::object object; 25 | 26 | group test_capiunaryunionprec_group("capi::GEOSUnaryUnionPrec"); 27 | 28 | // 29 | // Test Cases 30 | // 31 | 32 | 33 | // Self-union an empty point 34 | template<> 35 | template<> 36 | void object::test<1> 37 | () 38 | { 39 | geom1_ = GEOSGeomFromWKT("MULTIPOINT ((4 5), (6 7), (4 5), (6 5), (6 7))"); 40 | ensure(nullptr != geom1_); 41 | 42 | geom2_ = GEOSUnaryUnionPrec(geom1_, 2); 43 | ensure(nullptr != geom2_); 44 | 45 | ensure_equals(toWKT(geom2_), std::string("MULTIPOINT ((4 6), (6 6), (6 8))")); 46 | } 47 | 48 | 49 | } // namespace tut 50 | -------------------------------------------------------------------------------- /include/geos/version.h.in: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2007 Refractions Research Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | #ifndef GEOS_VERSION_H_INCLUDED 15 | #define GEOS_VERSION_H_INCLUDED 16 | 17 | #ifndef GEOS_VERSION_MAJOR 18 | #define GEOS_VERSION_MAJOR @VERSION_MAJOR@ 19 | #endif 20 | 21 | #ifndef GEOS_VERSION_MINOR 22 | #define GEOS_VERSION_MINOR @VERSION_MINOR@ 23 | #endif 24 | 25 | #ifndef GEOS_VERSION_PATCH 26 | #define GEOS_VERSION_PATCH @VERSION_PATCH@ 27 | #endif 28 | 29 | #ifndef GEOS_VERSION 30 | #define GEOS_VERSION "@VERSION@" 31 | #endif 32 | 33 | #ifndef GEOS_JTS_PORT 34 | #define GEOS_JTS_PORT "@JTS_PORT@" 35 | #endif 36 | 37 | #endif // GEOS_VERSION_H_INCLUDED 38 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeom_getDimensionsTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgeom_getdimensions_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosgeom_getdimensions("capi::GEOSGeom_getDimensions"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1> 22 | () 23 | { 24 | geom1_ = fromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))"); 25 | ensure_equals(GEOSGeom_getDimensions(geom1_), 2); 26 | 27 | geom3_ = fromWKT("LINESTRING (4 2 7 1, 8 2 9 5)"); 28 | ensure_equals(GEOSGeom_getDimensions(geom3_), 1); 29 | 30 | geom2_ = fromWKT("POINT (4 2 7)"); 31 | ensure_equals(GEOSGeom_getDimensions(geom2_), 0); 32 | } 33 | 34 | template<> 35 | template<> 36 | void object::test<2>() 37 | { 38 | input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 39 | ensure_equals(GEOSGeom_getDimensions(input_), 1); 40 | } 41 | 42 | } // namespace tut 43 | 44 | -------------------------------------------------------------------------------- /include/geos/index/strtree/EnvelopeUtil.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2019 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace geos { 19 | namespace index { // geos::index 20 | namespace strtree { // geos::index::strtree 21 | 22 | class GEOS_DLL EnvelopeUtil { 23 | public: 24 | // EnvelopeUtil(const void* newBounds, void* newItem); 25 | // ~EnvelopeUtil() override = default; 26 | 27 | static double maximumDistance(const geom::Envelope* env1, const geom::Envelope* env2); 28 | 29 | }; 30 | 31 | } // namespace geos::index::strtree 32 | } // namespace geos::index 33 | } // namespace geos 34 | -------------------------------------------------------------------------------- /include/geos/index/sweepline/SweepLineInterval.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace geos { 20 | namespace index { // geos.index 21 | namespace sweepline { // geos:index:sweepline 22 | 23 | class GEOS_DLL SweepLineInterval { 24 | public: 25 | SweepLineInterval(double newMin, double newMax, void* newItem = nullptr); 26 | double getMin(); 27 | double getMax(); 28 | void* getItem(); 29 | private: 30 | double min, max; 31 | void* item; 32 | }; 33 | 34 | } // namespace geos:index:sweepline 35 | } // namespace geos:index 36 | } // namespace geos 37 | 38 | -------------------------------------------------------------------------------- /tests/xmltester/tests/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 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | which cmake > /dev/null 2>&1 || { 4 | echo "You need cmake to build this package" >&2 5 | exit 1 6 | } 7 | 8 | srcdir=$(dirname $0) 9 | 10 | usage() { 11 | echo "$0 [--prefix=] [--enable-debug] [--help]" 12 | } 13 | 14 | cmd=cmake 15 | 16 | options=$(getopt -l "help,enable-debug,prefix:" "" "$@") 17 | #echo XXXX ${options} 18 | eval set -- "$options" 19 | 20 | while true; do 21 | case $1 in 22 | --prefix) 23 | shift 24 | cmd="${cmd} -DCMAKE_INSTALL_PREFIX:PATH=$1" 25 | ;; 26 | --enable-debug) 27 | cmd="${cmd} -DCMAKE_BUILD_TYPE=RelWithDebInfo" 28 | ;; 29 | --help) 30 | usage 31 | exit 32 | ;; 33 | --) 34 | shift 35 | break 36 | ;; 37 | *) 38 | echo "Unrecognized switch $1" >&2 39 | usage >&2 40 | exit 1 41 | ;; 42 | esac 43 | shift 44 | done 45 | 46 | cmd="${cmd} ${srcdir}" 47 | 48 | echo 49 | echo "WARNING: this script is a wrapper for cmake" 50 | echo 51 | echo "INFO: Invoking ${cmd}" 52 | echo 53 | $cmd 54 | 55 | echo 56 | echo "HINT: for interactive configuration use ccmake ${srcdir}" 57 | echo 58 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSSimplifyTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for C-API GEOSSimplify 3 | 4 | #include 5 | // geos 6 | #include 7 | 8 | #include "capi_test_utils.h" 9 | 10 | namespace tut { 11 | // 12 | // Test Group 13 | // 14 | 15 | // Common data used in test cases. 16 | struct test_capigeossimplify_data : public capitest::utility {}; 17 | 18 | typedef test_group group; 19 | typedef group::object object; 20 | 21 | group test_capigeossimplify_group("capi::GEOSSimplify"); 22 | 23 | // 24 | // Test Cases 25 | // 26 | 27 | // Test GEOSSimplify 28 | template<> 29 | template<> 30 | void object::test<1> 31 | () 32 | { 33 | geom1_ = GEOSGeomFromWKT("POLYGON EMPTY"); 34 | 35 | ensure(0 != GEOSisEmpty(geom1_)); 36 | 37 | geom2_ = GEOSSimplify(geom1_, 43.2); 38 | 39 | ensure(0 != GEOSisEmpty(geom2_)); 40 | } 41 | 42 | template<> 43 | template<> 44 | void object::test<2>() 45 | { 46 | input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 47 | ensure(input_ != nullptr); 48 | 49 | result_ = GEOSSimplify(input_, 2); 50 | ensure(result_ == nullptr); 51 | } 52 | 53 | } // namespace tut 54 | 55 | -------------------------------------------------------------------------------- /tests/unit/triangulate/quadedge/VertexTest.cpp: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Test Suite for geos::triangulate::quadedge::Vertex 4 | // 5 | // tut 6 | #include 7 | // geos 8 | #include 9 | //#include 10 | #include 11 | 12 | using namespace geos::triangulate::quadedge; 13 | 14 | namespace tut { 15 | // 16 | // Test Group 17 | // 18 | 19 | // dummy data, not used 20 | struct test_vertex_data { 21 | test_vertex_data() 22 | { 23 | } 24 | }; 25 | 26 | typedef test_group group; 27 | typedef group::object object; 28 | 29 | group test_vertex_group("geos::triangulate::quadedge::Vertex"); 30 | 31 | 32 | // 33 | // Test Cases 34 | // 35 | 36 | // 1 - Test for operator< 37 | template<> 38 | template<> 39 | void object::test<1> 40 | () 41 | { 42 | Vertex v1(10, 20); 43 | Vertex v2(20, 30); 44 | Vertex v3(0, 100); 45 | Vertex v4(10, 30); 46 | Vertex v5(10, 10); 47 | 48 | ensure(v1 < v2); 49 | ensure(!(v1 < v3)); 50 | ensure(v1 < v4); 51 | ensure(!(v1 < v5)); 52 | ensure(!(v4 < v5)); 53 | } 54 | 55 | } // namespace tut 56 | 57 | 58 | -------------------------------------------------------------------------------- /include/geos/io/WKBStreamReader.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Martin Davis 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | // Forward declarations 22 | namespace geos { 23 | namespace geom { 24 | class Geometry; 25 | class PrecisionModel; 26 | } 27 | } 28 | 29 | namespace geos { 30 | namespace io { 31 | 32 | class GEOS_DLL WKBStreamReader { 33 | 34 | public: 35 | WKBStreamReader(std::istream& instr); 36 | ~WKBStreamReader(); 37 | 38 | std::unique_ptr next(); 39 | 40 | private: 41 | 42 | std::istream& instr; 43 | WKBReader rdr; 44 | }; 45 | 46 | } 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /include/geos/io/WKTStreamReader.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Martin Davis 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | // Forward declarations 22 | namespace geos { 23 | namespace geom { 24 | 25 | class Geometry; 26 | class PrecisionModel; 27 | } 28 | } 29 | 30 | namespace geos { 31 | namespace io { 32 | 33 | class GEOS_DLL WKTStreamReader { 34 | 35 | public: 36 | WKTStreamReader(std::istream& instr); 37 | ~WKTStreamReader(); 38 | 39 | std::unique_ptr next(); 40 | 41 | private: 42 | 43 | std::istream& instr; 44 | WKTReader rdr; 45 | }; 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/dissolve/DissolveEdgeGraph.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (c) 2025 Martin Davis 7 | * Copyright (C) 2025 Paul Ramsey 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | 22 | using geos::edgegraph::HalfEdge; 23 | using geos::geom::CoordinateXYZM; 24 | 25 | 26 | namespace geos { // geos 27 | namespace dissolve { // geos.dissolve 28 | 29 | 30 | HalfEdge* 31 | DissolveEdgeGraph::createEdge(const CoordinateXYZM& p0) 32 | { 33 | dhEdges.emplace_back(p0); 34 | return &(dhEdges.back()); 35 | } 36 | 37 | 38 | } // namespace geos.dissolve 39 | } // namespace geos 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/triangulate/quadedge/LocateFailureException.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2012 Excensus LLC. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: triangulate/quadedge/LocateFailureException.java r524 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | 21 | namespace geos { 22 | namespace triangulate { //geos.triangulate 23 | namespace quadedge { //geos.triangulate.quadedge 24 | 25 | LocateFailureException::LocateFailureException(std::string const& msg) : 26 | util::GEOSException("LocateFailureException", msg) 27 | {} 28 | 29 | } //namespace geos.triangulate.quadedge 30 | } //namespace geos.triangulate 31 | } //namespace goes 32 | 33 | -------------------------------------------------------------------------------- /tools/astyle/LICENSE.md: -------------------------------------------------------------------------------- 1 | ### MIT License 2 | 3 | Copyright (c) 2018 by Jim Pattee . 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSUnionPrecTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosunionprec_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosunionprec("capi::GEOSUnionPrec"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | GEOSGeometry* a = GEOSGeomFromWKT("POINT (1.9 8.2)"); 24 | GEOSGeometry* b = GEOSGeomFromWKT("POINT (4.1 9.8)"); 25 | 26 | ensure(a); 27 | ensure(b); 28 | 29 | GEOSSetSRID(a, 4326); 30 | 31 | GEOSGeometry* result = GEOSUnionPrec(a, b, 2); 32 | GEOSGeometry* expected = GEOSGeomFromWKT("MULTIPOINT ((2 8), (4 10))"); 33 | 34 | ensure(result); 35 | ensure(expected); 36 | 37 | ensure_equals(GEOSEqualsExact(result, expected, 0), 1); 38 | ensure_equals(GEOSGetSRID(a), GEOSGetSRID(result)); 39 | 40 | GEOSGeom_destroy(a); 41 | GEOSGeom_destroy(b); 42 | GEOSGeom_destroy(result); 43 | GEOSGeom_destroy(expected); 44 | } 45 | 46 | } // namespace tut 47 | 48 | -------------------------------------------------------------------------------- /src/index/intervalrtree/IntervalRTreeLeafNode.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | #include 17 | 18 | 19 | namespace geos { 20 | namespace index { 21 | namespace intervalrtree { 22 | // 23 | // private: 24 | // 25 | 26 | // 27 | // protected: 28 | // 29 | 30 | // 31 | // public: 32 | // 33 | void 34 | IntervalRTreeLeafNode::query(double queryMin, double queryMax, index::ItemVisitor* visitor) const 35 | { 36 | if(! intersects(queryMin, queryMax)) { 37 | return; 38 | } 39 | 40 | visitor->visitItem(item); 41 | } 42 | 43 | } // geos::intervalrtree 44 | } // geos::index 45 | } // geos 46 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeom_createCircularStringTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "capi_test_utils.h" 3 | 4 | namespace tut { 5 | // 6 | // Test Group 7 | // 8 | 9 | struct test_geosgeom_createcircularstring_data : public capitest::utility {}; 10 | 11 | typedef test_group group; 12 | typedef group::object object; 13 | 14 | group test_geosgeom_createcircularstring("capi::GEOSGeom_createCircularString"); 15 | 16 | template<> 17 | template<> 18 | void object::test<1> 19 | () 20 | { 21 | GEOSCoordSequence* seq = GEOSCoordSeq_create(3, 2); 22 | GEOSCoordSeq_setXY(seq, 0, 1, 2); 23 | GEOSCoordSeq_setXY(seq, 1, 4, 5); 24 | GEOSCoordSeq_setXY(seq, 2, 9, -2); 25 | 26 | result_ = GEOSGeom_createCircularString(seq); 27 | expected_ = fromWKT("CIRCULARSTRING (1 2, 4 5, 9 -2)"); 28 | 29 | ensure_geometry_equals_identical(result_, expected_); 30 | } 31 | 32 | template<> 33 | template<> 34 | void object::test<2> 35 | () 36 | { 37 | result_ = GEOSGeom_createEmptyCircularString(); 38 | ensure(GEOSisEmpty(result_)); 39 | ensure(!GEOSHasZ(result_)); 40 | ensure(!GEOSHasM(result_)); 41 | } 42 | 43 | } // namespace tut 44 | 45 | -------------------------------------------------------------------------------- /tests/xmltester/tests/misc/Buffer-2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Extreme simplification of the Big Bad Nasty buffer. 8 | If the first element is reordered backward, things are fine !! 9 | 10 | 11 | 12 | MULTIPOLYGON((( 13 | 3135840 10098400, 14 | 3135702 10098200, 15 | 3135830 10098461, 16 | 3135840 10098400 17 | )) , (( 18 | 3129627 10098250, 19 | 3130490 10098813, 20 | 3130663 10098320, 21 | 3130263 10097448, 22 | 3129627 10098250 23 | ),( 24 | 3130240 10098310, 25 | 3130210 10098340, 26 | 3130193 10098318, 27 | 3130240 10098310 28 | ))) 29 | 30 | 31 | 32 | 33 | 34 | 35 | MULTIPOLYGON((( 36 | 3135840 10098400, 37 | 3135702 10098200, 38 | 3135830 10098461, 39 | 3135840 10098400 40 | )) , (( 41 | 3129627 10098250, 42 | 3130490 10098813, 43 | 3130663 10098320, 44 | 3130263 10097448, 45 | 3129627 10098250 46 | ),( 47 | 3130240 10098310, 48 | 3130210 10098340, 49 | 3130193 10098318, 50 | 3130240 10098310 51 | ))) 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSBuildAreaTest.cpp: -------------------------------------------------------------------------------- 1 | // Test Suite for C-API BuildArea 2 | 3 | #include 4 | // geos 5 | #include 6 | // std 7 | 8 | #include "capi_test_utils.h" 9 | 10 | namespace tut { 11 | // 12 | // Test Group 13 | // 14 | 15 | // Common data used in test cases. 16 | struct test_capi_buildarea_data : public capitest::utility {}; 17 | 18 | typedef test_group group; 19 | typedef group::object object; 20 | 21 | group test_capi_buildarea_group("capi::GEOSBuildArea"); 22 | 23 | // 24 | // Test Cases 25 | // 26 | 27 | template<> 28 | template<> 29 | void object::test<1>() 30 | { 31 | input_ = fromWKT("GEOMETRYCOLLECTION(LINESTRING(0 0,0 1,1 1),LINESTRING(1 1,1 0,0 0))"); 32 | result_ = GEOSBuildArea(input_); 33 | expected_ = fromWKT("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"); 34 | ensure_geometry_equals(result_, expected_, 0); 35 | } 36 | 37 | template<> 38 | template<> 39 | void object::test<2>() 40 | { 41 | input_ = fromWKT("MULTICURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0) )"); 42 | ensure(input_ != nullptr); 43 | 44 | result_ = GEOSBuildArea(input_); 45 | ensure(result_ == nullptr); 46 | } 47 | 48 | } // namespace tut 49 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSDisjointTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosdisjoint_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosdisjoint("capi::GEOSDisjoint"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("POINT (0 0)"); 24 | geom2_ = fromWKT("LINESTRING(2 0, 0 2)"); 25 | geom3_ = fromWKT("LINESTRING(0 0, 0 2)"); 26 | 27 | ensure_equals(1, GEOSDisjoint(geom1_, geom2_)); 28 | ensure_equals(0, GEOSDisjoint(geom1_, geom3_)); 29 | } 30 | 31 | template<> 32 | template<> 33 | void object::test<2>() 34 | { 35 | geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 36 | geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); 37 | 38 | ensure(geom1_); 39 | ensure(geom2_); 40 | 41 | ensure_equals("curved geometry not supported", GEOSDisjoint(geom1_, geom2_), 2); 42 | ensure_equals("curved geometry not supported", GEOSDisjoint(geom2_, geom1_), 2); 43 | } 44 | 45 | } // namespace tut 46 | 47 | -------------------------------------------------------------------------------- /include/geos/geomgraph/index/SweepLineEventObj.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | namespace geos { 21 | namespace geomgraph { // geos::geomgraph 22 | namespace index { // geos::geomgraph::index 23 | 24 | // This is here so that SweepLineEvent constructor 25 | // can use it as argument type. 26 | // Both SweepLineSegment and MonotoneChain will 27 | // inherit from it. 28 | class GEOS_DLL SweepLineEventOBJ { 29 | public: 30 | virtual 31 | ~SweepLineEventOBJ() {} 32 | }; 33 | 34 | 35 | } // namespace geos.geomgraph.index 36 | } // namespace geos.geomgraph 37 | } // namespace geos 38 | 39 | -------------------------------------------------------------------------------- /src/algorithm/NotRepresentableException.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | #include 18 | 19 | namespace geos { 20 | namespace algorithm { // geos.algorithm 21 | 22 | NotRepresentableException::NotRepresentableException() 23 | : 24 | GEOSException( 25 | "NotRepresentableException", 26 | "Projective point not representable on the Cartesian plane.") 27 | 28 | { 29 | } 30 | 31 | NotRepresentableException::NotRepresentableException(std::string msg) 32 | : 33 | GEOSException( 34 | "NotRepresentableException", msg) 35 | { 36 | } 37 | 38 | } // namespace geos.algorithm 39 | } // namespace geos 40 | 41 | -------------------------------------------------------------------------------- /include/geos/io/WKTFileReader.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Martin Davis 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | // Forward declarations 22 | namespace geos { 23 | namespace geom { 24 | 25 | class Geometry; 26 | class PrecisionModel; 27 | } 28 | } 29 | 30 | namespace geos { 31 | namespace io { 32 | 33 | class GEOS_DLL WKTFileReader { 34 | 35 | public: 36 | WKTFileReader(); 37 | ~WKTFileReader(); 38 | 39 | std::vector> read(std::string fname); 40 | 41 | private: 42 | std::unique_ptr readGeom(std::ifstream& f, geos::io::WKTReader& rdr); 43 | }; 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/geom/GeometryComponentFilter.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace geos { 23 | namespace geom { // geos::geom 24 | 25 | void 26 | GeometryComponentFilter::filter_rw(Geometry* geom) 27 | { 28 | ::geos::ignore_unused_variable_warning(geom); 29 | assert(0); 30 | } 31 | 32 | void 33 | GeometryComponentFilter::filter_ro(const Geometry* geom) 34 | { 35 | ::geos::ignore_unused_variable_warning(geom); 36 | assert(0); 37 | } 38 | 39 | 40 | } // namespace geos::geom 41 | } // namespace geos 42 | -------------------------------------------------------------------------------- /src/index/kdtree/KdNode.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | using namespace geos::geom; 18 | 19 | namespace geos { 20 | namespace index { // geos.index 21 | namespace kdtree { // geos.index.kdtree 22 | 23 | KdNode::KdNode(double p_x, double p_y, void* p_data) : 24 | p(p_x, p_y), 25 | data(p_data), 26 | left(nullptr), 27 | right(nullptr), 28 | count(1) {} 29 | 30 | KdNode::KdNode(const Coordinate& p_p, void* p_data) : 31 | p(p_p), 32 | data(p_data), 33 | left(nullptr), 34 | right(nullptr), 35 | count(1) {} 36 | 37 | 38 | } // namespace geos.index.kdtree 39 | } // namespace geos.index 40 | } // namespace geos 41 | -------------------------------------------------------------------------------- /tests/xmltester/JTSXMLTester.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ###################################################################### 4 | # 5 | # GEOS - Geometry Engine Open Source 6 | # http://geos.osgeo.org 7 | # 8 | # Copyright (C) 2010-2017 Sandro Santilli 9 | # Copyright (C) 2010-2012 Martin Davis 10 | # 11 | # This is free software; you can redistribute and/or modify it under 12 | # the terms of the GNU Lesser General Public Licence as published 13 | # by the Free Software Foundation. 14 | # See the COPYING file for more information. 15 | # 16 | ###################################################################### 17 | 18 | if test "x$JTS_LIB_DIR" = "x"; then 19 | JTS_LIB_DIR="$HOME/.m2/repository/org/locationtech/jts" 20 | fi 21 | 22 | #---------------------------------# 23 | # dynamically build the classpath # 24 | #---------------------------------# 25 | THE_CLASSPATH= 26 | for i in `find ${JTS_LIB_DIR} -name '*.jar'` 27 | do 28 | THE_CLASSPATH=${THE_CLASSPATH}:${i} 29 | done 30 | 31 | #---------------------------# 32 | # run the program # 33 | #---------------------------# 34 | java -cp ".:${THE_CLASSPATH}" \ 35 | org.locationtech.jtstest.testrunner.JTSTestRunnerCmd $@ 36 | -------------------------------------------------------------------------------- /include/geos/index/kdtree/KdNodeVisitor.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: index/kdtree/Node.java rev 1.8 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace geos { 24 | namespace index { // geos::index 25 | namespace kdtree { // geos::index::kdtree 26 | 27 | class GEOS_DLL KdNodeVisitor { 28 | 29 | private: 30 | 31 | protected: 32 | 33 | public: 34 | 35 | KdNodeVisitor() {}; 36 | virtual void visit(KdNode *node) = 0; 37 | 38 | 39 | }; 40 | 41 | 42 | } // namespace geos::index::kdtree 43 | } // namespace geos::index 44 | } // namespace geos 45 | 46 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSSymDifferenceTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geossymdifference_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geossymdifference("capi::GEOSSymDifference"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("LINESTRING(50 100, 50 200)"); 24 | ensure(geom1_); 25 | geom2_ = fromWKT("LINESTRING(50 50, 50 150)"); 26 | ensure(geom2_); 27 | geom3_ = GEOSSymDifference(geom1_, geom2_); 28 | 29 | ensure_equals("MULTILINESTRING ((50 150, 50 200), (50 50, 50 100))", toWKT(geom3_)); 30 | } 31 | 32 | template<> 33 | template<> 34 | void object::test<2>() 35 | { 36 | geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 37 | geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); 38 | 39 | ensure(geom1_); 40 | ensure(geom2_); 41 | 42 | result_ = GEOSSymDifference(geom1_, geom2_); 43 | ensure("curved geometry not supported", result_ == nullptr); 44 | } 45 | 46 | } // namespace tut 47 | 48 | -------------------------------------------------------------------------------- /include/geos/index/sweepline/SweepLineOverlapAction.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | // Forward declarations 20 | namespace geos { 21 | namespace index { 22 | namespace sweepline { 23 | class SweepLineInterval; 24 | } 25 | } 26 | } 27 | 28 | namespace geos { 29 | namespace index { // geos.index 30 | namespace sweepline { // geos:index:sweepline 31 | 32 | class GEOS_DLL SweepLineOverlapAction { 33 | public: 34 | virtual void overlap(SweepLineInterval* s0, SweepLineInterval* s1) = 0; 35 | 36 | virtual 37 | ~SweepLineOverlapAction() {} 38 | }; 39 | 40 | 41 | } // namespace geos:index:sweepline 42 | } // namespace geos:index 43 | } // namespace geos 44 | 45 | -------------------------------------------------------------------------------- /include/geos/triangulate/quadedge/LocateFailureException.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2012 Excensus LLC. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: triangulate/quadedge/LocateFailureException.java r524 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include 24 | 25 | namespace geos { 26 | namespace triangulate { //geos.triangulate 27 | namespace quadedge { //geos.triangulate.quadedge 28 | 29 | class GEOS_DLL LocateFailureException : public geos::util::GEOSException { 30 | public: 31 | LocateFailureException(std::string const& msg); 32 | }; 33 | 34 | } //namespace geos.triangulate.quadedge 35 | } //namespace geos.triangulate 36 | } //namespace goes 37 | 38 | -------------------------------------------------------------------------------- /src/geom/util/NoOpGeometryOperation.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace geos { 22 | namespace geom { // geos.geom 23 | namespace util { // geos.geom.util 24 | 25 | std::unique_ptr 26 | NoOpGeometryOperation::edit(const Geometry* geometry, 27 | const GeometryFactory* factory) 28 | { 29 | std::unique_ptr clonedGeom(factory->createGeometry(geometry)); 30 | return clonedGeom; 31 | } 32 | 33 | 34 | } // namespace geos.geom.util 35 | } // namespace geos.geom 36 | } // namespace geos 37 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/TestRelatePP.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | same point 5 | 6 | POINT(20 20) 7 | 8 | 9 | POINT(20 20) 10 | 11 | 12 | 13 | true 14 | 15 | 16 | 17 | 18 | 19 | different point 20 | 21 | POINT(20 20) 22 | 23 | 24 | POINT(20 30) 25 | 26 | 27 | 28 | true 29 | 30 | 31 | 32 | 33 | 34 | some same, some different points 35 | 36 | MULTIPOINT((40 40), (80 60), (40 100)) 37 | 38 | 39 | MULTIPOINT((40 40), (80 60), (120 100)) 40 | 41 | 42 | 43 | true 44 | 45 | 46 | 47 | 48 | 49 | same points 50 | 51 | MULTIPOINT((40 40), (80 60), (120 100)) 52 | 53 | 54 | MULTIPOINT((40 40), (80 60), (120 100)) 55 | 56 | 57 | 58 | true 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-997-union-fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | https://trac.osgeo.org/geos/ticket/997 4 | GEOS #997 - Extract containing geometry which fails with simple noding. 5 | 6 | 7 | 8 | 9 | GEOS #997 - Extract containing geometry which fails with simple noding. 10 | 11 | POLYGON ((-14735900 7678000, -14734775.733413335 7677081.324543352, -14734759.892794933 7677034.896890251, -14734755.426387085 7677015.922716262, -14734749.379277144 7676970.918132066, -14734748.706236055 7676951.007251211, -14734751.993518736 7676931.358079898, -14734759.110654198 7676912.750486192, -14734769.775166066 7676895.922998344, -14736900 7676600, -14735900 7678000)) 12 | 13 | 14 | POLYGON ((-14736100 7675500, -14736300 7677000, -14734772.848605746 7677023.01209576, -14734761.699689751 7677007.276952976, -14734753.778393028 7676989.694401839, -14734749.379303094 7676970.918325199, -14734746.00974369 7676945.841324383, -14734736.787535263 7676910.78962753, -14734733.838331584 7676893.609063869, -14736100 7675500)) 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSRelateTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosrelate_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosrelate("capi::GEOSRelate"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("LINESTRING(1 2, 3 4)"); 24 | ensure(nullptr != geom1_); 25 | geom2_ = fromWKT("LINESTRING(5 6, 7 8)"); 26 | ensure(nullptr != geom2_); 27 | 28 | char* pattern = GEOSRelate(geom1_, geom2_); 29 | ensure_equals(std::string{"FF1FF0102"}, pattern); 30 | GEOSFree(pattern); 31 | } 32 | 33 | template<> 34 | template<> 35 | void object::test<2>() 36 | { 37 | geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 38 | geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); 39 | 40 | ensure(geom1_); 41 | ensure(geom2_); 42 | 43 | ensure("curved geometry not supported", GEOSRelate(geom1_, geom2_) == nullptr); 44 | ensure("curved geometry not supported", GEOSRelate(geom2_, geom1_) == nullptr); 45 | } 46 | 47 | } // namespace tut 48 | 49 | -------------------------------------------------------------------------------- /src/index/strtree/GeometryItemDistance.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2016 Daniel Baston 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: index/strtree/GeometryItemDistance.java (JTS-1.14) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace geos::geom; 24 | using namespace geos::index::strtree; 25 | 26 | double 27 | GeometryItemDistance::distance(const ItemBoundable* item1, const ItemBoundable* item2) 28 | { 29 | const Geometry* g1 = static_cast(item1->getItem()); 30 | const Geometry* g2 = static_cast(item2->getItem()); 31 | return g1->distance(g2); 32 | } 33 | -------------------------------------------------------------------------------- /src/io/Writer.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: ORIGINAL WORK to be used like java.io.Writer 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | namespace geos { 24 | namespace io { // geos.io 25 | 26 | Writer::Writer() 27 | { 28 | } 29 | 30 | void 31 | Writer::reserve(std::size_t capacity) 32 | { 33 | str.reserve(capacity); 34 | } 35 | 36 | void 37 | Writer::write(const std::string& txt) 38 | { 39 | str.append(txt); 40 | } 41 | 42 | const std::string& 43 | Writer::toString() 44 | { 45 | return str; 46 | } 47 | 48 | } // namespace geos.io 49 | } // namespace geos 50 | -------------------------------------------------------------------------------- /util/geosop/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2020 Martin Davis 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | 12 | add_executable(geosop 13 | GeosOp.cpp 14 | GeometryOp.cpp 15 | ) 16 | 17 | target_link_libraries(geosop PRIVATE geos geos_c) 18 | 19 | if(NOT HAVE_FENV_H) 20 | target_compile_definitions(geosop PRIVATE MISSING_FENV) 21 | endif() 22 | 23 | install(TARGETS geosop 24 | DESTINATION ${CMAKE_INSTALL_BINDIR} 25 | ) 26 | 27 | if(BUILD_SHARED_LIBS) 28 | if(NOT DEFINED CMAKE_INSTALL_RPATH) 29 | # Use relative rpath 30 | if(APPLE) 31 | set_target_properties(geosop PROPERTIES 32 | INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") 33 | else() 34 | set_target_properties(geosop PROPERTIES 35 | INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") 36 | endif() 37 | endif() 38 | endif() 39 | 40 | 41 | -------------------------------------------------------------------------------- /include/geos/util/IllegalStateException.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2011 Sandro Santilli 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | namespace geos { 23 | namespace util { // geos::util 24 | 25 | /// Indicates an illegal state 26 | class GEOS_DLL IllegalStateException: public GEOSException { 27 | public: 28 | IllegalStateException() 29 | : 30 | GEOSException("IllegalStateException", "") 31 | {} 32 | 33 | IllegalStateException(const std::string& msg) 34 | : 35 | GEOSException("IllegalStateException", msg) 36 | {} 37 | 38 | ~IllegalStateException() noexcept override {} 39 | }; 40 | 41 | } // namespace geos::util 42 | } // namespace geos 43 | -------------------------------------------------------------------------------- /include/geos.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005 Refractions Research Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | /* 18 | * \file geos.h 19 | * \brief 20 | * This file is intended as an include wrapper for client application. 21 | * It includes commonly needed GEOS headers. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | /// Basic namespace for all GEOS functionalities. 38 | namespace geos { 39 | } 40 | -------------------------------------------------------------------------------- /src/dissolve/DissolveHalfEdge.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (c) 2025 Martin Davis 7 | * Copyright (C) 2025 Paul Ramsey 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #include 17 | 18 | namespace geos { // geos 19 | namespace dissolve { // geos.dissolve 20 | 21 | /** 22 | * Tests whether this edge is the starting segment 23 | * in a LineString being dissolved. 24 | * 25 | * @return true if this edge is a start segment 26 | */ 27 | bool 28 | DissolveHalfEdge::isStart() 29 | { 30 | return m_isStart; 31 | } 32 | 33 | /** 34 | * Sets this edge to be the start segment of an input LineString. 35 | */ 36 | void 37 | DissolveHalfEdge::setStart() 38 | { 39 | m_isStart = true; 40 | } 41 | 42 | 43 | } // namespace geos.dissolve 44 | } // namespace geos 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/noding/BasicSegmentString.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2009 Sandro Santilli 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: noding/BasicSegmentString.java rev. 1.1 (JTS-1.9) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | namespace geos { 26 | namespace noding { // geos.noding 27 | 28 | /* public virtual */ 29 | std::ostream& 30 | BasicSegmentString::print(std::ostream& os) const 31 | { 32 | os << "BasicSegmentString: " << std::endl; 33 | os << " LINESTRING" << *(getCoordinates()) << ";" << std::endl; 34 | 35 | return os; 36 | } 37 | 38 | 39 | } // namespace geos.noding 40 | } // namespace geos 41 | -------------------------------------------------------------------------------- /src/operation/buffer/MinimalEdgeRing.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * Copyright (C) 2005 Refractions Research Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | * 15 | **********************************************************************/ 16 | 17 | #include 18 | #include 19 | 20 | 21 | namespace geos { 22 | namespace operation { // geos.operation 23 | namespace buffer { // geos.operation.buffer 24 | 25 | 26 | MinimalEdgeRing::MinimalEdgeRing(geomgraph::DirectedEdge* start, 27 | const geom::GeometryFactory* p_geometryFactory) 28 | : 29 | geomgraph::EdgeRing(start, p_geometryFactory) 30 | { 31 | computePoints(start); 32 | computeRing(); 33 | } 34 | 35 | 36 | } // namespace geos.operation.buffer 37 | } // namespace geos.operation 38 | } // namespace geos 39 | 40 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeom_cloneTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | struct test_capigeosgeom_clone : public capitest::utility {}; 9 | 10 | typedef test_group group; 11 | typedef group::object object; 12 | 13 | group test_capigeosgeom_clone_group("capi::GEOSGeom_clone"); 14 | 15 | template<> 16 | template<> 17 | void object::test<1> 18 | () 19 | { 20 | geom1_ = GEOSGeomFromWKT("LINESTRING (3 8, -12 -4)"); 21 | GEOSSetSRID(geom1_, 32145); 22 | int data = 500; 23 | GEOSGeom_setUserData(geom1_, &data); 24 | 25 | geom2_ = GEOSGeom_clone(geom1_); 26 | 27 | ensure_geometry_equals(geom1_, geom2_); 28 | ensure(GEOSGeom_getCoordSeq(geom1_) != GEOSGeom_getCoordSeq(geom2_)); // deep copy 29 | ensure_equals(GEOSGetSRID(geom2_), 32145); 30 | ensure(GEOSGeom_getUserData(geom2_) == nullptr); // userData not transferred 31 | } 32 | 33 | template<> 34 | template<> 35 | void object::test<2> 36 | () 37 | { 38 | input_ = GEOSGeomFromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 39 | result_ = GEOSGeom_clone(input_); 40 | 41 | ensure_equals(toWKT(result_), "CIRCULARSTRING (0 0, 1 1, 2 0)"); 42 | } 43 | 44 | } // namespace tut 45 | 46 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-590.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Trac Issue 590 5 | 6 | POLYGON ((-85.0750607179665220 113.8654258494467400, 7 | 64.3672965899103670 156.0107332916275600, 8 | 137.3079656672400100 43.2577438927670460, 9 | 87.8851662143294450 -9.3724347171667830, 10 | 64.1043275247160270 12.5345351643778980, 11 | 57.6290566127233890 11.8540587044160620, 12 | 56.4515936228298330 23.0585489359124730, 13 | 66.2862534590275200 31.8839277149233600, 14 | 77.2983762851187630 29.5048162624378390, 15 | 75.6128088072109530 21.7028799222997040, 16 | 88.6113412524690600 -8.5991332777010179, 17 | 55.1320522049615960 -44.2511194421583620, 18 | 38.7066196617741550 -28.8266827415760860, 19 | 20.0462661184433340 -41.4559854697147760, 20 | -85.0750607179665220 113.8654258494467400), 21 | (30.0425661643411640 24.1756403122601360, 22 | 36.6948846784684620 54.9670302991890620, 23 | 73.5550410624974380 58.8406085742523290, 24 | 44.5925425701409350 103.6113561802426200, 25 | -12.7705879390574210 87.4339696968678620, 26 | 30.0425661643411640 24.1756403122601360)) 27 | 28 | false 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | file(GLOB_RECURSE _headers ${CMAKE_CURRENT_LIST_DIR}/*.h CONFIGURE_DEPEND) 12 | target_sources(geos PRIVATE ${_headers}) 13 | unset(_headers) 14 | 15 | target_include_directories(geos 16 | PUBLIC 17 | $ 18 | $ 19 | $) 20 | 21 | set(VERSION ${GEOS_VERSION}) 22 | set(VERSION_MAJOR ${GEOS_VERSION_MAJOR}) 23 | set(VERSION_MINOR ${GEOS_VERSION_MINOR}) 24 | set(VERSION_PATCH ${GEOS_VERSION_PATCH}) 25 | 26 | configure_file(${CMAKE_CURRENT_LIST_DIR}/geos/version.h.in 27 | ${CMAKE_CURRENT_BINARY_DIR}/geos/version.h 28 | @ONLY) 29 | 30 | unset(VERSION) 31 | unset(VERSION_MAJOR) 32 | unset(VERSION_MINOR) 33 | unset(VERSION_PATCH) 34 | -------------------------------------------------------------------------------- /.github/workflows/container.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions for GEOS 2 | # 3 | # Paul Ramsey 4 | # Build a geosop container and deploy to GHCR 5 | 6 | name: 'Container' 7 | 8 | on: 9 | push: 10 | branches: 11 | - main 12 | paths-ignore: 13 | - 'web/**' 14 | 15 | jobs: 16 | 17 | container: 18 | 19 | name: 'Build container' 20 | if: github.repository == 'libgeos/geos' 21 | runs-on: ubuntu-latest 22 | 23 | steps: 24 | 25 | - name: 'Check Out' 26 | uses: actions/checkout@v4 27 | 28 | - name: Set up Docker Buildx 29 | uses: docker/setup-buildx-action@v2 30 | 31 | - name: Login to GitHub Container Registry 32 | uses: docker/login-action@v2 33 | with: 34 | registry: ghcr.io 35 | username: ${{ github.repository_owner }} 36 | password: ${{ secrets.GITHUB_TOKEN }} 37 | 38 | - name: Get Dockerfile 39 | run: | 40 | cp tools/ci/geosop/Dockerfile . 41 | 42 | - name: Build and Push 43 | uses: docker/build-push-action@v4 44 | with: 45 | context: . 46 | # platforms: linux/amd64,linux/arm64 47 | platforms: linux/amd64 48 | push: true 49 | tags: | 50 | ghcr.io/libgeos/geosop:latest 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/geom/Location.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | namespace geos { 21 | namespace geom { // geos::geom 22 | 23 | std::ostream& 24 | operator<<(std::ostream& os, const Location& loc) 25 | { 26 | switch(loc) { 27 | case Location::EXTERIOR: 28 | os << 'e'; 29 | break; 30 | case Location::BOUNDARY: 31 | os << 'b'; 32 | break; 33 | case Location::INTERIOR: 34 | os << 'i'; 35 | break; 36 | case Location::NONE: 37 | os << '-'; 38 | break; 39 | } 40 | return os; 41 | } 42 | 43 | } // namespace geos::geom 44 | } // namespace geos 45 | -------------------------------------------------------------------------------- /src/geomgraph/NodeFactory.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * Copyright (C) 2005 Refractions Research Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: geomgraph/NodeFactory.java rev. 1.3 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | using namespace geos::geom; 24 | 25 | namespace geos { 26 | namespace geomgraph { // geos.geomgraph 27 | 28 | Node* 29 | NodeFactory::createNode(const Coordinate& coord) const 30 | { 31 | return new Node(coord, nullptr); 32 | } 33 | 34 | const NodeFactory& 35 | NodeFactory::instance() 36 | { 37 | static const NodeFactory nf; 38 | return nf; 39 | } 40 | 41 | 42 | } // namespace geos.geomgraph 43 | } // namespace geos 44 | -------------------------------------------------------------------------------- /tools/build-cmake.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Runs CMake to configure GEOS for Visual Studio 2017. 3 | rem Runs MSBuild to build the generated solution. 4 | rem 5 | rem Usage: 6 | rem 1. Copy build.bat to build.local.bat (git ignored file) 7 | rem 2. Make your adjustments in the CONFIGURATION section below 8 | rem 3. Run build.local.bat 32|64 9 | rem 4. Optionally, run devenv.exe {project}{32|64}.sln from command line 10 | 11 | rem ### CONFIGURATION ##################################### 12 | rem ####################################################### 13 | 14 | if [%1]==[] goto :Usage 15 | if [%1]==[32] goto :32 16 | if [%1]==[64] goto :64 17 | goto :Usage 18 | 19 | :32 20 | set GEOSP=32 21 | set MSBUILDP=Win32 22 | set GENERATOR="Visual Studio 15 2017" 23 | goto :Build 24 | 25 | :64 26 | set GEOSP=64 27 | set MSBUILDP=x64 28 | set GENERATOR="Visual Studio 15 2017 Win64" 29 | goto :Build 30 | 31 | :Build 32 | set BUILDDIR=_build.vs2017x%GEOSP% 33 | mkdir %BUILDDIR% 34 | pushd %BUILDDIR% 35 | "C:\Program Files\CMake\bin\cmake.exe" ^ 36 | -G %GENERATOR% ^ 37 | .. 38 | move geos.sln geos%GEOSP%.sln 39 | REM msbuild.exe geos%GEOSP%.sln /p:Configuration=Release /p:Platform=%MSBUILDP% 40 | popd 41 | goto :EOF 42 | 43 | :Usage 44 | @echo build.bat 45 | @echo Usage: build.bat [32 or 64] 46 | exit /B 1 47 | -------------------------------------------------------------------------------- /include/geos/operation/grid/Crossing.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2018-2025 ISciences, LLC 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | namespace geos::operation::grid { 21 | 22 | class Crossing 23 | { 24 | public: 25 | Crossing(Side s, double x, double y) 26 | : m_side{ s } 27 | , m_coord{ x, y } 28 | { 29 | } 30 | 31 | Crossing(Side s, const geom::CoordinateXY& c) 32 | : m_side{ s } 33 | , m_coord{ c } 34 | { 35 | } 36 | 37 | const Side& getSide() const 38 | { 39 | return m_side; 40 | } 41 | 42 | const geom::CoordinateXY& getCoord() const 43 | { 44 | return m_coord; 45 | } 46 | 47 | private: 48 | Side m_side; 49 | geom::CoordinateXY m_coord; 50 | }; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/operation/overlayng/EdgeSourceInfo.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | namespace geos { // geos 18 | namespace operation { // geos.operation 19 | namespace overlayng { // geos.operation.overlayng 20 | 21 | 22 | EdgeSourceInfo::EdgeSourceInfo(uint8_t p_index, int p_depthDelta, bool p_isHole) 23 | : index(p_index) 24 | , dim(geom::Dimension::A) 25 | , edgeIsHole(p_isHole) 26 | , depthDelta(p_depthDelta) 27 | {} 28 | 29 | EdgeSourceInfo::EdgeSourceInfo(uint8_t p_index) 30 | : index(p_index) 31 | , dim(geom::Dimension::L) 32 | , edgeIsHole(false) 33 | , depthDelta(0) 34 | {} 35 | 36 | 37 | } // namespace geos.operation.overlayng 38 | } // namespace geos.operation 39 | } // namespace geos 40 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSConvexHullTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for C-API GEOSConvexHull 3 | 4 | #include 5 | // geos 6 | #include 7 | // std 8 | 9 | #include "capi_test_utils.h" 10 | 11 | namespace tut { 12 | // 13 | // Test Group 14 | // 15 | 16 | // Common data used in test cases. 17 | struct test_capigeosconvexhull_data : public capitest::utility { 18 | }; 19 | 20 | typedef test_group group; 21 | typedef group::object object; 22 | 23 | group test_capigeosconvexhull_group("capi::GEOSConvexHull"); 24 | 25 | // 26 | // Test Cases 27 | // 28 | 29 | template<> 30 | template<> 31 | void object::test<1> 32 | () 33 | { 34 | input_ = fromWKT("MULTIPOINT ((130 240), (130 240), (570 240), (570 290), (650 240))"); 35 | expected_ = fromWKT("POLYGON ((130 240, 570 290, 650 240, 130 240))"); 36 | result_ = GEOSConvexHull(input_); 37 | ensure(nullptr != result_); 38 | ensure(0 == GEOSisEmpty(result_)); 39 | ensure_geometry_equals(result_, expected_); 40 | } 41 | 42 | template<> 43 | template<> 44 | void object::test<2>() 45 | { 46 | input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 47 | ensure(input_ != nullptr); 48 | 49 | result_ = GEOSConvexHull(input_); 50 | ensure(result_ == nullptr); 51 | } 52 | 53 | } // namespace tut 54 | 55 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/TestIntersectsPL.xml: -------------------------------------------------------------------------------- 1 | 2 | Test P/L intersects cases that require robust determinant. See discussion http://trac.osgeo.org/geos/ticket/591 3 | 4 | 5 | Point on segment between 3rd and 4th vertex of line 6 | 7 | POINT(-23.1094689600055 50.5195368635957) 8 | 9 | 10 | LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055 50.5223376452201,-23.1094689600055 50.5169177629559,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409) 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | Point on the 3rd vertex of line 21 | 22 | POINT(-23.1094689600055 50.5223376452201) 23 | 24 | 25 | LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055 50.5223376452201,-23.1094689600055 50.5169177629559,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409) 26 | 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/unit/index/chain/MonotoneChainBuilderTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for geos::index::chain::MonotoneChainBuilder class. 3 | 4 | #include 5 | #include 6 | // geos 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | namespace tut { 14 | // dummy data, not used 15 | struct test_monotonechain_data { 16 | geos::io::WKTReader wktreader; 17 | geos::io::WKTWriter wktwriter; 18 | 19 | test_monotonechain_data() 20 | : 21 | wktreader() 22 | {} 23 | }; 24 | 25 | typedef test_group group; 26 | typedef group::object object; 27 | 28 | group test_monotonechain_group("geos::index::chain::MonotoneChainBuilder"); 29 | 30 | // 31 | // Test Cases 32 | 33 | // This issue exercised a bug in MonotoneChainBuilder 34 | // https://github.com/libgeos/geos/issues/539 35 | template<> 36 | template<> 37 | void object::test<1> 38 | () 39 | { 40 | std::vector chain; 41 | geos::geom::CoordinateSequence pts; 42 | 43 | geos::index::chain::MonotoneChainBuilder::getChains(&pts, 0, chain); 44 | 45 | ensure_equals(chain.size(), 0u); 46 | } 47 | 48 | } // namespace tut 49 | -------------------------------------------------------------------------------- /benchmarks/index/chain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2021 Daniel Baston 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | 12 | IF(benchmark_FOUND) 13 | add_executable(perf_monotone_chain MonotoneChainPerfTest.cpp) 14 | target_include_directories(perf_monotone_chain PUBLIC 15 | $ 16 | $) 17 | target_link_libraries(perf_monotone_chain PRIVATE 18 | benchmark::benchmark geos) 19 | 20 | add_executable(perf_monotone_chain_builder MonotoneChainBuilderPerfTest.cpp) 21 | target_include_directories(perf_monotone_chain_builder PUBLIC 22 | $ 23 | $) 24 | target_link_libraries(perf_monotone_chain_builder PRIVATE 25 | benchmark::benchmark geos) 26 | endif() 27 | -------------------------------------------------------------------------------- /include/geos/io/CLocalizer.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2008 Sean Gillies 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: ORIGINAL WORK 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include 24 | 25 | #ifdef _MSC_VER 26 | #pragma warning(push) 27 | #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 28 | #endif 29 | 30 | namespace geos { 31 | namespace io { 32 | 33 | /** 34 | * \class CLocalizer io.h geos.h 35 | */ 36 | class GEOS_DLL CLocalizer { 37 | public: 38 | 39 | CLocalizer(); 40 | ~CLocalizer(); 41 | 42 | private: 43 | 44 | std::string saved_locale; 45 | }; 46 | 47 | #ifdef _MSC_VER 48 | #pragma warning(pop) 49 | #endif 50 | 51 | } // namespace io 52 | } // namespace geos 53 | 54 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgetnuminteriorrings_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_getnuminteriorrings("capi::GEOSGetNumInteriorRings"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | GEOSGeometry* input = GEOSGeomFromWKT("POLYGON ((1 -2, 9 -2, 9 5, 1 5, 1 -2))"); 24 | 25 | ensure_equals(GEOSGetNumInteriorRings(input), 0); 26 | 27 | GEOSGeom_destroy(input); 28 | } 29 | 30 | template<> 31 | template<> 32 | void object::test<2>() 33 | { 34 | GEOSGeometry* input = GEOSGeomFromWKT("LINESTRING (3 8, 4 7)"); 35 | 36 | ensure_equals(GEOSGetNumInteriorRings(input), -1); 37 | 38 | GEOSGeom_destroy(input); 39 | } 40 | 41 | template<> 42 | template<> 43 | void object::test<3>() 44 | { 45 | input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)), (8 8, 9 9, 9 8, 8 8))"); 46 | ensure(input_ != nullptr); 47 | 48 | ensure_equals(GEOSGetNumInteriorRings(input_), 1); 49 | } 50 | 51 | } // namespace tut 52 | 53 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | cmake_minimum_required(VERSION 3.12) 12 | 13 | project(geos-examples VERSION 1.0.0 LANGUAGES C CXX) 14 | find_package(GEOS 3.10 REQUIRED) 15 | 16 | add_executable(capi_read capi_read.c) 17 | target_link_libraries(capi_read PRIVATE GEOS::geos_c) 18 | 19 | add_executable(capi_prepared capi_prepared.c) 20 | target_link_libraries(capi_prepared PRIVATE GEOS::geos_c) 21 | 22 | add_executable(capi_strtree capi_strtree.c) 23 | target_link_libraries(capi_strtree PRIVATE GEOS::geos_c) 24 | 25 | add_executable(capi_read_ts capi_read_ts.c) 26 | target_link_libraries(capi_read_ts PRIVATE GEOS::geos_c) 27 | 28 | add_executable(cpp_strtree cpp_strtree.cpp) 29 | target_link_libraries(cpp_strtree PRIVATE GEOS::geos) 30 | 31 | add_executable(cpp_read cpp_read.cpp) 32 | target_link_libraries(cpp_read PRIVATE GEOS::geos) 33 | 34 | -------------------------------------------------------------------------------- /src/operation/buffer/BufferNodeFactory.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * Copyright (C) 2005 Refractions Research Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | using namespace geos::geomgraph; 21 | 22 | namespace geos { 23 | namespace operation { // geos.operation 24 | namespace buffer { // geos.operation.buffer 25 | 26 | Node* 27 | BufferNodeFactory::createNode(const geom::Coordinate& coord) const 28 | { 29 | return new Node(coord, new DirectedEdgeStar()); 30 | } 31 | 32 | const NodeFactory& 33 | BufferNodeFactory::instance() 34 | { 35 | static BufferNodeFactory onf; 36 | return onf; 37 | } 38 | 39 | } // namespace geos.operation.buffer 40 | } // namespace geos.operation 41 | } // namespace geos 42 | 43 | -------------------------------------------------------------------------------- /src/operation/polygonize/PolygonizeEdge.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: operation/polygonize/PolygonizeEdge.java rev. 1.3 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | 21 | #include 22 | 23 | using namespace geos::geom; 24 | 25 | namespace geos { 26 | namespace operation { // geos.operation 27 | namespace polygonize { // geos.operation.polygonize 28 | 29 | PolygonizeEdge::PolygonizeEdge(const LineString* newLine) 30 | { 31 | line = newLine; 32 | } 33 | 34 | const LineString* 35 | PolygonizeEdge::getLine() 36 | { 37 | return line; 38 | } 39 | 40 | } // namespace geos.operation.polygonize 41 | } // namespace geos.operation 42 | } // namespace geos 43 | -------------------------------------------------------------------------------- /src/io/CLocalizer.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2008 Sean Gillies 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: ORIGINAL WORK 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | 25 | 26 | namespace geos { 27 | namespace io { 28 | 29 | CLocalizer::CLocalizer() 30 | { 31 | #ifdef _MSC_VER 32 | // Avoid multithreading issues caused by setlocale 33 | _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); 34 | #endif 35 | char* p = std::setlocale(LC_NUMERIC, nullptr); 36 | if(nullptr != p) { 37 | saved_locale = p; 38 | } 39 | std::setlocale(LC_NUMERIC, "C"); 40 | } 41 | 42 | CLocalizer::~CLocalizer() 43 | { 44 | std::setlocale(LC_NUMERIC, saved_locale.c_str()); 45 | } 46 | 47 | } // namespace geos.io 48 | } // namespace geos 49 | 50 | -------------------------------------------------------------------------------- /include/geos/util/math.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * Copyright (C) 2006 Refractions Research Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | namespace geos { 19 | namespace util { 20 | 21 | /// Symmetric Rounding Algorithm 22 | double sym_round(double val); 23 | 24 | /// Asymmetric Rounding Algorithm 25 | double java_math_round(double val); 26 | 27 | /// Equivalent to Java Math.rint() 28 | double rint_vc(double val); 29 | 30 | 31 | /// Default rounding method for GEOS 32 | /// 33 | /// @note Always use this rounding method, to easy easy switching 34 | /// between different rounding method for the whole codebase. 35 | inline double 36 | round(double val) 37 | { 38 | return java_math_round(val); 39 | } 40 | 41 | /// Equivalent to std::clamp() in C++17 42 | double clamp(double x, double min, double max); 43 | 44 | } 45 | } // namespace geos::util 46 | -------------------------------------------------------------------------------- /src/index/intervalrtree/IntervalRTreeBranchNode.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | #include 17 | 18 | 19 | namespace geos { 20 | namespace index { 21 | namespace intervalrtree { 22 | // 23 | // private: 24 | // 25 | 26 | // 27 | // protected: 28 | // 29 | 30 | // 31 | // public: 32 | // 33 | 34 | 35 | void 36 | IntervalRTreeBranchNode::query(double queryMin, double queryMax, index::ItemVisitor* visitor) const 37 | { 38 | if(! intersects(queryMin, queryMax)) { 39 | return; 40 | } 41 | 42 | if(node1) { 43 | node1->query(queryMin, queryMax, visitor); 44 | } 45 | 46 | if(node2) { 47 | node2->query(queryMin, queryMax, visitor); 48 | } 49 | } 50 | 51 | 52 | } // geos::intervalrtree 53 | } // geos::index 54 | } // geos 55 | -------------------------------------------------------------------------------- /src/geom/prep/PreparedPoint.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: geom/prep/PreparedPoint.java rev. 1.2 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | 20 | #include 21 | #include 22 | 23 | #include "geos/util.h" 24 | 25 | namespace geos { 26 | namespace geom { // geos.geom 27 | namespace prep { // geos.geom.prep 28 | 29 | bool 30 | PreparedPoint::intersects(const geom::Geometry* g) const 31 | { 32 | util::ensureNoCurvedComponents(g); 33 | 34 | if(! envelopesIntersect(g)) { 35 | return false; 36 | } 37 | 38 | // This avoids computing topology for the test geometry 39 | return isAnyTargetComponentInTest(g); 40 | } 41 | 42 | } // namespace geos.geom.prep 43 | } // namespace geos.geom 44 | } // namespace geos 45 | -------------------------------------------------------------------------------- /src/operation/grid/FloodFill.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2018-2025 ISciences, LLC 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | using geos::geom::Geometry; 21 | 22 | namespace geos::operation::grid { 23 | 24 | FloodFill::FloodFill(const Geometry& g, const Grid& extent) 25 | : m_extent{ extent } 26 | , m_g{ g } 27 | , m_loc{ nullptr } 28 | { 29 | m_loc = std::make_unique(m_g); 30 | } 31 | 32 | FloodFill::~FloodFill() = default; 33 | 34 | bool 35 | FloodFill::cellIsInside(size_t i, size_t j) const 36 | { 37 | geom::CoordinateXY p( m_extent.getColX(j), m_extent.getRowY(i) ); 38 | 39 | return m_loc->locate(&p) == geom::Location::INTERIOR; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgeom_getcoordinatedimension_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosgeom_getcoordinatedimension("capi::GEOSGeom_getCoordinateDimension"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1> 22 | () 23 | { 24 | input_ = fromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))"); 25 | ensure_equals(GEOSGeom_getCoordinateDimension(input_), 2); 26 | } 27 | 28 | template<> 29 | template<> 30 | void object::test<2> 31 | () 32 | { 33 | input_ = fromWKT("POINT (4 2 7)"); 34 | ensure_equals(GEOSGeom_getCoordinateDimension(input_), 3); 35 | } 36 | 37 | template<> 38 | template<> 39 | void object::test<3> 40 | () 41 | { 42 | input_ = fromWKT("LINESTRING (4 2 7 1, 8 2 9 5)"); 43 | ensure_equals(GEOSGeom_getCoordinateDimension(input_), 4); 44 | } 45 | 46 | template<> 47 | template<> 48 | void object::test<4> 49 | () 50 | { 51 | input_ = fromWKT("CIRCULARSTRING Z (0 0 0, 1 1 1, 2 0 2)"); 52 | ensure_equals(GEOSGeom_getCoordinateDimension(input_), 3); 53 | } 54 | 55 | } // namespace tut 56 | 57 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSLineMergeTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for C-API GEOSLineMerge 3 | 4 | #include 5 | // geos 6 | #include 7 | 8 | #include "capi_test_utils.h" 9 | 10 | namespace tut { 11 | // 12 | // Test Group 13 | // 14 | 15 | // Common data used in test cases. 16 | struct test_capigeoslinemerge_data : public capitest::utility { 17 | }; 18 | 19 | typedef test_group group; 20 | typedef group::object object; 21 | 22 | group test_capigeoslinemerge_group("capi::GEOSLineMerge"); 23 | 24 | // 25 | // Test Cases 26 | // 27 | 28 | template<> 29 | template<> 30 | void object::test<1> 31 | () 32 | { 33 | auto input = GEOSGeomFromWKT("MULTILINESTRING((0 0, 0 100),(0 -5, 0 0))"); 34 | auto result = GEOSLineMerge(input); 35 | auto expected = GEOSGeomFromWKT("LINESTRING(0 -5,0 0,0 100)"); 36 | 37 | ensure(GEOSEqualsExact(result, expected, 0)); 38 | 39 | GEOSGeom_destroy(input); 40 | GEOSGeom_destroy(result); 41 | GEOSGeom_destroy(expected); 42 | } 43 | 44 | template<> 45 | template<> 46 | void object::test<2>() 47 | { 48 | input_ = fromWKT("MULTICURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 3 0))"); 49 | ensure(input_); 50 | 51 | result_ = GEOSLineMerge(input_); 52 | 53 | ensure("curved geometries not supported", result_ == nullptr); 54 | } 55 | 56 | } // namespace tut 57 | 58 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGetGeometryNTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgetgeometryn_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosgetgeometryn("capi::GEOSGetGeometryN"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("MULTIPOINT ((1 1), (2 2), (3 3))"); 24 | ensure(nullptr != geom1_); 25 | 26 | const GEOSGeometry* result = GEOSGetGeometryN(geom1_, 0); 27 | ensure(nullptr != result); 28 | ensure_equals("POINT (1 1)", toWKT(result)); 29 | 30 | result = GEOSGetGeometryN(geom1_, 2); 31 | ensure(nullptr != result); 32 | ensure_equals("POINT (3 3)", toWKT(result)); 33 | 34 | ensure(GEOSGetGeometryN(geom1_, -1) == nullptr); 35 | } 36 | 37 | template<> 38 | template<> 39 | void object::test<2>() 40 | { 41 | input_ = fromWKT("MULTICURVE ((0 0, 1 1), CIRCULARSTRING (1 1, 2 0, 3 1))"); 42 | ensure(input_); 43 | 44 | ensure_equals(toWKT(GEOSGetGeometryN(input_, 0)), "LINESTRING (0 0, 1 1)"); 45 | ensure_equals(toWKT(GEOSGetGeometryN(input_, 1)), "CIRCULARSTRING (1 1, 2 0, 3 1)"); 46 | } 47 | 48 | } // namespace tut 49 | 50 | -------------------------------------------------------------------------------- /tests/unit/geom/Geometry/toTextTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for Geometry's toText() function 3 | 4 | // tut 5 | #include 6 | // geos 7 | #include 8 | #include 9 | #include 10 | // std 11 | #include 12 | #include 13 | 14 | namespace tut { 15 | 16 | // 17 | // Test Group 18 | // 19 | 20 | struct test_totext_data { 21 | typedef std::unique_ptr GeomPtr; 22 | geos::io::WKTReader reader; 23 | 24 | test_totext_data() 25 | : reader() 26 | {} 27 | }; 28 | 29 | typedef test_group group; 30 | typedef group::object object; 31 | 32 | group test_totext_data("geos::geom::Geometry::toText"); 33 | 34 | // 35 | // Test Cases 36 | // 37 | 38 | // Input WKT is the same as output from toText() 39 | template<> template<> void object::test<1> 40 | () 41 | { 42 | 43 | std::vector variants{ 44 | "POINT (1 2)", 45 | "POINT Z (1 2 3)", 46 | "POINT M (1 2 4)", 47 | "POINT ZM (1 2 3 4)", 48 | "POINT EMPTY", 49 | "POINT Z EMPTY", 50 | "GEOMETRYCOLLECTION EMPTY", 51 | }; 52 | for (const auto& wkt : variants) { 53 | GeomPtr g1(reader.read(wkt)); 54 | ensure_equals(g1->toText(), wkt); 55 | } 56 | 57 | } 58 | 59 | } // namespace tut 60 | 61 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-398.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | http://trac.osgeo.org/geos/ticket/398 4 | 5 | 6 | 7 | 8 | 12 | 13 | MULTIPOLYGON (((60.0 6.5105151320986412, 14 | 44.0044859469790026 11.6931320480208569, 0.0 25.9507790663861222, 15 | 0.0 26.8608278557796467, 0.0 29.8387923019253307, 60.0 10.3985283676378408, 16 | 60.0 7.8021345594223774, 60.0000000000000000 6.6570998796460161, 60.0 17 | 6.5105151320986412)), ((43.3161197496508308 0.0, 18 | 0.0 0.0, 0.0 14.0346133423735822, 0.0 17.9226661292310787, 19 | 0.0 21.5874865260243638, 34.0258524396557860 20 | 6.8981402622972743, 55.3161197496508308 0.0, 21 | 50.0044466166182886 0.0, 43.3161197496508308 22 | 0.0)), ((13.4455725323347899 36.0, 23 | 60.0 36.0, 60.0 16.7944518298098018, 60.0 16.3644011555093201, 24 | 60.0 14.0439960304547569, 2.9187843276549756 25 | 36.0, 11.8945390820010992 36.0, 13.4455725323347899 36.0))) 26 | 27 | 28 | POLYGON ((50.0044466166182886 0.0, 29 | 0.0 21.5874865260243638, 0.0 30 | 35.7392139719321804, 60.0 13.1838946818537934, 31 | 60.0 0.0, 50.0044466166182886 0.0)) 32 | 33 | true 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /include/geos/algorithm/NotRepresentableException.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace geos { 23 | namespace algorithm { // geos::algorithm 24 | 25 | /** 26 | * \class NotRepresentableException 27 | * \brief 28 | * Indicates that a HCoordinate has been computed which is 29 | * not representable on the Cartesian plane. 30 | * 31 | * @version 1.4 32 | * @see HCoordinate 33 | */ 34 | class GEOS_DLL NotRepresentableException: public util::GEOSException { 35 | public: 36 | NotRepresentableException(); 37 | NotRepresentableException(std::string msg); 38 | ~NotRepresentableException() noexcept override {} 39 | }; 40 | 41 | } // namespace geos::algorithm 42 | } // namespace geos 43 | 44 | -------------------------------------------------------------------------------- /src/index/sweepline/SweepLineInterval.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #include 17 | 18 | namespace geos { 19 | namespace index { // geos.index 20 | namespace sweepline { // geos.index.sweepline 21 | 22 | SweepLineInterval::SweepLineInterval(double newMin, double newMax, void* newItem) 23 | { 24 | min = newMin < newMax ? newMin : newMax; 25 | max = newMax > newMin ? newMax : newMin; 26 | item = newItem; 27 | } 28 | 29 | double 30 | SweepLineInterval::getMin() 31 | { 32 | return min; 33 | } 34 | 35 | double 36 | SweepLineInterval::getMax() 37 | { 38 | return max; 39 | } 40 | 41 | void* 42 | SweepLineInterval::getItem() 43 | { 44 | return item; 45 | } 46 | 47 | } // namespace geos.index.sweepline 48 | } // namespace geos.index 49 | } // namespace geos 50 | 51 | -------------------------------------------------------------------------------- /src/io/WKBStreamReader.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Martin Davis 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include // for unique_ptr 21 | 22 | #include 23 | 24 | using geos::geom::Geometry; 25 | 26 | namespace geos { 27 | namespace io { 28 | 29 | WKBStreamReader::WKBStreamReader(std::istream& p_instr) 30 | : instr(p_instr) 31 | { 32 | } 33 | 34 | WKBStreamReader::~WKBStreamReader() { 35 | 36 | } 37 | 38 | /*public*/ 39 | 40 | 41 | /* 42 | Return: nullptr if at EOF 43 | */ 44 | std::unique_ptr 45 | WKBStreamReader::next() 46 | { 47 | std::string line; 48 | std::getline(instr, line); 49 | if (! instr) { 50 | return nullptr; 51 | } 52 | std::istringstream hex(line); 53 | auto g = rdr.readHEX( hex ); 54 | return g; 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/operation/overlayng/IndexedPointOnLineLocator.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | 24 | namespace geos { // geos 25 | namespace operation { // geos.operation 26 | namespace overlayng { // geos.operation.overlayng 27 | 28 | 29 | /*public*/ 30 | geom::Location 31 | IndexedPointOnLineLocator::locate(const geom::CoordinateXY* p) { 32 | // TODO: optimize this with a segment index 33 | algorithm::PointLocator locator; 34 | return locator.locate(*p, &inputGeom); 35 | } 36 | 37 | 38 | 39 | } // namespace geos.operation.overlayng 40 | } // namespace geos.operation 41 | } // namespace geos 42 | -------------------------------------------------------------------------------- /src/geom/prep/PreparedPolygonCovers.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: geom/prep/PreparedPolygonCovers.java rev 1.2 (JTS-1.10) 16 | * (2007-12-12) 17 | * 18 | **********************************************************************/ 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace geos { 26 | namespace geom { // geos.geom 27 | namespace prep { // geos.geom.prep 28 | // 29 | // private: 30 | // 31 | 32 | // 33 | // protected: 34 | // 35 | bool 36 | PreparedPolygonCovers::fullTopologicalPredicate(const geom::Geometry* geom) 37 | { 38 | bool result = prepPoly->getGeometry().covers(geom); 39 | return result; 40 | } 41 | 42 | // 43 | // public: 44 | // 45 | 46 | } // namespace geos.geom.prep 47 | } // namespace geos.geom 48 | } // namespace geos 49 | -------------------------------------------------------------------------------- /src/geomgraph/Label.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: geomgraph/Label.java r428 (JTS-1.12+) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | using namespace geos::geom; 28 | 29 | namespace geos { 30 | namespace geomgraph { // geos.geomgraph 31 | 32 | std::string 33 | Label::toString() const 34 | { 35 | std::stringstream ss; 36 | ss << *this; 37 | return ss.str(); 38 | } 39 | 40 | std::ostream& 41 | operator<< (std::ostream& os, const Label& l) 42 | { 43 | os << "A:" 44 | << l.elt[0] 45 | << " B:" 46 | << l.elt[1]; 47 | return os; 48 | } 49 | 50 | } // namespace geos.geomgraph 51 | } // namespace geos 52 | -------------------------------------------------------------------------------- /src/index/chain/MonotoneChainSelectAction.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: index/chain/MonotoneChainSelectAction.java rev. 1.6 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | namespace geos { 27 | namespace index { // geos.index 28 | namespace chain { // geos.index.chain 29 | 30 | void 31 | MonotoneChainSelectAction::select(const MonotoneChain& mc, std::size_t start) 32 | { 33 | mc.getLineSegment(start, selectedSegment); 34 | 35 | select(selectedSegment); 36 | } 37 | 38 | } // namespace geos.index.chain 39 | } // namespace geos.index 40 | } // namespace geos 41 | -------------------------------------------------------------------------------- /src/noding/SegmentNode.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: noding/SegmentNode.java 4667170ea (JTS-1.17) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | using geos::geom::CoordinateXYZM; 30 | using geos::geom::Coordinate; 31 | 32 | namespace geos { 33 | namespace noding { // geos.noding 34 | 35 | std::ostream& 36 | operator<< (std::ostream& os, const SegmentNode& n) 37 | { 38 | return os << n.coord << " seg#=" << n.segmentIndex << " octant#=" << n.segmentOctant << std::endl; 39 | } 40 | 41 | 42 | } // namespace geos.noding 43 | } // namespace geos 44 | 45 | -------------------------------------------------------------------------------- /tests/xmltester/tests/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 | false 25 | false 26 | false 27 | false 28 | false 29 | false 30 | true 31 | true 32 | false 33 | false 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/planargraph/Subgraph.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | * Last port: planargraph/Subgraph.java rev. 1.3 (JTS-1.7) 14 | * 15 | **********************************************************************/ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | 25 | 26 | namespace geos { 27 | namespace planargraph { 28 | 29 | std::pair 30 | Subgraph::add(Edge* e) 31 | { 32 | std::pair p = edges.insert(e); 33 | if(!p.second) { 34 | return p; 35 | } 36 | 37 | dirEdges.push_back(e->getDirEdge(0)); 38 | dirEdges.push_back(e->getDirEdge(1)); 39 | nodeMap.add(e->getDirEdge(0)->getFromNode()); 40 | nodeMap.add(e->getDirEdge(1)->getFromNode()); 41 | 42 | return p; 43 | } 44 | 45 | } // namespace planargraph 46 | } // namespace geos 47 | 48 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-188.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | http://trac.osgeo.org/geos/ticket/188 4 | 5 | 6 | com.vividsolutions.jtstest.testrunner.BufferResultMatcher 7 | 8 | 9 | 10 | Caused crash in RightmostEdgeFinder creating BufferSubgraphs 11 | 12 | 13 | 0103000000010000000B000000713D0AD7C3F9C3403D0AD7A3E8B01441295C8FC255FBC340C3F5285C0BB1144153BB8CF8AD01C44092DD2F29FEB0144148E17A14AE01C4408FC2F528FEB0144148E17A146E01C440A4703D0AF0B014411F85EB517801C44085EB51B8EFB014419A999999B9FFC34066666666CBB0144133333333F3FCC340CDCCCCCCC9B01441295C8FC2F5FBC3408FC2F528CAB014413D0AD7A3F0FBC340CDCCCCCCC9B01441713D0AD7C3F9C3403D0AD7A3E8B01441 14 | 15 | 16 | 17 | 0103000000010000000F000000693B38D7C3F9C340F428D7A3E8B0144168CCA9C255FBC3400F64275C0BB11441F72C82F8AD01C440D4982E29FEB01441501A4C14AE01C4402CC9F428FEB01441FB5951146E01C440B39F3D0AF0B01441E41853146E01C44058063D0AF0B01441C8385D146E01C44060833C0AF0B01441AA97BA517801C440699851B8EFB0144145027C99B9FFC340C0A56766CBB01441F3A43233F3FCC340E51CCECCC9B01441B94391C2F5FBC340C211F728CAB014412A4F79C2F5FBC340FDDFF628CAB014412F0869C2F5FBC340D64AF628CAB01441FD95D2A3F0FBC340CFB6CFCCC9B01441693B38D7C3F9C340F428D7A3E8B01441 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /include/geos/operation/cluster/EnvelopeIntersectsClusterFinder.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020-2021 Daniel Baston 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace geos { 20 | namespace operation { 21 | namespace cluster { 22 | 23 | /** EnvelopeIntersectsClusterFinder clusters geometries by envelope intersection. 24 | * Any two geometries whose envelopes intersect will be included in the same cluster. 25 | */ 26 | class GEOS_DLL EnvelopeIntersectsClusterFinder : public AbstractClusterFinder { 27 | protected: 28 | 29 | const geom::Envelope& queryEnvelope(const geom::Geometry* a) override { 30 | return *(a->getEnvelopeInternal()); 31 | } 32 | 33 | bool shouldJoin(const geom::Geometry* a, const geom::Geometry *b) override { 34 | return a->getEnvelopeInternal()->intersects(b->getEnvelopeInternal()); 35 | } 36 | 37 | }; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/geom/prep/PreparedLineStringNearestPoints.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Sandro Santilli 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: ORIGINAL WORK 16 | * 17 | **********************************************************************/ 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace geos { 26 | namespace geom { // geos.geom 27 | namespace prep { // geos.geom.prep 28 | 29 | std::unique_ptr 30 | PreparedLineStringNearestPoints::nearestPoints(const geom::Geometry* g) const 31 | { 32 | operation::distance::IndexedFacetDistance *idf = prepLine.getIndexedFacetDistance(); 33 | return idf->nearestPoints(g); 34 | } 35 | 36 | } // namespace geos.geom.prep 37 | } // namespace geos.geom 38 | } // namespace geos 39 | -------------------------------------------------------------------------------- /src/noding/snap/SnappingPointIndex.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | using namespace geos::geom; 18 | 19 | namespace geos { 20 | namespace noding { // geos.noding 21 | namespace snap { // geos.noding.snap 22 | 23 | SnappingPointIndex::SnappingPointIndex(double p_snapTolerance) : 24 | // snapTolerance(p_snapTolerance), 25 | snapPointIndex(new index::kdtree::KdTree(p_snapTolerance)) {} 26 | 27 | 28 | const Coordinate& 29 | SnappingPointIndex::snap(const Coordinate& p) 30 | { 31 | /** 32 | * Inserting the coordinate snaps it to any existing 33 | * one within tolerance, or adds it if not. 34 | */ 35 | index::kdtree::KdNode* node = snapPointIndex->insert(p); 36 | return node->getCoordinate(); 37 | } 38 | 39 | 40 | 41 | } // namespace geos.noding.snap 42 | } // namespace geos.noding 43 | } // namespace geos 44 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSSegmentIntersectionTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for C-API GEOSSegmentIntersection 3 | #include 4 | // geos 5 | #include 6 | 7 | #include "capi_test_utils.h" 8 | 9 | namespace tut { 10 | // 11 | // Test Group 12 | // 13 | 14 | // Common data used in test cases. 15 | struct test_capigeossegmentintersection : capitest::utility { 16 | }; 17 | 18 | typedef test_group group; 19 | typedef group::object object; 20 | 21 | group test_capigeossegmentintersection_group("capi::GEOSSegmentIntersection"); 22 | 23 | // 24 | // Test Cases 25 | // 26 | template<> 27 | template<> 28 | void object::test<1> 29 | () 30 | { 31 | // plain old intersection 32 | int result; 33 | double x, y; 34 | 35 | result = GEOSSegmentIntersection(0, 0, 10, 10, 36 | 8, 0, 8, 10, 37 | &x, &y); 38 | 39 | ensure_equals(result, 1); 40 | ensure_equals(x, 8); 41 | ensure_equals(y, 8); 42 | } 43 | 44 | template<> 45 | template<> 46 | void object::test<2> 47 | () 48 | { 49 | // no intersection 50 | int result; 51 | double x, y; 52 | 53 | result = GEOSSegmentIntersection(0, 0, 10, 10, 54 | 8, 0, 8, 2, 55 | &x, &y); 56 | 57 | ensure_equals(result, -1); 58 | } 59 | 60 | } // namespace tut 61 | -------------------------------------------------------------------------------- /include/geos/util/AssertionFailedException.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * Copyright (C) 2006 Refractions Research Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | namespace geos { 24 | namespace util { // geos.util 25 | 26 | /** \class AssertionFailedException util.h geos.h 27 | * \brief Indicates a bug in GEOS code. 28 | */ 29 | class GEOS_DLL AssertionFailedException: public GEOSException { 30 | 31 | public: 32 | 33 | AssertionFailedException() 34 | : 35 | GEOSException("AssertionFailedException", "") 36 | {} 37 | 38 | AssertionFailedException(const std::string& msg) 39 | : 40 | GEOSException("AssertionFailedException", msg) 41 | {} 42 | 43 | ~AssertionFailedException() noexcept override {} 44 | }; 45 | 46 | } // namespace geos.util 47 | } // namespace geos 48 | 49 | -------------------------------------------------------------------------------- /tests/xmltester/tests/general/TestPreparedIntersectsPL.xml: -------------------------------------------------------------------------------- 1 | 2 | Test P/L intersects cases that require robust determinant. See discussion http://trac.osgeo.org/geos/ticket/591 3 | com.vividsolutions.jtstest.geomop.PreparedGeometryOperation 4 | 5 | Point on segment between 3rd and 4th vertex of line 6 | 7 | POINT(-23.1094689600055 50.5195368635957) 8 | 9 | 10 | LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055 50.5223376452201,-23.1094689600055 50.5169177629559,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409) 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | Point on the 3rd vertex of line 21 | 22 | POINT(-23.1094689600055 50.5223376452201) 23 | 24 | 25 | LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055 50.5223376452201,-23.1094689600055 50.5169177629559,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409) 26 | 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /include/geos/geomgraph/NodeFactory.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: geomgraph/NodeFactory.java rev. 1.3 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | // Forward declarations 26 | namespace geos { 27 | namespace geom { 28 | class Coordinate; 29 | } 30 | namespace geomgraph { 31 | class Node; 32 | } 33 | } 34 | 35 | namespace geos { 36 | namespace geomgraph { // geos.geomgraph 37 | 38 | class GEOS_DLL NodeFactory /* non-final */ { 39 | public: 40 | virtual Node* createNode(const geom::Coordinate& coord) const; 41 | static const NodeFactory& instance(); 42 | virtual 43 | ~NodeFactory() {} 44 | protected: 45 | NodeFactory() {} 46 | }; 47 | 48 | 49 | } // namespace geos.geomgraph 50 | } // namespace geos 51 | 52 | -------------------------------------------------------------------------------- /include/geos/operation/grid/Side.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2018-2025 ISciences, LLC 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace geos::operation::grid { 20 | 21 | enum class Side 22 | { 23 | NONE, 24 | LEFT, 25 | RIGHT, 26 | TOP, 27 | BOTTOM 28 | }; 29 | 30 | inline std::ostream& 31 | operator<<(std::ostream& os, const Side& s) 32 | { 33 | switch (s) { 34 | case Side::NONE: 35 | os << "none"; 36 | return os; 37 | case Side::LEFT: 38 | os << "left"; 39 | return os; 40 | case Side::RIGHT: 41 | os << "right"; 42 | return os; 43 | case Side::TOP: 44 | os << "top"; 45 | return os; 46 | case Side::BOTTOM: 47 | os << "bottom"; 48 | return os; 49 | } 50 | 51 | return os; // unreachable statement needed for -Werror=return-type 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSCoversTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geoscovers_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geoscovers("capi::GEOSCovers"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))"); 24 | geom2_ = fromWKT("POLYGON ((5 5, 5 7, 7 7, 7 5, 5 5))"); 25 | geom3_ = fromWKT("POLYGON ((20 20, 20 30, 30 30, 30 20, 20 20))"); 26 | 27 | ensure_equals(1, GEOSCovers(geom1_, geom2_)); 28 | ensure_equals(0, GEOSCovers(geom2_, geom1_)); 29 | ensure_equals(0, GEOSCovers(geom1_, geom3_)); 30 | ensure_equals(0, GEOSCovers(geom3_, geom1_)); 31 | ensure_equals(0, GEOSCovers(geom2_, geom3_)); 32 | ensure_equals(0, GEOSCovers(geom3_, geom2_)); 33 | } 34 | 35 | template<> 36 | template<> 37 | void object::test<2>() 38 | { 39 | geom1_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)))"); 40 | geom2_ = fromWKT("LINESTRING (5 3, 5 4)"); 41 | 42 | ensure(geom1_); 43 | ensure(geom2_); 44 | 45 | ensure_equals("curved geometry not supported", GEOSCovers(geom1_, geom2_), 2); 46 | } 47 | 48 | } // namespace tut 49 | 50 | -------------------------------------------------------------------------------- /src/deps/ryu/LICENSE-Boost: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSCrossesTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geoscrosses_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geoscrosses("capi::GEOSCrosses"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("LINESTRING (1 1, 10 10)"); 24 | geom2_ = fromWKT("LINESTRING (10 1, 1 10)"); 25 | geom3_ = fromWKT("LINESTRING (20 20, 30 30)"); 26 | 27 | ensure_equals(1, GEOSCrosses(geom1_, geom2_)); 28 | ensure_equals(1, GEOSCrosses(geom2_, geom1_)); 29 | ensure_equals(0, GEOSCrosses(geom1_, geom3_)); 30 | ensure_equals(0, GEOSCrosses(geom3_, geom1_)); 31 | ensure_equals(0, GEOSCrosses(geom2_, geom3_)); 32 | ensure_equals(0, GEOSCrosses(geom3_, geom2_)); 33 | } 34 | 35 | template<> 36 | template<> 37 | void object::test<2>() 38 | { 39 | geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 40 | geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); 41 | 42 | ensure(geom1_); 43 | ensure(geom2_); 44 | 45 | ensure_equals("curved geometry not supported", GEOSCrosses(geom1_, geom2_), 2); 46 | ensure_equals("curved geometry not supported", GEOSCrosses(geom2_, geom1_), 2); 47 | } 48 | 49 | } // namespace tut 50 | 51 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSGeomGetNumPointsTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosgeomgetnumpoints_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geosgeomgetnumpoints("capi::GEOSGeomGetNumPoints"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | input_ = GEOSGeomFromWKT("LINESTRING EMPTY"); 24 | ensure_equals(GEOSGeomGetNumPoints(input_), 0); 25 | } 26 | 27 | template<> 28 | template<> 29 | void object::test<2>() 30 | { 31 | input_ = GEOSGeomFromWKT("LINESTRING (1 1, 2 2)"); 32 | ensure_equals(GEOSGeomGetNumPoints(input_), 2); 33 | } 34 | 35 | template<> 36 | template<> 37 | void object::test<3>() 38 | { 39 | input_ = GEOSGeomFromWKT("POINT (0 0)"); 40 | ensure_equals(GEOSGeomGetNumPoints(input_), -1); 41 | } 42 | 43 | template<> 44 | template<> 45 | void object::test<4>() 46 | { 47 | input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 48 | ensure_equals(GEOSGeomGetNumPoints(input_), 3); 49 | } 50 | 51 | template<> 52 | template<> 53 | void object::test<5>() 54 | { 55 | input_ = fromWKT("LINEARRING (0 0, 1 1, 2 0, 0 0)"); 56 | ensure_equals(GEOSGeomGetNumPoints(input_), 4); 57 | } 58 | 59 | } // namespace tut 60 | 61 | -------------------------------------------------------------------------------- /src/deps/ryu/ryu.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Ulf Adams 2 | // 3 | // The contents of this file may be used under the terms of the Apache License, 4 | // Version 2.0. 5 | // 6 | // (See accompanying file LICENSE-Apache or copy at 7 | // http://www.apache.org/licenses/LICENSE-2.0) 8 | // 9 | // Alternatively, the contents of this file may be used under the terms of 10 | // the Boost Software License, Version 1.0. 11 | // (See accompanying file LICENSE-Boost or copy at 12 | // https://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | // Unless required by applicable law or agreed to in writing, this software 15 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | // KIND, either express or implied. 17 | #ifndef RYU_H 18 | #define RYU_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | 26 | /* Print the shortest representation of a double using fixed notation 27 | * Only works for numbers smaller than 1e+17 (absolute value) 28 | * Precision limits the amount of digits of the decimal part 29 | */ 30 | int geos_d2sfixed_buffered_n(double f, uint32_t precision, char* result); 31 | 32 | /* Print the shortest representation of a double using scientific notation 33 | * Precision limits the amount of digits of the decimal part 34 | */ 35 | int geos_d2sexp_buffered_n(double f, uint32_t precision, char* result); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif // RYU_H 42 | -------------------------------------------------------------------------------- /src/operation/valid/PolygonRingTouch.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2021 Paul Ramsey 7 | * Copyright (C) 2021 Martin Davis 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | namespace geos { // geos 22 | namespace operation { // geos.operation 23 | namespace valid { // geos.operation.valid 24 | 25 | using namespace geos::geom; 26 | 27 | /* public */ 28 | const CoordinateXY* 29 | PolygonRingTouch::getCoordinate() const 30 | { 31 | return &touchPt; 32 | } 33 | 34 | /* public */ 35 | PolygonRing* 36 | PolygonRingTouch::getRing() const 37 | { 38 | return ring; 39 | } 40 | 41 | /* public */ 42 | bool 43 | PolygonRingTouch::isAtLocation(const CoordinateXY& pt) const 44 | { 45 | return touchPt.equals2D(pt); 46 | } 47 | 48 | 49 | } // namespace geos.operation.valid 50 | } // namespace geos.operation 51 | } // namespace geos 52 | -------------------------------------------------------------------------------- /benchmarks/geom/EnvelopePerfTest.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2021 Daniel Baston 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | 17 | #include 18 | 19 | using geos::geom::Coordinate; 20 | using geos::geom::Envelope; 21 | 22 | static void BM_EnvelopeIntersectsEnvelope(benchmark::State& state) { 23 | Envelope a = Envelope(2, 3, 4, 5); 24 | Envelope b = Envelope(6, 7, 8, 9); 25 | for (auto _ : state) { 26 | benchmark::DoNotOptimize(a.intersects(&b)); 27 | } 28 | } 29 | 30 | static void BM_CoordinateEnvelopeIntersectsEnvelope(benchmark::State& state) { 31 | Coordinate p0(2, 4); 32 | Coordinate p1(3, 5); 33 | Coordinate q0(7, 9); 34 | Coordinate q1(6, 8); 35 | 36 | for (auto _ : state) { 37 | benchmark::DoNotOptimize(Envelope::intersects(p0, p1, q0, q1)); 38 | } 39 | } 40 | 41 | BENCHMARK(BM_EnvelopeIntersectsEnvelope); 42 | BENCHMARK(BM_CoordinateEnvelopeIntersectsEnvelope); 43 | 44 | BENCHMARK_MAIN(); 45 | 46 | -------------------------------------------------------------------------------- /include/geos/simplify/RingHullIndex.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2021 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | 20 | namespace geos { 21 | namespace geom { 22 | class Envelope; 23 | } 24 | } 25 | 26 | namespace geos { 27 | namespace simplify { // geos::simplify 28 | 29 | 30 | class RingHullIndex 31 | { 32 | private: 33 | 34 | std::vector hulls; 35 | bool m_enabled; 36 | 37 | public: 38 | 39 | RingHullIndex() 40 | : m_enabled(true) 41 | {}; 42 | 43 | bool enabled(void) const { return m_enabled; }; 44 | void enabled(bool p_enabled) { m_enabled = p_enabled; }; 45 | void add(const RingHull* ringHull); 46 | std::vector query(const geos::geom::Envelope& queryEnv) const; 47 | std::size_t size() const; 48 | 49 | 50 | }; // RingHullIndex 51 | 52 | 53 | } // geos::simplify 54 | } // geos 55 | 56 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-586.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | http://trac.osgeo.org/geos/ticket/586 7 | 8 | 9 | 01060000000100000001030000000100000007000000FC9C4034A1C957C029FEFB19D9684A40F1502ADE523F56C061588FDD786C4C40417FBC44E19552C0D08D9DDB067C464089A1316892B753C02DCD95C08B6E4540BB379A190BBD54C058F25D2DADFE4440314E4AB97BC857C0C042B6CF69B74840FC9C4034A1C957C029FEFB19D9684A40 10 | 11 | 12 | 0102000020E61000001A0000009D11A5BDC19754C005172B6A305D454008944DB9C29754C0A1B94E232D5D454044FAEDEBC09754C07099D365315D45409D11A5BDC19754C05A0D897B2C5D454012DA722EC59754C07099D365315D4540793BC269C19754C07EE36BCF2C5D454008944DB9C29754C0936FB6B9315D4540C0E78711C29754C03012DA722E5D454020240B98C09754C0459E245D335D4540E4BD6A65C29754C0697407B1335D45409D11A5BDC19754C03012DA722E5D45408481E7DEC39754C0B745990D325D4540793BC269C19754C03012DA722E5D45402B6A300DC39754C04CC3F011315D454020240B98C09754C0697407B1335D454008944DB9C29754C0DA1B7C61325D454020240B98C09754C0A1B94E232D5D45402B6A300DC39754C0B745990D325D45409D11A5BDC19754C0C58F31772D5D4540D97745F0BF9754C0B745990D325D4540C0E78711C29754C04CC3F011315D4540793BC269C19754C01361C3D32B5D4540FD4D2844C09754C0BE6A65C22F5D454008944DB9C29754C0B745990D325D454020240B98C09754C03737A6272C5D4540C0E78711C29754C077BE9F1A2F5D4540 13 | 14 | 15 | true 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/geom/Curve.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2011 Sandro Santilli 7 | * Copyright (C) 2005-2006 Refractions Research Inc. 8 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 9 | * 10 | * This is free software; you can redistribute and/or modify it under 11 | * the terms of the GNU Lesser General Public Licence as published 12 | * by the Free Software Foundation. 13 | * See the COPYING file for more information. 14 | * 15 | **********************************************************************/ 16 | 17 | #include 18 | #include 19 | 20 | namespace geos { 21 | namespace geom { 22 | 23 | void 24 | Curve::apply_ro(GeometryComponentFilter* filter) const 25 | { 26 | assert(filter); 27 | filter->filter_ro(this); 28 | } 29 | 30 | void 31 | Curve::apply_ro(GeometryFilter* filter) const 32 | { 33 | assert(filter); 34 | filter->filter_ro(this); 35 | } 36 | 37 | void 38 | Curve::apply_rw(GeometryComponentFilter* filter) 39 | { 40 | assert(filter); 41 | filter->filter_rw(this); 42 | } 43 | 44 | void 45 | Curve::apply_rw(GeometryFilter* filter) 46 | { 47 | assert(filter); 48 | filter->filter_rw(this); 49 | } 50 | 51 | bool 52 | Curve::isRing() const 53 | { 54 | return isClosed() && isSimple(); 55 | } 56 | 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSCoveredByTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geoscoveredby_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geoscoveredby("capi::GEOSCoveredBy"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))"); 24 | geom2_ = fromWKT("POLYGON ((5 5, 5 7, 7 7, 7 5, 5 5))"); 25 | geom3_ = fromWKT("POLYGON ((20 20, 20 30, 30 30, 30 20, 20 20))"); 26 | 27 | ensure_equals(1, GEOSCoveredBy(geom2_, geom1_)); 28 | ensure_equals(0, GEOSCoveredBy(geom1_, geom2_)); 29 | ensure_equals(0, GEOSCoveredBy(geom1_, geom3_)); 30 | ensure_equals(0, GEOSCoveredBy(geom3_, geom1_)); 31 | ensure_equals(0, GEOSCoveredBy(geom2_, geom3_)); 32 | ensure_equals(0, GEOSCoveredBy(geom3_, geom2_)); 33 | } 34 | 35 | template<> 36 | template<> 37 | void object::test<2>() 38 | { 39 | geom1_ = fromWKT("LINESTRING (5 3, 5 4)"); 40 | geom2_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)))"); 41 | 42 | ensure(geom1_); 43 | ensure(geom2_); 44 | 45 | ensure_equals("curved geometry not supported", GEOSCoveredBy(geom1_, geom2_), 2); 46 | } 47 | 48 | } // namespace tut 49 | 50 | -------------------------------------------------------------------------------- /include/geos/io/Writer.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: ORIGINAL WORK to be used like java.io.Writer 17 | * 18 | **********************************************************************/ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include 25 | 26 | #ifdef _MSC_VER 27 | #pragma warning(push) 28 | #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 29 | #endif 30 | 31 | namespace geos { 32 | namespace io { 33 | 34 | class GEOS_DLL Writer { 35 | public: 36 | Writer(); 37 | void reserve(std::size_t capacity); 38 | ~Writer() = default; 39 | void write(const std::string& txt); 40 | const std::string& toString(); 41 | private: 42 | std::string str; 43 | }; 44 | 45 | } // namespace geos::io 46 | } // namespace geos 47 | 48 | #ifdef _MSC_VER 49 | #pragma warning(pop) 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /tests/xmltester/tests/issue/issue-geos-838.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Union of two valid polygons resulting in an invalid geometry in JTS 1.15. 6 | See https://trac.osgeo.org/geos/ticket/838. 7 | Failure is due to very close vertices leading to noding robustness failure. 8 | Fixed by improved noding validation detection, which allows 9 | snapping heuristic to be activated. 10 | 11 | 12 | 00000000060000000200000000030000000100000005412CD75B00000000413D8F0966666667412CD75933333333413D8F6D80000000412CD82166666667413D8F6E4CCCCCCD412CD82500000000413D8EA61999999A412CD75B00000000413D8F096666666700000000030000000100000005412CD82500000001413D8EA61999999A412CD82333333334413D8F0A33333333412CD8EB66666666413D8F0B19999999412CD8ED33333333413D8EA700000001412CD82500000001413D8EA61999999A 13 | 14 | 15 | 00000000030000000100000007412CD9D4D50CE8F7413D8EA7FBC39C12412CD8ED33333333413D8EA700000000412CD8EB66666667413D8F0B1999999A412CD82333333333413D8F0A33333333412CD82166666667413D8F6E4CCCCCCD412CD9B1CCCCCCCD413D8F701999999A412CD9D4D50CE8F7413D8EA7FBC39C12 16 | 17 | 18 | 19 | 010300000001000000080000003333333359D72C41000000806D8F3D416766666621D82C41CDCCCC4C6E8F3D41CDCCCCCCB1D92C419A999919708F3D41F7E80CD5D4D92C41129CC3FBA78E3D4133333333EDD82C4101000000A78E3D410000000025D82C419A999919A68E3D41000000005BD72C4167666666098F3D413333333359D72C41000000806D8F3D41 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/xmltester/tests/robust/overlay/TestOverlay-geos-838.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Union of two valid polygons resulting in an invalid geometry 6 | See https://trac.osgeo.org/geos/ticket/838 7 | 8 | 9 | 010600000002000000010300000001000000110000009A9999996ED32C4133333333CD8F3D41CDCCCCCC36D42C419A999919CE8F3D416766666638D42C41000000006A8F3D41CDCCCCCCC8D52C41333333B36B8F3D419A999999CAD52C419A999999078F3D41000000005BD72C4167666666098F3D413333333359D72C41000000806D8F3D416766666621D82C41CDCCCC4C6E8F3D410000000025D82C419A999919A68E3D419A99999994D62C4167666666A48E3D410000000098D62C4133333333DC8D3D419A99999907D52C4100000080DA8D3D416766666602D52C41CDCCCCCC068F3D41333333333AD42C41676666E6058F3D41000000003CD42C41CDCCCCCCA18E3D41CDCCCCCC73D32C41676666E6A08E3D419A9999996ED32C4133333333CD8F3D41010300000001000000050000000100000025D82C419A999919A68E3D413433333323D82C41333333330A8F3D4166666666EBD82C41999999190B8F3D4133333333EDD82C4101000000A78E3D410100000025D82C419A999919A68E3D41 10 | 11 | 12 | 0103000000010000000A000000696B6E2B55DA2C41DF30B9C0708F3D414E62109873DA2C4123DBF9FE468F3D414E6210D869DA2C41653BDFEF378F3D41F7E80CD5D4D92C41129CC3FBA78E3D4133333333EDD82C4100000000A78E3D4167666666EBD82C419A9999190B8F3D413333333323D82C41333333330A8F3D416766666621D82C41CDCCCC4C6E8F3D41CDCCCCCCB1D92C419A999919708F3D41696B6E2B55DA2C41DF30B9C0708F3D41 13 | 14 | 15 | true 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /include/geos/geom/util/NoOpGeometryOperation.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2020 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include // for inheritance 19 | 20 | // Forward declarations 21 | namespace geos { 22 | namespace geom { 23 | class Geometry; 24 | class CoordinateSequence; 25 | class GeometryFactory; 26 | } 27 | } 28 | 29 | namespace geos { 30 | namespace geom { // geos.geom 31 | namespace util { // geos.geom.util 32 | 33 | 34 | class GEOS_DLL NoOpGeometryOperation: public GeometryEditorOperation { 35 | 36 | public: 37 | 38 | /** 39 | * Return a newly created geometry, ownership to caller 40 | */ 41 | std::unique_ptr edit(const Geometry* geometry, 42 | const GeometryFactory* factory) override; 43 | 44 | ~NoOpGeometryOperation() override = default; 45 | }; 46 | 47 | 48 | 49 | } // namespace geos.geom.util 50 | } // namespace geos.geom 51 | } // namespace geos 52 | 53 | -------------------------------------------------------------------------------- /include/geos/io/ParseException.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: io/ParseException.java rev. 1.13 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace geos { 27 | namespace io { 28 | 29 | /** 30 | * \class ParseException 31 | * \brief Notifies a parsing error 32 | */ 33 | class GEOS_DLL ParseException : public util::GEOSException { 34 | 35 | public: 36 | 37 | ParseException(); 38 | 39 | ParseException(const std::string& msg); 40 | 41 | ParseException(const std::string& msg, const std::string& var); 42 | 43 | ParseException(const std::string& msg, double num); 44 | 45 | ~ParseException() noexcept override {} 46 | 47 | private: 48 | static std::string stringify(double num); 49 | }; 50 | 51 | } // namespace io 52 | } // namespace geos 53 | 54 | -------------------------------------------------------------------------------- /include/geos/index/strtree/GeometryItemDistance.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2016 Daniel Baston 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: index/strtree/GeometryItemDistance.java (JTS-1.14) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace geos { 25 | namespace index { 26 | namespace strtree { 27 | class GEOS_DLL GeometryItemDistance : public ItemDistance { 28 | public: 29 | /** 30 | * Computes the distance between two {@link Geometry} items, 31 | * using the {@link Geometry#distance(Geometry)} method. 32 | * 33 | * @param item1 an item which is a Geometry 34 | * @param item2 an item which is a Geometry 35 | * @return the distance between the geometries 36 | * @throws ClassCastException if either item is not a Geometry 37 | */ 38 | double distance(const ItemBoundable* item1, const ItemBoundable* item2) override; 39 | }; 40 | 41 | } 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /include/geos/util/IllegalArgumentException.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * Copyright (C) 2006 Refractions Research Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | namespace geos { 24 | namespace util { // geos::util 25 | 26 | /** 27 | * \brief Indicates one or more illegal arguments. 28 | * 29 | * This exception is thrown - for example - when 30 | * trying to apply set-theoretic methods to a 31 | * GeometryCollection object. 32 | */ 33 | class GEOS_DLL IllegalArgumentException: public GEOSException { 34 | public: 35 | IllegalArgumentException() 36 | : 37 | GEOSException("IllegalArgumentException", "") 38 | {} 39 | 40 | IllegalArgumentException(const std::string& msg) 41 | : 42 | GEOSException("IllegalArgumentException", msg) 43 | {} 44 | 45 | ~IllegalArgumentException() noexcept override {} 46 | }; 47 | 48 | } // namespace geos::util 49 | } // namespace geos 50 | 51 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSEnvelopeTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geosenvelope_data : public capitest::utility 13 | { 14 | void 15 | checkEnvelope(const char* wktIn, const char* wktExp) 16 | { 17 | input_ = fromWKT(wktIn); 18 | result_ = GEOSEnvelope(input_); 19 | expected_ = fromWKT(wktExp); 20 | ensure_geometry_equals(result_, expected_, 0); 21 | } 22 | 23 | }; 24 | 25 | typedef test_group group; 26 | typedef group::object object; 27 | 28 | group test_geosenvelope("capi::GEOSEnvelope"); 29 | 30 | // non-degenerate input 31 | template<> 32 | template<> 33 | void object::test<1>() 34 | { 35 | checkEnvelope( 36 | "LINESTRING (1 2, 4 5, 9 -2)", 37 | "POLYGON ((1 -2, 9 -2, 9 5, 1 5, 1 -2))" 38 | ); 39 | } 40 | 41 | // point input 42 | template<> 43 | template<> 44 | void object::test<2>() 45 | { 46 | checkEnvelope( 47 | "POINT (3 8)", 48 | "POINT (3 8)"); 49 | } 50 | 51 | // empty point input 52 | template<> 53 | template<> 54 | void object::test<3>() 55 | { 56 | checkEnvelope( 57 | "POINT EMPTY", 58 | "POINT EMPTY"); 59 | } 60 | 61 | // empty polygon input 62 | template<> 63 | template<> 64 | void object::test<4>() 65 | { 66 | checkEnvelope( 67 | "POLYGON EMPTY", 68 | "POINT EMPTY"); 69 | } 70 | 71 | } // namespace tut 72 | 73 | -------------------------------------------------------------------------------- /src/simplify/RingHullIndex.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2022 Paul Ramsey 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | **********************************************************************/ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | using geos::geom::Envelope; 21 | 22 | 23 | namespace geos { 24 | namespace simplify { // geos.simplify 25 | 26 | 27 | /* public */ 28 | void 29 | RingHullIndex::add(const RingHull* ringHull) 30 | { 31 | hulls.push_back(ringHull); 32 | } 33 | 34 | std::size_t 35 | RingHullIndex::size() const 36 | { 37 | return hulls.size(); 38 | } 39 | 40 | /* public */ 41 | std::vector 42 | RingHullIndex::query(const Envelope& queryEnv) const 43 | { 44 | std::vector result; 45 | for (auto hull : hulls) { 46 | const Envelope* envHull = hull->getEnvelope(); 47 | if (queryEnv.intersects(*envHull)) { 48 | result.push_back(hull); 49 | } 50 | } 51 | return result; 52 | } 53 | 54 | 55 | } // namespace geos.simplify 56 | } // namespace geos 57 | 58 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | GEOS Testing 2 | ============ 3 | 4 | ## Build locations 5 | 6 | Paths are given relative to GEOS root. 7 | Note some executables have different names. 8 | 9 | ### CMake 10 | 11 | * Executables are in build directory (usually `../build`) 12 | * `../build/bin/test_geos_unit` 13 | * `../build/bin/test_xmltester` 14 | 15 | ## Unit tests 16 | 17 | bin/test_geos_unit [name] [test number] 18 | 19 | The test name is the **tut group name** found in the unit test file on a line beginning `group` (e.g. like [this](https://github.com/libgeos/geos/blob/main/tests/unit/operation/buffer/BufferOpTest.cpp#L55). 20 | 21 | ### Run all unit tests 22 | 23 | bin/test_geos_unit 24 | 25 | ### Run single unit test class 26 | 27 | bin/test_geos_unit capi::GEOSNode 28 | 29 | ### Run single test within unit test class 30 | 31 | bin/test_geos_unit capi::GEOSNode 1 32 | 33 | ## XML Tests 34 | 35 | xmltester [options] test-file ... 36 | 37 | ### Options 38 | 39 | * `-v` - show test case summary with time 40 | * `-v -v` - show test case info including dump of geometry 41 | 42 | CMake - Run test file 43 | 44 | bin/test_xmltester ../geos/tests/xmltester/tests/general/TestBoundary.xml 45 | 46 | ## Adding New Tests 47 | 48 | * In order for new unit tests to be picked up by the test harness, they **must** be named using the name pattern "\*Test.cpp". 49 | * In order for new XML tests to be picked up, they must reside in a directory under the `xmltester/` directory and have a `.xml` file suffix. 50 | 51 | 52 | -------------------------------------------------------------------------------- /include/geos/index/intervalrtree/IntervalRTreeLeafNode.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2006 Refractions Research Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | * 14 | **********************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include // inherited 19 | 20 | 21 | // forward declarations 22 | namespace geos { 23 | namespace index { 24 | class ItemVisitor; 25 | } 26 | } 27 | 28 | 29 | namespace geos { 30 | namespace index { 31 | namespace intervalrtree { 32 | 33 | class IntervalRTreeLeafNode : public IntervalRTreeNode { 34 | private: 35 | /// externally owned 36 | void* item; 37 | 38 | protected: 39 | public: 40 | 41 | /// @param p_item externally owned 42 | IntervalRTreeLeafNode(double p_min, double p_max, void* p_item) 43 | : IntervalRTreeNode(p_min, p_max), 44 | item(p_item) 45 | { } 46 | 47 | ~IntervalRTreeLeafNode() override 48 | { 49 | } 50 | 51 | void query(double queryMin, double queryMax, index::ItemVisitor* visitor) const override; 52 | 53 | }; 54 | 55 | } // geos::intervalrtree 56 | } // geos::index 57 | } // geos 58 | 59 | -------------------------------------------------------------------------------- /src/operation/linemerge/LineMergeEdge.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2005-2006 Refractions Research Inc. 7 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 8 | * 9 | * This is free software; you can redistribute and/or modify it under 10 | * the terms of the GNU Lesser General Public Licence as published 11 | * by the Free Software Foundation. 12 | * See the COPYING file for more information. 13 | * 14 | ********************************************************************** 15 | * 16 | * Last port: operation/linemerge/LineMergeEdge.java r378 (JTS-1.12) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | 22 | using namespace geos::geom; 23 | 24 | namespace geos { 25 | namespace operation { // geos.operation 26 | namespace linemerge { // geos.operation.linemerge 27 | 28 | /** 29 | * Constructs a LineMergeEdge with vertices given by the specified LineString. 30 | */ 31 | LineMergeEdge::LineMergeEdge(const LineString* newLine): 32 | line(newLine) 33 | { 34 | //line=newLine; 35 | } 36 | 37 | /** 38 | * Returns the LineString specifying the vertices of this edge. 39 | */ 40 | const LineString* 41 | LineMergeEdge::getLine() const 42 | { 43 | return line; 44 | } 45 | 46 | } // namespace geos.operation.linemerge 47 | } // namespace geos.operation 48 | } // namespace geos 49 | -------------------------------------------------------------------------------- /capi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Part of CMake configuration for GEOS 3 | # 4 | # Copyright (C) 2018 Mateusz Loskot 5 | # 6 | # This is free software; you can redistribute and/or modify it under 7 | # the terms of the GNU Lesser General Public Licence as published 8 | # by the Free Software Foundation. 9 | # See the COPYING file for more information. 10 | ################################################################################ 11 | 12 | file(GLOB_RECURSE _headers ${CMAKE_CURRENT_LIST_DIR}/*.cpp CONFIGURE_DEPEND) 13 | target_sources(geos_c PRIVATE ${_headers}) 14 | unset(_headers) 15 | 16 | target_include_directories(geos_c 17 | PUBLIC 18 | $ 19 | $) 20 | 21 | target_include_directories(geos_c 22 | INTERFACE 23 | $ 24 | $ 25 | $) 26 | 27 | # Copy these over so they match the @VARIABLES@ used by autoconf 28 | # in geos_c.h.in 29 | set(VERSION ${GEOS_VERSION}) 30 | set(VERSION_MAJOR ${GEOS_VERSION_MAJOR}) 31 | set(VERSION_MINOR ${GEOS_VERSION_MINOR}) 32 | set(VERSION_PATCH ${GEOS_VERSION_PATCH}) 33 | 34 | configure_file( 35 | ${CMAKE_CURRENT_LIST_DIR}/geos_c.h.in 36 | ${CMAKE_CURRENT_BINARY_DIR}/geos_c.h 37 | @ONLY) 38 | 39 | unset(VERSION) 40 | unset(VERSION_MAJOR) 41 | unset(VERSION_MINOR) 42 | unset(VERSION_PATCH) 43 | -------------------------------------------------------------------------------- /src/index/chain/MonotoneChainOverlapAction.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 | * 8 | * This is free software; you can redistribute and/or modify it under 9 | * the terms of the GNU Lesser General Public Licence as published 10 | * by the Free Software Foundation. 11 | * See the COPYING file for more information. 12 | * 13 | ********************************************************************** 14 | * 15 | * Last port: index/chain/MonotoneChainOverlapAction.java rev. 1.6 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | //#include 26 | 27 | namespace geos { 28 | namespace index { // geos.index 29 | namespace chain { // geos.index.chain 30 | 31 | void 32 | MonotoneChainOverlapAction::overlap(const MonotoneChain& mc1, std::size_t start1, 33 | const MonotoneChain& mc2, std::size_t start2) 34 | { 35 | mc1.getLineSegment(start1, overlapSeg1); 36 | mc2.getLineSegment(start2, overlapSeg2); 37 | overlap(overlapSeg1, overlapSeg2); 38 | } 39 | 40 | } // namespace geos.index.chain 41 | } // namespace geos.index 42 | } // namespace geos 43 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSTouchesTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // geos 3 | #include 4 | 5 | #include "capi_test_utils.h" 6 | 7 | namespace tut { 8 | // 9 | // Test Group 10 | // 11 | 12 | struct test_geostouches_data : public capitest::utility {}; 13 | 14 | typedef test_group group; 15 | typedef group::object object; 16 | 17 | group test_geostouches("capi::GEOSTouches"); 18 | 19 | template<> 20 | template<> 21 | void object::test<1>() 22 | { 23 | geom1_ = fromWKT("LINESTRING (1 1, 10 1)"); 24 | ensure(nullptr != geom1_); 25 | geom2_ = fromWKT("LINESTRING (5 1, 5 10)"); 26 | ensure(nullptr != geom2_); 27 | geom3_ = fromWKT("LINESTRING (20 20, 30 30)"); 28 | ensure(nullptr != geom3_); 29 | 30 | ensure_equals(1, GEOSTouches(geom1_, geom2_)); 31 | ensure_equals(1, GEOSTouches(geom2_, geom1_)); 32 | ensure_equals(0, GEOSTouches(geom1_, geom3_)); 33 | ensure_equals(0, GEOSTouches(geom3_, geom1_)); 34 | ensure_equals(0, GEOSTouches(geom2_, geom3_)); 35 | ensure_equals(0, GEOSTouches(geom3_, geom2_)); 36 | } 37 | 38 | template<> 39 | template<> 40 | void object::test<2>() 41 | { 42 | geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); 43 | geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); 44 | 45 | ensure(geom1_); 46 | ensure(geom2_); 47 | 48 | ensure_equals("curved geometry not supported", GEOSTouches(geom1_, geom2_), 2); 49 | ensure_equals("curved geometry not supported", GEOSTouches(geom2_, geom1_), 2); 50 | } 51 | 52 | } // namespace tut 53 | 54 | -------------------------------------------------------------------------------- /tests/unit/capi/GEOSUserDataTest.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Test Suite for C-API GEOSGeom_setUserData 3 | 4 | #include 5 | // geos 6 | #include 7 | 8 | #include "capi_test_utils.h" 9 | 10 | namespace tut { 11 | // 12 | // Test Group 13 | // 14 | 15 | // Common data used in test cases. 16 | struct test_capigeouserdata_data : public capitest::utility {}; 17 | 18 | typedef test_group group; 19 | typedef group::object object; 20 | 21 | group test_capigeosuserdata_group("capi::GEOSUserData"); 22 | 23 | // 24 | // Test Cases 25 | // 26 | 27 | // Test GEOSUserData 28 | template<> 29 | template<> 30 | void object::test<1> 31 | () 32 | { 33 | geom1_ = GEOSGeomFromWKT("POLYGON EMPTY"); 34 | 35 | ensure(0 != GEOSisEmpty(geom1_)); 36 | 37 | int in = 1; 38 | GEOSGeom_setUserData(geom1_, &in); 39 | 40 | int* out = (int*)GEOSGeom_getUserData(geom1_); 41 | 42 | ensure_equals(*out, 1); 43 | } 44 | 45 | struct UserData { 46 | int a; 47 | int b; 48 | } ; 49 | 50 | template<> 51 | template<> 52 | void object::test<2> 53 | () 54 | { 55 | geom1_ = GEOSGeomFromWKT("POLYGON EMPTY"); 56 | 57 | ensure(0 != GEOSisEmpty(geom1_)); 58 | 59 | UserData in; 60 | in.a = 1; 61 | in.b = 2; 62 | 63 | GEOSGeom_setUserData(geom1_, &in); 64 | 65 | struct UserData* out = (struct UserData*)GEOSGeom_getUserData(geom1_); 66 | 67 | ensure_equals(in.a, out->a); 68 | ensure_equals(in.b, out->b); 69 | ensure_equals(&in, out); 70 | } 71 | 72 | } // namespace tut 73 | 74 | --------------------------------------------------------------------------------