PolygonRing.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca>
* Copyright (C) 2021 Martin Davis
*
* 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/operation/valid/PolygonRingTouch.h>
#include <geos/operation/valid/PolygonRingSelfNode.h>
#include <geos/export.h>
#include <memory>
#include <map>
// Forward declarations
namespace geos {
namespace geom {
class LinearRing;
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace valid { // geos.operation.valid
class GEOS_DLL PolygonRing {
using CoordinateXY = geos::geom::CoordinateXY;
using LinearRing = geos::geom::LinearRing;
private:
int id = -1;
PolygonRing* shell = nullptr;
const LinearRing* ring = nullptr;
PolygonRing* touchSetRoot = nullptr;
std::map<int, PolygonRingTouch> touches;
std::vector<PolygonRingSelfNode> selfNodes;
/* METHODS */
bool isOnlyTouch(const PolygonRing* polyRing, const CoordinateXY& pt) const;
const CoordinateXY* findHoleCycleLocation();
void init(PolygonRing* root, std::stack<PolygonRingTouch*>& touchStack);
const CoordinateXY* scanForHoleCycle(PolygonRingTouch* currentTouch,
PolygonRing* root,
std::stack<PolygonRingTouch*>& touchStack);
bool isInTouchSet() const
{
return touchSetRoot != nullptr;
};
void setTouchSetRoot(PolygonRing* polyRing)
{
touchSetRoot = polyRing;
};
PolygonRing* getTouchSetRoot() const
{
return touchSetRoot;
};
bool hasTouches() const
{
return ! touches.empty();
};
std::vector<PolygonRingTouch*> getTouches() const;
void addTouch(PolygonRing* polyRing, const CoordinateXY& pt);
public:
PolygonRing(const LinearRing* p_ring, int p_index, PolygonRing* p_shell)
: id(p_index)
, shell(p_shell)
, ring(p_ring)
{};
PolygonRing(const LinearRing* p_ring)
: PolygonRing(p_ring, -1, this)
{};
static bool isShell(const PolygonRing* polyRing);
static bool addTouch(PolygonRing* ring0, PolygonRing* ring1, const CoordinateXY& pt);
static const CoordinateXY* findHoleCycleLocation(std::vector<PolygonRing*> polyRings);
static const CoordinateXY* findInteriorSelfNode(std::vector<PolygonRing*> polyRings);
bool isSamePolygon(const PolygonRing* polyRing) const
{
return shell == polyRing->shell;
};
bool isShell() const
{
return shell == this;
};
void addSelfTouch(const CoordinateXY& origin,
const CoordinateXY* e00, const CoordinateXY* e01,
const CoordinateXY* e10, const CoordinateXY* e11);
const CoordinateXY* findInteriorSelfNode();
};
} // namespace geos.operation.valid
} // namespace geos.operation
} // namespace geos
geos::geom::LinearRing
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
geos::geom
Definition Angle.h:26
geos::operation::valid
Provides classes for testing the validity of geometries.
Definition namespaces.h:289
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38