├── .github └── workflows │ └── main.yml ├── .gitignore ├── .gitmodules ├── .vscode └── settings.json ├── CMakeLists.txt ├── Makefile ├── README.md ├── examples └── embedded-c++ │ ├── CMakeLists.txt │ ├── Makefile │ └── main.cpp ├── geo ├── CMakeLists.txt ├── COPYING ├── LICENSE.TXT ├── geo-extension.cpp ├── geo-functions.cpp ├── geometry.cpp ├── include │ ├── accessor-functions.hpp │ ├── constructor-functions.hpp │ ├── formatter-functions.hpp │ ├── geo-extension.hpp │ ├── geo-functions.hpp │ ├── geo_aggregate_function.hpp │ ├── geometry.hpp │ ├── lib │ │ └── ryu.hpp │ ├── liblwgeom │ │ ├── gserialized.hpp │ │ ├── gserialized1.hpp │ │ ├── gserialized2.hpp │ │ ├── liblwgeom.hpp │ │ ├── liblwgeom_internal.hpp │ │ ├── lwgeodetic.hpp │ │ ├── lwgeodetic_tree.hpp │ │ ├── lwgeom_geos.hpp │ │ ├── lwin_wkt.hpp │ │ ├── lwinline.hpp │ │ ├── lwunionfind.hpp │ │ ├── measures.hpp │ │ ├── postigs_config.hpp │ │ └── stringbuffer.hpp │ ├── libpgcommon │ │ ├── lwgeom_pg.hpp │ │ └── lwgeom_transform.hpp │ ├── measure-functions.hpp │ ├── parser-functions.hpp │ ├── parser │ │ └── lwin_wkt_parse.hpp │ ├── postgis.hpp │ ├── postgis │ │ ├── geography.hpp │ │ ├── geography_centroid.hpp │ │ ├── geography_inout.hpp │ │ ├── geography_measurement.hpp │ │ ├── geography_measurement_trees.hpp │ │ ├── lwgeom_box.hpp │ │ ├── lwgeom_dump.hpp │ │ ├── lwgeom_export.hpp │ │ ├── lwgeom_functions_analytic.hpp │ │ ├── lwgeom_functions_basic.hpp │ │ ├── lwgeom_geos.hpp │ │ ├── lwgeom_in_geohash.hpp │ │ ├── lwgeom_inout.hpp │ │ ├── lwgeom_ogc.hpp │ │ └── lwgeom_window.hpp │ ├── postgres.hpp │ ├── predicate-functions.hpp │ └── transformation-functions.hpp ├── lib │ └── ryu.cpp ├── liblwgeom │ ├── gbox.cpp │ ├── gserialized.cpp │ ├── gserialized1.cpp │ ├── gserialized2.cpp │ ├── lwalgorithm.cpp │ ├── lwcircstring.cpp │ ├── lwcollection.cpp │ ├── lwcompound.cpp │ ├── lwcurvepoly.cpp │ ├── lwgeodetic.cpp │ ├── lwgeodetic_tree.cpp │ ├── lwgeom.cpp │ ├── lwgeom_api.cpp │ ├── lwgeom_geos.cpp │ ├── lwgeom_geos_cluster.cpp │ ├── lwin_geojson.cpp │ ├── lwin_wkb.cpp │ ├── lwin_wkt.cpp │ ├── lwiterator.cpp │ ├── lwline.cpp │ ├── lwmline.cpp │ ├── lwmpoint.cpp │ ├── lwmpoly.cpp │ ├── lwout_geojson.cpp │ ├── lwout_wkb.cpp │ ├── lwout_wkt.cpp │ ├── lwpoint.cpp │ ├── lwpoly.cpp │ ├── lwprint.cpp │ ├── lwpsurface.cpp │ ├── lwspheroid.cpp │ ├── lwstroke.cpp │ ├── lwtin.cpp │ ├── lwtriangle.cpp │ ├── lwunionfind.cpp │ ├── lwutil.cpp │ ├── measures.cpp │ ├── ptarray.cpp │ └── stringbuffer.cpp ├── libpgcommon │ ├── lwgeom_pg.cpp │ └── lwgeom_transform.cpp ├── parser │ ├── lwin_wkt_lex.cpp │ ├── lwin_wkt_lex.l │ ├── lwin_wkt_parse.cpp │ └── lwin_wkt_parse.y ├── postgis.cpp ├── postgis │ ├── geography_centroid.cpp │ ├── geography_inout.cpp │ ├── geography_measurement.cpp │ ├── geography_measurement_trees.cpp │ ├── gserialized_typmod.cpp │ ├── lwgeom_box.cpp │ ├── lwgeom_dump.cpp │ ├── lwgeom_export.cpp │ ├── lwgeom_functions_analytic.cpp │ ├── lwgeom_functions_basic.cpp │ ├── lwgeom_geos.cpp │ ├── lwgeom_in_geohash.cpp │ ├── lwgeom_in_geojson.cpp │ ├── lwgeom_inout.cpp │ ├── lwgeom_ogc.cpp │ └── lwgeom_window.cpp └── third_party │ ├── CMakeLists.txt │ ├── geos │ ├── CMakeLists.txt │ ├── algorithm │ │ ├── Angle.cpp │ │ ├── Area.cpp │ │ ├── BoundaryNodeRule.cpp │ │ ├── CGAlgorithumsDD.cpp │ │ ├── Centroid.cpp │ │ ├── ConvexHull.cpp │ │ ├── Distance.cpp │ │ ├── Intersection.cpp │ │ ├── Length.cpp │ │ ├── LineIntersector.cpp │ │ ├── Orientation.cpp │ │ ├── PointLocation.cpp │ │ ├── PointLocator.cpp │ │ ├── PolygonNodeTopology.cpp │ │ ├── RayCrossingCounter.cpp │ │ └── locate │ │ │ ├── IndexedPointInAreaLocator.cpp │ │ │ └── SimplePointInAreaLocator.cpp │ ├── edgegraph │ │ └── HalfEdge.cpp │ ├── geom │ │ ├── Coordinate.cpp │ │ ├── CoordinateArraySequence.cpp │ │ ├── CoordinateSequence.cpp │ │ ├── DefaultCoordinateSequencefactory.cpp │ │ ├── Dimension.cpp │ │ ├── Envelope.cpp │ │ ├── Geometry.cpp │ │ ├── GeometryCollection.cpp │ │ ├── GeometryComponentFilter.cpp │ │ ├── GeometryFactory.cpp │ │ ├── HeuristicOverlay.cpp │ │ ├── IntersectionMatrix.cpp │ │ ├── LineSegment.cpp │ │ ├── LineString.cpp │ │ ├── LinearRing.cpp │ │ ├── Location.cpp │ │ ├── MultiLineString.cpp │ │ ├── MultiPoint.cpp │ │ ├── MultiPolygon.cpp │ │ ├── Point.cpp │ │ ├── Polygon.cpp │ │ ├── Position.cpp │ │ ├── PrecisionModel.cpp │ │ ├── Triangle.cpp │ │ └── util │ │ │ ├── CoordinateOperation.cpp │ │ │ ├── GeometryCombiner.cpp │ │ │ ├── GeometryEditor.cpp │ │ │ ├── GeometryTransformer.cpp │ │ │ ├── LinearComponentExtracter.cpp │ │ │ ├── NoOpGeometryOperation.cpp │ │ │ └── ShortCircuitedGeometryVisitor.cpp │ ├── geomgraph │ │ ├── Depth.cpp │ │ ├── DirectedEdge.cpp │ │ ├── DirectedEdgeStar.cpp │ │ ├── Edge.cpp │ │ ├── EdgeEnd.cpp │ │ ├── EdgeEndStar.cpp │ │ ├── EdgeIntersectionList.cpp │ │ ├── EdgeList.cpp │ │ ├── EdgeNodingValidator.cpp │ │ ├── EdgeRing.cpp │ │ ├── GeometryGraph.cpp │ │ ├── GraphComponent.cpp │ │ ├── Node.cpp │ │ ├── NodeFactory.cpp │ │ ├── NodeMap.cpp │ │ ├── PlanarGraph.cpp │ │ ├── PlannarGraph.cpp │ │ ├── TopologyLocation.cpp │ │ └── index │ │ │ ├── MonotoneChainEdge.cpp │ │ │ ├── MonotoneChainIndexer.cpp │ │ │ ├── SegmentIntersector.cpp │ │ │ ├── SimpleMCSweepLineIntersector.cpp │ │ │ └── SweepLineEvent.cpp │ ├── geos_c.cpp │ ├── geos_ts_c.cpp │ ├── include │ │ ├── geos │ │ │ ├── algorithm │ │ │ │ ├── Angle.hpp │ │ │ │ ├── Area.hpp │ │ │ │ ├── BoundaryNodeRule.hpp │ │ │ │ ├── CGAlgorithmsDD.hpp │ │ │ │ ├── Centroid.hpp │ │ │ │ ├── ConvexHull.hpp │ │ │ │ ├── Distance.hpp │ │ │ │ ├── Intersection.hpp │ │ │ │ ├── Length.hpp │ │ │ │ ├── LineIntersector.hpp │ │ │ │ ├── Orientation.hpp │ │ │ │ ├── PointLocation.hpp │ │ │ │ ├── PointLocator.hpp │ │ │ │ ├── PolygonNodeTopology.hpp │ │ │ │ ├── RayCrossingCounter.hpp │ │ │ │ └── locate │ │ │ │ │ ├── IndexedPointInAreaLocator.hpp │ │ │ │ │ ├── PointOnGeometryLocator.hpp │ │ │ │ │ └── SimplePointInAreaLocator.hpp │ │ │ ├── constants.hpp │ │ │ ├── edgegraph │ │ │ │ └── HalfEdge.hpp │ │ │ ├── export.hpp │ │ │ ├── geom │ │ │ │ ├── Coordinate.hpp │ │ │ │ ├── CoordinateArraySequence.hpp │ │ │ │ ├── CoordinateFilter.hpp │ │ │ │ ├── CoordinateList.hpp │ │ │ │ ├── CoordinateSequence.hpp │ │ │ │ ├── CoordinateSequenceFactory.hpp │ │ │ │ ├── CoordinateSequenceFilter.hpp │ │ │ │ ├── CoordinateSequenceIterator.hpp │ │ │ │ ├── DefaultCoordinateSequenceFactory.hpp │ │ │ │ ├── Dimension.hpp │ │ │ │ ├── Envelope.hpp │ │ │ │ ├── FixedSizeCoordinateSequence.hpp │ │ │ │ ├── Geometry.hpp │ │ │ │ ├── GeometryCollection.hpp │ │ │ │ ├── GeometryComponentFilter.hpp │ │ │ │ ├── GeometryFactory.hpp │ │ │ │ ├── GeometryFilter.hpp │ │ │ │ ├── HeuristicOverlay.hpp │ │ │ │ ├── IntersectionMatrix.hpp │ │ │ │ ├── LineSegment.hpp │ │ │ │ ├── LineString.hpp │ │ │ │ ├── LinearRing.hpp │ │ │ │ ├── Location.hpp │ │ │ │ ├── MultiLineString.hpp │ │ │ │ ├── MultiPoint.hpp │ │ │ │ ├── MultiPolygon.hpp │ │ │ │ ├── Point.hpp │ │ │ │ ├── Polygon.hpp │ │ │ │ ├── Position.hpp │ │ │ │ ├── PrecisionModel.hpp │ │ │ │ ├── Quadrant.hpp │ │ │ │ ├── Triangle.hpp │ │ │ │ └── util │ │ │ │ │ ├── CoordinateOperation.hpp │ │ │ │ │ ├── GeometryCombiner.hpp │ │ │ │ │ ├── GeometryEditor.hpp │ │ │ │ │ ├── GeometryEditorOperation.hpp │ │ │ │ │ ├── GeometryExtracter.hpp │ │ │ │ │ ├── GeometryTransformer.hpp │ │ │ │ │ ├── LinearComponentExtracter.hpp │ │ │ │ │ ├── NoOpGeometryOperation.hpp │ │ │ │ │ └── ShortCircuitedGeometryVisitor.hpp │ │ │ ├── geomgraph │ │ │ │ ├── Depth.hpp │ │ │ │ ├── DirectedEdge.hpp │ │ │ │ ├── DirectedEdgeStar.hpp │ │ │ │ ├── Edge.hpp │ │ │ │ ├── EdgeEnd.hpp │ │ │ │ ├── EdgeEndStar.hpp │ │ │ │ ├── EdgeIntersection.hpp │ │ │ │ ├── EdgeIntersectionList.hpp │ │ │ │ ├── EdgeList.hpp │ │ │ │ ├── EdgeNodingValidator.hpp │ │ │ │ ├── EdgeRing.hpp │ │ │ │ ├── GeometryGraph.hpp │ │ │ │ ├── GraphComponent.hpp │ │ │ │ ├── Label.hpp │ │ │ │ ├── Node.hpp │ │ │ │ ├── NodeFactory.hpp │ │ │ │ ├── NodeMap.hpp │ │ │ │ ├── PlanarGraph.hpp │ │ │ │ ├── TopologyLocation.hpp │ │ │ │ └── index │ │ │ │ │ ├── EdgeSetIntersector.hpp │ │ │ │ │ ├── MonotoneChain.hpp │ │ │ │ │ ├── MonotoneChainEdge.hpp │ │ │ │ │ ├── MonotoneChainIndexer.hpp │ │ │ │ │ ├── SegmentIntersector.hpp │ │ │ │ │ ├── SimpleMCSweepLineIntersector.hpp │ │ │ │ │ ├── SweepLineEvent.hpp │ │ │ │ │ └── SweepLineEventObj.hpp │ │ │ ├── index │ │ │ │ ├── ItemVisitor.hpp │ │ │ │ ├── SpatialIndex.hpp │ │ │ │ ├── chain │ │ │ │ │ ├── MonotoneChain.hpp │ │ │ │ │ ├── MonotoneChainBuilder.hpp │ │ │ │ │ └── MonotoneChainOverlapAction.hpp │ │ │ │ ├── kdtree │ │ │ │ │ ├── KdNode.hpp │ │ │ │ │ ├── KdNodeVisitor.hpp │ │ │ │ │ └── KdTree.hpp │ │ │ │ └── strtree │ │ │ │ │ ├── Boundable.hpp │ │ │ │ │ ├── Interval.hpp │ │ │ │ │ ├── ItemBoundable.hpp │ │ │ │ │ ├── STRtree.hpp │ │ │ │ │ ├── SimpleSTRnode.hpp │ │ │ │ │ ├── SimpleSTRtree.hpp │ │ │ │ │ ├── TemplateSTRNode.hpp │ │ │ │ │ └── TemplateSTRtree.hpp │ │ │ ├── math │ │ │ │ └── DD.hpp │ │ │ ├── noding │ │ │ │ ├── BasicSegmentString.hpp │ │ │ │ ├── FastNodingValidator.hpp │ │ │ │ ├── IntersectionAdder.hpp │ │ │ │ ├── IntersectionFinderAdder.hpp │ │ │ │ ├── MCIndexNoder.hpp │ │ │ │ ├── NodableSegmentString.hpp │ │ │ │ ├── NodedSegmentString.hpp │ │ │ │ ├── Noder.hpp │ │ │ │ ├── NodingIntersectionFinder.hpp │ │ │ │ ├── NodingValidator.hpp │ │ │ │ ├── Octant.hpp │ │ │ │ ├── OrientedCoordinateArray.hpp │ │ │ │ ├── ScaledNoder.hpp │ │ │ │ ├── SegmentIntersector.hpp │ │ │ │ ├── SegmentNode.hpp │ │ │ │ ├── SegmentNodeList.hpp │ │ │ │ ├── SegmentPointComparator.hpp │ │ │ │ ├── SegmentString.hpp │ │ │ │ ├── SinglePassNoder.hpp │ │ │ │ ├── ValidatingNoder.hpp │ │ │ │ ├── snap │ │ │ │ │ ├── SnappingIntersectionAdder.hpp │ │ │ │ │ ├── SnappingNoder.hpp │ │ │ │ │ └── SnappingPointIndex.hpp │ │ │ │ └── snapround │ │ │ │ │ ├── HotPixel.hpp │ │ │ │ │ ├── HotPixelIndex.hpp │ │ │ │ │ ├── MCIndexPointSnapper.hpp │ │ │ │ │ ├── MCIndexSnapRounder.hpp │ │ │ │ │ ├── SnapRoundingIntersectionAdder.hpp │ │ │ │ │ └── SnapRoundingNoder.hpp │ │ │ ├── operation │ │ │ │ ├── BoundaryOp.hpp │ │ │ │ ├── GeometryGraphOperation.hpp │ │ │ │ ├── buffer │ │ │ │ │ ├── BufferBuilder.hpp │ │ │ │ │ ├── BufferCurveSetBuilder.hpp │ │ │ │ │ ├── BufferInputLineSimplifier.hpp │ │ │ │ │ ├── BufferOp.hpp │ │ │ │ │ ├── BufferParameters.hpp │ │ │ │ │ ├── BufferSubgraph.hpp │ │ │ │ │ ├── OffsetCurveBuilder.hpp │ │ │ │ │ ├── OffsetSegmentGenerator.hpp │ │ │ │ │ ├── OffsetSegmentString.hpp │ │ │ │ │ ├── RightmostEdgeFinder.hpp │ │ │ │ │ └── SubgraphDepthLocater.hpp │ │ │ │ ├── overlay │ │ │ │ │ ├── ElevationMatrix.hpp │ │ │ │ │ ├── ElevationMatrixCell.hpp │ │ │ │ │ ├── LineBuilder.hpp │ │ │ │ │ ├── MaximalEdgeRing.hpp │ │ │ │ │ ├── MinimalEdgeRing.hpp │ │ │ │ │ ├── OverlayNodeFactory.hpp │ │ │ │ │ ├── OverlayOp.hpp │ │ │ │ │ ├── PointBuilder.hpp │ │ │ │ │ ├── PolygonBuilder.hpp │ │ │ │ │ └── snap │ │ │ │ │ │ ├── GeometrySnapper.hpp │ │ │ │ │ │ └── LineStringSnapper.hpp │ │ │ │ ├── overlayng │ │ │ │ │ ├── Edge.hpp │ │ │ │ │ ├── EdgeKey.hpp │ │ │ │ │ ├── EdgeMerger.hpp │ │ │ │ │ ├── EdgeNodingBuilder.hpp │ │ │ │ │ ├── EdgeSourceInfo.hpp │ │ │ │ │ ├── ElevationModel.hpp │ │ │ │ │ ├── IndexedPointOnLineLocator.hpp │ │ │ │ │ ├── InputGeometry.hpp │ │ │ │ │ ├── IntersectionPointBuilder.hpp │ │ │ │ │ ├── LineBuilder.hpp │ │ │ │ │ ├── LineLimiter.hpp │ │ │ │ │ ├── MaximalEdgeRing.hpp │ │ │ │ │ ├── OverlayEdge.hpp │ │ │ │ │ ├── OverlayEdgeRing.hpp │ │ │ │ │ ├── OverlayGraph.hpp │ │ │ │ │ ├── OverlayLabel.hpp │ │ │ │ │ ├── OverlayLabeller.hpp │ │ │ │ │ ├── OverlayMixedPoints.hpp │ │ │ │ │ ├── OverlayNG.hpp │ │ │ │ │ ├── OverlayNGRobust.hpp │ │ │ │ │ ├── OverlayPoints.hpp │ │ │ │ │ ├── OverlayUtil.hpp │ │ │ │ │ ├── PolygonBuilder.hpp │ │ │ │ │ ├── PrecisionReducer.hpp │ │ │ │ │ ├── PrecisionUtil.hpp │ │ │ │ │ ├── RingClipper.hpp │ │ │ │ │ └── RobustClipEnvelopeComputer.hpp │ │ │ │ ├── polygonize │ │ │ │ │ └── EdgeRing.hpp │ │ │ │ ├── predicate │ │ │ │ │ ├── RectangleContains.hpp │ │ │ │ │ ├── RectangleIntersects.hpp │ │ │ │ │ └── SegmentIntersectionTester.hpp │ │ │ │ ├── relate │ │ │ │ │ ├── EdgeEndBuilder.hpp │ │ │ │ │ ├── EdgeEndBundle.hpp │ │ │ │ │ ├── EdgeEndBundleStar.hpp │ │ │ │ │ ├── RelateComputer.hpp │ │ │ │ │ ├── RelateNode.hpp │ │ │ │ │ ├── RelateNodeFactory.hpp │ │ │ │ │ └── RelateOp.hpp │ │ │ │ ├── union │ │ │ │ │ ├── CascadedPolygonUnion.hpp │ │ │ │ │ ├── PointGeometryUnion.hpp │ │ │ │ │ ├── UnaryUnionOp.hpp │ │ │ │ │ └── UnionStrategy.hpp │ │ │ │ └── valid │ │ │ │ │ ├── IndexedNestedHoleTester.hpp │ │ │ │ │ ├── IndexedNestedPolygonTester.hpp │ │ │ │ │ ├── IsSimpleOp.hpp │ │ │ │ │ ├── IsValidOp.hpp │ │ │ │ │ ├── PolygonIntersectionAnalyzer.hpp │ │ │ │ │ ├── PolygonRing.hpp │ │ │ │ │ ├── PolygonRingSelfNode.hpp │ │ │ │ │ ├── PolygonRingTouch.hpp │ │ │ │ │ ├── PolygonTopologyAnalyzer.hpp │ │ │ │ │ ├── RepeatedPointRemover.hpp │ │ │ │ │ ├── RepeatedPointTester.hpp │ │ │ │ │ └── TopologyValidationError.hpp │ │ │ ├── precision │ │ │ │ ├── CommonBits.hpp │ │ │ │ ├── CommonBitsRemover.hpp │ │ │ │ ├── GeometryPrecisionReducer.hpp │ │ │ │ ├── PointwisePrecisionReducerTransformer.hpp │ │ │ │ ├── PrecisionReducerCoordinateOperation.hpp │ │ │ │ └── PrecisionReducerTransformer.hpp │ │ │ ├── util.hpp │ │ │ └── util │ │ │ │ ├── Assert.hpp │ │ │ │ ├── AssertionFailedException.hpp │ │ │ │ ├── GEOSException.hpp │ │ │ │ ├── IllegalArgumentException.hpp │ │ │ │ ├── IllegalStateException.hpp │ │ │ │ ├── Interrupt.hpp │ │ │ │ ├── Machine.hpp │ │ │ │ ├── TopologyException.hpp │ │ │ │ ├── UniqueCoordinateArrayFilter.hpp │ │ │ │ ├── UnsupportedOperationException.hpp │ │ │ │ └── math.hpp │ │ └── geos_c.hpp │ ├── index │ │ ├── chain │ │ │ ├── MonotoneChain.cpp │ │ │ ├── MonotoneChainBuilder.cpp │ │ │ └── MonotoneChainOverlapAction.cpp │ │ ├── kdtree │ │ │ ├── KdNode.cpp │ │ │ └── KdTree.cpp │ │ └── strtree │ │ │ ├── SimpleSTRnode.cpp │ │ │ └── SimpleSTRtree.cpp │ ├── math │ │ └── DD.cpp │ ├── noding │ │ ├── FastNodingValidator.cpp │ │ ├── IntersectionAdder.cpp │ │ ├── IntersectionFinderAdder.cpp │ │ ├── MCIndexNoder.cpp │ │ ├── NodedSegmentString.cpp │ │ ├── NodingIntersectionFinder.cpp │ │ ├── NodingValidator.cpp │ │ ├── Octant.cpp │ │ ├── OrientedCoordinateArray.cpp │ │ ├── ScaledNoder.cpp │ │ ├── SegmentNode.cpp │ │ ├── SegmentNodeList.cpp │ │ ├── ValidatingNoder.cpp │ │ ├── snap │ │ │ ├── SnappingIntersectionAdder.cpp │ │ │ ├── SnappingNoder.cpp │ │ │ └── SnappingPointIndex.cpp │ │ └── snapround │ │ │ ├── HotPixel.cpp │ │ │ ├── HotPixelIndex.cpp │ │ │ ├── SnapRoundingIntersectionAdder.cpp │ │ │ └── SnapRoundingNoder.cpp │ ├── operation │ │ ├── BoundaryOp.cpp │ │ ├── GeometryGraphOperation.cpp │ │ ├── buffer │ │ │ ├── BufferBuilder.cpp │ │ │ ├── BufferCurveSetBuilder.cpp │ │ │ ├── BufferInputLineSimplifier.cpp │ │ │ ├── BufferOp.cpp │ │ │ ├── BufferParameters.cpp │ │ │ ├── BufferSubgraph.cpp │ │ │ ├── OffsetCurveBuilder.cpp │ │ │ ├── OffsetSegmentGenerator.cpp │ │ │ ├── RightmostEdgeFinder.cpp │ │ │ └── SubgraphDepthLocater.cpp │ │ ├── overlay │ │ │ ├── ElevationMatrix.cpp │ │ │ ├── ElevationMatrixCell.cpp │ │ │ ├── LineBuilder.cpp │ │ │ ├── MaximalEdgeRing.cpp │ │ │ ├── MinimalEdgeRing.cpp │ │ │ ├── OverlayNodeFactory.cpp │ │ │ ├── OverlayOp.cpp │ │ │ ├── PointBuilder.cpp │ │ │ ├── PolygonBuilder.cpp │ │ │ └── snap │ │ │ │ ├── GeometrySnapper.cpp │ │ │ │ └── LineStringSnapper.cpp │ │ ├── overlayng │ │ │ ├── Edge.cpp │ │ │ ├── EdgeMerger.cpp │ │ │ ├── EdgeNodingBuilder.cpp │ │ │ ├── EdgeSourceInfo.cpp │ │ │ ├── ElevationModel.cpp │ │ │ ├── IndexedPointOnLineLocator.cpp │ │ │ ├── InputGeometry.cpp │ │ │ ├── IntersectionPointBuilder.cpp │ │ │ ├── LineBuilder.cpp │ │ │ ├── LineLimiter.cpp │ │ │ ├── MaximalEdgeRing.cpp │ │ │ ├── OverlayEdge.cpp │ │ │ ├── OverlayEdgeRing.cpp │ │ │ ├── OverlayGraph.cpp │ │ │ ├── OverlayLabel.cpp │ │ │ ├── OverlayLabeller.cpp │ │ │ ├── OverlayMixedPoints.cpp │ │ │ ├── OverlayNG.cpp │ │ │ ├── OverlayNGRobust.cpp │ │ │ ├── OverlayPoints.cpp │ │ │ ├── OverlayUtil.cpp │ │ │ ├── PolygonBuilder.cpp │ │ │ ├── PrecisionReducer.cpp │ │ │ ├── PrecisionUtil.cpp │ │ │ ├── RingClipper.cpp │ │ │ └── RobustClipEnvelopeComputer.cpp │ │ ├── polygonize │ │ │ └── EdgeRing.cpp │ │ ├── predicate │ │ │ ├── RectangleContains.cpp │ │ │ ├── RectangleIntersects.cpp │ │ │ └── SegmentIntersectionTester.cpp │ │ ├── relate │ │ │ ├── EdgeEndBuilder.cpp │ │ │ ├── EdgeEndBundle.cpp │ │ │ ├── EdgeEndBundleStar.cpp │ │ │ ├── RelateComputer.cpp │ │ │ ├── RelateNode.cpp │ │ │ ├── RelateNodeFactory.cpp │ │ │ └── RelateOp.cpp │ │ ├── union │ │ │ ├── CascadedPolygonUnion.cpp │ │ │ ├── PointGeometryUnion.cpp │ │ │ ├── UnaryUnionOp.cpp │ │ │ └── UnionStrategy.cpp │ │ └── valid │ │ │ ├── IndexedNestedHoleTester.cpp │ │ │ ├── IndexedNestedPolygonTester.cpp │ │ │ ├── IsSimpleOp.cpp │ │ │ ├── IsValidOp.cpp │ │ │ ├── PolygonIntersectionAnalyzer.cpp │ │ │ ├── PolygonRing.cpp │ │ │ ├── PolygonRingSelfNode.cpp │ │ │ ├── PolygonRingTouch.cpp │ │ │ ├── PolygonTopologyAnalyzer.cpp │ │ │ ├── RepeatedPointRemover.cpp │ │ │ ├── RepeatedPointTester.cpp │ │ │ └── TopologyValidationError.cpp │ ├── precision │ │ ├── CommonBits.cpp │ │ ├── CommonBitsRemover.cpp │ │ ├── GeometryPrecisionReducer.cpp │ │ ├── PointwisePrecisionReducerTransformer.cpp │ │ └── PrecisionReducerTransformer.cpp │ └── util │ │ ├── Assert.cpp │ │ ├── Interrupt.cpp │ │ └── math.cpp │ └── json │ ├── CMakeLists.txt │ ├── LICENSE │ ├── arraylist.cpp │ ├── include │ ├── arraylist.hpp │ ├── config.hpp │ ├── json.hpp │ ├── json_object.hpp │ ├── json_object_private.hpp │ ├── json_tokener.hpp │ ├── json_types.hpp │ ├── json_util.hpp │ ├── linkhash.hpp │ ├── printbuf.hpp │ └── random_seed.hpp │ ├── json_object.cpp │ ├── json_tokener.cpp │ ├── json_util.cpp │ ├── linkhash.cpp │ ├── printbuf.cpp │ └── random_seed.cpp └── test └── sql ├── test_angle.test ├── test_area.test ├── test_as_binary.test ├── test_as_geojson.test ├── test_as_text.test ├── test_azimuth.test ├── test_boundary.test ├── test_boundingbox.test ├── test_buffer.test ├── test_centroid.test ├── test_closestpoint.test ├── test_clusterdbscan.test ├── test_collection.test ├── test_contains.test ├── test_convexhull.test ├── test_coveredby.test ├── test_covers.test ├── test_difference.test ├── test_dimension.test ├── test_disjoint.test ├── test_distance.test ├── test_dump.test ├── test_dwithin.test ├── test_endpoint.test ├── test_equals.test ├── test_extent.test ├── test_from_text.test ├── test_geofromgeojson.test ├── test_geofromtext.test ├── test_geofromwkb.test ├── test_geogfrom.test ├── test_geogpointfromhash.test ├── test_geohash.test ├── test_geometry.test ├── test_geometrytype.test ├── test_get_x.test ├── test_get_y.test ├── test_intersection.test ├── test_intersects.test ├── test_isclosed.test ├── test_iscollection.test ├── test_isempty.test ├── test_isring.test ├── test_length.test ├── test_line.test ├── test_makeline.test ├── test_makepoint.test ├── test_makepolygon.test ├── test_maxdistance.test ├── test_multiline.test ├── test_multipoint.test ├── test_multipolygon.test ├── test_npoints.test ├── test_numgeometries.test ├── test_numpoints.test ├── test_perimeter.test ├── test_point.test ├── test_pointn.test ├── test_polygon.test ├── test_simplify.test ├── test_snaptogrid.test ├── test_startpoint.test ├── test_touches.test ├── test_union.test └── test_within.test /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request,repository_dispatch] 2 | 3 | defaults: 4 | run: 5 | shell: bash 6 | 7 | jobs: 8 | sql: 9 | name: SQL 10 | runs-on: macos-latest 11 | env: 12 | GEN: ninja 13 | 14 | steps: 15 | - name: Install Ninja 16 | run: brew install ninja 17 | 18 | - uses: actions/checkout@v2 19 | with: 20 | fetch-depth: 0 21 | 22 | - name: Update DuckDB submodule 23 | run: | 24 | git config --global --add safe.directory '*' 25 | make pull 26 | 27 | - name: Build 28 | run: make release 29 | 30 | - name: Test 31 | run: make test_all -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .idea 3 | cmake-build-debug 4 | duckdb_unittest_tempdir/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "duckdb"] 2 | path = duckdb 3 | url = https://github.com/duckdb/duckdb 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "go2sh.cmake-integration" 3 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | 3 | if(DEFINED EXTERNAL_EXTENSION_DIRECTORIES) 4 | # Extension is being built from DuckDB CMake file, just add the extension dir 5 | add_subdirectory(geo) 6 | else() 7 | set(TARGET_NAME geo) 8 | project(${TARGET_NAME}) 9 | 10 | # set(EXTENSION_CLASS ${TARGET_NAME}Extension) 11 | string(SUBSTRING ${TARGET_NAME} 0 1 FIRST_LETTER) 12 | string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) 13 | string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" EXTENSION_CLASS 14 | "${TARGET_NAME}") 15 | 16 | cmake_policy(SET CMP0079 NEW) 17 | 18 | include_directories(${TARGET_NAME}/include) 19 | add_compile_definitions(DUCKDB_OUT_OF_TREE) 20 | add_compile_definitions(DUCKDB_EXTENSION_CLASS=${EXTENSION_CLASS}Extension) 21 | add_compile_definitions(DUCKDB_EXTENSION_HEADER="${TARGET_NAME}-extension.hpp") 22 | 23 | set(EXTERNAL_EXTENSION_DIRECTORIES ../${TARGET_NAME}) 24 | 25 | add_subdirectory(duckdb) 26 | 27 | target_link_libraries(unittest ${TARGET_NAME}_extension) 28 | 29 | endif() -------------------------------------------------------------------------------- /examples/embedded-c++/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | project(example-c++) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | include_directories(../../duckdb/src/include) 7 | link_directories(../../build/release/src) 8 | 9 | add_executable(example main.cpp) 10 | target_link_libraries(example duckdb) 11 | -------------------------------------------------------------------------------- /examples/embedded-c++/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | .PHONY: duckdb clean main 4 | 5 | all: duckdb main 6 | 7 | clean: 8 | rm -rf build 9 | 10 | duckdb: 11 | cd ../.. && make 12 | 13 | main: 14 | mkdir -p build 15 | cd build && cmake .. && make 16 | build/example 17 | 18 | 19 | -------------------------------------------------------------------------------- /geo/include/formatter-functions.hpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // DuckDB 3 | // 4 | // formatter-functions.hpp 5 | // 6 | // 7 | //===----------------------------------------------------------------------===// 8 | 9 | #include "geo-functions.hpp" 10 | 11 | #pragma once 12 | 13 | namespace duckdb { 14 | 15 | static const std::vector GetFormatterScalarFunctions(LogicalType geo_type) { 16 | std::vector func_set {}; 17 | 18 | // ST_ASBINARY 19 | ScalarFunctionSet as_binary("st_asbinary"); 20 | as_binary.AddFunction(ScalarFunction({geo_type}, LogicalType::BLOB, GeoFunctions::GeometryAsBinaryFunction)); 21 | as_binary.AddFunction( 22 | ScalarFunction({geo_type, LogicalType::VARCHAR}, LogicalType::BLOB, GeoFunctions::GeometryAsBinaryFunction)); 23 | func_set.push_back(as_binary); 24 | 25 | // ST_ASTEXT 26 | ScalarFunctionSet as_text("st_astext"); 27 | as_text.AddFunction(ScalarFunction({geo_type}, LogicalType::VARCHAR, GeoFunctions::GeometryAsTextFunction)); 28 | as_text.AddFunction( 29 | ScalarFunction({geo_type, LogicalType::INTEGER}, LogicalType::VARCHAR, GeoFunctions::GeometryAsTextFunction)); 30 | func_set.push_back(as_text); 31 | 32 | // ST_ASGEOJSON 33 | ScalarFunctionSet as_geojson("st_asgeojson"); 34 | as_geojson.AddFunction(ScalarFunction({geo_type}, LogicalType::VARCHAR, GeoFunctions::GeometryAsGeojsonFunction)); 35 | as_geojson.AddFunction(ScalarFunction({geo_type, LogicalType::INTEGER}, LogicalType::VARCHAR, 36 | GeoFunctions::GeometryAsGeojsonFunction)); 37 | func_set.push_back(as_geojson); 38 | 39 | // ST_GEOHASH 40 | ScalarFunctionSet geohash("st_geohash"); 41 | geohash.AddFunction(ScalarFunction({geo_type}, LogicalType::VARCHAR, GeoFunctions::GeometryGeoHashFunction)); 42 | geohash.AddFunction( 43 | ScalarFunction({geo_type, LogicalType::INTEGER}, LogicalType::VARCHAR, GeoFunctions::GeometryGeoHashFunction)); 44 | func_set.push_back(geohash); 45 | 46 | return func_set; 47 | } 48 | 49 | } // namespace duckdb 50 | -------------------------------------------------------------------------------- /geo/include/geo-extension.hpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // DuckDB 3 | // 4 | // geo-extension.hpp 5 | // 6 | // 7 | //===----------------------------------------------------------------------===// 8 | #pragma once 9 | 10 | #include "duckdb.hpp" 11 | #include "duckdb/main/client_context.hpp" 12 | 13 | namespace duckdb { 14 | 15 | class GeoExtension : public Extension { 16 | public: 17 | void Load(DuckDB &db) override; 18 | std::string Name() override; 19 | }; 20 | 21 | } // namespace duckdb 22 | -------------------------------------------------------------------------------- /geo/include/liblwgeom/lwgeom_geos.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2011 Sandro Santilli 22 | * Copyright 2018 Darafei Praliaskouski 23 | * 24 | **********************************************************************/ 25 | 26 | #pragma once 27 | #include "duckdb.hpp" 28 | #include "geos_c.hpp" 29 | #include "liblwgeom/liblwgeom.hpp" 30 | #include "liblwgeom/lwunionfind.hpp" 31 | 32 | namespace duckdb { 33 | 34 | /* 35 | ** Public prototypes for GEOS utility functions. 36 | */ 37 | LWGEOM *GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d); 38 | GEOSGeometry *LWGEOM2GEOS(const LWGEOM *g, uint8_t autofix); 39 | 40 | POINTARRAY *ptarray_from_GEOSCoordSeq(const GEOSCoordSequence *cs, uint8_t want3d); 41 | 42 | GEOSGeometry *make_geos_point(double x, double y); 43 | GEOSGeometry *make_geos_segment(double x1, double y1, double x2, double y2); 44 | 45 | int union_dbscan(LWGEOM **geoms, uint32_t num_geoms, UNIONFIND *uf, double eps, uint32_t min_points, 46 | char **is_in_cluster_ret); 47 | 48 | } // namespace duckdb 49 | -------------------------------------------------------------------------------- /geo/include/liblwgeom/postigs_config.hpp: -------------------------------------------------------------------------------- 1 | namespace duckdb { 2 | 3 | /* Manually manipulate the POSTGIS_DEBUG_LEVEL, it is not affected by the 4 | configure process */ 5 | #define POSTGIS_DEBUG_LEVEL 0 6 | 7 | } // namespace duckdb 8 | -------------------------------------------------------------------------------- /geo/include/libpgcommon/lwgeom_pg.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * 5 | * Copyright (C) 2011 Sandro Santilli 6 | * Copyright (C) 2009-2011 Paul Ramsey 7 | * Copyright (C) 2008 Mark Cave-Ayland 8 | * Copyright (C) 2004-2007 Refractions Research Inc. 9 | * 10 | * This is free software; you can redistribute and/or modify it under 11 | * the terms of the GNU General Public Licence. See the COPYING file. 12 | * 13 | **********************************************************************/ 14 | 15 | #pragma once 16 | #include "duckdb.hpp" 17 | #include "liblwgeom/liblwgeom.hpp" 18 | 19 | namespace duckdb { 20 | 21 | /** 22 | * Utility method to call the serialization and then set the 23 | * PgSQL varsize header appropriately with the serialized size. 24 | */ 25 | GSERIALIZED *geometry_serialize(LWGEOM *lwgeom); 26 | 27 | /** 28 | * Utility method to call the serialization and then set the 29 | * PgSQL varsize header appropriately with the serialized size. 30 | */ 31 | GSERIALIZED *geography_serialize(LWGEOM *lwgeom); 32 | 33 | /** 34 | * Compare SRIDs of two GSERIALIZEDs and print informative error message if they differ. 35 | */ 36 | void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname); 37 | 38 | /** 39 | * Compare SRIDs of GSERIALIZEDs to reference and print informative error message if they differ. 40 | */ 41 | void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid, const char *funcname); 42 | 43 | } // namespace duckdb 44 | -------------------------------------------------------------------------------- /geo/include/libpgcommon/lwgeom_transform.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * Copyright 2001-2003 Refractions Research Inc. 6 | * 7 | * This is free software; you can redistribute and/or modify it under 8 | * the terms of the GNU General Public Licence. See the COPYING file. 9 | * 10 | **********************************************************************/ 11 | 12 | #pragma once 13 | #include "duckdb.hpp" 14 | #include "liblwgeom/liblwgeom.hpp" 15 | 16 | namespace duckdb { 17 | 18 | /* 19 | * Proj4 caching has it's own mechanism, and is 20 | * stored globally as the cost of proj_create_crs_to_crs() 21 | * is so high (20-40ms) that the lifetime of fcinfo->flinfo->fn_extra 22 | * is too short to assist some work loads. 23 | */ 24 | 25 | // /* An entry in the PROJ SRS cache */ 26 | // typedef struct struct_PROJSRSCacheItem 27 | // { 28 | // int32_t srid_from; 29 | // int32_t srid_to; 30 | // uint64_t hits; 31 | // LWPROJ *projection; 32 | // } 33 | // PROJSRSCacheItem; 34 | 35 | // /* PROJ 4 lookup transaction cache methods */ 36 | // #define PROJ_CACHE_ITEMS 128 37 | 38 | // /* 39 | // * The proj4 cache holds a fixed number of reprojection 40 | // * entries. In normal usage we don't expect it to have 41 | // * many entries, so we always linearly scan the list. 42 | // */ 43 | // typedef struct struct_PROJSRSCache 44 | // { 45 | // PROJSRSCacheItem PROJSRSCache[PROJ_CACHE_ITEMS]; 46 | // uint32_t PROJSRSCacheCount; 47 | // MemoryContext PROJSRSCacheContext; 48 | // } 49 | // PROJSRSCache; 50 | 51 | // int GetLWPROJ(int32_t srid_from, int32_t srid_to, LWPROJ **pj); 52 | int spheroid_init_from_srid(int32_t srid, SPHEROID *s); 53 | 54 | } // namespace duckdb 55 | -------------------------------------------------------------------------------- /geo/include/postgis/geography.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2009 Paul Ramsey 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | 29 | namespace duckdb { 30 | 31 | /* Check that the typmod matches the flags on the lwgeom */ 32 | GSERIALIZED *postgis_valid_typmod(GSERIALIZED *gser, int32_t typmod); 33 | 34 | /* Check that the type is legal in geography (no curves please!) */ 35 | void geography_valid_type(uint8_t type); 36 | 37 | } // namespace duckdb 38 | -------------------------------------------------------------------------------- /geo/include/postgis/geography_centroid.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright (C) 2017 Danny Götte 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | 29 | namespace duckdb { 30 | 31 | GSERIALIZED *geography_centroid(GSERIALIZED *geom, bool use_spheroid); 32 | 33 | } // namespace duckdb 34 | -------------------------------------------------------------------------------- /geo/include/postgis/geography_inout.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2009-2011 Paul Ramsey 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom_internal.hpp" 28 | 29 | namespace duckdb { 30 | 31 | GSERIALIZED *gserialized_geography_from_lwgeom(LWGEOM *lwgeom, int32_t geog_typmod); 32 | GSERIALIZED *geography_from_text(char *input); 33 | GSERIALIZED *geography_from_binary(const char *bytea_wkb, size_t byte_size); 34 | GSERIALIZED *geography_in(char *input); 35 | 36 | } // namespace duckdb 37 | -------------------------------------------------------------------------------- /geo/include/postgis/geography_measurement.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright (C) 2009 Paul Ramsey 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | #include "liblwgeom/liblwgeom_internal.hpp" 29 | 30 | namespace duckdb { 31 | 32 | #ifndef _LIBGEOGRAPHY_MEASUREMENT_H 33 | #define _LIBGEOGRAPHY_MEASUREMENT_H 1 34 | 35 | double geography_distance(GSERIALIZED *geom1, GSERIALIZED *geom2, bool use_spheroid); 36 | double geography_maxdistance(GSERIALIZED *geom1, GSERIALIZED *geom2, bool use_spheroid); 37 | double geography_area(GSERIALIZED *g, bool use_spheroid); 38 | double geography_perimeter(GSERIALIZED *g, bool use_spheroid); 39 | double geography_azimuth(GSERIALIZED *g1, GSERIALIZED *g2); 40 | double geography_length(GSERIALIZED *g, bool use_spheroid); 41 | bool geography_dwithin(GSERIALIZED *g1, GSERIALIZED *g2, double tolerance, bool use_spheroid); 42 | 43 | #endif /* !defined _LIBGEOGRAPHY_MEASUREMENT_H */ 44 | 45 | } // namespace duckdb 46 | -------------------------------------------------------------------------------- /geo/include/postgis/geography_measurement_trees.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * ^copyright^ 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | #include "liblwgeom/liblwgeom_internal.hpp" 29 | 30 | namespace duckdb { 31 | 32 | #ifndef _LIBGEOGRAPHY_MEASUREMENT_TREES_H 33 | #define _LIBGEOGRAPHY_MEASUREMENT_TREES_H 1 34 | 35 | int geography_tree_distance(const GSERIALIZED *g1, const GSERIALIZED *g2, const SPHEROID *s, double tolerance, 36 | double *distance); 37 | 38 | int geography_tree_maxdistance(const GSERIALIZED *g1, const GSERIALIZED *g2, const SPHEROID *s, double tolerance, 39 | double *distance); 40 | 41 | #endif /* !defined _LIBGEOGRAPHY_MEASUREMENT_TREES_H */ 42 | 43 | } // namespace duckdb 44 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_box.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2001-2009 Refractions Research Inc. 22 | * Copyright 2009 Mark Cave-Ayland 23 | * 24 | **********************************************************************/ 25 | 26 | #pragma once 27 | #include "duckdb.hpp" 28 | #include "liblwgeom/liblwgeom.hpp" 29 | 30 | namespace duckdb { 31 | 32 | GSERIALIZED *BOX2D_to_LWGEOM(GBOX *box); 33 | 34 | } // namespace duckdb 35 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_dump.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2001-2009 Refractions Research Inc. 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | 29 | namespace duckdb { 30 | 31 | std::vector LWGEOM_dump(GSERIALIZED *geom); 32 | 33 | } // namespace duckdb 34 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_export.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2009-2011 Olivier Courtin 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom_internal.hpp" 28 | 29 | namespace duckdb { 30 | 31 | lwvarlena_t *LWGEOM_asGeoJson(GSERIALIZED *gser, size_t m_dec_digits = OUT_DEFAULT_DECIMAL_DIGITS); 32 | 33 | } // namespace duckdb 34 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_functions_analytic.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright (C) 2001-2005 Refractions Research Inc. 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | 29 | namespace duckdb { 30 | 31 | GSERIALIZED *LWGEOM_simplify2d(GSERIALIZED *geom, double dist); 32 | GSERIALIZED *LWGEOM_snaptogrid(GSERIALIZED *geom, double ipx, double ipy, double xsize, double ysize); 33 | 34 | int point_in_polygon(LWPOLY *polygon, LWPOINT *point); 35 | int point_in_multipolygon(LWMPOLY *mpolygon, LWPOINT *pont); 36 | 37 | } // namespace duckdb 38 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_in_geohash.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2012 J Smith 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | 29 | namespace duckdb { 30 | 31 | GBOX *box2d_from_geohash(char *hash, int precision = -1); 32 | 33 | GSERIALIZED *LWGEOM_from_GeoHash(char *hash, int precision = -1); 34 | 35 | } // namespace duckdb 36 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_inout.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * ^copyright^ 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom_internal.hpp" 28 | 29 | namespace duckdb { 30 | GSERIALIZED *LWGEOM_getGserialized(const void *base, size_t size); 31 | 32 | GSERIALIZED *geom_from_geojson(char *json); 33 | size_t LWGEOM_size(GSERIALIZED *gser); 34 | char *LWGEOM_base(GSERIALIZED *gser); 35 | lwvarlena_t *LWGEOM_asBinary(GSERIALIZED *gser, string text = ""); 36 | std::string LWGEOM_asBinary(const void *base, size_t size); 37 | std::string LWGEOM_asText(GSERIALIZED *gser, size_t max_digits = OUT_DEFAULT_DECIMAL_DIGITS); 38 | std::string LWGEOM_asGeoJson(const void *base, size_t size); 39 | void LWGEOM_free(GSERIALIZED *gser); 40 | 41 | } // namespace duckdb 42 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_ogc.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2001-2005 Refractions Research Inc. 22 | * 23 | **********************************************************************/ 24 | 25 | #pragma once 26 | #include "duckdb.hpp" 27 | #include "liblwgeom/liblwgeom.hpp" 28 | 29 | namespace duckdb { 30 | 31 | GSERIALIZED *LWGEOM_boundary(GSERIALIZED *geom); 32 | int LWGEOM_dimension(GSERIALIZED *geom); 33 | GSERIALIZED *LWGEOM_endpoint_linestring(GSERIALIZED *geom); 34 | std::string geometry_geometrytype(GSERIALIZED *geom); 35 | bool LWGEOM_isclosed(GSERIALIZED *geom); 36 | int LWGEOM_numgeometries_collection(GSERIALIZED *geom); 37 | int LWGEOM_numpoints_linestring(GSERIALIZED *geom); 38 | GSERIALIZED *LWGEOM_pointn_linestring(GSERIALIZED *geom, int where); 39 | GSERIALIZED *LWGEOM_startpoint_linestring(GSERIALIZED *geom); 40 | double LWGEOM_x_point(GSERIALIZED *geom); 41 | double LWGEOM_y_point(GSERIALIZED *geom); 42 | 43 | } // namespace duckdb 44 | -------------------------------------------------------------------------------- /geo/include/postgis/lwgeom_window.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2016 Paul Ramsey 22 | * Copyright 2016 Daniel Baston 23 | * 24 | **********************************************************************/ 25 | 26 | #pragma once 27 | #include "duckdb.hpp" 28 | #include "liblwgeom/liblwgeom.hpp" 29 | 30 | namespace duckdb { 31 | 32 | std::vector ST_ClusterDBSCAN(GSERIALIZED *gserArray[], int nelems, double tolerance, int minpoints); 33 | 34 | } // namespace duckdb 35 | -------------------------------------------------------------------------------- /geo/liblwgeom/lwmline.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2001-2006 Refractions Research Inc. 22 | * 23 | **********************************************************************/ 24 | 25 | #include "liblwgeom/liblwgeom_internal.hpp" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace duckdb { 32 | 33 | LWMLINE *lwmline_construct_empty(int32_t srid, char hasz, char hasm) { 34 | LWMLINE *ret = (LWMLINE *)lwcollection_construct_empty(MULTILINETYPE, srid, hasz, hasm); 35 | return ret; 36 | } 37 | 38 | void lwmline_free(LWMLINE *mline) { 39 | if (!mline) 40 | return; 41 | 42 | if (mline->bbox) 43 | lwfree(mline->bbox); 44 | 45 | if (mline->geoms) { 46 | for (uint32_t i = 0; i < mline->ngeoms; i++) 47 | if (mline->geoms[i]) 48 | lwline_free(mline->geoms[i]); 49 | lwfree(mline->geoms); 50 | } 51 | 52 | lwfree(mline); 53 | } 54 | 55 | LWMLINE *lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj) { 56 | return (LWMLINE *)lwcollection_add_lwgeom((LWCOLLECTION *)mobj, (LWGEOM *)obj); 57 | } 58 | 59 | } // namespace duckdb 60 | -------------------------------------------------------------------------------- /geo/liblwgeom/lwmpoint.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright (C) 2001-2006 Refractions Research Inc. 22 | * 23 | **********************************************************************/ 24 | 25 | #include "liblwgeom/liblwgeom_internal.hpp" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace duckdb { 32 | 33 | void lwmpoint_free(LWMPOINT *mpt) { 34 | uint32_t i; 35 | 36 | if (!mpt) 37 | return; 38 | 39 | if (mpt->bbox) 40 | lwfree(mpt->bbox); 41 | 42 | for (i = 0; i < mpt->ngeoms; i++) 43 | if (mpt->geoms && mpt->geoms[i]) 44 | lwpoint_free(mpt->geoms[i]); 45 | 46 | if (mpt->geoms) 47 | lwfree(mpt->geoms); 48 | 49 | lwfree(mpt); 50 | } 51 | 52 | LWMPOINT *lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj) { 53 | return (LWMPOINT *)lwcollection_add_lwgeom((LWCOLLECTION *)mobj, (LWGEOM *)obj); 54 | } 55 | 56 | } // namespace duckdb 57 | -------------------------------------------------------------------------------- /geo/liblwgeom/lwprint.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright (C) 2010-2015 Paul Ramsey 22 | * Copyright (C) 2011 Sandro Santilli 23 | * 24 | **********************************************************************/ 25 | 26 | #include "lib/ryu.hpp" 27 | #include "liblwgeom/liblwgeom_internal.hpp" 28 | 29 | namespace duckdb { 30 | 31 | /* 32 | * Print an ordinate value using at most **maxdd** number of decimal digits 33 | * The actual number of printed decimal digits may be less than the 34 | * requested ones if out of significant digits. 35 | * 36 | * The function will write at most OUT_DOUBLE_BUFFER_SIZE bytes, including the 37 | * terminating NULL. 38 | * It returns the number of bytes written (exluding the final NULL) 39 | * 40 | */ 41 | int lwprint_double(double d, int maxdd, char *buf) { 42 | int length; 43 | double ad = fabs(d); 44 | int precision = FP_MAX(0, maxdd); 45 | 46 | if (ad <= OUT_MIN_DOUBLE || ad >= OUT_MAX_DOUBLE) { 47 | length = d2sexp_buffered_n(d, precision, buf); 48 | } else { 49 | length = d2sfixed_buffered_n(d, precision, buf); 50 | } 51 | buf[length] = '\0'; 52 | 53 | return length; 54 | } 55 | 56 | } // namespace duckdb 57 | -------------------------------------------------------------------------------- /geo/libpgcommon/lwgeom_pg.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * 5 | * http://postgis.net 6 | * 7 | * Copyright (C) 2011 Sandro Santilli 8 | * Copyright (C) 2009-2011 Paul Ramsey 9 | * Copyright (C) 2008 Mark Cave-Ayland 10 | * Copyright (C) 2004-2007 Refractions Research Inc. 11 | * 12 | * This is free software; you can redistribute and/or modify it under 13 | * the terms of the GNU General Public Licence. See the COPYING file. 14 | * 15 | **********************************************************************/ 16 | 17 | #include "libpgcommon/lwgeom_pg.hpp" 18 | 19 | #include "liblwgeom/gserialized.hpp" 20 | 21 | namespace duckdb { 22 | 23 | /** 24 | * Utility method to call the serialization and then set the 25 | * PgSQL varsize header appropriately with the serialized size. 26 | */ 27 | GSERIALIZED *geometry_serialize(LWGEOM *lwgeom) { 28 | size_t ret_size; 29 | GSERIALIZED *g; 30 | 31 | g = gserialized_from_lwgeom(lwgeom, &ret_size); 32 | SET_VARSIZE(g, ret_size); 33 | return g; 34 | } 35 | 36 | /** 37 | * Utility method to call the serialization and then set the 38 | * PgSQL varsize header appropriately with the serialized size. 39 | */ 40 | GSERIALIZED *geography_serialize(LWGEOM *lwgeom) { 41 | size_t ret_size; 42 | GSERIALIZED *g; 43 | /** force to geodetic in case it's not **/ 44 | lwgeom_set_geodetic(lwgeom, true); 45 | 46 | g = gserialized_from_lwgeom(lwgeom, &ret_size); 47 | SET_VARSIZE(g, ret_size); 48 | return g; 49 | } 50 | 51 | } // namespace duckdb 52 | -------------------------------------------------------------------------------- /geo/postgis/lwgeom_export.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2009-2011 Olivier Courtin 22 | * 23 | **********************************************************************/ 24 | 25 | #include "postgis/lwgeom_export.hpp" 26 | 27 | #include "liblwgeom/gserialized.hpp" 28 | 29 | namespace duckdb { 30 | 31 | lwvarlena_t *LWGEOM_asGeoJson(GSERIALIZED *geom, size_t m_dec_digits) { 32 | LWGEOM *lwgeom; 33 | int precision = m_dec_digits; 34 | int output_bbox = LW_FALSE; 35 | const char *srs = NULL; 36 | // int32_t srid; 37 | // srid = gserialized_get_srid(geom); 38 | 39 | lwgeom = lwgeom_from_gserialized(geom); 40 | auto geojson = lwgeom_to_geojson(lwgeom, srs, precision, output_bbox); 41 | lwgeom_free(lwgeom); 42 | return geojson; 43 | } 44 | 45 | } // namespace duckdb 46 | -------------------------------------------------------------------------------- /geo/postgis/lwgeom_in_geojson.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * PostGIS - Spatial Types for PostgreSQL 4 | * http://postgis.net 5 | * 6 | * PostGIS is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * PostGIS is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with PostGIS. If not, see . 18 | * 19 | ********************************************************************** 20 | * 21 | * Copyright 2011 Kashif Rasul 22 | * 23 | **********************************************************************/ 24 | 25 | #include "liblwgeom/gserialized.hpp" 26 | #include "libpgcommon/lwgeom_pg.hpp" 27 | #include "postgis/geography_inout.hpp" 28 | #include "postgis/lwgeom_inout.hpp" 29 | 30 | #include 31 | #include 32 | 33 | namespace duckdb { 34 | 35 | GSERIALIZED *geom_from_geojson(char *geojson) { 36 | int32_t geog_typmod = -1; 37 | GSERIALIZED *geom; 38 | LWGEOM *lwgeom; 39 | char *srs = NULL; 40 | 41 | lwgeom = lwgeom_from_geojson(geojson, &srs); 42 | if (!lwgeom) { 43 | /* Shouldn't get here */ 44 | // elog(ERROR, "lwgeom_from_geojson returned NULL"); 45 | return nullptr; 46 | } 47 | 48 | geom = gserialized_geography_from_lwgeom(lwgeom, geog_typmod); 49 | lwgeom_free(lwgeom); 50 | 51 | return geom; 52 | } 53 | 54 | } // namespace duckdb 55 | -------------------------------------------------------------------------------- /geo/third_party/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(json) 2 | add_subdirectory(geos) 3 | 4 | set(GEO_LIBRARY_FILES 5 | ${GEO_LIBRARY_FILES} 6 | PARENT_SCOPE) 7 | -------------------------------------------------------------------------------- /geo/third_party/geos/algorithm/Angle.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2009-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 | * Last port: algorithm/Angle.java r378 (JTS-1.12) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | namespace geos { 24 | namespace algorithm { // geos.algorithm 25 | 26 | /* public static */ 27 | double Angle::angle(const geom::CoordinateXY &p0, const geom::CoordinateXY &p1) { 28 | double dx = p1.x - p0.x; 29 | double dy = p1.y - p0.y; 30 | return atan2(dy, dx); 31 | } 32 | 33 | /* public static */ 34 | double Angle::angle(const geom::CoordinateXY &p) { 35 | return atan2(p.y, p.x); 36 | } 37 | 38 | /* public static */ 39 | double Angle::normalize(double angle) { 40 | while (angle > MATH_PI) { 41 | angle -= PI_TIMES_2; 42 | } 43 | while (angle <= -MATH_PI) { 44 | angle += PI_TIMES_2; 45 | } 46 | return angle; 47 | } 48 | 49 | /* public static */ 50 | double Angle::angleBetweenOriented(const geom::CoordinateXY &tip1, const geom::CoordinateXY &tail, 51 | const geom::CoordinateXY &tip2) { 52 | double a1 = angle(tail, tip1); 53 | double a2 = angle(tail, tip2); 54 | double angDel = a2 - a1; 55 | 56 | // normalize, maintaining orientation 57 | if (angDel <= -MATH_PI) { 58 | return angDel + PI_TIMES_2; 59 | } 60 | if (angDel > MATH_PI) { 61 | return angDel - PI_TIMES_2; 62 | } 63 | return angDel; 64 | } 65 | 66 | } // namespace algorithm 67 | } // namespace geos 68 | -------------------------------------------------------------------------------- /geo/third_party/geos/algorithm/Length.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2018 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: algorithm/Length.java @ 2017-09-04 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | namespace geos { 24 | namespace algorithm { // geos.algorithm 25 | 26 | /* public static */ 27 | double Length::ofLine(const geom::CoordinateSequence *pts) { 28 | // optimized for processing CoordinateSequences 29 | std::size_t n = pts->size(); 30 | if (n <= 1) { 31 | return 0.0; 32 | } 33 | 34 | double len = 0.0; 35 | 36 | const geom::Coordinate &p = pts->getAt(0); 37 | double x0 = p.x; 38 | double y0 = p.y; 39 | 40 | for (std::size_t i = 1; i < n; i++) { 41 | const geom::Coordinate &pi = pts->getAt(i); 42 | double x1 = pi.x; 43 | double y1 = pi.y; 44 | double dx = x1 - x0; 45 | double dy = y1 - y0; 46 | 47 | len += std::sqrt(dx * dx + dy * dy); 48 | 49 | x0 = x1; 50 | y0 = y1; 51 | } 52 | return len; 53 | } 54 | 55 | } // namespace algorithm 56 | } // namespace geos 57 | -------------------------------------------------------------------------------- /geo/third_party/geos/geom/Coordinate.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 // for std::isnan 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace geos { 23 | namespace geom { // geos::geom 24 | 25 | CoordinateXY CoordinateXY::_nullCoord = CoordinateXY(DoubleNotANumber, DoubleNotANumber); 26 | Coordinate Coordinate::_nullCoord = Coordinate(DoubleNotANumber, DoubleNotANumber, DoubleNotANumber); 27 | 28 | CoordinateXY &CoordinateXY::getNull() { 29 | return _nullCoord; 30 | } 31 | 32 | Coordinate &Coordinate::getNull() { 33 | return _nullCoord; 34 | } 35 | 36 | std::ostream &operator<<(std::ostream &os, const CoordinateXY &c) { 37 | os << c.x << " " << c.y; 38 | return os; 39 | } 40 | 41 | std::ostream &operator<<(std::ostream &os, const Coordinate &c) { 42 | if (std::isnan(c.z)) { 43 | os << c.x << " " << c.y; 44 | } else { 45 | os << c.x << " " << c.y << " " << c.z; 46 | } 47 | return os; 48 | } 49 | 50 | } // namespace geom 51 | } // namespace geos 52 | -------------------------------------------------------------------------------- /geo/third_party/geos/geom/DefaultCoordinateSequencefactory.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2019 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 geom { // geos::geom 19 | 20 | static DefaultCoordinateSequenceFactory defaultCoordinateSequenceFactory; 21 | 22 | const CoordinateSequenceFactory *DefaultCoordinateSequenceFactory::instance() { 23 | return &defaultCoordinateSequenceFactory; 24 | } 25 | 26 | } // namespace geom 27 | } // namespace geos 28 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | #include 18 | #include 19 | #include 20 | 21 | namespace geos { 22 | namespace geom { // geos::geom 23 | 24 | void GeometryComponentFilter::filter_rw(Geometry *geom) { 25 | ::geos::ignore_unused_variable_warning(geom); 26 | assert(0); 27 | } 28 | 29 | void GeometryComponentFilter::filter_ro(const Geometry *geom) { 30 | ::geos::ignore_unused_variable_warning(geom); 31 | assert(0); 32 | } 33 | 34 | } // namespace geom 35 | } // namespace geos 36 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | #include 18 | 19 | namespace geos { 20 | namespace geom { // geos::geom 21 | 22 | std::ostream &operator<<(std::ostream &os, const Location &loc) { 23 | switch (loc) { 24 | case Location::EXTERIOR: 25 | os << 'e'; 26 | break; 27 | case Location::BOUNDARY: 28 | os << 'b'; 29 | break; 30 | case Location::INTERIOR: 31 | os << 'i'; 32 | break; 33 | case Location::NONE: 34 | os << '-'; 35 | break; 36 | } 37 | return os; 38 | } 39 | 40 | } // namespace geom 41 | } // namespace geos 42 | -------------------------------------------------------------------------------- /geo/third_party/geos/geom/Position.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: geom/Position.java rev. 1.4 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | 22 | namespace geos { 23 | namespace geom { // geos.geom 24 | 25 | /** 26 | * Returns LEFT if the position is RIGHT, RIGHT if the position is LEFT, or the position 27 | * otherwise. 28 | */ 29 | int Position::opposite(int position) { 30 | if (position == LEFT) { 31 | return RIGHT; 32 | } 33 | if (position == RIGHT) { 34 | return LEFT; 35 | } 36 | return position; 37 | } 38 | 39 | } // namespace geom 40 | } // namespace geos 41 | -------------------------------------------------------------------------------- /geo/third_party/geos/geom/Triangle.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 | #include 18 | #include 19 | 20 | using geos::algorithm::Angle; 21 | using geos::algorithm::Orientation; 22 | 23 | namespace geos { 24 | namespace geom { // geos::geom 25 | 26 | void Triangle::inCentre(CoordinateXY &result) { 27 | // the lengths of the sides, labelled by their opposite vertex 28 | double len0 = p1.distance(p2); 29 | double len1 = p0.distance(p2); 30 | double len2 = p0.distance(p1); 31 | double circum = len0 + len1 + len2; 32 | double inCentreX = (len0 * p0.x + len1 * p1.x + len2 * p2.x) / circum; 33 | double inCentreY = (len0 * p0.y + len1 * p1.y + len2 * p2.y) / circum; 34 | 35 | result = CoordinateXY(inCentreX, inCentreY); 36 | } 37 | 38 | } // namespace geom 39 | } // namespace geos 40 | -------------------------------------------------------------------------------- /geo/third_party/geos/geom/util/CoordinateOperation.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 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace geos { 25 | namespace geom { // geos.geom 26 | namespace util { // geos.geom.util 27 | 28 | std::unique_ptr CoordinateOperation::edit(const Geometry *geometry, const GeometryFactory *factory) { 29 | if (geometry == nullptr) { 30 | return nullptr; 31 | } 32 | 33 | if (const LinearRing *ring = dynamic_cast(geometry)) { 34 | const CoordinateSequence *coords = ring->getCoordinatesRO(); 35 | auto newCoords = edit(coords, geometry); 36 | // LinearRing instance takes over ownership of newCoords instance 37 | return factory->createLinearRing(std::move(newCoords)); 38 | } 39 | if (const LineString *line = dynamic_cast(geometry)) { 40 | const CoordinateSequence *coords = line->getCoordinatesRO(); 41 | auto newCoords = edit(coords, geometry); 42 | return factory->createLineString(std::move(newCoords)); 43 | } 44 | if (const Point *point = dynamic_cast(geometry)) { 45 | auto coords = point->getCoordinatesRO(); 46 | auto newCoords = edit(coords, geometry); 47 | return std::unique_ptr(factory->createPoint(newCoords.release())); 48 | } 49 | 50 | return geometry->clone(); 51 | } 52 | 53 | } // namespace util 54 | } // namespace geom 55 | } // namespace geos 56 | -------------------------------------------------------------------------------- /geo/third_party/geos/geom/util/LinearComponentExtracter.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) 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 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace geos { 22 | namespace geom { // geos.geom 23 | namespace util { // geos.geom.util 24 | 25 | LinearComponentExtracter::LinearComponentExtracter(std::vector &newComps) : comps(newComps) { 26 | } 27 | 28 | void LinearComponentExtracter::getLines(const Geometry &geom, std::vector &ret) { 29 | LinearComponentExtracter lce(ret); 30 | geom.apply_ro(&lce); 31 | } 32 | 33 | void LinearComponentExtracter::filter_rw(Geometry *geom) { 34 | if (geom->isEmpty()) 35 | return; 36 | if (const LineString *ls = dynamic_cast(geom)) { 37 | comps.push_back(ls); 38 | } 39 | } 40 | 41 | void LinearComponentExtracter::filter_ro(const Geometry *geom) { 42 | if (geom->isEmpty()) 43 | return; 44 | if (const LineString *ls = dynamic_cast(geom)) { 45 | comps.push_back(ls); 46 | } 47 | } 48 | 49 | } // namespace util 50 | } // namespace geom 51 | } // namespace geos 52 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | #include 17 | #include 18 | #include 19 | 20 | namespace geos { 21 | namespace geom { // geos.geom 22 | namespace util { // geos.geom.util 23 | 24 | std::unique_ptr NoOpGeometryOperation::edit(const Geometry *geometry, const GeometryFactory *factory) { 25 | std::unique_ptr clonedGeom(factory->createGeometry(geometry)); 26 | return clonedGeom; 27 | } 28 | 29 | } // namespace util 30 | } // namespace geom 31 | } // namespace geos 32 | -------------------------------------------------------------------------------- /geo/third_party/geos/geom/util/ShortCircuitedGeometryVisitor.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 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/util/ShortCircuitedGeometryVisitor.java rev. 1.1 (JTS-1.7) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace geos::geom; 24 | 25 | namespace geos { 26 | namespace geom { // geos.geom 27 | namespace util { // geos.geom.util 28 | 29 | void ShortCircuitedGeometryVisitor::applyTo(const Geometry &geom) { 30 | for (std::size_t i = 0, n = geom.getNumGeometries(); i < n; ++i) { 31 | const Geometry *element = geom.getGeometryN(i); 32 | if (element == nullptr) { 33 | continue; 34 | } 35 | 36 | if (dynamic_cast(element)) { 37 | applyTo(*element); 38 | } else { 39 | // calls the abstract virtual 40 | visit(*element); 41 | if (isDone()) { 42 | done = true; 43 | } 44 | } 45 | 46 | if (done) { 47 | return; 48 | } 49 | } 50 | } 51 | 52 | } // namespace util 53 | } // namespace geom 54 | } // namespace geos 55 | -------------------------------------------------------------------------------- /geo/third_party/geos/geomgraph/EdgeList.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: geomgraph/EdgeList.java rev. 1.4 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | using namespace geos::noding; 27 | 28 | namespace geos { 29 | namespace geomgraph { // geos.geomgraph 30 | 31 | /*public*/ 32 | void EdgeList::add(Edge *e) { 33 | edges.push_back(e); 34 | OrientedCoordinateArray oca(*e->getCoordinates()); 35 | ocaMap[oca] = e; 36 | } 37 | 38 | void EdgeList::clearList() { 39 | for (auto *edge : edges) { 40 | delete edge; 41 | } 42 | 43 | edges.clear(); 44 | } 45 | 46 | /** 47 | * If there is an edge equal to e already in the list, return it. 48 | * Otherwise return null. 49 | * @return equal edge, if there is one already in the list 50 | * null otherwise 51 | */ 52 | Edge *EdgeList::findEqualEdge(const Edge *e) const { 53 | OrientedCoordinateArray oca(*(e->getCoordinates())); 54 | auto it = ocaMap.find(oca); 55 | 56 | if (it != ocaMap.end()) { 57 | return it->second; 58 | } 59 | return nullptr; 60 | } 61 | 62 | } // namespace geomgraph 63 | } // namespace geos 64 | -------------------------------------------------------------------------------- /geo/third_party/geos/geomgraph/EdgeNodingValidator.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: geomgraph/EdgeNodingValidator.java rev. 1.6 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | using namespace geos::noding; 27 | using namespace geos::geom; 28 | 29 | namespace geos { 30 | namespace geomgraph { // geos.geomgraph 31 | 32 | std::vector &EdgeNodingValidator::toSegmentStrings(std::vector &edges) { 33 | // convert Edges to SegmentStrings 34 | for (std::size_t i = 0, n = edges.size(); i < n; ++i) { 35 | Edge *e = edges[i]; 36 | auto cs = e->getCoordinates()->clone(); 37 | segStr.push_back(new BasicSegmentString(cs.get(), e)); 38 | newCoordSeq.push_back(cs.release()); 39 | } 40 | return segStr; 41 | } 42 | 43 | EdgeNodingValidator::~EdgeNodingValidator() { 44 | for (SegmentString::NonConstVect::iterator i = segStr.begin(), e = segStr.end(); i != e; ++i) { 45 | delete *i; 46 | } 47 | 48 | for (std::size_t i = 0, n = newCoordSeq.size(); i < n; ++i) { 49 | delete newCoordSeq[i]; 50 | } 51 | } 52 | 53 | } // namespace geomgraph 54 | } // namespace geos 55 | -------------------------------------------------------------------------------- /geo/third_party/geos/geomgraph/GraphComponent.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 | * Last port: geomgraph/GraphComponent.java r428 (JTS-1.12+) 18 | * 19 | **********************************************************************/ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace geos::geom; 26 | 27 | namespace geos { 28 | namespace geomgraph { // geos.geomgraph 29 | 30 | GraphComponent::GraphComponent() 31 | : label(), isInResultVar(false), isCoveredVar(false), isCoveredSetVar(false), isVisitedVar(false) { 32 | } 33 | 34 | GraphComponent::GraphComponent(const Label &newLabel) 35 | : label(newLabel), isInResultVar(false), isCoveredVar(false), isCoveredSetVar(false), isVisitedVar(false) { 36 | } 37 | 38 | void GraphComponent::setCovered(bool p_isCovered) { 39 | isCoveredVar = p_isCovered; 40 | isCoveredSetVar = true; 41 | } 42 | 43 | void GraphComponent::updateIM(IntersectionMatrix &im) { 44 | assert(label.getGeometryCount() >= 2); // found partial label 45 | computeIM(im); 46 | } 47 | 48 | } // namespace geomgraph 49 | } // namespace geos 50 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 *NodeFactory::createNode(const Coordinate &coord) const { 29 | return new Node(coord, nullptr); 30 | } 31 | 32 | const NodeFactory &NodeFactory::instance() { 33 | static const NodeFactory nf; 34 | return nf; 35 | } 36 | 37 | } // namespace geomgraph 38 | } // namespace geos 39 | -------------------------------------------------------------------------------- /geo/third_party/geos/geomgraph/PlannarGraph.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/PlanarGraph.java r428 (JTS-1.12+) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 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 | #include 37 | #include 38 | 39 | #ifndef GEOS_DEBUG 40 | #define GEOS_DEBUG 0 41 | #endif 42 | 43 | using namespace geos::algorithm; 44 | using namespace geos::geom; 45 | 46 | namespace geos { 47 | namespace geomgraph { // geos.geomgraph 48 | 49 | /*protected*/ 50 | void PlanarGraph::insertEdge(Edge *e) { 51 | assert(e); 52 | assert(edges); 53 | edges->push_back(e); 54 | } 55 | 56 | } // namespace geomgraph 57 | } // namespace geos 58 | -------------------------------------------------------------------------------- /geo/third_party/geos/geomgraph/TopologyLocation.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/TopologyLocation.java r428 (JTS-1.12+) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using geos::geom::Location; 30 | using geos::geom::Position; 31 | 32 | namespace geos { 33 | namespace geomgraph { // geos.geomgraph 34 | 35 | /*public*/ 36 | void TopologyLocation::merge(const TopologyLocation &gl) { 37 | // if the src is an Area label & and the dest is not, increase the dest to be an Area 38 | std::size_t sz = locationSize; 39 | std::size_t glsz = gl.locationSize; 40 | if (glsz > sz) { 41 | locationSize = 3; 42 | location[Position::LEFT] = Location::NONE; 43 | location[Position::RIGHT] = Location::NONE; 44 | } 45 | const std::size_t maxIndex = std::min(static_cast(locationSize), glsz); 46 | for (std::size_t i = 0; i < maxIndex; ++i) { 47 | if (location[i] == Location::NONE) { 48 | location[i] = gl.location[i]; 49 | } 50 | } 51 | } 52 | 53 | } // namespace geomgraph 54 | } // namespace geos 55 | -------------------------------------------------------------------------------- /geo/third_party/geos/geomgraph/index/SweepLineEvent.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 | namespace geos { 21 | namespace geomgraph { // geos.geomgraph 22 | namespace index { // geos.geomgraph.index 23 | 24 | SweepLineEvent::SweepLineEvent(void *newEdgeSet, double x, SweepLineEvent *newInsertEvent, SweepLineEventOBJ *newObj) 25 | : edgeSet(newEdgeSet), obj(newObj), xValue(x), insertEvent(newInsertEvent), deleteEventIndex(0) { 26 | } 27 | 28 | } // namespace index 29 | } // namespace geomgraph 30 | } // namespace geos 31 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/algorithm/Intersection.hpp: -------------------------------------------------------------------------------- 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 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace geos { 22 | namespace algorithm { // geos::algorithm 23 | 24 | /** \brief 25 | * Computes the intersection point of two lines. 26 | * If the lines are parallel or collinear this case is detected 27 | * and null is returned. 28 | *

