Function S2Polygon.encode
Appends a serialized representation of the S2Polygon to "encoder".
void encode(ORangeT)
(
Encoder!ORangeT encoder
) const;
The encoding uses about 4 bytes per vertex for typical polygons in Google's geographic repository, assuming that most vertices have been snapped to the centers of S2Cells at some fixed level (typically using InitToSnapped). The remaining vertices are stored using 24 bytes. Decoding a polygon encoded this way always returns the original polygon, without any loss of precision.
The snap level is chosen to be the one that has the most vertices snapped to S2Cells at that level. If most vertices need 24 bytes, then all vertices are encoded this way (this method automatically chooses the encoding that has the best chance of giving the smaller output size).