GEOS  3.13.0dev
MCIndexSegmentSetMutualIntersector.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 #pragma once
16 
17 #include <geos/noding/SegmentSetMutualIntersector.h> // inherited
18 #include <geos/index/chain/MonotoneChainOverlapAction.h> // inherited
19 #include <geos/index/chain/MonotoneChain.h> // inherited
20 #include <geos/index/strtree/TemplateSTRtree.h> // inherited
21 
22 namespace geos {
23 namespace index {
24 class SpatialIndex;
25 }
26 namespace noding {
27 class SegmentString;
28 class SegmentIntersector;
29 }
30 }
31 
32 //using namespace geos::index::strtree;
33 
34 namespace geos {
35 namespace noding { // geos::noding
36 
45 public:
46 
47  MCIndexSegmentSetMutualIntersector(double p_tolerance)
48  : monoChains()
49  , indexCounter(0)
50  , processCounter(0)
51  , nOverlaps(0)
52  , overlapTolerance(p_tolerance)
53  , indexBuilt(false)
54  {}
55 
58  {}
59 
61  {};
62 
64  getIndex()
65  {
66  return &index;
67  }
68 
69  void setBaseSegments(SegmentString::ConstVect* segStrings) override;
70 
71  // NOTE: re-populates the MonotoneChain vector with newly created chains
72  void process(SegmentString::ConstVect* segStrings) override;
73 
74  class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
75  private:
77 
78  // Declare type as noncopyable
79  SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
80  SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
81 
82  public:
83  SegmentOverlapAction(SegmentIntersector& p_si) :
84  index::chain::MonotoneChainOverlapAction(), si(p_si)
85  {}
86 
87  void overlap(const index::chain::MonotoneChain& mc1, std::size_t start1,
88  const index::chain::MonotoneChain& mc2, std::size_t start2) override;
89  };
90 
97 
98 private:
99 
100  typedef std::vector<index::chain::MonotoneChain> MonoChains;
101  MonoChains monoChains;
102 
103  /*
104  * The index::SpatialIndex used should be something that supports
105  * envelope (range) queries efficiently (such as a index::quadtree::Quadtree
106  * or index::strtree::STRtree).
107  */
108  index::strtree::TemplateSTRtree<const index::chain::MonotoneChain*> index;
109  int indexCounter;
110  int processCounter;
111  // statistics
112  int nOverlaps;
113  double overlapTolerance;
114 
115  /* memory management helper, holds MonotoneChain objects used
116  * in the SpatialIndex. It's cleared when the SpatialIndex is
117  */
118  bool indexBuilt;
119  MonoChains indexChains;
120 
121  void addToIndex(SegmentString* segStr);
122 
123  void intersectChains();
124 
125  void addToMonoChains(SegmentString* segStr);
126 
127 };
128 
129 } // namespace geos::noding
130 } // namespace geos
131 
Abstract class defines basic insertion and query operations supported by classes implementing spatial...
Definition: SpatialIndex.h:46
The action for the internal iterator for performing overlap queries on a MonotoneChain.
Definition: MonotoneChainOverlapAction.h:42
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition: index/chain/MonotoneChain.h:85
Intersects two sets of SegmentStrings using a index based on MonotoneChains and a SpatialIndex.
Definition: MCIndexSegmentSetMutualIntersector.h:44
MCIndexSegmentSetMutualIntersector(const MCIndexSegmentSetMutualIntersector &)=delete
void setBaseSegments(SegmentString::ConstVect *segStrings) override
void process(SegmentString::ConstVect *segStrings) override
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:45
An intersector for the red-blue intersection problem.
Definition: SegmentSetMutualIntersector.h:36
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:47
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25