bertt / mapbox-vector-tile-cs

A .NET library for decoding a Mapbox vector tile
MIT License
74 stars 14 forks source link

Mapbox-vector-tile does not support MemoryStream #27

Closed ScriptHound closed 9 months ago

ScriptHound commented 9 months ago

The case is:

Im trying to read .pbf files from Rosreestr and in case where I want to transform them into MemoryStream and pass to mapbox-tile-server the library doesnt parse it.

Example file 1195.pbf.zip

This example works totally fine

namespace test_mapbox;
using GeoJSON.Net.Feature;

using Mapbox.Vector.Tile;

class Program
{
    static void Main(string[] args)
    {
        using (var stream = File.OpenRead("test.pbf"))
        {
            var tile = VectorTileParser.Parse(stream);
            foreach (var layer in tile)
            {
                Console.WriteLine(layer.Name);
            }            
        }
    }
}

But when I try to:

var pbfFile = response.ResponseBinary;
var stream = new MemoryStream();
stream.Write(pbfFile, 0, pbfFile.Length);
var layers = VectorTileParser.Parse(stream); // This one returns zero length sequence

You can try download the file by yourself using this link https://pkk.rosreestr.ru/arcgis/rest/services/Hosted/caddivsion/VectorTileServer/tile/12/1190/2392.pbf but VPN within Russia is needed to access it

bertt commented 9 months ago

maybe it's gzip?

https://github.com/bertt/mapbox-vector-tile-cs/blob/master/tests/mapbox.vector.tile.tests/TileParserTests.cs#L88

ScriptHound commented 9 months ago

oh, thank you. Indeed my http client uses compression. Im going to check for it tomorrow

ScriptHound commented 9 months ago

Thank you again, it worked