SegmentIntersectionDetector.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
*
* 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 <cstddef>
#include <geos/noding/SegmentIntersector.h>
#include <geos/algorithm/LineIntersector.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/CoordinateSequence.h>
#include <geos/noding/SegmentString.h>
namespace geos {
namespace noding { // geos::noding
class SegmentIntersectionDetector : public SegmentIntersector {
private:
algorithm::LineIntersector* li;
bool findProper;
bool findAllTypes;
bool _hasIntersection;
bool _hasProperIntersection;
bool _hasNonProperIntersection;
const geom::Coordinate* intPt;
geom::CoordinateSequence* intSegments;
protected:
public:
SegmentIntersectionDetector(algorithm::LineIntersector* p_li)
:
li(p_li),
findProper(false),
findAllTypes(false),
_hasIntersection(false),
_hasProperIntersection(false),
_hasNonProperIntersection(false),
intPt(nullptr),
intSegments(nullptr)
{ }
~SegmentIntersectionDetector() override
{
//delete intPt;
delete intSegments;
}
void
setFindProper(bool p_findProper)
{
this->findProper = p_findProper;
}
void
setFindAllIntersectionTypes(bool p_findAllTypes)
{
this->findAllTypes = p_findAllTypes;
}
bool
hasIntersection() const
{
return _hasIntersection;
}
bool
hasProperIntersection() const
{
return _hasProperIntersection;
}
bool
hasNonProperIntersection() const
{
return _hasNonProperIntersection;
}
const geom::Coordinate*
getIntersection() const
{
return intPt;
}
const geom::CoordinateSequence*
getIntersectionSegments() const
{
return intSegments;
}
bool
isDone() const override
{
// If finding all types, we can stop
// when both possible types have been found.
if(findAllTypes) {
return _hasProperIntersection && _hasNonProperIntersection;
}
// If searching for a proper intersection, only stop if one is found
if(findProper) {
return _hasProperIntersection;
}
return _hasIntersection;
}
void processIntersections(noding::SegmentString* e0, std::size_t segIndex0,
noding::SegmentString* e1, std::size_t segIndex1) override;
};
} // namespace geos::noding
} // namespace geos
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::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::noding::SegmentIntersectionDetector::hasIntersection
bool hasIntersection() const
Tests whether an intersection was found.
Definition SegmentIntersectionDetector.h:94
geos::noding::SegmentIntersectionDetector::getIntersection
const geom::Coordinate * getIntersection() const
Gets the computed location of the intersection. Due to round-off, the location may not be exact.
Definition SegmentIntersectionDetector.h:128
geos::noding::SegmentIntersectionDetector::isDone
bool isDone() const override
Reports whether the client of this class needs to continue testing all intersections in an arrangemen...
Definition SegmentIntersectionDetector.h:146
geos::noding::SegmentIntersectionDetector::getIntersectionSegments
const geom::CoordinateSequence * getIntersectionSegments() const
Gets the endpoints of the intersecting segments.
Definition SegmentIntersectionDetector.h:140
geos::noding::SegmentIntersectionDetector::hasNonProperIntersection
bool hasNonProperIntersection() const
Tests whether a non-proper intersection was found.
Definition SegmentIntersectionDetector.h:116
geos::noding::SegmentIntersectionDetector::processIntersections
void processIntersections(noding::SegmentString *e0, std::size_t segIndex0, noding::SegmentString *e1, std::size_t segIndex1) override
This method is called by clients of the SegmentIntersector class to process intersections for two seg...
geos::noding::SegmentIntersectionDetector::hasProperIntersection
bool hasProperIntersection() const
Tests whether a proper intersection was found.
Definition SegmentIntersectionDetector.h:105
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38