Function S2Polygon.initializeToSimplifiedInCell
Like InitToSimplified, except that any vertices or edges on the boundary of the given S2Cell are preserved if possible. This method requires that the polygon has already been clipped so that it does not extend outside the cell by more than "boundary_tolerance". In other words, it operates on polygons that have already been intersected with a cell.
Typically this method is used in geometry-processing pipelines that intersect polygons with a collection of S2Cells and then process those cells in parallel, where each cell generates some geometry that needs to be simplified. In contrast, if you just need to simplify the *input* geometry then it is easier and faster to do the simplification before computing the intersection with any S2Cells.
"boundary_tolerance" specifies how close a vertex must be to the cell boundary to be kept. The default tolerance is large enough to handle any reasonable way of interpolating points along the cell boundary, such as
S2
:GetIntersection(), S2::Interpolate(), or direct (u,v) interpolation using S2::FaceUVtoXYZ(). However, if the vertices have been snapped to a lower-precision representation (e.g., S2CellId centers or E7 coordinates) then you will need to set this tolerance explicitly. For example, if the vertices were snapped to E7 coordinates then "boundary_tolerance" should be set to
s2builderutil
:IntLatLngSnapFunction::MinSnapRadiusForExponent(7)
Degenerate portions of loops are always removed, so if a vertex on the cell boundary belongs only to degenerate regions then it will not be kept. For example, if the input polygon is a narrow strip of width less than "snap_radius" along one side of the cell, then the entire loop may become degenerate and be removed.
REQUIRES
all vertices of "a" are within "boundary_tolerance" of "cell".