예제 #1
0
        /// <summary>
        /// Returns the destination hexagon from the unidirectional edge H3Index
        /// </summary>
        /// <param name="edge">The edge H3 index</param>
        /// <returns>The destination H3 hexagon index</returns>
        /// <!-- Based off 3.1.1 -->
        public static H3Index getDestinationH3IndexFromUnidirectionalEdge(H3Index edge)
        {
            if (H3Index.H3_GET_MODE(ref edge) != Constants.H3_UNIEDGE_MODE)
            {
                return(H3Index.H3_INVALID_INDEX);
            }
            Direction direction   = (Direction)H3Index.H3_GET_RESERVED_BITS(edge);
            int       rotations   = 0;
            H3Index   destination = Algos
                                    .h3NeighborRotations
                                    (
                getOriginH3IndexFromUnidirectionalEdge(edge),
                direction,
                ref rotations
                                    );

            return(destination);
        }
예제 #2
0
        /// <summary>
        /// Determines if the provided H3Index is a valid unidirectional edge index
        /// </summary>
        /// <param name="edge">The unidirectional edge H3Index</param>
        /// <returns>1 if it is a unidirectional edge H3Index, otherwise 0.</returns>
        /// <!-- Based off 3.1.1 -->
        public static int h3UnidirectionalEdgeIsValid(H3Index edge)
        {
            if (H3Index.H3_GET_MODE(ref edge) != Constants.H3_UNIEDGE_MODE)
            {
                return(0);
            }

            Direction neighborDirection = (Direction)H3Index.H3_GET_RESERVED_BITS(edge);

            if (neighborDirection <= Direction.CENTER_DIGIT ||
                neighborDirection >= Direction.NUM_DIGITS)
            {
                return(0);
            }

            H3Index origin = getOriginH3IndexFromUnidirectionalEdge(edge);

            if (H3Index.h3IsPentagon(origin) != 0 && neighborDirection == Direction.K_AXES_DIGIT)
            {
                return(0);
            }

            return(H3Index.h3IsValid(origin));
        }