OverlapUnion.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
*
* 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: ORIGINAL WORK, generalization of CascadedPolygonUnion
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <geos/geom/Geometry.h>
#include <geos/operation/union/UnionStrategy.h>
#include <geos/operation/union/CascadedPolygonUnion.h>
// Forward declarations
namespace geos {
namespace geom {
class Envelope;
class LineSegment;
}
}
namespace geos {
namespace operation { // geos::operation
namespace geounion { // geos::operation::geounion
class GEOS_DLL OverlapUnion {
public:
OverlapUnion(const geom::Geometry* p_g0, const geom::Geometry* p_g1, geounion::UnionStrategy* unionFun)
: g0(p_g0)
, g1(p_g1)
, unionFunction(unionFun)
, geomFactory(p_g0->getFactory())
, isUnionSafe(false)
{};
OverlapUnion(const geom::Geometry* p_g0, const geom::Geometry* p_g1)
: OverlapUnion(p_g0, p_g1, &defaultUnionFunction)
{};
std::unique_ptr<geom::Geometry> doUnion();
private:
const geom::Geometry* g0;
const geom::Geometry* g1;
geounion::UnionStrategy* unionFunction;
const geom::GeometryFactory* geomFactory;
bool isUnionSafe;
geounion::ClassicUnionStrategy defaultUnionFunction;
static geom::Envelope overlapEnvelope(const geom::Geometry* geom0, const geom::Geometry* geom1);
std::unique_ptr<geom::Geometry> extractByEnvelope(const geom::Envelope& env, const geom::Geometry* geom, std::vector<std::unique_ptr<geom::Geometry>>& disjointGeoms);
static std::unique_ptr<geom::Geometry> combine(std::unique_ptr<geom::Geometry>& unionGeom, std::vector<std::unique_ptr<geom::Geometry>>& disjointPolys);
std::unique_ptr<geom::Geometry> unionFull(const geom::Geometry* geom0, const geom::Geometry* geom1);
static std::unique_ptr<geom::Geometry> unionBuffer(const geom::Geometry* geom0, const geom::Geometry* geom1);
bool isBorderSegmentsSame(const geom::Geometry* result, const geom::Envelope& env);
static bool isEqual(std::vector<geom::LineSegment>& segs0, std::vector<geom::LineSegment>& segs1);
std::vector<geom::LineSegment> extractBorderSegments(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::Envelope& env);
void extractBorderSegments(const geom::Geometry* geom, const geom::Envelope& penv, std::vector<geom::LineSegment>& psegs);
};
} // namespace geos::operation::union
} // namespace geos::operation
} // namespace geos
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
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::Geometry::getFactory
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition Geometry.h:226
geos::geom::LineSegment
Definition LineSegment.h:61
geos::operation::geounion::ClassicUnionStrategy
Implementation of UnionStrategy that provides overlay using the first generation overlay routines.
Definition CascadedPolygonUnion.h:50
geos::operation::geounion::UnionStrategy
Definition UnionStrategy.h:40
geos::geom
Definition Angle.h:26
geos::operation::geounion
Classes to perform efficient unioning of collections of geometries.
Definition namespaces.h:286
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38