29 | * In general it is not possible to accurately compute 30 | * the intersection point of two lines, due to 31 | * numerical roundoff. 32 | * This is particularly true when the input lines are nearly parallel. 33 | * This routine uses numerical conditioning on the input values 34 | * to ensure that the computed value should be very close to the correct value. 35 | * 36 | * @param p1 an endpoint of line 1 37 | * @param p2 an endpoint of line 1 38 | * @param q1 an endpoint of line 2 39 | * @param q2 an endpoint of line 2 40 | * @return the intersection point between the lines, if there is one, 41 | * or null if the lines are parallel or collinear 42 | * 43 | * @see CGAlgorithmsDD#intersection(Coordinate, Coordinate, Coordinate, Coordinate) 44 | */ 45 | class GEOS_DLL Intersection { 46 | 47 | public: 48 | static geom::Coordinate intersection(const geom::Coordinate &p1, const geom::Coordinate &p2, 49 | const geom::Coordinate &q1, const geom::Coordinate &q2); 50 | }; 51 | 52 | } // namespace algorithm 53 | } // namespace geos 54 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/algorithm/Length.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2018 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: algorithm/Length.java @ 2017-09-04 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace geos { 26 | namespace algorithm { // geos::algorithm 27 | 28 | /** \brief 29 | * Functions for computing length. 30 | * 31 | * @author Martin Davis 32 | */ 33 | class GEOS_DLL Length { 34 | public: 35 | /** 36 | * Computes the length of a linestring specified by a sequence of points. 37 | * 38 | * @param ring the points specifying the linestring 39 | * @return the length of the linestring 40 | */ 41 | static double ofLine(const geom::CoordinateSequence *ring); 42 | }; 43 | 44 | } // namespace algorithm 45 | } // namespace geos 46 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/algorithm/locate/PointOnGeometryLocator.hpp: -------------------------------------------------------------------------------- 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 19 | 20 | namespace geos { 21 | namespace geom { 22 | class CoordinateXY; 23 | } 24 | } // namespace geos 25 | 26 | namespace geos { 27 | namespace algorithm { // geos::algorithm 28 | namespace locate { // geos::algorithm::locate 29 | 30 | /** \brief 31 | * An interface for classes which determine the [Location](@ref geom::Location) of 32 | * points in [Polygon](@ref geom::Polygon) or [MultiPolygon](@ref geom::MultiPolygon) geometries. 33 | * 34 | * @author Martin Davis 35 | */ 36 | class GEOS_DLL PointOnGeometryLocator { 37 | public: 38 | virtual ~PointOnGeometryLocator() { 39 | } 40 | 41 | /** 42 | * Determines the [Location](@ref geom::Location) of a point in an areal [Geometry](@ref geom::Geometry). 43 | * 44 | * @param p the point to test 45 | * @return the location of the point in the geometry 46 | */ 47 | virtual geom::Location locate(const geom::CoordinateXY * /*const*/ p) = 0; 48 | }; 49 | 50 | } // namespace locate 51 | } // namespace algorithm 52 | } // namespace geos 53 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/constants.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * constants.h 4 | * 5 | * GEOS - Geometry Engine Open Source 6 | * http://geos.osgeo.org 7 | * 8 | * Copyright (C) 2018 Vicky Vergara 9 | * Copyright (C) 2009 Mateusz Loskot 10 | * Copyright (C) 2005-2009 Refractions Research Inc. 11 | * Copyright (C) 2001-2009 Vivid Solutions Inc. 12 | * 13 | * This is free software; you can redistribute and/or modify it under 14 | * the terms of the GNU Lesser General Public Licence as published 15 | * by the Free Software Foundation. 16 | * See the COPYING file for more information. 17 | * 18 | *********************************************************************/ 19 | 20 | #pragma once 21 | 22 | #ifdef _MSC_VER 23 | #ifndef NOMINMAX 24 | #define NOMINMAX 1 25 | typedef __int64 int64; 26 | #endif 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace geos { 34 | 35 | constexpr double MATH_PI = 3.14159265358979323846; 36 | 37 | // Some handy constants 38 | constexpr double DoubleNotANumber = std::numeric_limits::quiet_NaN(); 39 | constexpr double DoubleMax = (std::numeric_limits::max)(); 40 | constexpr double DoubleInfinity = (std::numeric_limits::infinity)(); 41 | constexpr double DoubleNegInfinity = (-(std::numeric_limits::infinity)()); 42 | constexpr double DoubleEpsilon = std::numeric_limits::epsilon(); 43 | 44 | } // namespace geos 45 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/export.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2009 Ragi Y. Burhum 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 | #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BCPLUSPLUS__) || defined(__MWERKS__) 17 | 18 | #if defined(GEOS_DLL_EXPORT) 19 | #define GEOS_DLL __declspec(dllexport) 20 | #elif defined(GEOS_DLL_IMPORT) 21 | #define GEOS_DLL extern __declspec(dllimport) 22 | #else 23 | #define GEOS_DLL 24 | #endif 25 | #else 26 | #define GEOS_DLL 27 | #endif 28 | 29 | #if defined(_MSC_VER) 30 | #pragma warning( \ 31 | disable : 4251) // identifier : class type needs to have dll-interface to be used by clients of class type2 32 | #endif 33 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/CoordinateFilter.hpp: -------------------------------------------------------------------------------- 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 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | namespace geos { 21 | namespace geom { // geos::geom 22 | 23 | class Coordinate; 24 | 25 | /** \brief 26 | * Geometry classes support the concept of applying a 27 | * coordinate filter to every coordinate in the Geometry. 28 | * 29 | * A coordinate filter can either record information about each coordinate or 30 | * change the coordinate in some way. Coordinate filters implement the 31 | * interface CoordinateFilter. (CoordinateFilter is 32 | * an example of the Gang-of-Four Visitor pattern). Coordinate filters can be 33 | * used to implement such things as coordinate transformations, centroid and 34 | * envelope computation, and many other functions. 35 | * 36 | * TODO: provide geom::CoordinateInspector and geom::CoordinateMutator instead 37 | * of having the two versions of filter_rw and filter_ro 38 | * 39 | */ 40 | class GEOS_DLL CoordinateFilter { 41 | public: 42 | virtual ~CoordinateFilter() { 43 | } 44 | 45 | /** \brief 46 | * Performs an operation on `coord`. 47 | * 48 | * **param** `coord` a Coordinate to which the filter is applied. 49 | */ 50 | virtual void filter_rw(Coordinate * /*coord*/) const { 51 | assert(0); 52 | } 53 | 54 | /** \brief 55 | * Performs an operation with `coord`. 56 | * 57 | * **param** `coord` a Coordinate to which the filter is applied. 58 | */ 59 | virtual void filter_ro(const Coordinate * /*coord*/) { 60 | assert(0); 61 | } 62 | }; 63 | 64 | } // namespace geom 65 | } // namespace geos 66 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/Dimension.hpp: -------------------------------------------------------------------------------- 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 geom { // geos::geom 21 | 22 | /// Constants representing the dimensions of a point, a curve and a surface. 23 | /// 24 | /// Also, constants representing the dimensions of the empty geometry and 25 | /// non-empty geometries, and a wildcard dimension meaning "any dimension". 26 | /// 27 | class GEOS_DLL Dimension { 28 | public: 29 | enum DimensionType { 30 | /// Dimension value for any dimension (= {FALSE, TRUE}). 31 | DONTCARE = -3, 32 | 33 | /// Dimension value of non-empty geometries (= {P, L, A}). 34 | True = -2, 35 | 36 | /// Dimension value of the empty geometry (-1). 37 | False = -1, 38 | 39 | /// Dimension value of a point (0). 40 | P = 0, 41 | 42 | /// Dimension value of a curve (1). 43 | L = 1, 44 | 45 | /// Dimension value of a surface (2). 46 | A = 2 47 | }; 48 | 49 | // static const int P = 0; /// Dimension value of a point (0). 50 | // static const int L = 1; /// Dimension value of a curve (1). 51 | // static const int A = 2; /// Dimension value of a surface (2). 52 | // static const int False = -1; /// Dimension value of the empty geometry (-1). 53 | // static const int True = -2; /// Dimension value of non-empty geometries (= {P, L, A}). 54 | // static const int DONTCARE = -3; /// Dimension value for any dimension (= {FALSE, TRUE}). 55 | static char toDimensionSymbol(int dimensionValue); 56 | 57 | static int toDimensionValue(char dimensionSymbol); 58 | }; 59 | 60 | } // namespace geom 61 | } // namespace geos 62 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/GeometryComponentFilter.hpp: -------------------------------------------------------------------------------- 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 | #pragma once 16 | 17 | #include 18 | 19 | namespace geos { 20 | namespace geom { // geos::geom 21 | class Geometry; 22 | } 23 | } // namespace geos 24 | 25 | namespace geos { 26 | namespace geom { // geos::geom 27 | 28 | /** 29 | * Geometry classes support the concept of applying 30 | * a GeometryComponentFilter 31 | * filter to the Geometry. 32 | * The filter is applied to every component of the Geometry 33 | * which is itself a Geometry. 34 | * A GeometryComponentFilter filter can either 35 | * record information about the Geometry 36 | * or change the Geometry in some way. 37 | * GeometryComponentFilter 38 | * is an example of the Gang-of-Four Visitor pattern. 39 | * 40 | */ 41 | class GEOS_DLL GeometryComponentFilter { 42 | public: 43 | /** 44 | * Performs an operation with or on geom. 45 | * 46 | * @param geom a Geometry to which the filter 47 | * is applied. 48 | */ 49 | virtual void filter_rw(Geometry *geom); 50 | virtual void filter_ro(const Geometry *geom); 51 | 52 | virtual bool isDone() { 53 | return false; 54 | } 55 | 56 | virtual ~GeometryComponentFilter() { 57 | } 58 | }; 59 | 60 | } // namespace geom 61 | } // namespace geos 62 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/GeometryFilter.hpp: -------------------------------------------------------------------------------- 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 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 | #include 21 | #include 22 | 23 | namespace geos { 24 | namespace geom { // geos::geom 25 | class Geometry; 26 | } 27 | } // namespace geos 28 | 29 | namespace geos { 30 | namespace geom { // geos::geom 31 | 32 | /** \brief 33 | * Geometry classes support the concept of applying a Geometry 34 | * filter to the Geometry. 35 | * 36 | * In the case of GeometryCollection 37 | * subclasses, the filter is applied to every element Geometry. 38 | * A Geometry filter can either record information about the Geometry 39 | * or change the Geometry in some way. 40 | * Geometry filters implement the interface GeometryFilter. 41 | * (GeometryFilter is an example of the Gang-of-Four Visitor pattern). 42 | */ 43 | class GEOS_DLL GeometryFilter { 44 | public: 45 | /* 46 | * Performs an operation with or on geom. 47 | * 48 | * @param geom a Geometry to which the filter 49 | * is applied. 50 | * 51 | * NOTE: this are not pure abstract to allow read-only 52 | * or read-write-only filters to avoid defining a fake 53 | * version of the not-implemented kind. 54 | */ 55 | virtual void filter_ro(const Geometry * /*geom*/) { 56 | assert(0); 57 | } 58 | virtual void filter_rw(Geometry * /*geom*/) { 59 | assert(0); 60 | } 61 | 62 | virtual ~GeometryFilter() { 63 | } 64 | }; 65 | 66 | } // namespace geom 67 | } // namespace geos 68 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/HeuristicOverlay.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2013-2020 Sandro Santilli 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 | * Last port: ORIGINAL WORK 17 | * 18 | **********************************************************************/ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include // for unique_ptr 24 | 25 | namespace geos { 26 | namespace geom { // geos::geom 27 | 28 | class Geometry; 29 | 30 | std::unique_ptr GEOS_DLL HeuristicOverlay(const Geometry *g0, const Geometry *g1, int opCode); 31 | 32 | } // namespace geom 33 | } // namespace geos 34 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/Location.hpp: -------------------------------------------------------------------------------- 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 | #include // for ostream 19 | 20 | namespace geos { 21 | namespace geom { // geos::geom 22 | 23 | /** \brief 24 | * Constants representing the location of a point relative to a geometry. 25 | * 26 | * They can also be thought of as the row or column index of a DE-9IM matrix. 27 | * For a description of the DE-9IM, see the 28 | * [OpenGIS Simple Features Specification for SQL](http://www.opengis.org/techno/specs.htm"). 29 | */ 30 | 31 | enum class Location : char { 32 | /** 33 | * Used for uninitialized location values. 34 | */ 35 | NONE = (char)(-1), // Instead of NULL 36 | 37 | /** 38 | * DE-9IM row index of the interior of the first geometry and 39 | * column index of the interior of the second geometry. 40 | * Location value for the interior of a geometry. 41 | */ 42 | INTERIOR = 0, 43 | 44 | /** 45 | * DE-9IM row index of the boundary of the first geometry and 46 | * column index of the boundary of the second geometry. 47 | * Location value for the boundary of a geometry. 48 | */ 49 | BOUNDARY = 1, 50 | 51 | /** 52 | * DE-9IM row index of the exterior of the first geometry and 53 | * column index of the exterior of the second geometry. 54 | * Location value for the exterior of a geometry. 55 | */ 56 | EXTERIOR = 2 57 | }; 58 | 59 | GEOS_DLL std::ostream &operator<<(std::ostream &os, const Location &loc); 60 | 61 | } // namespace geom 62 | } // namespace geos 63 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/Position.hpp: -------------------------------------------------------------------------------- 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: geom/Position.java rev. 1.4 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace geos { 28 | namespace geom { // geos.geom 29 | 30 | /** \brief 31 | * A Position indicates the position of a Location relative to a graph 32 | * component (Node, Edge, or Area). 33 | */ 34 | class GEOS_DLL Position { 35 | public: 36 | enum { 37 | /** \brief 38 | * An indicator that a Location is *on* 39 | * a GraphComponent 40 | */ 41 | ON = 0, 42 | 43 | /** \brief 44 | * An indicator that a Location is to the 45 | * *left* of a GraphComponent 46 | */ 47 | LEFT, 48 | 49 | /** \brief 50 | * An indicator that a Location is to the 51 | * *right* of a GraphComponent 52 | */ 53 | RIGHT 54 | }; 55 | 56 | /** \brief 57 | * Returns LEFT if the position is RIGHT, RIGHT if 58 | * the position is LEFT, or the position otherwise. 59 | */ 60 | static int opposite(int position); 61 | }; 62 | 63 | } // namespace geom 64 | } // namespace geos 65 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/Triangle.hpp: -------------------------------------------------------------------------------- 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 | #include 19 | 20 | namespace geos { 21 | namespace geom { // geos::geom 22 | 23 | /** 24 | * \brief 25 | * Represents a planar triangle, and provides methods for calculating various 26 | * properties of triangles. 27 | */ 28 | class GEOS_DLL Triangle { 29 | public: 30 | CoordinateXY p0, p1, p2; 31 | 32 | Triangle(const CoordinateXY &nP0, const CoordinateXY &nP1, const CoordinateXY &nP2) : p0(nP0), p1(nP1), p2(nP2) { 33 | } 34 | 35 | /** \brief 36 | * The inCentre of a triangle is the point which is equidistant 37 | * from the sides of the triangle. 38 | * 39 | * This is also the point at which the bisectors of the angles meet. 40 | * 41 | * @param resultPoint the point into which to write the inCentre of the triangle 42 | */ 43 | void inCentre(CoordinateXY &resultPoint); 44 | }; 45 | 46 | } // namespace geom 47 | } // namespace geos 48 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/util/GeometryEditorOperation.hpp: -------------------------------------------------------------------------------- 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 | // Forward declarations 22 | namespace geos { 23 | namespace geom { 24 | class Geometry; 25 | class GeometryFactory; 26 | } // namespace geom 27 | } // namespace geos 28 | 29 | namespace geos { 30 | namespace geom { // geos.geom 31 | namespace util { // geos.geom.util 32 | 33 | /** 34 | * A interface which specifies an edit operation for Geometries. 35 | */ 36 | class GEOS_DLL GeometryEditorOperation { 37 | 38 | public: 39 | /** 40 | * Edits a Geometry by returning a new Geometry with a modification. 41 | * The returned Geometry might be the same as the Geometry passed in. 42 | * 43 | * @param geometry the Geometry to modify 44 | * 45 | * @param factory the factory with which to construct the modified 46 | * Geometry (may be different to the factory of the 47 | * input geometry) 48 | * 49 | * @return a new Geometry which is a modification of the input Geometry 50 | */ 51 | virtual std::unique_ptr edit(const Geometry *geometry, const GeometryFactory *factory) = 0; 52 | 53 | virtual ~GeometryEditorOperation() { 54 | } 55 | }; 56 | 57 | } // namespace util 58 | } // namespace geom 59 | } // namespace geos 60 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/util/LinearComponentExtracter.hpp: -------------------------------------------------------------------------------- 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 // to be removed when we have the .inl 20 | #include 21 | #include // to be removed when we have the .inl 22 | #include 23 | 24 | namespace geos { 25 | namespace geom { // geos.geom 26 | namespace util { // geos.geom.util 27 | 28 | /** 29 | * Extracts all the 1-dimensional (LineString) components from a Geometry. 30 | */ 31 | class GEOS_DLL LinearComponentExtracter : public GeometryComponentFilter { 32 | private: 33 | LineString::ConstVect &comps; 34 | 35 | public: 36 | /** 37 | * Push the linear components from a single geometry into 38 | * the provided vector. 39 | * If more than one geometry is to be processed, it is more 40 | * efficient to create a single LinearComponentExtracterFilter instance 41 | * and pass it to multiple geometries. 42 | */ 43 | static void getLines(const Geometry &geom, std::vector &ret); 44 | 45 | /** 46 | * Constructs a LinearComponentExtracterFilter with a list in which 47 | * to store LineStrings found. 48 | */ 49 | LinearComponentExtracter(std::vector &newComps); 50 | 51 | void filter_rw(Geometry *geom) override; 52 | 53 | void filter_ro(const Geometry *geom) override; 54 | }; 55 | 56 | } // namespace util 57 | } // namespace geom 58 | } // namespace geos 59 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/util/NoOpGeometryOperation.hpp: -------------------------------------------------------------------------------- 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 | } // namespace geom 27 | } // namespace geos 28 | 29 | namespace geos { 30 | namespace geom { // geos.geom 31 | namespace util { // geos.geom.util 32 | 33 | class GEOS_DLL NoOpGeometryOperation : public GeometryEditorOperation { 34 | public: 35 | /** 36 | * Return a newly created geometry, ownership to caller 37 | */ 38 | std::unique_ptr edit(const Geometry *geometry, const GeometryFactory *factory) override; 39 | 40 | ~NoOpGeometryOperation() override = default; 41 | }; 42 | } // namespace util 43 | } // namespace geom 44 | } // namespace geos 45 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geom/util/ShortCircuitedGeometryVisitor.hpp: -------------------------------------------------------------------------------- 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 | 20 | // Forward declarations 21 | namespace geos { 22 | namespace geom { 23 | class Geometry; 24 | } 25 | } // namespace geos 26 | 27 | namespace geos { 28 | namespace geom { // geos.geom 29 | namespace util { // geos.geom.util 30 | 31 | /** \brief 32 | * A visitor to Geometry elements which can 33 | * be short-circuited by a given condition 34 | * 35 | * Last port: geom/util/ShortCircuitedGeometryVisitor.java rev. 1.1 (JTS-1.7) 36 | */ 37 | class GEOS_DLL ShortCircuitedGeometryVisitor { 38 | 39 | private: 40 | bool done; 41 | 42 | protected: 43 | virtual void visit(const Geometry &element) = 0; 44 | virtual bool isDone() = 0; 45 | 46 | public: 47 | ShortCircuitedGeometryVisitor() : done(false) { 48 | } 49 | 50 | void applyTo(const Geometry &geom); 51 | 52 | virtual ~ShortCircuitedGeometryVisitor() { 53 | } 54 | }; 55 | 56 | } // namespace util 57 | } // namespace geom 58 | } // namespace geos 59 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geomgraph/EdgeList.hpp: -------------------------------------------------------------------------------- 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/EdgeList.java rev. 1.4 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include // for map comparator 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // Forward declarations 30 | namespace geos { 31 | namespace index { 32 | class SpatialIndex; 33 | } 34 | namespace geomgraph { 35 | class Edge; 36 | } 37 | } // namespace geos 38 | 39 | namespace geos { 40 | namespace geomgraph { // geos.geomgraph 41 | 42 | /** \brief 43 | * A EdgeList is a list of Edges. 44 | * 45 | * It supports locating edges 46 | * that are pointwise equals to a target edge. 47 | */ 48 | class GEOS_DLL EdgeList { 49 | private: 50 | std::vector edges; 51 | 52 | /** 53 | * An index of the edges, for fast lookup. 54 | */ 55 | typedef std::unordered_map 56 | EdgeMap; 57 | 58 | EdgeMap ocaMap; 59 | 60 | public: 61 | std::vector &getEdges() { 62 | return edges; 63 | } 64 | 65 | /** 66 | * Insert an edge unless it is already in the list 67 | */ 68 | void add(Edge *e); 69 | 70 | void clearList(); 71 | 72 | Edge *findEqualEdge(const Edge *e) const; 73 | }; 74 | 75 | } // namespace geomgraph 76 | } // namespace geos 77 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geomgraph/NodeFactory.hpp: -------------------------------------------------------------------------------- 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 | #pragma once 21 | 22 | #include 23 | 24 | // Forward declarations 25 | namespace geos { 26 | namespace geom { 27 | class Coordinate; 28 | } 29 | namespace geomgraph { 30 | class Node; 31 | } 32 | } // namespace geos 33 | 34 | namespace geos { 35 | namespace geomgraph { // geos.geomgraph 36 | 37 | class GEOS_DLL NodeFactory { 38 | public: 39 | virtual Node *createNode(const geom::Coordinate &coord) const; 40 | static const NodeFactory &instance(); 41 | virtual ~NodeFactory() { 42 | } 43 | 44 | protected: 45 | NodeFactory() { 46 | } 47 | }; 48 | 49 | } // namespace geomgraph 50 | } // namespace geos 51 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geomgraph/index/MonotoneChain.hpp: -------------------------------------------------------------------------------- 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/index/MonotoneChain.java rev. 1.3 (JTS-1.7) 17 | * 18 | **********************************************************************/ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include // for inline 25 | #include // for inheritance 26 | 27 | // Forward declarations 28 | namespace geos { 29 | namespace geomgraph { 30 | namespace index { 31 | class SegmentIntersector; 32 | } 33 | } // namespace geomgraph 34 | } // namespace geos 35 | 36 | namespace geos { 37 | namespace geomgraph { // geos::geomgraph 38 | namespace index { // geos::geomgraph::index 39 | 40 | /** 41 | * A chain in a MonotoneChainEdge 42 | */ 43 | class GEOS_DLL MonotoneChain : public SweepLineEventOBJ { 44 | private: 45 | MonotoneChainEdge *mce; 46 | std::size_t chainIndex; 47 | 48 | public: 49 | MonotoneChain(MonotoneChainEdge *newMce, std::size_t newChainIndex) : mce(newMce), chainIndex(newChainIndex) { 50 | } 51 | 52 | ~MonotoneChain() override { 53 | } 54 | 55 | void computeIntersections(MonotoneChain *mc, SegmentIntersector *si) { 56 | mce->computeIntersectsForChain(chainIndex, *(mc->mce), mc->chainIndex, *si); 57 | } 58 | }; 59 | } // namespace index 60 | } // namespace geomgraph 61 | } // namespace geos 62 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/geomgraph/index/SweepLineEventObj.hpp: -------------------------------------------------------------------------------- 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 ~SweepLineEventOBJ() { 31 | } 32 | }; 33 | 34 | } // namespace index 35 | } // namespace geomgraph 36 | } // namespace geos 37 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/index/ItemVisitor.hpp: -------------------------------------------------------------------------------- 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 ~ItemVisitor() { 33 | } 34 | }; 35 | 36 | } // namespace index 37 | } // namespace geos 38 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/index/chain/MonotoneChainBuilder.hpp: -------------------------------------------------------------------------------- 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/MonotoneChainBuilder.java r388 (JTS-1.12) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | // Forward declarations 27 | namespace geos { 28 | namespace geom { 29 | class CoordinateSequence; 30 | } 31 | namespace index { 32 | namespace chain { 33 | class MonotoneChain; 34 | } 35 | } // namespace index 36 | } // namespace geos 37 | 38 | namespace geos { 39 | namespace index { // geos::index 40 | namespace chain { // geos::index::chain 41 | 42 | /** \brief 43 | * Constructs [MonotoneChains](@ref index::chain::MonotoneChain) 44 | * for sequences of [Coordinates](@ref geom::Coordinate). 45 | * 46 | * TODO: use vector instead ? 47 | */ 48 | class GEOS_DLL MonotoneChainBuilder { 49 | public: 50 | /** \brief 51 | * Computes a list of the {@link MonotoneChain}s for a list of coordinates, 52 | * attaching a context data object to each. 53 | * 54 | * @param pts the list of points to compute chains for 55 | * @param context a data object to attach to each chain 56 | * @param[out] mcList a list of the monotone chains for the points 57 | */ 58 | static void getChains(const geom::CoordinateSequence *pts, void *context, std::vector &mcList); 59 | }; 60 | 61 | } // namespace chain 62 | } // namespace index 63 | } // namespace geos 64 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/index/kdtree/KdNode.hpp: -------------------------------------------------------------------------------- 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 // for composition 22 | 23 | namespace geos { 24 | namespace index { // geos::index 25 | namespace kdtree { // geos::index::kdtree 26 | 27 | /** 28 | * A node of a {@link KdTree}, which represents one or more points in the same location. 29 | */ 30 | class GEOS_DLL KdNode { 31 | 32 | private: 33 | geom::Coordinate p; 34 | void *data; 35 | KdNode *left; 36 | KdNode *right; 37 | std::size_t count; 38 | 39 | public: 40 | KdNode(double p_x, double p_y, void *p_data); 41 | KdNode(const geom::Coordinate &p_p, void *p_data); 42 | 43 | double getX() { 44 | return p.x; 45 | } 46 | double getY() { 47 | return p.y; 48 | } 49 | const geom::Coordinate &getCoordinate() { 50 | return p; 51 | } 52 | void *getData() { 53 | return data; 54 | } 55 | KdNode *getLeft() { 56 | return left; 57 | } 58 | KdNode *getRight() { 59 | return right; 60 | } 61 | void increment() { 62 | count++; 63 | } 64 | std::size_t getCount() { 65 | return count; 66 | } 67 | bool isRepeated() { 68 | return count > 1; 69 | } 70 | void setLeft(KdNode *p_left) { 71 | left = p_left; 72 | } 73 | void setRight(KdNode *p_right) { 74 | right = p_right; 75 | } 76 | }; 77 | 78 | } // namespace kdtree 79 | } // namespace index 80 | } // namespace geos 81 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/index/kdtree/KdNodeVisitor.hpp: -------------------------------------------------------------------------------- 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 | protected: 31 | public: 32 | KdNodeVisitor() {}; 33 | virtual void visit(KdNode *node) = 0; 34 | }; 35 | 36 | } // namespace kdtree 37 | } // namespace index 38 | } // namespace geos 39 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/index/strtree/Boundable.hpp: -------------------------------------------------------------------------------- 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 | #ifndef GEOS_INDEX_STRTREE_BOUNDABLE_H 16 | #define GEOS_INDEX_STRTREE_BOUNDABLE_H 17 | 18 | #include 19 | 20 | namespace geos { 21 | namespace index { // geos::index 22 | namespace strtree { // geos::index::strtree 23 | 24 | /// A spatial object in an AbstractSTRtree. 25 | class GEOS_DLL Boundable { 26 | public: 27 | virtual bool isLeaf() const = 0; 28 | virtual ~Boundable() { 29 | } 30 | }; 31 | 32 | } // namespace strtree 33 | } // namespace index 34 | } // namespace geos 35 | 36 | #endif // GEOS_INDEX_STRTREE_BOUNDABLE_H 37 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/index/strtree/Interval.hpp: -------------------------------------------------------------------------------- 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 | #include 19 | #include 20 | 21 | namespace geos { 22 | namespace index { // geos::index 23 | namespace strtree { // geos::index::strtree 24 | 25 | /// A contiguous portion of 1D-space. Used internally by SIRtree. 26 | // 27 | /// @see SIRtree 28 | /// 29 | class GEOS_DLL Interval { 30 | public: 31 | Interval(double newMin, double newMax) : imin(newMin), imax(newMax) { 32 | assert(imin <= imax); 33 | } 34 | 35 | double getMin() const { 36 | return imin; 37 | } 38 | double getMax() const { 39 | return imax; 40 | } 41 | double getWidth() const { 42 | return imax - imin; 43 | } 44 | double getCentre() const { 45 | return (imin + imax) / 2; 46 | } 47 | Interval *expandToInclude(const Interval *other) { 48 | imax = std::max(imax, other->imax); 49 | imin = std::min(imin, other->imin); 50 | return this; 51 | } 52 | bool intersects(const Interval *other) const { 53 | return !(other->imin > imax || other->imax < imin); 54 | } 55 | bool equals(const Interval *other) const { 56 | return imin == other->imin && imax == other->imax; 57 | } 58 | 59 | private: 60 | double imin; 61 | double imax; 62 | }; 63 | 64 | } // namespace strtree 65 | } // namespace index 66 | } // namespace geos 67 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/index/strtree/ItemBoundable.hpp: -------------------------------------------------------------------------------- 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 | #ifndef GEOS_INDEX_STRTREE_ITEMBOUNDABLE_H 15 | #define GEOS_INDEX_STRTREE_ITEMBOUNDABLE_H 16 | 17 | #include 18 | #include // for inheritance 19 | 20 | namespace geos { 21 | namespace index { // geos::index 22 | namespace strtree { // geos::index::strtree 23 | 24 | /** 25 | * \brief 26 | * Boundable wrapper for a non-Boundable spatial object. 27 | * Used internally by AbstractSTRtree. 28 | * 29 | * \todo TODO: It's unclear who takes ownership of passed newBounds and newItem objects. 30 | */ 31 | class GEOS_DLL ItemBoundable : public Boundable { 32 | public: 33 | ItemBoundable(const void *newBounds, void *newItem) : bounds(newBounds), item(newItem) { 34 | } 35 | ~ItemBoundable() override = default; 36 | 37 | bool isLeaf() const override { 38 | return true; 39 | } 40 | 41 | private: 42 | const void *bounds; 43 | void *item; 44 | }; 45 | 46 | } // namespace strtree 47 | } // namespace index 48 | } // namespace geos 49 | 50 | #endif // GEOS_INDEX_STRTREE_ITEMBOUNDABLE_H 51 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/noding/NodableSegmentString.hpp: -------------------------------------------------------------------------------- 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 19 | #include // for inheritance 20 | 21 | namespace geos { 22 | namespace geom { 23 | class Coordinate; 24 | } 25 | } // namespace geos 26 | 27 | namespace geos { 28 | namespace noding { // geos::noding 29 | 30 | /** \brief 31 | * An interface for classes which support adding nodes to 32 | * a segment string. 33 | * 34 | * @author Martin Davis 35 | */ 36 | class GEOS_DLL NodableSegmentString : public SegmentString { 37 | public: 38 | NodableSegmentString(const void *newContext) : SegmentString(newContext) { 39 | } 40 | }; 41 | 42 | } // namespace noding 43 | } // namespace geos 44 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/noding/Octant.hpp: -------------------------------------------------------------------------------- 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 | #include 19 | 20 | // Forward declarations 21 | namespace geos { 22 | namespace geom { 23 | class Coordinate; 24 | } 25 | } // namespace geos 26 | 27 | namespace geos { 28 | namespace noding { // geos.noding 29 | 30 | /** \brief 31 | * Methods for computing and working with octants of the Cartesian plane. 32 | * 33 | * Octants are numbered as follows: 34 | * 35 | * 2|1 36 | * 3 | 0 37 | * ---+-- 38 | * 4 | 7 39 | * 5|6 40 | * 41 | * If line segments lie along a coordinate axis, the octant is the lower of the two 42 | * possible values. 43 | * 44 | * Last port: noding/Octant.java rev. 1.2 (JTS-1.7) 45 | */ 46 | class GEOS_DLL Octant { 47 | private: 48 | Octant() { 49 | } // Can't instanciate it 50 | public: 51 | /** 52 | * Returns the octant of a directed line segment (specified 53 | * as x and y displacements, which cannot both be 0). 54 | */ 55 | static int octant(double dx, double dy); 56 | 57 | /** 58 | * Returns the octant of a directed line segment from p0 to p1. 59 | */ 60 | static int octant(const geom::Coordinate &p0, const geom::Coordinate &p1); 61 | 62 | static int octant(const geom::Coordinate *p0, const geom::Coordinate *p1) { 63 | ::geos::ignore_unused_variable_warning(p0); 64 | return octant(*p0, *p1); 65 | } 66 | }; 67 | 68 | } // namespace noding 69 | } // namespace geos 70 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/noding/ValidatingNoder.hpp: -------------------------------------------------------------------------------- 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 19 | #include // for unique_ptr 20 | 21 | // Forward declarations 22 | namespace geos { 23 | namespace algorithm { 24 | class LineIntersector; 25 | } 26 | namespace geom { 27 | class Geometry; 28 | } 29 | } // namespace geos 30 | 31 | namespace geos { 32 | namespace noding { // geos.noding 33 | 34 | /** 35 | * A wrapper for {@link noding::Noder}s which validates 36 | * the output arrangement is correctly noded. 37 | * An arrangement of line segments is fully noded if 38 | * there is no line segment 39 | * which has another segment intersecting its interior. 40 | * If the noding is not correct, a {@link util::TopologyException} is thrown 41 | * with details of the first invalid location found. 42 | * 43 | * @author mdavis 44 | * 45 | * @see FastNodingValidator 46 | * 47 | */ 48 | class GEOS_DLL ValidatingNoder : public Noder { 49 | 50 | private: 51 | std::vector *nodedSS; 52 | noding::Noder &noder; 53 | 54 | public: 55 | ValidatingNoder(Noder &noderArg) : noder(noderArg) { 56 | } 57 | 58 | void computeNodes(std::vector *segStrings) override; 59 | 60 | void validate(); 61 | 62 | std::vector *getNodedSubstrings() const override; 63 | }; 64 | 65 | } // namespace noding 66 | } // namespace geos 67 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/noding/snap/SnappingPointIndex.hpp: -------------------------------------------------------------------------------- 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: noding/snap/SnappingPointIndex.java 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace geos { 26 | namespace noding { // geos::noding 27 | namespace snap { // geos::noding::snap 28 | 29 | class GEOS_DLL SnappingPointIndex { 30 | 31 | /** 32 | * An index providing fast creation and lookup of snap points. 33 | * @author mdavis 34 | */ 35 | 36 | private: 37 | // double snapTolerance; 38 | std::unique_ptr snapPointIndex; 39 | 40 | public: 41 | SnappingPointIndex(double p_snapTolerance); 42 | 43 | /** 44 | * Snaps a coordinate to an existing snap point, 45 | * if it is within the snap tolerance distance. 46 | * Otherwise adds the coordinate to the snap point index. 47 | * 48 | * @param p the point to snap 49 | * @return the point it snapped to, or the input point 50 | */ 51 | const geom::Coordinate &snap(const geom::Coordinate &p); 52 | }; 53 | 54 | } // namespace snap 55 | } // namespace noding 56 | } // namespace geos 57 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/noding/snapround/MCIndexPointSnapper.hpp: -------------------------------------------------------------------------------- 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 | * Last port: noding/snapround/MCIndexPointSnapper.java r486 (JTS-1.12+) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | // Forward declarations 25 | namespace geos { 26 | namespace geom { 27 | class Envelope; 28 | } 29 | namespace index { 30 | class SpatialIndex; 31 | } 32 | namespace noding { 33 | class SegmentString; 34 | namespace snapround { 35 | class HotPixel; 36 | } 37 | } // namespace noding 38 | } // namespace geos 39 | 40 | namespace geos { 41 | namespace noding { // geos::noding 42 | namespace snapround { // geos::noding::snapround 43 | 44 | /** \brief 45 | * "Snaps" all [SegmentStrings](@ref SegmentString) in a [SpatialIndex](@ref index::SpatialIndex) containing 46 | * [MonotoneChains](@ref index::chain::MonotoneChain) to a given HotPixel. 47 | * 48 | */ 49 | class GEOS_DLL MCIndexPointSnapper {}; 50 | 51 | } // namespace snapround 52 | } // namespace noding 53 | } // namespace geos 54 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/overlay/ElevationMatrixCell.hpp: -------------------------------------------------------------------------------- 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 | * Last port: original (by strk) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | // Forward declarations 25 | namespace geos { 26 | namespace geom { 27 | class Coordinate; 28 | } 29 | } // namespace geos 30 | 31 | namespace geos { 32 | namespace operation { // geos::operation 33 | namespace overlay { // geos::operation::overlay 34 | 35 | class GEOS_DLL ElevationMatrixCell { 36 | public: 37 | ElevationMatrixCell(); 38 | ~ElevationMatrixCell() = default; 39 | void add(const geom::Coordinate &c); 40 | void add(double z); 41 | double getAvg(void) const; 42 | double getTotal(void) const; 43 | std::string print() const; 44 | 45 | private: 46 | std::set zvals; 47 | double ztot; 48 | }; 49 | 50 | } // namespace overlay 51 | } // namespace operation 52 | } // namespace geos 53 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/overlay/OverlayNodeFactory.hpp: -------------------------------------------------------------------------------- 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 | * Last port: operation/overlay/OverlayNodeFactory.java rev. 1.11 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include // for inheritance 23 | #include 24 | 25 | // Forward declarations 26 | namespace geos { 27 | namespace geom { 28 | class Coordinate; 29 | } 30 | namespace geomgraph { 31 | class Node; 32 | } 33 | } // namespace geos 34 | 35 | namespace geos { 36 | namespace operation { // geos::operation 37 | namespace overlay { // geos::operation::overlay 38 | 39 | /** \brief 40 | * Creates nodes for use in the geomgraph::PlanarGraph constructed during 41 | * overlay operations. NOTE: also used by operation::valid 42 | */ 43 | class GEOS_DLL OverlayNodeFactory : public geomgraph::NodeFactory { 44 | public: 45 | OverlayNodeFactory() : geomgraph::NodeFactory() { 46 | } 47 | geomgraph::Node *createNode(const geom::Coordinate &coord) const override; 48 | static const geomgraph::NodeFactory &instance(); 49 | }; 50 | 51 | } // namespace overlay 52 | } // namespace operation 53 | } // namespace geos 54 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/overlayng/EdgeSourceInfo.hpp: -------------------------------------------------------------------------------- 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 19 | #include 20 | 21 | namespace geos { // geos. 22 | namespace operation { // geos.operation 23 | namespace overlayng { // geos.operation.overlayng 24 | /** 25 | * Records topological information about an 26 | * edge representing a piece of linework (lineString or polygon ring) 27 | * from a single source geometry. 28 | * This information is carried through the noding process 29 | * (which may result in many noded edges sharing the same information object). 30 | * It is then used to populate the topology info fields 31 | * in {@link Edge}s (possibly via merging). 32 | * That information is used to construct the topology graph {@link OverlayLabel}s. 33 | * 34 | * @author mdavis 35 | * 36 | */ 37 | 38 | class GEOS_DLL EdgeSourceInfo { 39 | 40 | private: 41 | // Members 42 | uint8_t index; 43 | int8_t dim; 44 | bool edgeIsHole; 45 | int depthDelta; 46 | 47 | public: 48 | EdgeSourceInfo(uint8_t p_index, int p_depthDelta, bool p_isHole); 49 | EdgeSourceInfo(uint8_t p_index); 50 | 51 | uint8_t getIndex() const { 52 | return index; 53 | } 54 | int getDimension() const { 55 | return dim; 56 | } 57 | int getDepthDelta() const { 58 | return depthDelta; 59 | } 60 | bool isHole() const { 61 | return edgeIsHole; 62 | } 63 | }; 64 | 65 | } // namespace overlayng 66 | } // namespace operation 67 | } // namespace geos 68 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/overlayng/IndexedPointOnLineLocator.hpp: -------------------------------------------------------------------------------- 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 19 | #include 20 | 21 | // Forward declarations 22 | namespace geos { 23 | namespace geom { 24 | class Geometry; 25 | class Coordinate; 26 | } // namespace geom 27 | } // namespace geos 28 | 29 | namespace geos { // geos. 30 | namespace operation { // geos.operation 31 | namespace overlayng { // geos.operation.overlayng 32 | 33 | /** 34 | * Locates points on a linear geometry, 35 | * using a spatial index to provide good performance. 36 | * 37 | * @author mdavis 38 | */ 39 | class IndexedPointOnLineLocator : public algorithm::locate::PointOnGeometryLocator { 40 | 41 | private: 42 | // Members 43 | const geom::Geometry &inputGeom; 44 | 45 | public: 46 | IndexedPointOnLineLocator(const geom::Geometry &geomLinear) : inputGeom(geomLinear) { 47 | } 48 | 49 | geom::Location locate(const geom::CoordinateXY *p) override; 50 | }; 51 | 52 | } // namespace overlayng 53 | } // namespace operation 54 | } // namespace geos 55 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/overlayng/PrecisionReducer.hpp: -------------------------------------------------------------------------------- 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 19 | #include 20 | #include 21 | 22 | // Forward declarations 23 | namespace geos { 24 | namespace geom { 25 | class PrecisionModel; 26 | class Geometry; 27 | } // namespace geom 28 | namespace operation {} 29 | } // namespace geos 30 | 31 | namespace geos { // geos. 32 | namespace operation { // geos.operation 33 | namespace overlayng { // geos.operation.overlayng 34 | 35 | using namespace geos::geom; 36 | 37 | /** 38 | * Reduces the precision of a geometry by rounding it to the 39 | * supplied {@link geom::PrecisionModel}. 40 | * 41 | * The output is always a valid geometry. This implies that input components 42 | * may be merged if they are closer than the grid precision. 43 | * if merging is not desired, then the individual geometry components 44 | * should be processed separately. 45 | * 46 | * The output is fully noded. 47 | * This provides an effective way to node / snap-round a collection of {@link geom::LineString}s. 48 | */ 49 | class GEOS_DLL PrecisionReducer { 50 | public: 51 | PrecisionReducer() {}; 52 | 53 | static std::unique_ptr reducePrecision(const Geometry *geom, const PrecisionModel *pm, 54 | bool replacePrecisionModel = false); 55 | }; 56 | 57 | } // namespace overlayng 58 | } // namespace operation 59 | } // namespace geos 60 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/relate/EdgeEndBundleStar.hpp: -------------------------------------------------------------------------------- 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 | * Last port: operation/relate/EdgeEndBundleStar.java rev. 1.13 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include // for EdgeEndBundleStar inheritance 23 | 24 | // Forward declarations 25 | namespace geos { 26 | namespace geom { 27 | class IntersectionMatrix; 28 | } 29 | namespace geomgraph { 30 | class EdgeEnd; 31 | } 32 | } // namespace geos 33 | 34 | namespace geos { 35 | namespace operation { // geos::operation 36 | namespace relate { // geos::operation::relate 37 | 38 | /** \brief 39 | * An ordered list of EdgeEndBundle objects around a RelateNode. 40 | * 41 | * They are maintained in CCW order (starting with the positive x-axis) 42 | * around the node 43 | * for efficient lookup and topology building. 44 | */ 45 | class GEOS_DLL EdgeEndBundleStar : public geomgraph::EdgeEndStar { 46 | public: 47 | /// Creates a new empty EdgeEndBundleStar 48 | EdgeEndBundleStar() { 49 | } 50 | 51 | ~EdgeEndBundleStar() override; 52 | void insert(geomgraph::EdgeEnd *e) override; 53 | 54 | /** 55 | * Update the IM with the contribution for the EdgeStubs around the node. 56 | */ 57 | void updateIM(geom::IntersectionMatrix &im); 58 | }; 59 | 60 | } // namespace relate 61 | } // namespace operation 62 | } // namespace geos 63 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/relate/RelateNode.hpp: -------------------------------------------------------------------------------- 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 | * Last port: operation/relate/RelateNode.java rev. 1.11 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include // for inheritance 23 | 24 | // Forward declarations 25 | namespace geos { 26 | namespace geom { 27 | class IntersectionMatrix; 28 | class Coordinate; 29 | } // namespace geom 30 | namespace geomgraph { 31 | class EdgeEndStar; 32 | } 33 | } // namespace geos 34 | 35 | namespace geos { 36 | namespace operation { // geos::operation 37 | namespace relate { // geos::operation::relate 38 | 39 | /** \brief 40 | * Represents a node in the topological graph used to compute spatial 41 | * relationships. 42 | */ 43 | class GEOS_DLL RelateNode : public geomgraph::Node { 44 | 45 | public: 46 | RelateNode(const geom::Coordinate &coord, geomgraph::EdgeEndStar *edges); 47 | 48 | ~RelateNode() override = default; 49 | 50 | /** 51 | * Update the IM with the contribution for the EdgeEnds incident on this node. 52 | */ 53 | void updateIMFromEdges(geom::IntersectionMatrix &im); 54 | 55 | protected: 56 | void computeIM(geom::IntersectionMatrix &im) override; 57 | }; 58 | 59 | } // namespace relate 60 | } // namespace operation 61 | } // namespace geos 62 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/relate/RelateNodeFactory.hpp: -------------------------------------------------------------------------------- 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 | * Last port: operation/relate/RelateNodeFactory.java rev. 1.11 (JTS-1.10) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include // for RelateNodeFactory inheritance 23 | 24 | // Forward declarations 25 | namespace geos { 26 | namespace geom { 27 | class Coordinate; 28 | } 29 | namespace geomgraph { 30 | class Node; 31 | } 32 | } // namespace geos 33 | 34 | namespace geos { 35 | namespace operation { // geos::operation 36 | namespace relate { // geos::operation::relate 37 | 38 | /** \brief 39 | * Used by the geomgraph::NodeMap in a RelateNodeGraph to create RelateNode objects. 40 | */ 41 | class GEOS_DLL RelateNodeFactory : public geomgraph::NodeFactory { 42 | public: 43 | geomgraph::Node *createNode(const geom::Coordinate &coord) const override; 44 | static const geomgraph::NodeFactory &instance(); 45 | 46 | private: 47 | RelateNodeFactory() { 48 | } 49 | }; 50 | 51 | } // namespace relate 52 | } // namespace operation 53 | } // namespace geos 54 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/union/PointGeometryUnion.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2011 Sandro Santilli 22 | #include 23 | #include 24 | 25 | // Forward declarations 26 | namespace geos { 27 | namespace geom { 28 | class GeometryFactory; 29 | class Geometry; 30 | } // namespace geom 31 | } // namespace geos 32 | 33 | namespace geos { 34 | namespace operation { // geos::operation 35 | namespace geounion { // geos::operation::geounion 36 | 37 | /** 38 | * \brief 39 | * Computes the union of a puntal geometry with another 40 | * arbitrary [Geometry](@ref geom::Geometry). 41 | * 42 | * Does not copy any component geometries. 43 | * 44 | */ 45 | class GEOS_DLL PointGeometryUnion { 46 | public: 47 | static std::unique_ptr Union(const geom::Geometry &pointGeom, const geom::Geometry &otherGeom); 48 | 49 | PointGeometryUnion(const geom::Geometry &pointGeom, const geom::Geometry &otherGeom); 50 | 51 | std::unique_ptr Union() const; 52 | 53 | private: 54 | const geom::Geometry &pointGeom; 55 | const geom::Geometry &otherGeom; 56 | const geom::GeometryFactory *geomFact; 57 | 58 | // Declared as non-copyable 59 | PointGeometryUnion(const PointGeometryUnion &other); 60 | PointGeometryUnion &operator=(const PointGeometryUnion &rhs); 61 | }; 62 | 63 | } // namespace geounion 64 | } // namespace operation 65 | } // namespace geos 66 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/valid/IndexedNestedHoleTester.hpp: -------------------------------------------------------------------------------- 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 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | // Forward declarations 23 | namespace geos { 24 | namespace geom { 25 | class Coordinate; 26 | class Polygon; 27 | class LinearRing; 28 | } // namespace geom 29 | } // namespace geos 30 | 31 | namespace geos { // geos. 32 | namespace operation { // geos.operation 33 | namespace valid { // geos.operation.valid 34 | 35 | using geos::geom::CoordinateXY; 36 | using geos::geom::LinearRing; 37 | using geos::geom::Polygon; 38 | 39 | class GEOS_DLL IndexedNestedHoleTester { 40 | private: 41 | const Polygon *polygon; 42 | index::strtree::TemplateSTRtree index; 43 | CoordinateXY nestedPt; 44 | 45 | void loadIndex(); 46 | 47 | public: 48 | IndexedNestedHoleTester(const Polygon *p_polygon) : polygon(p_polygon) { 49 | loadIndex(); 50 | } 51 | 52 | /** 53 | * Gets a point on a nested hole, if one exists. 54 | * 55 | * @return a point on a nested hole, or null if none are nested 56 | */ 57 | const CoordinateXY &getNestedPoint() { 58 | return nestedPt; 59 | } 60 | 61 | /** 62 | * Tests if any hole is nested (contained) within another hole. 63 | * This is invalid. 64 | * The nested point will be set to reflect this. 65 | * @return true if some hole is nested 66 | */ 67 | bool isNested(); 68 | }; 69 | 70 | } // namespace valid 71 | } // namespace operation 72 | } // namespace geos 73 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/valid/PolygonRingTouch.hpp: -------------------------------------------------------------------------------- 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 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | // Forward declarations 23 | namespace geos { 24 | namespace operation { 25 | namespace valid { 26 | class PolygonRing; 27 | } 28 | } // namespace operation 29 | } // namespace geos 30 | 31 | namespace geos { // geos. 32 | namespace operation { // geos.operation 33 | namespace valid { // geos.operation.valid 34 | 35 | using geos::geom::CoordinateXY; 36 | 37 | class GEOS_DLL PolygonRingTouch { 38 | private: 39 | PolygonRing *ring; 40 | CoordinateXY touchPt; 41 | 42 | public: 43 | PolygonRingTouch(PolygonRing *p_ring, const CoordinateXY &p_pt) : ring(p_ring), touchPt(p_pt) {}; 44 | 45 | const CoordinateXY *getCoordinate() const; 46 | 47 | PolygonRing *getRing() const; 48 | 49 | bool isAtLocation(const CoordinateXY &pt) const; 50 | }; 51 | 52 | } // namespace valid 53 | } // namespace operation 54 | } // namespace geos 55 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/operation/valid/RepeatedPointRemover.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2019 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 | #include 19 | 20 | namespace geos { 21 | namespace operation { 22 | namespace valid { 23 | /** 24 | * Removes repeated, consecutive equal, coordinates from a CoordinateSequence. 25 | */ 26 | class GEOS_DLL RepeatedPointRemover { 27 | public: 28 | /** 29 | * Returns a new CoordinateSequence being a copy of the input 30 | * with any consecutive equal Coordinate removed. 31 | * Equality test is 2D based. 32 | * 33 | * \param seq to filter 34 | * \param tolerance to apply 35 | * \return Geometr, ownership of returned object goes to the caller. 36 | */ 37 | static std::unique_ptr removeRepeatedPoints(const geom::CoordinateSequence *seq, 38 | double tolerance = 0.0); 39 | 40 | static std::unique_ptr 41 | removeRepeatedAndInvalidPoints(const geom::CoordinateSequence *seq, double tolerance = 0.0); 42 | 43 | static std::unique_ptr removeRepeatedPoints(const geom::Geometry *geom, double tolerance = 0.0); 44 | }; 45 | 46 | } // namespace valid 47 | } // namespace operation 48 | } // namespace geos 49 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/precision/PointwisePrecisionReducerTransformer.hpp: -------------------------------------------------------------------------------- 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 | #include 19 | #include 20 | 21 | // Forward declarations 22 | namespace geos { 23 | namespace geom { 24 | class PrecisionModel; 25 | class Geometry; 26 | class CoordinateSequence; 27 | } // namespace geom 28 | } // namespace geos 29 | 30 | namespace geos { 31 | namespace precision { // geos.precision 32 | 33 | /** 34 | * A transformer to reduce the precision of a geometry pointwise. 35 | * 36 | * @author mdavis 37 | */ 38 | class GEOS_DLL PointwisePrecisionReducerTransformer : public geom::util::GeometryTransformer { 39 | 40 | private: 41 | const geom::PrecisionModel &targetPM; 42 | 43 | std::vector reducePointwise(const geom::CoordinateSequence *coordinates); 44 | 45 | public: 46 | PointwisePrecisionReducerTransformer(const geom::PrecisionModel &p_targetPM) : targetPM(p_targetPM) {}; 47 | 48 | static std::unique_ptr reduce(const geom::Geometry &geom, const geom::PrecisionModel &targetPM); 49 | 50 | protected: 51 | std::unique_ptr transformCoordinates(const geom::CoordinateSequence *coords, 52 | const geom::Geometry *parent); 53 | }; 54 | 55 | } // namespace precision 56 | } // namespace geos 57 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/precision/PrecisionReducerCoordinateOperation.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2012 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: precision/PrecisionreducerCoordinateOperation.java r591 (JTS-1.12) 16 | * 17 | **********************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | // Forward declarations 24 | namespace geos { 25 | namespace geom { 26 | class PrecisionModel; 27 | class CoordinateSequence; 28 | class Geometry; 29 | } // namespace geom 30 | } // namespace geos 31 | 32 | namespace geos { 33 | namespace precision { // geos.precision 34 | 35 | class PrecisionReducerCoordinateOperation : public geom::util::CoordinateOperation { 36 | using CoordinateOperation::edit; 37 | 38 | private: 39 | const geom::PrecisionModel &targetPM; 40 | 41 | bool removeCollapsed; 42 | 43 | PrecisionReducerCoordinateOperation(PrecisionReducerCoordinateOperation const &); /*= delete*/ 44 | PrecisionReducerCoordinateOperation &operator=(PrecisionReducerCoordinateOperation const &); /*= delete*/ 45 | 46 | public: 47 | PrecisionReducerCoordinateOperation(const geom::PrecisionModel &pm, bool doRemoveCollapsed) 48 | : targetPM(pm), removeCollapsed(doRemoveCollapsed) { 49 | } 50 | 51 | /// Ownership of returned CoordinateSequence to caller 52 | /// 53 | /// virtual function 54 | std::unique_ptr edit(const geom::CoordinateSequence *coordinates, 55 | const geom::Geometry *geom) override; 56 | }; 57 | 58 | } // namespace precision 59 | } // namespace geos 60 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/Assert.hpp: -------------------------------------------------------------------------------- 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 | // Forward declarations 22 | namespace geos { 23 | namespace geom { 24 | class CoordinateXY; 25 | } 26 | } // namespace geos 27 | 28 | namespace geos { 29 | namespace util { // geos.util 30 | 31 | class GEOS_DLL Assert { 32 | public: 33 | static void isTrue(bool assertion, const std::string &message); 34 | 35 | static void isTrue(bool assertion) { 36 | isTrue(assertion, std::string()); 37 | } 38 | 39 | static void equals(const geom::CoordinateXY &expectedValue, const geom::CoordinateXY &actualValue, 40 | const std::string &message); 41 | 42 | static void equals(const geom::CoordinateXY &expectedValue, const geom::CoordinateXY &actualValue) { 43 | equals(expectedValue, actualValue, std::string()); 44 | } 45 | 46 | static void shouldNeverReachHere(const std::string &message); 47 | 48 | static void shouldNeverReachHere() { 49 | shouldNeverReachHere(std::string()); 50 | } 51 | }; 52 | 53 | } // namespace util 54 | } // namespace geos 55 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/AssertionFailedException.hpp: -------------------------------------------------------------------------------- 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 | #include 21 | 22 | namespace geos { 23 | namespace util { // geos.util 24 | 25 | /** \class AssertionFailedException util.h geos.h 26 | * \brief Indicates a bug in GEOS code. 27 | */ 28 | class GEOS_DLL AssertionFailedException : public GEOSException { 29 | 30 | public: 31 | AssertionFailedException() : GEOSException("AssertionFailedException", "") { 32 | } 33 | 34 | AssertionFailedException(const std::string &msg) : GEOSException("AssertionFailedException", msg) { 35 | } 36 | 37 | ~AssertionFailedException() noexcept override { 38 | } 39 | }; 40 | 41 | } // namespace util 42 | } // namespace geos 43 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/GEOSException.hpp: -------------------------------------------------------------------------------- 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 "geos/export.hpp" 19 | #include 20 | #include 21 | 22 | namespace geos { 23 | namespace util { // geos.util 24 | 25 | /** 26 | * 27 | * \brief Base class for all GEOS exceptions. 28 | * 29 | * Use what() to get a readable message. 30 | */ 31 | class GEOS_DLL GEOSException : public std::runtime_error { 32 | 33 | public: 34 | GEOSException() : std::runtime_error("Unknown error") { 35 | } 36 | 37 | GEOSException(std::string const &msg) : std::runtime_error(msg) { 38 | } 39 | 40 | GEOSException(std::string const &name, std::string const &msg) : std::runtime_error(name + ": " + msg) { 41 | } 42 | }; 43 | 44 | } // namespace util 45 | } // namespace geos 46 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/IllegalArgumentException.hpp: -------------------------------------------------------------------------------- 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 "geos/export.hpp" 19 | #include "geos/util/GEOSException.hpp" 20 | #include 21 | 22 | namespace geos { 23 | namespace util { // geos::util 24 | 25 | /** 26 | * \brief Indicates one or more illegal arguments. 27 | * 28 | * This exception is thrown - for example - when 29 | * trying to apply set-theoretic methods to a 30 | * GeometryCollection object. 31 | */ 32 | class GEOS_DLL IllegalArgumentException : public GEOSException { 33 | public: 34 | IllegalArgumentException() : GEOSException("IllegalArgumentException", "") { 35 | } 36 | 37 | IllegalArgumentException(const std::string &msg) : GEOSException("IllegalArgumentException", msg) { 38 | } 39 | 40 | ~IllegalArgumentException() noexcept override { 41 | } 42 | }; 43 | 44 | } // namespace util 45 | } // namespace geos 46 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/IllegalStateException.hpp: -------------------------------------------------------------------------------- 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 | #include 20 | 21 | namespace geos { 22 | namespace util { // geos::util 23 | 24 | /// Indicates an illegal state 25 | class GEOS_DLL IllegalStateException : public GEOSException { 26 | public: 27 | IllegalStateException() : GEOSException("IllegalStateException", "") { 28 | } 29 | 30 | IllegalStateException(const std::string &msg) : GEOSException("IllegalStateException", msg) { 31 | } 32 | 33 | ~IllegalStateException() noexcept override { 34 | } 35 | }; 36 | 37 | } // namespace util 38 | } // namespace geos 39 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/Interrupt.hpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2012 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 | 19 | namespace geos { 20 | namespace util { // geos::util 21 | 22 | #define GEOS_CHECK_FOR_INTERRUPTS() geos::util::Interrupt::process() 23 | 24 | /** \brief Used to manage interruption requests and callbacks. */ 25 | class GEOS_DLL Interrupt { 26 | 27 | public: 28 | typedef void(Callback)(void); 29 | 30 | /** 31 | * Request interruption of operations 32 | * 33 | * Operations will be terminated by a GEOSInterrupt 34 | * exception at first occasion. 35 | */ 36 | static void request(); 37 | 38 | /** Cancel a pending interruption request */ 39 | static void cancel(); 40 | 41 | /** Check if an interruption request is pending */ 42 | static bool check(); 43 | 44 | /** \brief 45 | * Register a callback that will be invoked 46 | * before checking for interruption requests. 47 | * 48 | * NOTE that interruption request checking may happen 49 | * frequently so any callback would better be quick. 50 | * 51 | * The callback can be used to call Interrupt::request() 52 | * 53 | */ 54 | static Callback *registerCallback(Callback *cb); 55 | 56 | /** 57 | * Invoke the callback, if any. Process pending interruption, if any. 58 | * 59 | */ 60 | static void process(); 61 | 62 | /* Perform the actual interruption (simply throw an exception) */ 63 | static void interrupt(); 64 | }; 65 | 66 | } // namespace util 67 | } // namespace geos 68 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/Machine.hpp: -------------------------------------------------------------------------------- 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 getMachineByteOrder() { 22 | static int endian_check = 1; // don't modify !! 23 | return *((char *)&endian_check); 24 | } 25 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/TopologyException.hpp: -------------------------------------------------------------------------------- 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 | #include // to be removed when .inl is available 21 | #include 22 | 23 | namespace geos { 24 | namespace util { // geos.util 25 | 26 | /** 27 | * \class TopologyException util.h geos.h 28 | * 29 | * \brief 30 | * Indicates an invalid or inconsistent topological situation encountered 31 | * during processing 32 | */ 33 | class GEOS_DLL TopologyException : public GEOSException { 34 | public: 35 | TopologyException() : GEOSException("TopologyException", "") { 36 | } 37 | 38 | TopologyException(const std::string &msg) : GEOSException("TopologyException", msg) { 39 | } 40 | 41 | TopologyException(const std::string &msg, const geom::Coordinate &newPt) 42 | : GEOSException("TopologyException", msg + " at "), pt(newPt) { 43 | } 44 | 45 | ~TopologyException() noexcept override { 46 | } 47 | geom::Coordinate &getCoordinate() { 48 | return pt; 49 | } 50 | 51 | private: 52 | geom::Coordinate pt; 53 | }; 54 | 55 | } // namespace util 56 | } // namespace geos 57 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/UnsupportedOperationException.hpp: -------------------------------------------------------------------------------- 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 | #include 21 | 22 | namespace geos { 23 | namespace util { // geos::util 24 | 25 | /** 26 | * \class UnsupportedOperationException util.h geos.h 27 | * 28 | * \brief Indicates that the requested operation is unsupported. 29 | * 30 | * This exception is thrown - for example - when requesting the 31 | * X or Y member of an empty Point 32 | */ 33 | class GEOS_DLL UnsupportedOperationException : public GEOSException { 34 | public: 35 | UnsupportedOperationException() : GEOSException("UnsupportedOperationException", "") { 36 | } 37 | 38 | UnsupportedOperationException(const std::string &msg) : GEOSException("UnsupportedOperationException", msg) { 39 | } 40 | 41 | ~UnsupportedOperationException() noexcept override { 42 | } 43 | }; 44 | 45 | } // namespace util 46 | } // namespace geos 47 | -------------------------------------------------------------------------------- /geo/third_party/geos/include/geos/util/math.hpp: -------------------------------------------------------------------------------- 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 | /// Default rounding method for GEOS 31 | /// 32 | /// @note Always use this rounding method, to easy easy switching 33 | /// between different rounding method for the whole codebase. 34 | inline double round(double val) { 35 | return java_math_round(val); 36 | } 37 | 38 | /// Equivalent to std::clamp() in C++17 39 | double clamp(double x, double min, double max); 40 | 41 | } // namespace util 42 | } // namespace geos 43 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | 24 | // #include 25 | 26 | namespace geos { 27 | namespace index { // geos.index 28 | namespace chain { // geos.index.chain 29 | 30 | void MonotoneChainOverlapAction::overlap(const MonotoneChain &mc1, std::size_t start1, const MonotoneChain &mc2, 31 | std::size_t start2) { 32 | mc1.getLineSegment(start1, overlapSeg1); 33 | mc2.getLineSegment(start2, overlapSeg2); 34 | overlap(overlapSeg1, overlapSeg2); 35 | } 36 | 37 | } // namespace chain 38 | } // namespace index 39 | } // namespace geos 40 | -------------------------------------------------------------------------------- /geo/third_party/geos/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), data(p_data), left(nullptr), right(nullptr), count(1) { 25 | } 26 | 27 | KdNode::KdNode(const Coordinate &p_p, void *p_data) : p(p_p), data(p_data), left(nullptr), right(nullptr), count(1) { 28 | } 29 | 30 | } // namespace kdtree 31 | } // namespace index 32 | } // namespace geos 33 | -------------------------------------------------------------------------------- /geo/third_party/geos/index/strtree/SimpleSTRnode.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 | #include 17 | #include 18 | 19 | using namespace geos::geom; 20 | 21 | namespace geos { 22 | namespace index { // geos.index 23 | namespace strtree { // geos.index.strtree 24 | 25 | /*public*/ 26 | void SimpleSTRnode::addChildNode(SimpleSTRnode *childNode) { 27 | if (bounds.isNull()) 28 | bounds = childNode->getEnvelope(); 29 | else 30 | bounds.expandToInclude(childNode->getEnvelope()); 31 | 32 | childNodes.push_back(childNode); 33 | } 34 | 35 | bool SimpleSTRnode::removeItem(void *itemToRemove) { 36 | for (auto it = childNodes.begin(); it != childNodes.end(); ++it) { 37 | if ((*it)->getItem() == itemToRemove) { 38 | childNodes.erase(it); 39 | return true; 40 | } 41 | } 42 | return false; 43 | } 44 | 45 | bool SimpleSTRnode::removeChild(SimpleSTRnode *child) { 46 | for (auto it = childNodes.begin(); it != childNodes.end(); ++it) { 47 | if ((*it) == child) { 48 | childNodes.erase(it); 49 | return true; 50 | } 51 | } 52 | return false; 53 | } 54 | 55 | } // namespace strtree 56 | } // namespace index 57 | } // namespace geos 58 | -------------------------------------------------------------------------------- /geo/third_party/geos/noding/Octant.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 | ********************************************************************** 14 | * 15 | * Last port: noding/Octant.java rev. 1.2 (JTS-1.7) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | // 26 | using namespace geos::geom; 27 | 28 | namespace geos { 29 | namespace noding { // geos.noding 30 | 31 | /*public static*/ 32 | int Octant::octant(double dx, double dy) { 33 | if (dx == 0.0 && dy == 0.0) { 34 | std::ostringstream s; 35 | s << "Cannot compute the octant for point ( " << dx << ", " << dy << " )"; 36 | throw util::IllegalArgumentException(s.str()); 37 | } 38 | 39 | double adx = std::fabs(dx); 40 | double ady = std::fabs(dy); 41 | 42 | if (dx >= 0) { 43 | if (dy >= 0) { 44 | if (adx >= ady) { 45 | return 0; 46 | } else { 47 | return 1; 48 | } 49 | } else { // dy < 0 50 | if (adx >= ady) { 51 | return 7; 52 | } else { 53 | return 6; 54 | } 55 | } 56 | } else { // dx < 0 57 | if (dy >= 0) { 58 | if (adx >= ady) { 59 | return 3; 60 | } else { 61 | return 2; 62 | } 63 | } else { // dy < 0 64 | if (adx >= ady) { 65 | return 4; 66 | } else { 67 | return 5; 68 | } 69 | } 70 | } 71 | } 72 | 73 | /*public static*/ 74 | int Octant::octant(const Coordinate &p0, const Coordinate &p1) { 75 | double dx = p1.x - p0.x; 76 | double dy = p1.y - p0.y; 77 | 78 | return octant(dx, dy); 79 | } 80 | 81 | } // namespace noding 82 | } // namespace geos 83 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | #include 24 | #include 25 | #include 26 | 27 | using geos::geom::Coordinate; 28 | 29 | namespace geos { 30 | namespace noding { // geos.noding 31 | 32 | /*public*/ 33 | SegmentNode::SegmentNode(const NodedSegmentString &ss, const Coordinate &nCoord, std::size_t nSegmentIndex, 34 | int nSegmentOctant) 35 | : segmentOctant(nSegmentOctant), coord(nCoord), segmentIndex(nSegmentIndex) { 36 | // Number of points in NodedSegmentString is one-more number of segments 37 | assert(segmentIndex < ss.size()); 38 | isInteriorVar = !coord.equals2D(ss.getCoordinate(segmentIndex)); 39 | } 40 | 41 | } // namespace noding 42 | } // namespace geos 43 | -------------------------------------------------------------------------------- /geo/third_party/geos/noding/ValidatingNoder.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 | #include 17 | #include 18 | #include 19 | #include 20 | #include // for unique_ptr 21 | 22 | namespace geos { 23 | namespace noding { // geos.noding 24 | 25 | void ValidatingNoder::computeNodes(std::vector *segStrings) { 26 | noder.computeNodes(segStrings); 27 | nodedSS = noder.getNodedSubstrings(); 28 | validate(); 29 | } 30 | 31 | void ValidatingNoder::validate() { 32 | FastNodingValidator nv(*nodedSS); 33 | try { 34 | nv.checkValid(); 35 | } catch (const std::exception &) { 36 | for (SegmentString *ss : *nodedSS) { 37 | delete ss; 38 | } 39 | delete nodedSS; 40 | nodedSS = nullptr; 41 | throw; 42 | } 43 | } 44 | 45 | std::vector *ValidatingNoder::getNodedSubstrings() const { 46 | return nodedSS; 47 | } 48 | 49 | } // namespace noding 50 | } // namespace geos 51 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 &SnappingPointIndex::snap(const Coordinate &p) { 29 | /** 30 | * Inserting the coordinate snaps it to any existing 31 | * one within tolerance, or adds it if not. 32 | */ 33 | index::kdtree::KdNode *node = snapPointIndex->insert(p); 34 | return node->getCoordinate(); 35 | } 36 | 37 | } // namespace snap 38 | } // namespace noding 39 | } // namespace geos 40 | -------------------------------------------------------------------------------- /geo/third_party/geos/operation/overlay/ElevationMatrixCell.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: original (by strk) 16 | * 17 | **********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | using namespace geos::geom; 28 | 29 | namespace geos { 30 | namespace operation { // geos.operation 31 | namespace overlay { // geos.operation.overlay 32 | 33 | ElevationMatrixCell::ElevationMatrixCell() : ztot(0) { 34 | } 35 | 36 | void ElevationMatrixCell::add(const Coordinate &c) { 37 | if (!std::isnan(c.z)) { 38 | if (zvals.insert(c.z).second) { 39 | ztot += c.z; 40 | } 41 | } 42 | } 43 | 44 | void ElevationMatrixCell::add(double z) { 45 | if (!std::isnan(z)) { 46 | if (zvals.insert(z).second) { 47 | ztot += z; 48 | } 49 | } 50 | } 51 | 52 | double ElevationMatrixCell::getTotal() const { 53 | return ztot; 54 | } 55 | 56 | double ElevationMatrixCell::getAvg() const { 57 | return zvals.size() ? ztot / static_cast(zvals.size()) : DoubleNotANumber; 58 | } 59 | 60 | std::string ElevationMatrixCell::print() const { 61 | std::ostringstream ret; 62 | // ret<<"["< 21 | #include 22 | 23 | namespace geos { 24 | namespace operation { // geos.operation 25 | namespace overlay { // geos.operation.overlay 26 | 27 | MinimalEdgeRing::MinimalEdgeRing(geomgraph::DirectedEdge *start, const geom::GeometryFactory *p_geometryFactory) 28 | : geomgraph::EdgeRing(start, p_geometryFactory) { 29 | computePoints(start); 30 | computeRing(); 31 | } 32 | 33 | } // namespace overlay 34 | } // namespace operation 35 | } // namespace geos 36 | -------------------------------------------------------------------------------- /geo/third_party/geos/operation/overlay/OverlayNodeFactory.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: operation/overlay/OverlayNodeFactory.java rev. 1.11 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | using namespace geos::geomgraph; 25 | 26 | namespace geos { 27 | namespace operation { // geos.operation 28 | namespace overlay { // geos.operation.overlay 29 | 30 | Node *OverlayNodeFactory::createNode(const geom::Coordinate &coord) const { 31 | return new Node(coord, new DirectedEdgeStar()); 32 | } 33 | 34 | const NodeFactory &OverlayNodeFactory::instance() { 35 | static OverlayNodeFactory onf; 36 | return onf; 37 | } 38 | 39 | } // namespace overlay 40 | } // namespace operation 41 | } // namespace geos 42 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | EdgeSourceInfo::EdgeSourceInfo(uint8_t p_index, int p_depthDelta, bool p_isHole) 22 | : index(p_index), dim(geom::Dimension::A), edgeIsHole(p_isHole), depthDelta(p_depthDelta) { 23 | } 24 | 25 | EdgeSourceInfo::EdgeSourceInfo(uint8_t p_index) 26 | : index(p_index), dim(geom::Dimension::L), edgeIsHole(false), depthDelta(0) { 27 | } 28 | 29 | } // namespace overlayng 30 | } // namespace operation 31 | } // namespace geos 32 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace geos { // geos 22 | namespace operation { // geos.operation 23 | namespace overlayng { // geos.operation.overlayng 24 | 25 | /*public*/ 26 | geom::Location IndexedPointOnLineLocator::locate(const geom::CoordinateXY *p) { 27 | // TODO: optimize this with a segment index 28 | algorithm::PointLocator locator; 29 | return locator.locate(*p, &inputGeom); 30 | } 31 | 32 | } // namespace overlayng 33 | } // namespace operation 34 | } // namespace geos 35 | -------------------------------------------------------------------------------- /geo/third_party/geos/operation/overlayng/PrecisionReducer.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 | #include 17 | #include 18 | 19 | namespace geos { // geos 20 | namespace operation { // geos.operation 21 | namespace overlayng { // geos.operation.overlayng 22 | 23 | /*public static*/ 24 | std::unique_ptr PrecisionReducer::reducePrecision(const Geometry *geom, const PrecisionModel *pm, 25 | bool replacePrecisionModel) { 26 | if (replacePrecisionModel) { 27 | auto gf = GeometryFactory::create(pm, geom->getSRID()); 28 | OverlayNG ov(geom, nullptr, gf.get(), OverlayNG::UNION); 29 | /** 30 | * Ensure reducing a area only produces polygonal result. 31 | * (I.e. collapse lines are not output) 32 | */ 33 | if (geom->getDimension() == 2) 34 | ov.setAreaResultOnly(true); 35 | 36 | return ov.getResult(); 37 | } else { 38 | OverlayNG ov(geom, nullptr, pm, OverlayNG::UNION); 39 | if (geom->getDimension() == 2) 40 | ov.setAreaResultOnly(true); 41 | 42 | return ov.getResult(); 43 | } 44 | } 45 | 46 | } // namespace overlayng 47 | } // namespace operation 48 | } // namespace geos 49 | -------------------------------------------------------------------------------- /geo/third_party/geos/operation/relate/RelateNode.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: operation/relate/RelateNode.java rev. 1.11 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace geos::geomgraph; 29 | using namespace geos::geom; 30 | 31 | namespace geos { 32 | namespace operation { // geos.operation 33 | namespace relate { // geos.operation.relate 34 | 35 | RelateNode::RelateNode(const Coordinate &p_coord, EdgeEndStar *p_edges) : Node(p_coord, p_edges) { 36 | } 37 | 38 | /** 39 | * Update the IM with the contribution for this component. 40 | * A component only contributes if it has a labelling for both parent geometries 41 | */ 42 | void RelateNode::computeIM(IntersectionMatrix &im) { 43 | im.setAtLeastIfValid(label.getLocation(0), label.getLocation(1), 0); 44 | } 45 | 46 | void RelateNode::updateIMFromEdges(IntersectionMatrix &im) { 47 | EdgeEndBundleStar *eebs = detail::down_cast(edges); 48 | 49 | eebs->updateIM(im); 50 | } 51 | 52 | } // namespace relate 53 | } // namespace operation 54 | } // namespace geos 55 | -------------------------------------------------------------------------------- /geo/third_party/geos/operation/relate/RelateNodeFactory.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: operation/relate/RelateNodeFactory.java rev. 1.11 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | using namespace geos::geom; 25 | using namespace geos::geomgraph; 26 | 27 | namespace geos { 28 | namespace operation { // geos.operation 29 | namespace relate { // geos.operation.relate 30 | 31 | Node *RelateNodeFactory::createNode(const Coordinate &coord) const { 32 | return new RelateNode(coord, new EdgeEndBundleStar()); 33 | } 34 | 35 | const NodeFactory &RelateNodeFactory::instance() { 36 | static const RelateNodeFactory rnf; 37 | return rnf; 38 | } 39 | 40 | } // namespace relate 41 | } // namespace operation 42 | } // namespace geos 43 | -------------------------------------------------------------------------------- /geo/third_party/geos/operation/relate/RelateOp.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: operation/relate/RelateOp.java rev. 1.19 (JTS-1.10) 17 | * 18 | **********************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | // Forward declarations 24 | namespace geos { 25 | namespace geom { 26 | class IntersectionMatrix; 27 | class Geometry; 28 | } // namespace geom 29 | } // namespace geos 30 | 31 | using namespace geos::geom; 32 | 33 | namespace geos { 34 | namespace operation { // geos.operation 35 | namespace relate { // geos.operation.relate 36 | 37 | std::unique_ptr RelateOp::relate(const Geometry *a, const Geometry *b) { 38 | RelateOp relOp(a, b); 39 | return relOp.getIntersectionMatrix(); 40 | } 41 | 42 | RelateOp::RelateOp(const Geometry *g0, const Geometry *g1) : GeometryGraphOperation(g0, g1), relateComp(&arg) { 43 | } 44 | 45 | RelateOp::RelateOp(const Geometry *g0, const Geometry *g1, const algorithm::BoundaryNodeRule &boundaryNodeRule) 46 | : GeometryGraphOperation(g0, g1, boundaryNodeRule), relateComp(&arg) { 47 | } 48 | 49 | std::unique_ptr RelateOp::getIntersectionMatrix() { 50 | return relateComp.computeIM(); 51 | } 52 | 53 | } // namespace relate 54 | } // namespace operation 55 | } // namespace geos 56 | -------------------------------------------------------------------------------- /geo/third_party/geos/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, 23 | std::unique_ptr &&g1) { 24 | // Default implementation just copies the inputs. 25 | return Union(g0.get(), g1.get()); 26 | } 27 | 28 | } // namespace geounion 29 | } // namespace operation 30 | } // namespace geos 31 | -------------------------------------------------------------------------------- /geo/third_party/geos/operation/valid/PolygonRingSelfNode.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 | 19 | namespace geos { // geos 20 | namespace operation { // geos.operation 21 | namespace valid { // geos.operation.valid 22 | 23 | using geos::algorithm::PolygonNodeTopology; 24 | 25 | /* public */ 26 | bool PolygonRingSelfNode::isExterior(bool isInteriorOnRight) const { 27 | (void)e11; // unused variable 28 | /** 29 | * Note that either corner and either of the other edges could be used to test. 30 | * The situation is fully symmetrical. 31 | */ 32 | bool bIsInteriorSeg = PolygonNodeTopology::isInteriorSegment(&nodePt, e00, e01, e10); 33 | bool bIsExterior = isInteriorOnRight ? !bIsInteriorSeg : bIsInteriorSeg; 34 | return bIsExterior; 35 | } 36 | 37 | } // namespace valid 38 | } // namespace operation 39 | } // namespace geos 40 | -------------------------------------------------------------------------------- /geo/third_party/geos/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 | namespace geos { // geos 21 | namespace operation { // geos.operation 22 | namespace valid { // geos.operation.valid 23 | 24 | using namespace geos::geom; 25 | 26 | /* public */ 27 | const CoordinateXY *PolygonRingTouch::getCoordinate() const { 28 | return &touchPt; 29 | } 30 | 31 | /* public */ 32 | PolygonRing *PolygonRingTouch::getRing() const { 33 | return ring; 34 | } 35 | 36 | /* public */ 37 | bool PolygonRingTouch::isAtLocation(const CoordinateXY &pt) const { 38 | return touchPt.equals2D(pt); 39 | } 40 | 41 | } // namespace valid 42 | } // namespace operation 43 | } // namespace geos 44 | -------------------------------------------------------------------------------- /geo/third_party/geos/util/Assert.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 | #include 18 | #include 19 | 20 | using std::string; 21 | using namespace geos::geom; 22 | 23 | namespace geos { 24 | namespace util { // geos.util 25 | 26 | void Assert::isTrue(bool assertion, const std::string &message) { 27 | if (!assertion) { 28 | if (message.empty()) { 29 | throw AssertionFailedException(); 30 | } else { 31 | throw AssertionFailedException(message); 32 | } 33 | } 34 | } 35 | 36 | void Assert::equals(const CoordinateXY &expectedValue, const CoordinateXY &actualValue, const std::string &message) { 37 | if (!(actualValue == expectedValue)) { 38 | throw AssertionFailedException("Expected Coordinate but encountered Coordinate" + 39 | (!message.empty() ? ": " + message : "")); 40 | } 41 | } 42 | 43 | void Assert::shouldNeverReachHere(const std::string &message) { 44 | throw AssertionFailedException("Should never reach here" + (!message.empty() ? ": " + message : "")); 45 | } 46 | 47 | } // namespace util 48 | } // namespace geos 49 | -------------------------------------------------------------------------------- /geo/third_party/geos/util/Interrupt.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * GEOS - Geometry Engine Open Source 4 | * http://geos.osgeo.org 5 | * 6 | * Copyright (C) 2012 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 | #include // for inheritance 16 | #include 17 | 18 | namespace { 19 | /* Could these be portably stored in thread-specific space ? */ 20 | bool requested = false; 21 | 22 | geos::util::Interrupt::Callback *callback = nullptr; 23 | } // namespace 24 | 25 | namespace geos { 26 | namespace util { // geos::util 27 | 28 | class GEOS_DLL InterruptedException : public GEOSException { 29 | public: 30 | InterruptedException() : GEOSException("InterruptedException", "Interrupted!") { 31 | } 32 | }; 33 | 34 | void Interrupt::request() { 35 | requested = true; 36 | } 37 | 38 | void Interrupt::cancel() { 39 | requested = false; 40 | } 41 | 42 | bool Interrupt::check() { 43 | return requested; 44 | } 45 | 46 | Interrupt::Callback *Interrupt::registerCallback(Interrupt::Callback *cb) { 47 | Callback *prev = callback; 48 | callback = cb; 49 | return prev; 50 | } 51 | 52 | void Interrupt::process() { 53 | if (callback) { 54 | (*callback)(); 55 | } 56 | if (requested) { 57 | requested = false; 58 | interrupt(); 59 | } 60 | } 61 | 62 | void Interrupt::interrupt() { 63 | requested = false; 64 | throw InterruptedException(); 65 | } 66 | 67 | } // namespace util 68 | } // namespace geos 69 | -------------------------------------------------------------------------------- /geo/third_party/json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library( 2 | duckdb_geo_json OBJECT 3 | json_tokener.cpp 4 | printbuf.cpp 5 | json_object.cpp 6 | linkhash.cpp 7 | arraylist.cpp 8 | random_seed.cpp 9 | json_util.cpp) 10 | set(GEO_LIBRARY_FILES 11 | ${GEO_LIBRARY_FILES} $ 12 | PARENT_SCOPE) 13 | -------------------------------------------------------------------------------- /geo/third_party/json/include/arraylist.hpp: -------------------------------------------------------------------------------- 1 | #pragma one 2 | 3 | #include "duckdb.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace json { 10 | 11 | #ifndef _json_c_arraylist_h_ 12 | #define _json_c_arraylist_h_ 13 | 14 | #define ARRAY_LIST_DEFAULT_SIZE 32 15 | 16 | typedef void(array_list_free_fn)(void *data); 17 | 18 | struct array_list { 19 | void **array; 20 | size_t length; 21 | size_t size; 22 | array_list_free_fn *free_fn; 23 | }; 24 | typedef struct array_list array_list; 25 | 26 | /** 27 | * Allocate an array_list of the desired size. 28 | * 29 | * If possible, the size should be chosen to closely match 30 | * the actual number of elements expected to be used. 31 | * If the exact size is unknown, there are tradeoffs to be made: 32 | * - too small - the array_list code will need to call realloc() more 33 | * often (which might incur an additional memory copy). 34 | * - too large - will waste memory, but that can be mitigated 35 | * by calling array_list_shrink() once the final size is known. 36 | * 37 | * @see array_list_shrink 38 | */ 39 | extern struct array_list *array_list_new2(array_list_free_fn *free_fn, int initial_size); 40 | 41 | extern void *array_list_get_idx(struct array_list *al, size_t i); 42 | 43 | extern size_t array_list_length(struct array_list *al); 44 | 45 | extern void array_list_free(struct array_list *al); 46 | 47 | /** 48 | * Shrink the array list to just enough to fit the number of elements in it, 49 | * plus empty_slots. 50 | */ 51 | extern int array_list_shrink(struct array_list *arr, size_t empty_slots); 52 | 53 | extern int array_list_add(struct array_list *al, void *data); 54 | 55 | #endif 56 | 57 | } // namespace json 58 | -------------------------------------------------------------------------------- /geo/third_party/json/include/config.hpp: -------------------------------------------------------------------------------- 1 | 2 | /* Define to 1 if you have the `strncasecmp' function. */ 3 | #define HAVE_STRNCASECMP 1 4 | -------------------------------------------------------------------------------- /geo/third_party/json/include/json.hpp: -------------------------------------------------------------------------------- 1 | #pragma one 2 | 3 | #include "json_tokener.hpp" 4 | #include "linkhash.hpp" 5 | 6 | #include 7 | 8 | namespace json {} // namespace json 9 | -------------------------------------------------------------------------------- /geo/third_party/json/include/json_object_private.hpp: -------------------------------------------------------------------------------- 1 | #pragma one 2 | 3 | #include "json_types.hpp" 4 | 5 | #include 6 | #include 7 | 8 | namespace json { 9 | 10 | /* json object int type, support extension*/ 11 | typedef enum json_object_int_type { json_object_int_type_int64, json_object_int_type_uint64 } json_object_int_type; 12 | 13 | struct json_object { 14 | enum json_type o_type; 15 | uint32_t _ref_count; 16 | json_object_to_json_string_fn *_to_json_string; 17 | struct printbuf *_pb; 18 | json_object_delete_fn *_user_delete; 19 | void *_userdata; 20 | // Actually longer, always malloc'd as some more-specific type. 21 | // The rest of a struct json_object_${o_type} follows 22 | }; 23 | 24 | struct json_object_object { 25 | struct json_object base; 26 | struct lh_table *c_object; 27 | }; 28 | 29 | struct json_object_array { 30 | struct json_object base; 31 | struct array_list *c_array; 32 | }; 33 | 34 | struct json_object_boolean { 35 | struct json_object base; 36 | json_bool c_boolean; 37 | }; 38 | 39 | struct json_object_double { 40 | struct json_object base; 41 | double c_double; 42 | }; 43 | 44 | struct json_object_int { 45 | struct json_object base; 46 | enum json_object_int_type cint_type; 47 | union { 48 | int64_t c_int64; 49 | uint64_t c_uint64; 50 | } cint; 51 | }; 52 | 53 | struct json_object_string { 54 | struct json_object base; 55 | std::ptrdiff_t len; // Signed b/c negative lengths indicate data is a pointer 56 | // Consider adding an "alloc" field here, if json_object_set_string calls 57 | // to expand the length of a string are common operations to perform. 58 | union { 59 | char idata[1]; // Immediate data. Actually longer 60 | char *pdata; // Only when len < 0 61 | } c_string; 62 | }; 63 | 64 | extern const char *json_hex_chars; 65 | 66 | } // namespace json 67 | -------------------------------------------------------------------------------- /geo/third_party/json/include/json_types.hpp: -------------------------------------------------------------------------------- 1 | #pragma one 2 | 3 | #include "duckdb.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace json { 13 | 14 | typedef int json_bool; 15 | 16 | /** 17 | * A structure to use with json_object_object_foreachC() loops. 18 | * Contains key, val and entry members. 19 | */ 20 | struct json_object_iter { 21 | char *key; 22 | struct json_object *val; 23 | struct lh_entry *entry; 24 | }; 25 | typedef struct json_object_iter json_object_iter; 26 | 27 | /** 28 | * Type of custom user delete functions. See json_object_set_serializer. 29 | */ 30 | typedef void(json_object_delete_fn)(struct json_object *jso, void *userdata); 31 | 32 | /** 33 | * Type of a custom serialization function. See json_object_set_serializer. 34 | */ 35 | typedef int(json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level, int flags); 36 | 37 | typedef enum json_type { 38 | /* If you change this, be sure to update json_type_to_name() too */ 39 | json_type_null, 40 | json_type_boolean, 41 | json_type_double, 42 | json_type_int, 43 | json_type_object, 44 | json_type_array, 45 | json_type_string 46 | } json_type; 47 | } // namespace json 48 | -------------------------------------------------------------------------------- /geo/third_party/json/include/json_util.hpp: -------------------------------------------------------------------------------- 1 | #pragma one 2 | 3 | #include "duckdb.hpp" 4 | 5 | #include 6 | 7 | namespace json { 8 | 9 | #define json_min(a, b) ((a) < (b) ? (a) : (b)) 10 | 11 | /* these parsing helpers return zero on success */ 12 | extern int json_parse_int64(const char *buf, int64_t *retval); 13 | extern int json_parse_uint64(const char *buf, uint64_t *retval); 14 | 15 | } // namespace json 16 | -------------------------------------------------------------------------------- /geo/third_party/json/include/random_seed.hpp: -------------------------------------------------------------------------------- 1 | #pragma one 2 | 3 | #include "duckdb.hpp" 4 | 5 | namespace json { 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_UNISTD_H 1 9 | 10 | extern int json_c_get_random_seed(void); 11 | 12 | } // namespace json 13 | -------------------------------------------------------------------------------- /geo/third_party/json/json_util.cpp: -------------------------------------------------------------------------------- 1 | #include "json_util.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace json { 9 | 10 | int json_parse_int64(const char *buf, int64_t *retval) { 11 | char *end = NULL; 12 | int64_t val; 13 | 14 | errno = 0; 15 | val = strtoll(buf, &end, 10); 16 | if (end != buf) 17 | *retval = val; 18 | return ((val == 0 && errno != 0) || (end == buf)) ? 1 : 0; 19 | } 20 | 21 | int json_parse_uint64(const char *buf, uint64_t *retval) { 22 | char *end = NULL; 23 | uint64_t val; 24 | 25 | errno = 0; 26 | while (*buf == ' ') 27 | buf++; 28 | if (*buf == '-') 29 | return 1; /* error: uint cannot be negative */ 30 | 31 | val = strtoull(buf, &end, 10); 32 | if (end != buf) 33 | *retval = val; 34 | return ((val == 0 && errno != 0) || (end == buf)) ? 1 : 0; 35 | } 36 | 37 | } // namespace json 38 | -------------------------------------------------------------------------------- /geo/third_party/json/random_seed.cpp: -------------------------------------------------------------------------------- 1 | #include "random_seed.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #ifdef HAVE_BSD_STDLIB_H 7 | #include 8 | #endif 9 | 10 | namespace json { 11 | 12 | #define DEBUG_SEED(s) 13 | 14 | /* get_time_seed */ 15 | 16 | #ifndef HAVE_ARC4RANDOM 17 | #include 18 | 19 | static int get_time_seed(void) { 20 | DEBUG_SEED("get_time_seed"); 21 | 22 | return (unsigned)time(NULL) * 433494437; 23 | } 24 | #endif 25 | 26 | /* json_c_get_random_seed */ 27 | 28 | int json_c_get_random_seed(void) { 29 | #ifdef OVERRIDE_GET_RANDOM_SEED 30 | OVERRIDE_GET_RANDOM_SEED; 31 | #endif 32 | #if defined HAVE_RDRAND && HAVE_RDRAND 33 | if (has_rdrand()) 34 | return get_rdrand_seed(); 35 | #endif 36 | #ifdef HAVE_ARC4RANDOM 37 | /* arc4random never fails, so use it if it's available */ 38 | return arc4random(); 39 | #else 40 | #ifdef HAVE_GETRANDOM 41 | { 42 | int seed = 0; 43 | if (get_getrandom_seed(&seed) == 0) 44 | return seed; 45 | } 46 | #endif 47 | #if defined HAVE_DEV_RANDOM && HAVE_DEV_RANDOM 48 | { 49 | int seed = 0; 50 | if (get_dev_random_seed(&seed) == 0) 51 | return seed; 52 | } 53 | #endif 54 | #if defined HAVE_CRYPTGENRANDOM && HAVE_CRYPTGENRANDOM 55 | { 56 | int seed = 0; 57 | if (get_cryptgenrandom_seed(&seed) == 0) 58 | return seed; 59 | } 60 | #endif 61 | return get_time_seed(); 62 | #endif /* !HAVE_ARC4RANDOM */ 63 | } 64 | 65 | } // namespace json 66 | -------------------------------------------------------------------------------- /test/sql/test_from_text.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_from_text.test 2 | # description: ST_GEOMFROMTEXT test 3 | # group: [sql] 4 | 5 | statement ok 6 | LOAD 'build/release/extension/geo/geo.duckdb_extension'; 7 | 8 | statement ok 9 | PRAGMA enable_verification 10 | 11 | # test with valid text string 12 | query I 13 | SELECT ST_GEOMFROMTEXT('POINT(50.23233 -43.45454)') 14 | ---- 15 | 0101000020E610000099F04BFDBC1D4940A75CE15D2EBA45C0 16 | 17 | #test with srid 18 | query I 19 | SELECT ST_GEOMFROMTEXT('POINT(50.23233 -43.45454)') 20 | ---- 21 | 0101000020E610000099F04BFDBC1D4940A75CE15D2EBA45C0 22 | 23 | # test with NULL and empty value 24 | query I 25 | SELECT ST_GEOMFROMTEXT('') 26 | ---- 27 | (empty) 28 | 29 | query I 30 | SELECT ST_GEOMFROMTEXT(NULL) 31 | ---- 32 | NULL 33 | 34 | #test with invalid string 35 | statement error 36 | SELECT ST_GEOMFROMTEXT('PAOINT(12.2323 -34.7565)') 37 | 38 | # test with string in table 39 | statement ok 40 | CREATE TABLE geometries(g VARCHAR) 41 | 42 | statement ok 43 | INSERT INTO geometries VALUES('POINT(50.23233 -43.45454)'), (''), (NULL), ('POINT(-71.064544 42.28787)') 44 | 45 | query I 46 | SELECT ST_GEOMFROMTEXT(g) FROM geometries 47 | ---- 48 | 0101000020E610000099F04BFDBC1D4940A75CE15D2EBA45C0 49 | (empty) 50 | NULL 51 | 0101000020E6100000CB49287D21C451C0F0BF95ECD8244540 52 | 53 | #test with invalid string 54 | statement ok 55 | INSERT INTO geometries VALUES('POAINT(50.23233 -43.45454)') 56 | 57 | statement error 58 | SELECT ST_GEOMFROMTEXT(g) FROM geometries 59 | -------------------------------------------------------------------------------- /test/sql/test_geogpointfromhash.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/function/test_geogpointfromhash.test 2 | # description: ST_GEOMFROMGEOHASH/ST_GEOGPOINTFROMGEOHASH test 3 | # group: [function] 4 | 5 | statement ok 6 | LOAD 'build/release/extension/geo/geo.duckdb_extension'; 7 | 8 | statement ok 9 | PRAGMA enable_verification 10 | 11 | query I 12 | SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 10)) 13 | ---- 14 | POLYGON((-115.17282128334045 36.11464083194733,-115.17282128334045 36.114646196365356,-115.1728105545044 36.114646196365356,-115.1728105545044 36.11464083194733,-115.17282128334045 36.11464083194733)) 15 | 16 | query I 17 | SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0')) 18 | ---- 19 | POLYGON((-115.17281600000001 36.11464599999999,-115.17281600000001 36.114646,-115.172816 36.114646,-115.172816 36.11464599999999,-115.17281600000001 36.11464599999999)) 20 | 21 | query I 22 | SELECT ST_AsText(ST_GEOGPOINTFROMGEOHASH('s1gw4xw40eb3ur11nctj')) 23 | ---- 24 | POINT(5.039999999999924 10.939999999999966) 25 | 26 | query I 27 | SELECT ST_AsText(ST_GEOGPOINTFROMGEOHASH('drt2uqqec401fwxu0phq')) 28 | ---- 29 | POINT(-71.17145049999986 42.35432300000004) 30 | 31 | statement error 32 | SELECT ST_GEOGPOINTFROMGEOHASH('aaa') 33 | 34 | query I 35 | SELECT ST_GEOGPOINTFROMGEOHASH('') 36 | ---- 37 | (empty) 38 | -------------------------------------------------------------------------------- /test/sql/test_makepoint.test: -------------------------------------------------------------------------------- 1 | # name: test/sql/test_makepoint.test 2 | # description: ST_MAKEPOINT test 3 | # group: [sql] 4 | 5 | statement ok 6 | LOAD 'build/release/extension/geo/geo.duckdb_extension'; 7 | 8 | statement ok 9 | PRAGMA enable_verification 10 | 11 | # test basic 2D make point 12 | query I 13 | SELECT ST_MAKEPOINT(5, 6) 14 | ---- 15 | 0101000020E610000000000000000014400000000000001840 16 | 17 | # test basic 3D make point 18 | query I 19 | SELECT ST_MAKEPOINT(5, 6, 7) 20 | ---- 21 | 01010000A0E6100000000000000000144000000000000018400000000000001C40 22 | 23 | # test invalid decodes 24 | statement error 25 | SELECT ST_MAKEPOINT(5, 'a') 26 | 27 | # test make point with table 28 | statement ok 29 | CREATE TABLE tbl_doubles(p1 DOUBLE, p2 DOUBLE) 30 | 31 | statement ok 32 | INSERT INTO tbl_doubles VALUES (42.123456, 10.54), (-73.34343, 50.3432242) 33 | 34 | query R 35 | SELECT ST_MAKEPOINT(p1, p2) from tbl_doubles 36 | ---- 37 | 0101000020E61000005B3FFD67CD0F454014AE47E17A142540 38 | 0101000020E6100000C79DD2C1FA5552C00F1945C5EE2B4940 39 | 40 | #test make point with null value 41 | #statement ok 42 | #DELETE FROM tbl_doubles 43 | 44 | statement ok 45 | INSERT INTO tbl_doubles VALUES(1.0, NULL), (-73.34343, 50.3432242) 46 | 47 | query R 48 | SELECT ST_MAKEPOINT(p1, p2) from tbl_doubles 49 | ---- 50 | 0101000020E61000005B3FFD67CD0F454014AE47E17A142540 51 | 0101000020E6100000C79DD2C1FA5552C00F1945C5EE2B4940 52 | NULL 53 | 0101000020E6100000C79DD2C1FA5552C00F1945C5EE2B4940 54 | 55 | query R 56 | SELECT ST_ASTEXT(ST_MAKEPOINT(p1, p2)) from tbl_doubles 57 | ---- 58 | POINT(42.123456 10.54) 59 | POINT(-73.34343 50.3432242) 60 | NULL 61 | POINT(-73.34343 50.3432242) 62 | 63 | --------------------------------------------------------------------------------