Esempio n. 1
0
        public float ReadBitCoordMP(BitCoordType coordType)
        {
            int sign;

            var integral = coordType == BitCoordType.Integral;
            var lowPrec  = coordType == BitCoordType.LowPrecision;

            var inBounds = ReadOneBit();

            if (integral)
            {
                if (!ReadOneBit())
                {
                    return(0f);
                }

                sign = ReadOneBit() ? -1 : 1;
                return(sign * ReadUBitLong(inBounds ? CoordIntegerBitsMP : CoordIntegerBits) + 1f);
            }

            var hasInt = ReadOneBit();

            sign = ReadOneBit() ? -1 : 1;

            var intVal = 0;

            if (hasInt)
            {
                intVal = (int)ReadUBitLong(inBounds ? CoordIntegerBitsMP : CoordIntegerBits) + 1;
            }

            var fractVal = ReadUBitLong(lowPrec ? CoordFractionalBitsLowPrecision : CoordFractionalBits);

            return(sign * (intVal + fractVal * (lowPrec ? CoordResolutionLowPrecision : CoordResolution)));
        }
Esempio n. 2
0
        public float ReadBitCellCoord(int bits, BitCoordType coordType)
        {
            var integral = coordType == BitCoordType.Integral;
            var lowPrec  = coordType == BitCoordType.LowPrecision;

            if (integral)
            {
                return(ReadUBitLong(bits));
            }

            var intVal   = ReadUBitLong(bits);
            var fractVal = ReadUBitLong(lowPrec ? CoordFractionalBitsLowPrecision : CoordFractionalBits);

            return(intVal + (fractVal * (lowPrec ? CoordResolutionLowPrecision : CoordResolution)));
        }