GEOS
3.9.1dev
|
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of intersections. More...
#include <MonotoneChain.h>
Public Member Functions | |
MonotoneChain (const geom::CoordinateSequence &pts, std::size_t start, std::size_t end, void *context) | |
~MonotoneChain ()=default | |
const geom::Envelope & | getEnvelope () |
Returned envelope is owned by this class. More... | |
const geom::Envelope & | getEnvelope (double expansionDistance) |
size_t | getStartIndex () const |
size_t | getEndIndex () const |
void | getLineSegment (std::size_t index, geom::LineSegment &ls) const |
Set given LineSegment with points of the segment starting at the given index. More... | |
std::unique_ptr< geom::CoordinateSequence > | getCoordinates () const |
void | select (const geom::Envelope &searchEnv, MonotoneChainSelectAction &mcs) |
void | computeOverlaps (MonotoneChain *mc, MonotoneChainOverlapAction *mco) |
void | computeOverlaps (MonotoneChain *mc, double overlapTolerance, MonotoneChainOverlapAction *mco) |
void | setId (int nId) |
int | getId () const |
void * | getContext () |
Private Member Functions | |
void | computeSelect (const geom::Envelope &searchEnv, size_t start0, size_t end0, MonotoneChainSelectAction &mcs) |
void | computeOverlaps (std::size_t start0, std::size_t end0, MonotoneChain &mc, std::size_t start1, std::size_t end1, double overlapTolerance, MonotoneChainOverlapAction &mco) |
bool | overlaps (size_t start0, size_t end0, const MonotoneChain &mc, size_t start1, size_t end1, double overlapTolerance) const |
bool | overlaps (const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q1, const geom::Coordinate &q2, double overlapTolerance) const |
MonotoneChain (const MonotoneChain &other)=delete | |
MonotoneChain & | operator= (const MonotoneChain &rhs)=delete |
Private Attributes | |
const geom::CoordinateSequence & | pts |
Externally owned. More... | |
void * | context |
user-defined information More... | |
size_t | start |
Index of chain start vertex into the CoordinateSequence, 0 based. More... | |
size_t | end |
Index of chain end vertex into the CoordinateSequence, 0 based. More... | |
geom::Envelope | env |
Owned by this class. More... | |
bool | envIsSet |
int | id |
useful for optimizing chain comparisons More... | |
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of intersections.
They have the following properties:
Property 1 means that there is no need to test pairs of segments from within the same monotone chain for intersection. Property 2 allows an efficient binary search to be used to find the intersection points of two monotone chains.
For many types of real-world data, these properties eliminate a large number of segment comparisons, producing substantial speed gains.
One of the goals of this implementation of MonotoneChains is to be as space and time efficient as possible. One design choice that aids this is that a MonotoneChain is based on a subarray of a list of points. This means that new arrays of points (potentially very large) do not have to be allocated.
MonotoneChains support the following kinds of queries:
This implementation of MonotoneChains uses the concept of internal iterators to return the resultsets for the above queries. This has time and space advantages, since it is not necessary to build lists of instantiated objects to represent the segments returned by the query. However, it does mean that the queries are not thread-safe.
Definition at line 84 of file index/chain/MonotoneChain.h.
geos::index::chain::MonotoneChain::MonotoneChain | ( | const geom::CoordinateSequence & | pts, |
std::size_t | start, | ||
std::size_t | end, | ||
void * | context | ||
) |
pts | Ownership left to caller, this class holds a reference. |
start | |
end | |
context | Ownership left to caller, this class holds a reference. |
|
default |
|
privatedelete |
void geos::index::chain::MonotoneChain::computeOverlaps | ( | MonotoneChain * | mc, |
MonotoneChainOverlapAction * | mco | ||
) |
void geos::index::chain::MonotoneChain::computeOverlaps | ( | MonotoneChain * | mc, |
double | overlapTolerance, | ||
MonotoneChainOverlapAction * | mco | ||
) |
|
private |
|
private |
|
inline |
Definition at line 157 of file index/chain/MonotoneChain.h.
std::unique_ptr<geom::CoordinateSequence> geos::index::chain::MonotoneChain::getCoordinates | ( | ) | const |
Return the subsequence of coordinates forming this chain. Allocates a new CoordinateSequence to hold the Coordinates
|
inline |
Definition at line 113 of file index/chain/MonotoneChain.h.
const geom::Envelope& geos::index::chain::MonotoneChain::getEnvelope | ( | ) |
Returned envelope is owned by this class.
const geom::Envelope& geos::index::chain::MonotoneChain::getEnvelope | ( | double | expansionDistance | ) |
|
inline |
Definition at line 151 of file index/chain/MonotoneChain.h.
void geos::index::chain::MonotoneChain::getLineSegment | ( | std::size_t | index, |
geom::LineSegment & | ls | ||
) | const |
Set given LineSegment with points of the segment starting at the given index.
|
inline |
Definition at line 107 of file index/chain/MonotoneChain.h.
|
privatedelete |
|
private |
|
private |
void geos::index::chain::MonotoneChain::select | ( | const geom::Envelope & | searchEnv, |
MonotoneChainSelectAction & | mcs | ||
) |
Determine all the line segments in the chain whose envelopes overlap the searchEnvelope, and process them
|
inline |
Definition at line 145 of file index/chain/MonotoneChain.h.
|
private |
user-defined information
Definition at line 186 of file index/chain/MonotoneChain.h.
|
private |
Index of chain end vertex into the CoordinateSequence, 0 based.
Definition at line 192 of file index/chain/MonotoneChain.h.
|
private |
Owned by this class.
Definition at line 195 of file index/chain/MonotoneChain.h.
|
private |
Definition at line 196 of file index/chain/MonotoneChain.h.
|
private |
useful for optimizing chain comparisons
Definition at line 199 of file index/chain/MonotoneChain.h.
|
private |
Externally owned.
Definition at line 183 of file index/chain/MonotoneChain.h.
|
private |
Index of chain start vertex into the CoordinateSequence, 0 based.
Definition at line 189 of file index/chain/MonotoneChain.h.