IntLatLngSnapFunction

A SnapFunction that snaps vertices to S2LatLng E5, E6, or E7 coordinates. These coordinates are expressed in degrees multiplied by a power of 10 and then rounded to the nearest integer. For example, in E6 coordinates the point (23.12345651, -45.65432149) would become (23123457, -45654321).

The main argument of the SnapFunction is the exponent for the power of 10 that coordinates should be multipled by before rounding. For example, IntLatLngSnapFunction(7) is a function that snaps to E7 coordinates. The exponent can range from 0 to 10.

Each exponent has a corresponding minimum snap radius, which is simply the maximum distance that a vertex can move when snapped. It is approximately equal to 1/sqrt(2) times the nominal point spacing; for example, for snapping to E7 the minimum snap radius is (1e-7 / sqrt(2)) degrees. You can also set the snap radius to any value larger than this; this can result in significant extra simplification (similar to using a larger exponent) but does not move vertices unnecessarily.

Constructors

this
this()

The default constructor yields an invalid snap function. You must set the exponent explicitly before using it.

this
this(int exponent)

Convenience constructor equivalent to calling set_exponent(exponent).

this
this(IntLatLngSnapFunction other)
Undocumented in source.

Members

Functions

clone
S2Builder.SnapFunction clone()
Undocumented in source. Be warned that the author may not have intended to support it.
exponent
int exponent()
Undocumented in source. Be warned that the author may not have intended to support it.
minEdgeVertexSeparation
S1Angle minEdgeVertexSeparation()

For IntLatLng snapping, the minimum separation between edges and non-incident vertices depends on level() and snap_radius(). It can be as low as 0.222 * snap_radius(), but is typically 0.39 * snap_radius() or more.

minVertexSeparation
S1Angle minVertexSeparation()

For IntLatLng snapping, the minimum separation between vertices depends on exponent() and snap_radius(). It can vary between snap_radius() and snap_radius().

setExponent
void setExponent(int exponent)

Snaps vertices to points whose (lat, lng) coordinates are integers after converting to degrees and multiplying by 10 raised to the given exponent. For example, (exponent == 7) yields E7 coordinates. As a side effect, this method also resets "snap_radius" to the minimum value allowed for this exponent:

setSnapRadius
void setSnapRadius(S1Angle snap_radius)

Defines the snap radius to be used (see s2builder.h). The snap radius must be at least the minimum value for the current exponent(), but larger values can also be used (e.g., to simplify the geometry).

snapPoint
S2Point snapPoint(S2Point point)
Undocumented in source.
snapRadius
S1Angle snapRadius()
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

exponentForMaxSnapRadius
int exponentForMaxSnapRadius(S1Angle snap_radius)

Returns the minimum exponent such that vertices will not move by more than "snap_radius". This can be useful when choosing an appropriate exponent for snapping. The return value is always a valid exponent (out of range values are silently clamped).

minSnapRadiusForExponent
S1Angle minSnapRadiusForExponent(int exponent)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

MAX_EXPONENT
enum int MAX_EXPONENT;

The maximum exponent supported for snapping.

MIN_EXPONENT
enum int MIN_EXPONENT;

The minum exponent supported for snapping.

Inherited Members

From SnapFunction

snapRadius
S1Angle snapRadius()

The maximum distance that vertices can move when snapped.

kMaxSnapRadius
S1Angle kMaxSnapRadius()

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.

maxEdgeDeviation
S1Angle maxEdgeDeviation()

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.

minVertexSeparation
S1Angle minVertexSeparation()

The guaranteed minimum distance between vertices in the output. This is generally some fraction of "snap_radius".

minEdgeVertexSeparation
S1Angle minEdgeVertexSeparation()

The guaranteed minimum spacing between edges and non-incident vertices in the output. This is generally some fraction of "snap_radius".

snapPoint
S2Point snapPoint(S2Point point)

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).

clone
SnapFunction clone()
Undocumented in source.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta