GEOS 3.11.1
SegmentIntersectionDetector.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 *
14 **********************************************************************/
15
16#pragma once
17
18#include <cstddef>
19#include <geos/noding/SegmentIntersector.h>
20#include <geos/algorithm/LineIntersector.h>
21#include <geos/geom/Coordinate.h>
22#include <geos/geom/CoordinateArraySequence.h>
23#include <geos/noding/SegmentString.h>
24
25namespace geos {
26namespace noding { // geos::noding
27
42private:
44
45 bool findProper;
46 bool findAllTypes;
47
48 bool _hasIntersection;
49 bool _hasProperIntersection;
50 bool _hasNonProperIntersection;
51
52 const geom::Coordinate* intPt;
54
55protected:
56public:
58 :
59 li(p_li),
60 findProper(false),
61 findAllTypes(false),
62 _hasIntersection(false),
63 _hasProperIntersection(false),
64 _hasNonProperIntersection(false),
65 intPt(nullptr),
66 intSegments(nullptr)
67 { }
68
70 {
71 //delete intPt;
72 delete intSegments;
73 }
74
75
76 void
77 setFindProper(bool p_findProper)
78 {
79 this->findProper = p_findProper;
80 }
81
82 void
83 setFindAllIntersectionTypes(bool p_findAllTypes)
84 {
85 this->findAllTypes = p_findAllTypes;
86 }
87
93 bool
95 {
96 return _hasIntersection;
97 }
98
104 bool
106 {
107 return _hasProperIntersection;
108 }
109
115 bool
117 {
118 return _hasNonProperIntersection;
119 }
120
127 const geom::Coordinate*
129 {
130 return intPt;
131 }
132
133
141 {
142 return intSegments;
143 }
144
145 bool
146 isDone() const override
147 {
148 // If finding all types, we can stop
149 // when both possible types have been found.
150 if(findAllTypes) {
151 return _hasProperIntersection && _hasNonProperIntersection;
152 }
153
154 // If searching for a proper intersection, only stop if one is found
155 if(findProper) {
156 return _hasProperIntersection;
157 }
158
159 return _hasIntersection;
160 }
161
170 void processIntersections(noding::SegmentString* e0, std::size_t segIndex0,
171 noding::SegmentString* e1, std::size_t segIndex1) override;
172
173};
174
175} // namespace geos::noding
176} // namespace geos
177
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:50
The default implementation of CoordinateSequence.
Definition: CoordinateArraySequence.h:35
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Detects and records an intersection between two SegmentStrings, if one exists.
Definition: SegmentIntersectionDetector.h:41
bool hasIntersection() const
Tests whether an intersection was found.
Definition: SegmentIntersectionDetector.h:94
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
bool isDone() const override
Reports whether the client of this class needs to continue testing all intersections in an arrangemen...
Definition: SegmentIntersectionDetector.h:146
const geom::CoordinateSequence * getIntersectionSegments() const
Gets the endpoints of the intersecting segments.
Definition: SegmentIntersectionDetector.h:140
bool hasNonProperIntersection() const
Tests whether a non-proper intersection was found.
Definition: SegmentIntersectionDetector.h:116
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...
bool hasProperIntersection() const
Tests whether a proper intersection was found.
Definition: SegmentIntersectionDetector.h:105
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:45
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:45
Basic namespace for all GEOS functionalities.
Definition: geos.h:39