Skip to content

Commit

Permalink
Fix buffer element erosion for negative distance and remove overlay d…
Browse files Browse the repository at this point in the history
…eps (#1239)
  • Loading branch information
dr-jts authored Feb 12, 2025
1 parent 6e25476 commit 0f90d0a
Show file tree
Hide file tree
Showing 11 changed files with 1,045 additions and 7 deletions.
5 changes: 2 additions & 3 deletions include/geos/operation/buffer/BufferBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ class PlanarGraph;
namespace operation {
namespace buffer {
class BufferSubgraph;
}
namespace overlay {
class PolygonBuilder;
}

}
}

Expand Down Expand Up @@ -233,7 +232,7 @@ class GEOS_DLL BufferBuilder {
* the final polygons
*/
void buildSubgraphs(const std::vector<BufferSubgraph*>& subgraphList,
overlay::PolygonBuilder& polyBuilder);
PolygonBuilder& polyBuilder);

/// \brief
/// Return the externally-set noding::Noder OR a newly created
Expand Down
52 changes: 52 additions & 0 deletions include/geos/operation/buffer/BufferNodeFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/

#pragma once

#include <geos/export.h>

#include <vector>

#include <geos/geomgraph/NodeFactory.h> // for inheritance

// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
}
namespace geomgraph {
class Node;
}
}

namespace geos {
namespace operation { // geos::operation
namespace buffer { // geos::operation::buffer

/** \brief
* Creates nodes for use in the geomgraph::PlanarGraph constructed during
* buffer operations. NOTE: also used by operation::valid
*/
class GEOS_DLL BufferNodeFactory: public geomgraph::NodeFactory {
public:
BufferNodeFactory(): geomgraph::NodeFactory() {}
geomgraph::Node* createNode(const geom::Coordinate& coord) const override;
static const geomgraph::NodeFactory& instance();
};


} // namespace geos::operation::buffer
} // namespace geos::operation
} // namespace geos

104 changes: 104 additions & 0 deletions include/geos/operation/buffer/MaximalEdgeRing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: operation/overlay/MaximalEdgeRing.java rev. 1.15 (JTS-1.10)
*
**********************************************************************/

#pragma once

#include <geos/export.h>

#include <vector>

#include <geos/geomgraph/EdgeRing.h> // for inheritance

// Forward declarations
namespace geos {
namespace geom {
class GeometryFactory;
}
namespace geomgraph {
class DirectedEdge;
}
namespace operation {
namespace buffer {
class MinimalEdgeRing;
}
}
}

namespace geos {
namespace operation { // geos::operation
namespace buffer { // geos::operation::buffer

/** \brief
* A ring of [DirectedEdges](@ref geomgraph::DirectedEdge) which may contain nodes of degree > 2.
*
* A MaximalEdgeRing may represent two different spatial entities:
*
* - a single polygon possibly containing inversions (if the ring is oriented CW)
* - a single hole possibly containing exversions (if the ring is oriented CCW)
*
* If the MaximalEdgeRing represents a polygon,
* the interior of the polygon is strongly connected.
*
* These are the form of rings used to define polygons under some spatial data models.
* However, under the OGC SFS model, [MinimalEdgeRings](@ref MinimalEdgeRing) are required.
* A MaximalEdgeRing can be converted to a list of MinimalEdgeRings using the
* {@link #buildMinimalRings() } method.
*
* @see com.vividsolutions.jts.operation.overlay.MinimalEdgeRing
*/
class GEOS_DLL MaximalEdgeRing: public geomgraph::EdgeRing {

public:

MaximalEdgeRing(geomgraph::DirectedEdge* start,
const geom::GeometryFactory* geometryFactory);
// throw(const TopologyException &)

~MaximalEdgeRing() override = default;

geomgraph::DirectedEdge* getNext(geomgraph::DirectedEdge* de) override;

void setEdgeRing(geomgraph::DirectedEdge* de, geomgraph::EdgeRing* er) override;

/// \brief
/// This function returns a newly allocated vector of
/// pointers to newly allocated MinimalEdgeRing objects.
///
/// @deprecated pass the vector yourself instead
///
std::vector<MinimalEdgeRing*>* buildMinimalRings();

/// \brief
/// This function pushes pointers to newly allocated MinimalEdgeRing
/// objects to the provided vector.
///
void buildMinimalRings(std::vector<MinimalEdgeRing*>& minEdgeRings);
void buildMinimalRings(std::vector<EdgeRing*>& minEdgeRings);

/// \brief
/// For all nodes in this EdgeRing,
/// link the DirectedEdges at the node to form minimalEdgeRings
///
void linkDirectedEdgesForMinimalEdgeRings();
};


} // namespace geos::operation::buffer
} // namespace geos::operation
} // namespace geos

80 changes: 80 additions & 0 deletions include/geos/operation/buffer/MinimalEdgeRing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: operation/overlay/MinimalEdgeRing.java rev. 1.13 (JTS-1.10)
*
**********************************************************************/

#pragma once


#include <geos/export.h>

#include <geos/geomgraph/EdgeRing.h> // for inheritance
#include <geos/geomgraph/DirectedEdge.h> // for inlines

#include <vector>

// Forward declarations
namespace geos {
namespace geom {
class GeometryFactory;
}
namespace geomgraph {
class DirectedEdge;
class EdgeRing;
}
}

namespace geos {
namespace operation { // geos::operation
namespace buffer { // geos::operation::buffer

/** \brief
* A ring of [Edges](@ref geomgraph::Edge) with the property that no node
* has degree greater than 2.
*
* These are the form of rings required to represent polygons
* under the OGC SFS spatial data model.
*
* @see operation::buffer::MaximalEdgeRing
*
*/
class GEOS_DLL MinimalEdgeRing: public geomgraph::EdgeRing {

public:

MinimalEdgeRing(geomgraph::DirectedEdge* start,
const geom::GeometryFactory* geometryFactory);

~MinimalEdgeRing() override {};

geomgraph::DirectedEdge* getNext(geomgraph::DirectedEdge* de) override
{
return de->getNextMin();
};

void setEdgeRing(geomgraph::DirectedEdge* de,
geomgraph::EdgeRing* er) override
{
de->setMinEdgeRing(er);
};

};


} // namespace geos::operation::buffer
} // namespace geos::operation
} // namespace geos

Loading

0 comments on commit 0f90d0a

Please sign in to comment.