GeometryFixer.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2021 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 <memory>
#include <vector>
#include <geos/geom/Geometry.h>
#include <geos/export.h>
// Forward declarations
namespace geos {
namespace geom {
class GeometryFactory;
class Point;
class Polygon;
class LineString;
class LinearRing;
class MultiPoint;
class MultiPolygon;
class MultiLineString;
class GeometryCollection;
}
}
namespace geos {
namespace geom { // geos.geom
namespace util { // geos.geom.util
class GEOS_DLL GeometryFixer {
private:
const geom::Geometry* geom;
const geom::GeometryFactory* factory;
bool isKeepCollapsed; // false
public:
GeometryFixer(const geom::Geometry* p_geom)
: geom(p_geom)
, factory(p_geom->getFactory())
, isKeepCollapsed(false)
{};
static std::unique_ptr<geom::Geometry> fix(const geom::Geometry* geom);
void setKeepCollapsed(bool p_isKeepCollapsed);
std::unique_ptr<geom::Geometry> getResult() const;
private:
std::unique_ptr<geom::Point> fixPoint(const geom::Point* geom) const;
std::unique_ptr<geom::Point> fixPointElement(const geom::Point* geom) const;
bool isValidPoint(const geom::Point* pt) const;
std::unique_ptr<geom::Geometry> fixMultiPoint(const geom::MultiPoint* geom) const;
std::unique_ptr<geom::Geometry> fixLinearRing(const geom::LinearRing* geom) const;
std::unique_ptr<geom::Geometry> fixLinearRingElement(const geom::LinearRing* geom) const;
std::unique_ptr<geom::Geometry> fixLineString(const geom::LineString* geom) const;
std::unique_ptr<geom::Geometry> fixLineStringElement(const geom::LineString* geom) const;
std::unique_ptr<geom::Geometry> fixMultiLineString(const MultiLineString* geom) const;
std::unique_ptr<geom::Geometry> fixPolygon(const geom::Polygon* geom) const;
std::unique_ptr<geom::Geometry> fixPolygonElement(const geom::Polygon* geom) const;
std::vector<std::unique_ptr<Geometry>> fixHoles(const geom::Polygon* geom) const;
std::unique_ptr<geom::Geometry> removeHoles(const geom::Geometry* shell, const geom::Geometry* holes) const;
std::unique_ptr<geom::Geometry> fixRing(const geom::LinearRing* ring) const;
std::unique_ptr<geom::Geometry> fixMultiPolygon(const geom::MultiPolygon* geom) const;
std::unique_ptr<geom::Geometry> fixCollection(const geom::GeometryCollection* geom) const;
void classifyHoles(
const Geometry* shell,
std::vector<std::unique_ptr<Geometry>>& holesFixed,
std::vector<const Geometry*>& holes,
std::vector<const Geometry*>& shells) const;
std::unique_ptr<Geometry> difference(
const Geometry* shell,
std::vector<const Geometry*>& holes) const;
std::unique_ptr<Geometry> unionGeometry(
std::vector<const Geometry*>& polys) const;
};
} // namespace geos.geom.util
} // namespace geos.geom
} // namespace geos
geos::geom::GeometryCollection
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:51
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::LineString
Definition LineString.h:66
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::MultiLineString
Models a collection of LineStrings.
Definition MultiLineString.h:49
geos::geom::MultiPoint
Definition MultiPoint.h:50
geos::geom::MultiPolygon
Definition MultiPolygon.h:58
geos::geom::Point
Definition Point.h:61
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::geom::util::GeometryFixer::getResult
std::unique_ptr< geom::Geometry > getResult() const
geos::geom::util::GeometryFixer::setKeepCollapsed
void setKeepCollapsed(bool p_isKeepCollapsed)
geos::geom::util
Provides classes that parse and modify Geometry objects.
Definition ComponentCoordinateExtracter.h:28
geos::geom
Definition Angle.h:26
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38