public void Test()
        {
            var stream  = new MemoryStream();
            var breader = new BinaryReader(stream, Encoding.UTF8, true);
            var bwriter = new BinaryWriter(stream, Encoding.UTF8, true);

            var writer = new DeltaWriter(bwriter);
            var reader = new DeltaReader(breader);

            writer.WriteZigZag(10);
            writer.WriteZigZag(15);
            writer.WriteZigZag(7);
            writer.WriteZigZag(12);
            writer.WriteZigZag(1);

            bwriter.Flush();

            stream.Position = 0;

            reader.ReadZigZag().Should().Be(10);
            reader.ReadZigZag().Should().Be(15);
            reader.ReadZigZag().Should().Be(7);
            reader.ReadZigZag().Should().Be(12);
            reader.ReadZigZag().Should().Be(1);
        }
        private SWay[] ReadAllWays()
        {
            var split = reader.ReadByte();

            if (split != 0)
            {
                throw new InvalidOperationException("Not all ways were read.");
            }

            wayIdReader.Reset();
            wayNodeIdReader.Reset();
            wayLatReader.Reset();
            wayLonReader.Reset();

            var allWays = new SWay[waysCount];

            for (var i = 0; i < allWays.Length; i++)
            {
                var id    = wayIdReader.ReadZigZag();
                var type  = (int)reader.Read7BitEncodedInt();
                var count = (int)reader.Read7BitEncodedInt();

                wayLatReader.Reset();
                wayLonReader.Reset();

                var nodes = new List <WayNode>(count);
                for (var j = 0; j < count; j++)
                {
                    var nodeId = (ulong)wayNodeIdReader.ReadZigZag();
                    var lat    = (int)wayLatReader.ReadZigZag();
                    var lon    = (int)wayLonReader.ReadZigZag();

                    nodes.Add(new WayNode(
                                  nodeId,
                                  lat,
                                  lon
                                  ));
                }

                var way = new SWay
                {
                    Id      = id,
                    WayType = type,
                    Nodes   = nodes
                };

                allWays[i] = way;
            }

            return(allWays);
        }