/// <summary> /// Returns two dimensional coordinates for the given index /// </summary> public static int ExperimentalH3ToLocalIj( H3Index origin, H3Index h3, out CoordIj outCoord ) { int status; (status, outCoord) = origin.ToLocalIjExperimental(h3); return(status); }
public void ExperimentalH3ToLocalIjFailed() { var(status, ij) = bc1.ToLocalIjExperimental(bc1); Assert.AreEqual(0, status); Assert.IsTrue(ij.I == 0 && ij.J == 0); (status, ij) = bc1.ToLocalIjExperimental(pent1); Assert.AreEqual(0, status); Assert.IsTrue(ij.I == 1 && ij.J == 0); (status, ij) = bc1.ToLocalIjExperimental(bc2); Assert.AreEqual(0, status); Assert.IsTrue(ij.I == 0 && ij.J == -1); (status, ij) = bc1.ToLocalIjExperimental(bc3); Assert.AreEqual(0, status); Assert.IsTrue(ij.I == -1 && ij.J == 0); (status, ij) = pent1.ToLocalIjExperimental(bc3); Assert.AreNotEqual(0, status); }
public void OnOffPentagonSame() { // Test that coming from the same direction outside the pentagon is handled // the same as coming from the same direction inside the pentagon. for (var bc = 0; bc < Constants.H3.NUM_BASE_CELLS; bc++) { for (var res = 1; res <= Constants.H3.MAX_H3_RES; res++) { // K_AXES_DIGIT is the first internal direction, and it's also // invalid for pentagons, so skip to next. var startDir = Direction.K_AXES_DIGIT; if (bc.IsBaseCellPentagon()) { startDir++; } for (var dir = startDir; dir < Direction.NUM_DIGITS; dir++) { var internalOrigin = new H3Index(res, bc, dir); var externalOrigin = new H3Index(res, bc.GetNeighbor(dir), Direction.CENTER_DIGIT); for (var testDir = startDir; testDir < Direction.NUM_DIGITS; testDir++) { var testIndex = new H3Index(res, bc, testDir); (int internalIjFailed, var internalIj) = internalOrigin.ToLocalIjExperimental(testIndex); (int externalIjFailed, var externalIj) = externalOrigin.ToLocalIjExperimental(testIndex); Assert.AreEqual(externalIjFailed != 0, internalIjFailed != 0); if (internalIjFailed != 0) { continue; } (int internalIjFailed2, var internalIndex) = internalIj.ToH3Experimental(internalOrigin); (int externalIjFailed2, var externalIndex) = externalIj.ToH3Experimental(externalOrigin); Assert.AreEqual(externalIjFailed2 != 0, internalIjFailed2 != 0); if (internalIjFailed2 != 0) { continue; } Assert.AreEqual(externalIndex, internalIndex); } } } } }