Function S2RegionCoverer.Options.maxCells
Sets the desired maximum number of cells in the approximation. Note the following:
int maxCells() const;
- For any setting of max_cells(), up to 6 cells may be returned if that is the minimum number required (e.g. if the region intersects all six cube faces). Even for very tiny regions, up to 3 cells may be returned if they happen to be located at the intersection of three cube faces.
- min_level() takes priority over max_cells(), i.e. cells below the given level will never be used even if this causes a large number of cells to be returned.
- If max_cells() is less than 4, the area of the covering may be arbitrarily large compared to the area of the original region even if the region is convex (e.g. an S2Cap or S2LatLngRect).
Accuracy is measured by dividing the area of the covering by the area of the original region. The following table shows the median and worst case values for this area ratio on a test case consisting of 100,000 spherical caps of random size (generated using s2region_coverer_test):
max_cells: 3 4 5 6 8 12 20 100 1000
median ratio: 5.33 3.32 2.73 2.34 1.98 1.66 1.42 1.11 1.01
worst case: 215518 14.41 9.72 5.26 3.91 2.75 1.92 1.20 1.02
The default value of 8 gives a reasonable tradeoff between the number of cells used and the accuracy of the approximation.
DEFAULT
DEFAULT_MAX_CELLS