public class MonotoneChain
extends java.lang.Object
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:
MonotoneChainSelectAction
and MonotoneChainOverlapAction
)
to return the results for 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.
Queries made in this manner are thread-safe.Constructor | Description |
---|---|
MonotoneChain(Coordinate[] pts,
int start,
int end,
java.lang.Object context) |
Modifier and Type | Method | Description |
---|---|---|
void |
computeOverlaps(MonotoneChain mc,
MonotoneChainOverlapAction mco) |
Determine all the line segments in two chains which may overlap, and process them.
|
java.lang.Object |
getContext() |
|
Coordinate[] |
getCoordinates() |
Return the subsequence of coordinates forming this chain.
|
int |
getEndIndex() |
|
Envelope |
getEnvelope() |
|
int |
getId() |
|
void |
getLineSegment(int index,
LineSegment ls) |
Gets the line segment starting at
index |
int |
getStartIndex() |
|
void |
select(Envelope searchEnv,
MonotoneChainSelectAction mcs) |
Determine all the line segments in the chain whose envelopes overlap
the searchEnvelope, and process them.
|
void |
setId(int id) |
public MonotoneChain(Coordinate[] pts, int start, int end, java.lang.Object context)
public void setId(int id)
public int getId()
public java.lang.Object getContext()
public Envelope getEnvelope()
public int getStartIndex()
public int getEndIndex()
public void getLineSegment(int index, LineSegment ls)
index
index
- index of segmentls
- line segment to extract intopublic Coordinate[] getCoordinates()
public void select(Envelope searchEnv, MonotoneChainSelectAction mcs)
The monotone chain search algorithm attempts to optimize performance by not calling the select action on chain segments which it can determine are not in the search envelope. However, it *may* call the select action on segments which do not intersect the search envelope. This saves on the overhead of checking envelope intersection each time, since clients may be able to do this more efficiently.
searchEnv
- the search envelopemcs
- the select action to execute on selected segmentspublic void computeOverlaps(MonotoneChain mc, MonotoneChainOverlapAction mco)
The monotone chain search algorithm attempts to optimize performance by not calling the overlap action on chain segments which it can determine do not overlap. However, it *may* call the overlap action on segments which do not actually interact. This saves on the overhead of checking intersection each time, since clients may be able to do this more efficiently.
searchEnv
- the search envelopemco
- the overlap action to execute on selected segmentsCopyright © 2018. All rights reserved.