LineDissolver.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (c) 2025 Martin Davis
* Copyright (C) 2025 Paul Ramsey <pramsey@cleverelephant.ca>
*
* 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/dissolve/DissolveEdgeGraph.h>
// #include <memory>
// #include <vector>
// #include <stack>
#include <geos/geom/LineString.h>
#include <geos/export.h>
// Forward declarations
namespace geos {
namespace dissolve {
class DissolveHalfEdge;
}
namespace edgegraph {
class HalfEdge;
}
namespace geom {
class CoordinateSequence;
class Geometry;
class GeometryFactory;
// class LineString;
}
}
namespace geos { // geos.
namespace dissolve { // geos.dissolve
class GEOS_DLL LineDissolver {
using CoordinateSequence = geos::geom::CoordinateSequence;
using Geometry = geos::geom::Geometry;
using GeometryFactory = geos::geom::GeometryFactory;
using LineString = geos::geom::LineString;
using HalfEdge = geos::edgegraph::HalfEdge;
private:
std::unique_ptr<Geometry> result;
const GeometryFactory* factory = nullptr;
DissolveEdgeGraph graph;
std::vector<std::unique_ptr<LineString>> lines;
std::stack<HalfEdge*> nodeEdgeStack;
DissolveHalfEdge* ringStartEdge = nullptr;
void computeResult();
void process(HalfEdge* e);
void stackEdges(HalfEdge* node);
void buildLines();
void updateRingStartEdge(DissolveHalfEdge* e);
void buildLine(HalfEdge* eStart);
void buildRing(HalfEdge* eStartRing);
void addLine(std::unique_ptr<CoordinateSequence>& cs);
public:
LineDissolver() : result(nullptr) {};
static std::unique_ptr<Geometry> dissolve(const Geometry* g);
void add(const Geometry* geometry);
void add(std::vector<const Geometry*> geometries);
void add(const LineString* lineString);
std::unique_ptr<Geometry> getResult();
LineDissolver(const LineDissolver&) = delete;
LineDissolver& operator=(const LineDissolver&) = delete;
};
} // namespace geos.dissolve
} // namespace geos
geos::dissolve::LineDissolver::getResult
std::unique_ptr< Geometry > getResult()
geos::dissolve::LineDissolver::LineDissolver
LineDissolver(const LineDissolver &)=delete
geos::dissolve::LineDissolver::dissolve
static std::unique_ptr< Geometry > dissolve(const Geometry *g)
geos::dissolve::LineDissolver::add
void add(std::vector< const Geometry * > geometries)
geos::dissolve::LineDissolver::add
void add(const Geometry *geometry)
geos::edgegraph::HalfEdge
Definition HalfEdge.h:56
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineString
Definition LineString.h:66
geos::geom
Definition Angle.h:26
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38