コード例 #1
0
        public static async Task <Blob> ReadBlobAsync(PbfBlobParser parser)
        {
            var blobHeader = await parser.ReadBlobHeader();

            Blob blob = null;

            if (blobHeader != null)
            {
                blob = await parser.ReadBlobDataAsync(blobHeader);
            }

            return(blob);
        }
コード例 #2
0
        public static async Task Process(string fileName, string indexFileName)
        {
            var index = BlobIdsInfo.ReadIdsIndex(indexFileName).ToList();

            Console.WriteLine($"Index size: {index.Count}");

            using (var stream = File.OpenRead(fileName))
            {
                foreach (var info in index.Where(x => x.WaysCount > 0).Take(5))
                {
                    stream.Position = 0;
                    var parser = new PbfBlobParser(stream);
                    parser.SkipBlob((ulong)(info.StartPosition - 4));
                    var header = await parser.ReadBlobHeader();

                    var blob = await parser.ReadBlobAsync(header);

                    var primitiveReader = PbfPrimitiveReader.Create(blob);
                    var data            = primitiveReader.ReadData();

                    var ways = PrimitiveDecoder.DecodeWays(data).ToList();

                    Console.WriteLine();

                    foreach (var way in ways)
                    {
                        var nodeIds = way.NodeIds.Distinct().OrderBy(x => x).ToList();

                        var blobsToRead = FindBlobIdsToRead(index, nodeIds);

                        Console.WriteLine($"Id: {way.Id}, Cnt: {blobsToRead.Count}. {string.Join(", ",blobsToRead)}");
                    }
                }
            }

            Console.WriteLine("Done! Press any key....");
            Console.ReadKey();
        }