The default constructor snaps to S2CellId::kMaxLevel (i.e., the centers of leaf cells), and uses the minimum allowable snap radius at that level.
Convenience constructor equivalent to calling set_level(level).
For S2CellId snapping, the minimum separation between edges and non-incident vertices depends on level() and snap_radius(). It can be as low as 0.219 * snap_radius(), but is typically 0.5 * snap_radius() or more.
For S2CellId snapping, the minimum separation between vertices depends on level() and snap_radius(). It can vary between 0.5 * snap_radius() and snap_radius().
Snaps vertices to S2Cell centers at the given level. As a side effect, this method also resets "snap_radius" to the minimum value allowed at this level:
Defines the snap radius to be used (see s2builder.h). The snap radius must be at least the minimum value for the current level(), but larger values can also be used (e.g., to simplify the geometry).
Returns the minimum S2Cell level (i.e., largest S2Cells) such that vertices will not move by more than "snap_radius". This can be useful when choosing an appropriate level to snap to. The return value is always a valid level (out of range values are silently clamped).
Returns the minimum allowable snap radius for the given S2Cell level (approximately equal to half of the maximum cell diagonal length).
The maximum distance that vertices can move when snapped.
The maximum snap radius is just large enough to support snapping to S2CellId level 0. It is equivalent to 7800km on the Earth's surface.
The maximum distance that the center of an edge can move when snapped. This is slightly larger than "snap_radius" because when a geodesic edge is snapped, the center of the edge moves further than its endpoints.
The guaranteed minimum distance between vertices in the output. This is generally some fraction of "snap_radius".
The guaranteed minimum spacing between edges and non-incident vertices in the output. This is generally some fraction of "snap_radius".
Returns a candidate snap site for the given point. The final vertex locations are a subset of the snap sites returned by this function (spaced at least "min_vertex_separation" apart).
A SnapFunction that snaps vertices to S2CellId centers. This can be useful if you want to encode your geometry compactly using S2Polygon::Encode(), for example. You can snap to the centers of cells at any level.
Every snap level has a corresponding minimum snap radius, which is simply the maximum distance that a vertex can move when snapped. It is approximately equal to half of the maximum diagonal length for cells at the chosen level. You can also set the snap radius to a larger value; for example, you could snap to the centers of leaf cells (1cm resolution) but set the snap_radius() to 10m. This would result in significant extra simplification, without moving vertices unnecessarily (i.e., vertices that are at least 10m away from all other vertices will move by less than 1cm).