Lenti Pacurar
Lenti Pacurar

Reputation: 49

Point/circle in polygons search in Marklogic 7 using cts:circle-intersect

I have a list of around 1100 polygons to iterate through in $polygons (none of them overlapping each other) and I need to find to which polygon my point or circle with a 1 mile radius belongs/intersects. I used the function below and it takes about 1 second and a half, which is good, but I was wondering, is there is another better/faster approach to it? I read about R/M-tree algorithms, but I don't have any rectangle hierarchies indexed inside the DB. I'm also trying cts:polygon-intersect to see if it is faster, but I doubt it.

cts:circle-intersects(cts:circle(1,cts:point(5.8864790,51.0006240)), $polygons)

Upvotes: 3

Views: 66

Answers (2)

Lenti Pacurar
Lenti Pacurar

Reputation: 49

So far, cts:circle-intersects is the fastest, iterates in 1.3 seconds between all the 1100+ polygons. I've tried cts:polygon-intersects and cts:region-intersects also. Since this is not a very critical task in order to apply some fancy and speedy algorithms I will leave it like this for the moment.

Upvotes: 0

mholstege
mholstege

Reputation: 4912

You can use cts:bounding-boxes to get bounding boxes (of varying granularity in the case of the polygons) and check whether they overlap, and only go to the more expensive check if they do. Checking whether two boxes intersect is very quick.

Upvotes: 1

Related Questions