Tests/NUnit/H3Suite/TestH3ToLocalIjExhaustive.cs
/// <summary>
/// Test the the immediate neighbors of an index are at the expected locations in
/// the local IJ coordinate space.
/// </summary>
Test the the immediate neighbors of an index are at the expected locations in
the local IJ coordinate space.
Test the the immediate neighbors of an index are at the expected locations in the local IJ coordinate space .
private void H3ToLocalIjNeighborsAssertions(H3Index h3)
        {
            (int status, var origin) = h3.ToLocalIjExperimental(h3);
            Assert.AreEqual(0, status);
            var originIjk = origin.ToIjk();
            for (var d = Direction.K_AXES_DIGIT; d < Direction.INVALID_DIGIT; d++)
            {
                if (d == Direction.K_AXES_DIGIT && h3.IsPentagon())
                {
                    continue;
                }
                const int rotations = 0;
                H3Index offset;
                (offset, _) = h3.NeighborRotations(d, rotations);
                (int result, var ij) = h3.ToLocalIjExperimental(offset);
                Assert.AreEqual(0, result);
                var ijk = ij.ToIjk();
                var invertedIjk = new CoordIjk().Neighbor(d);
                for (int i = 0; i < 3; i++)
                {
                    invertedIjk = invertedIjk.Rotate60CounterClockwise();
                }
                ijk += invertedIjk;
                ijk = ijk.Normalized();
                Assert.AreEqual(originIjk, ijk);
            }
        }
private void H3ToLocalIjNeighborsAssertions ( H3Index h3 ) { ( int status , var origin ) = h3 . ToLocalIjExperimental ( h3 ) ; Assert . AreEqual ( 0 , status ) ; var originIjk = origin . ToIjk ( ) ; for ( var d = Direction . K_AXES_DIGIT ; d < Direction . INVALID_DIGIT ; d ++ ) { if ( d == Direction . K_AXES_DIGIT && h3 . IsPentagon ( ) ) { continue ; } const int rotations = 0 ; H3Index offset ; ( offset , _ ) = h3 . NeighborRotations ( d , rotations ) ; ( int result , var ij ) = h3 . ToLocalIjExperimental ( offset ) ; Assert . AreEqual ( 0 , result ) ; var ijk = ij . ToIjk ( ) ; var invertedIjk = new CoordIjk ( ) . Neighbor ( d ) ; for ( int i = 0 ; i < 3 ; i ++ ) { invertedIjk = invertedIjk . Rotate60CounterClockwise ( ) ; } ijk += invertedIjk ; ijk = ijk . Normalized ( ) ; Assert . AreEqual ( originIjk , ijk ) ; } }
Test the the immediate neighbors of an index are at the expected locations in
the local IJ coordinate space.
Test the the immediate neighbors of an index are at the expected locations in the local IJ coordinate space .
h3
H3Index