Wednesday, 15 February 2012

c# - Is it possible to efficiently count the number of line segments that overlap a single point P on a number line? -


Whether the number of this line segment can be counted efficiently, which is a point to P Does the line line overlap?

All line segments are sitting on a single line (this is not a 1-D world, no 3-D world)

For example

Formerly> line segment X1 = 1 to X2 = 1 x 1 line from section B x1 = X2 to X2 == 4 line segment X1 = X1 = 3 to X2 = 5 5 block section D x 1 to expence == 1 X2 == 4 --------------------------------------- - Ex1: row segment overlap P == 2: A, B and D> & gt; & Gt; Overlap Count == 3 Ex2: Line Segment Overlap P == 7: None & gt; & Gt; & Gt; Overlap count == 0 Ex3: Line segment overlap P == 3: A, B, C and D> & gt; & Gt; Overlap counts == 4

Of course, if there are only 4 line segments, the code is simple. However, if the 400 million line segment has a large spatial database, then the search is very slow.

Are there any algorithms that can efficiently search this list of line segments for the total number of overlaps?

What I'm Seeing So Far

  • Article on the Local Index Search Algorithm.
  • (looks very promising)
  • (looks very promising).
  • If you list the starting value and then Repeat the price) By length, you end up with the roots of an efficient algorithm.

      Sort the list with the starting value for the same starting value, sort by length (longest first)   

    Then, When you need the number of overlaps for a line, then to overlap that point, p:

      p values ​​for a given value, with the starting value,  ; = P for every starting value (binary search - fast), start at the longest length if it increases the interest rate, if not increment counter, continue on to the next small start price until you are the most   

    This is not correct, but better than searching through 10 M points is very good (although the initial type will take some time, obviously but you have toEvl must once).

No comments:

Post a Comment