public void NegativeCoordinateShouldThrowAnExceptionOnPositiveHilbertGrid()
        {
            HilbertEncoder encoder = new HilbertEncoder(false, false);

            Should.Throw <ArgumentException>(() => encoder.Encode(new Coordinate(-1, 1)));
            Should.Throw <ArgumentException>(() => encoder.Encode(new Coordinate(1, -1)));
            Should.Throw <ArgumentException>(() => encoder.Encode(new Coordinate(-1, -1)));
        }
        public void EncodeInteger2DNegativePointOnHilbertCurveTest()
        {
            HilbertEncoder encoder = new HilbertEncoder(false, true);

            // correct for offset to search for zero point on the grid
            UInt32     correction = UInt32.MaxValue / 2;
            Coordinate zeroPointOnNegativeGrid = new Coordinate(-correction, -correction);
            BigInteger hilbertCode             = encoder.Encode(zeroPointOnNegativeGrid);

            hilbertCode.ShouldBe(new BigInteger(0));
        }
        public void EncodeFractional2DPositivePointOnHilbertCurveTest()
        {
            HilbertEncoder encoder = new HilbertEncoder(false, false);

            BigInteger hilbertCode = encoder.Encode(new Coordinate(0.1D, 0.1D));

            hilbertCode.ShouldBe(new BigInteger(0));

            hilbertCode = encoder.Encode(new Coordinate(0.8D, 0D));
            hilbertCode.ShouldBe(new BigInteger(1));

            hilbertCode = encoder.Encode(new Coordinate(0.5D, 0D));
            hilbertCode.ShouldBe(new BigInteger(0));

            hilbertCode = encoder.Encode(new Coordinate(0, 0.8D));
            hilbertCode.ShouldBe(new BigInteger(3));
        }
        public void EncodeInteger3DPositivePointOnHilbertCurveTest()
        {
            HilbertEncoder encoder = new HilbertEncoder(true, false);

            BigInteger hilbertCode = encoder.Encode(new Coordinate(0, 0, 0));

            hilbertCode.ShouldBe(new BigInteger(0));

            hilbertCode = encoder.Encode(new Coordinate(1, 0, 0));
            hilbertCode.ShouldBe(new BigInteger(1));

            hilbertCode = encoder.Encode(new Coordinate(0, 1, 0));
            hilbertCode.ShouldBe(new BigInteger(7));

            hilbertCode = encoder.Encode(new Coordinate(0, 0, 1));
            hilbertCode.ShouldBe(new BigInteger(3));

            hilbertCode = encoder.Encode(new Coordinate(5, 5, 5));
            hilbertCode.ShouldBe(new BigInteger(359));
        }