H3Lib/Extensions/H3IndexExtensions.cs
/// <summary>
/// ToCenterChild produces the center child index for a given H3 index at
/// the specified resolution
/// </summary>
/// <param name="h">H3Index to find center child of</param>
/// <param name="childRes">The resolution to switch to</param>
/// <returns>
/// H3Index of the center child, or H3_NULL if you actually asked for a parent
/// </returns>
ToCenterChild produces the center child index for a given H3 index at
the specified resolution
ToCenterChild produces the center child index for a given H3 index at the specified resolution
public static H3Index ToCenterChild(this H3Index h, int childRes)
        {
            int parentRes = h.Resolution;
            if (!parentRes.IsValidChildRes(childRes))
            {
                return Constants.H3Index.H3_NULL;
            }
            if (childRes == parentRes)
            {
                return h;
            }
            var child = h;
            child = child.SetResolution(childRes);
            for (int i = parentRes + 1; i <= childRes; i++)
            {
                child = child.SetIndexDigit(i, 0);
            }
            return child;
        }
public static H3Index ToCenterChild ( this H3Index h , int childRes ) { int parentRes = h . Resolution ; if ( ! parentRes . IsValidChildRes ( childRes ) ) { return Constants . H3Index . H3_NULL ; } if ( childRes == parentRes ) { return h ; } var child = h ; child = child . SetResolution ( childRes ) ; for ( int i = parentRes + 1 ; i <= childRes ; i ++ ) { child = child . SetIndexDigit ( i , 0 ) ; } return child ; }
ToCenterChild produces the center child index for a given H3 index at
the specified resolution
ToCenterChild produces the center child index for a given H3 index at the specified resolution
H3Index of the center child, or H3_NULL if you actually asked for a parent
H3Index of the center child or H3_NULL if you actually asked for a parent
H3Index
this
childRes
int
The resolution to switch to
The resolution to switch to
h
H3Index to find center child of
H3Index to find center child of