Speedup polygon inclusion checks
jcoupey opened this issue · comments
Currently each node of the OSM extract is tested for inclusion in all (multi-)polygon in input (https://github.com/jcoupey/osmium-polygon/blob/a73edb7/src/osm_parser.cpp#L38-L42). This results in a sub-optimal complexity of O(N x p)
where N
is the number of nodes and p
the number of polygons. This is really time-consuming when a lot of polygons are used.
The polygons should be included in a R-tree. Then for each node, we should first query only the few polygons required for checking (the ones whose R-tree box contains the node). The R-tree query times being O(log(p))
, this would improve computing times by an order of magnitude when using many polygons.