3

I have tremendous flows of point data (in 2D) (thousands every second). On this map I have several fixed polygons (dozens to a few hundreds of them).

I would like to determine in real time (the order of a few milliseconds on a rather powerful laptop) for each point in which polygons it lies (polygons can intersect). I thought I'd use the ray casting algorithm.

Nevertheless, I need a way to preprocess the data, to avoid scanning every polygon. I therefore consider using tree approaches (PM quadtree or Rtree ?). Is there any other relevant method ? Is there a good PM Quadtree implementation you would recommend (in whatever language, preferably C(++), Java or Python) ?

Robin
  • 605
  • 2
  • 8
  • 25

1 Answers1

2

I have developed a library of several multi-dimensional indexes in Java, it can be found here. It contains R*Tree, STR-Tree, 4 quadtrees (2 for points, 2 for rectangles) and a critbit tree (can be used for spatial data by interleaving the coordinates). I also developed the PH-Tree.

There are all rectange/point based trees, so you would have to convert your polygons into rectangles, for example by calculating the bounding box. For all returned bounding boxes you would have to calculate manually if the polygon really intersects with your point. If your rectangles are not too elongated, this should still be efficient.

I usually find the PH-Tree the most efficient tree, it has fast building times and very fast query times if a point intersects with 100 rectangles or less (even better with 10 or less). STR/R*-trees are better with larger overlap sizes (1000+). The quadtrees are a bit unreliable, they have problems with numeric precision when inserting millions of elements.

Assuming a 3D tree with 1 million rectangles and on average one result per query, the PH-Tree requires about 3 microseconds per query on my desktop (i7 4xxx), i.e. 300 queries per millisecond.

TilmannZ
  • 1,784
  • 11
  • 18