IsSimpleOp.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
* Copyright (C) 2009 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2005-2006 Refractions Research Inc.
* 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 <geos/algorithm/LineIntersector.h>
#include <geos/algorithm/BoundaryNodeRule.h>
#include <geos/noding/SegmentIntersector.h>
// Forward declarations
namespace geos {
namespace noding {
class SegmentString;
class BasicSegmentString;
}
// namespace algorithm {
// class BoundaryNodeRule;
// }
namespace geom {
class LineString;
class LinearRing;
class MultiLineString;
class MultiPoint;
class Geometry;
class Polygon;
class GeometryCollection;
}
}
namespace geos { // geos
namespace operation { // geos.operation
namespace valid { // geos.operation.valid
class GEOS_DLL IsSimpleOp {
private:
const geom::Geometry& inputGeom;
bool isClosedEndpointsInInterior = true;
bool isFindAllLocations = false;
bool isSimpleResult = false;
std::vector<geom::CoordinateXY> nonSimplePts;
bool computed = false;
void compute();
bool computeSimple(const geom::Geometry& geom);
bool isSimpleMultiPoint(const geom::MultiPoint& mp);
bool isSimplePolygonal(const geom::Geometry& geom);
bool isSimpleGeometryCollection(const geom::Geometry& geom);
bool isSimpleLinearGeometry(const geom::Geometry& geom);
static std::vector<std::unique_ptr<geos::geom::CoordinateSequence>>
removeRepeatedPts(const geom::Geometry& geom);
static std::vector<std::unique_ptr<noding::SegmentString>>
createSegmentStrings(std::vector<std::unique_ptr<geos::geom::CoordinateSequence>>& seqs);
class NonSimpleIntersectionFinder : public noding::SegmentIntersector
{
private:
bool isClosedEndpointsInInterior;
bool isFindAll = false;
std::vector<geom::CoordinateXY>& intersectionPts;
algorithm::LineIntersector li;
// bool hasInteriorInt;
// bool hasInteriorVertexInt;
// bool hasEqualSegments;
// bool hasInteriorEndpointInt;
bool findIntersection(
noding::SegmentString* ss0, std::size_t segIndex0,
noding::SegmentString* ss1, std::size_t segIndex1,
const geom::CoordinateXY& p00, const geom::CoordinateXY& p01,
const geom::CoordinateXY& p10, const geom::CoordinateXY& p11);
bool isIntersectionEndpoint(
const noding::SegmentString* ss, std::size_t ssIndex,
const algorithm::LineIntersector& li, std::size_t liSegmentIndex) const;
std::size_t intersectionVertexIndex(
const algorithm::LineIntersector& li, std::size_t segmentIndex) const;
public:
NonSimpleIntersectionFinder(
bool p_isClosedEndpointsInInterior,
bool p_isFindAll,
std::vector<geom::CoordinateXY>& p_intersectionPts)
: isClosedEndpointsInInterior(p_isClosedEndpointsInInterior)
, isFindAll(p_isFindAll)
, intersectionPts(p_intersectionPts)
{};
bool hasIntersection() const;
void processIntersections(
noding::SegmentString* ss0, std::size_t segIndex0,
noding::SegmentString* ss1, std::size_t segIndex1) override;
bool isDone() const override;
}; // NonSimpleIntersectionFinder
public:
IsSimpleOp(const geom::Geometry* geom)
: IsSimpleOp(*geom)
{};
IsSimpleOp(const geom::Geometry& geom)
: IsSimpleOp(geom, algorithm::BoundaryNodeRule::getBoundaryRuleMod2())
{};
IsSimpleOp(const geom::Geometry& geom, const algorithm::BoundaryNodeRule& p_boundaryNodeRule)
: inputGeom(geom)
, isClosedEndpointsInInterior(! p_boundaryNodeRule.isInBoundary(2))
, isFindAllLocations(false)
, computed(false)
{};
static bool isSimple(const geom::Geometry& geom);
static bool isSimple(const geom::Geometry* geom) {
if (!geom) return false;
return isSimple(*geom);
}
geom::CoordinateXY getNonSimpleLocation(const geom::Geometry& geom);
void setFindAllLocations(bool isFindAll);
bool isSimple();
geom::CoordinateXY getNonSimpleLocation();
const std::vector<geom::CoordinateXY>& getNonSimpleLocations();
}; // IsSimpleOp
} // namespace geos.operation.valid
} // namespace geos.operation
} // namespace geos
geos::algorithm::BoundaryNodeRule
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition BoundaryNodeRule.h:52
geos::algorithm::LineIntersector
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
geos::geom::GeometryCollection
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:51
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::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::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::noding::BasicSegmentString
Represents a list of contiguous line segments, and supports noding the segments.
Definition BasicSegmentString.h:44
geos::noding::SegmentIntersector
Processes possible intersections detected by a Noder.
Definition noding/SegmentIntersector.h:45
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
geos::operation::valid::IsSimpleOp::setFindAllLocations
void setFindAllLocations(bool isFindAll)
geos::operation::valid::IsSimpleOp::IsSimpleOp
IsSimpleOp(const geom::Geometry &geom)
Definition IsSimpleOp.h:222
geos::operation::valid::IsSimpleOp::getNonSimpleLocation
geom::CoordinateXY getNonSimpleLocation()
geos::operation::valid::IsSimpleOp::isSimple
static bool isSimple(const geom::Geometry &geom)
geos::operation::valid::IsSimpleOp::isSimple
bool isSimple()
geos::operation::valid::IsSimpleOp::getNonSimpleLocations
const std::vector< geom::CoordinateXY > & getNonSimpleLocations()
geos::operation::valid::IsSimpleOp::getNonSimpleLocation
geom::CoordinateXY getNonSimpleLocation(const geom::Geometry &geom)
geos::operation::valid::IsSimpleOp::IsSimpleOp
IsSimpleOp(const geom::Geometry &geom, const algorithm::BoundaryNodeRule &p_boundaryNodeRule)
Definition IsSimpleOp.h:232
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
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