Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
Why decoding the MVT using the specification protofile is different from using their python package

I'm decoding some proto buffers of Mapbox. See spec. In Python, I can do this pretty easily with:

import mapbox_vector_tile
mapbox_vector_tile.decode(buffer)

And I get the following JSON:

{
   "default":{
      "extent":4096,
      "version":2,
      "features":[
         {
            "geometry":{
               "type":"Point",
               "coordinates":[
                  1208,
                  2556
               ]
            },
            "properties":{
               "original_address":"11919 Jamaica Ave, Jamaica, NY 11418, EE. UU."
            },
            "id":0,
            "type":1
         },  
      ]
   }
}                      

BUT, if I do the same in Javascript, with the following code:

async function decodeMessage(buffer) {
  const PROTO_FILE = await protobuf.load("vector_tile.proto");
  const testMessage = PROTO_FILE.lookupType("vector_tile.Tile");
  const err = testMessage.verify(buffer);
  if (err) {
    throw err;
  }
  const message = testMessage.decode(buffer);
  return testMessage.toObject(message);
}

Being the vector_tile.proto the file from the specification 2.1 (or the 2.0, it does not matter). I get the following result:

{
    "layers": [
        {
            "name": "default",
            "features": [
                {
                    "tags": [
                        0,
                        0
                    ],
                    "type": 1,
                    "geometry": [
                        9,
                        2416,
                        3080
                    ]
                },
            ],
            "keys": [
                "original_address"
            ],
            "values": [
                {
                    "stringValue": "Haags Kwartier 55, 2491 BM Den Haag, Netherlands"
                }
            ],
            "extent": 4096,
            "version": 2
        }
    ]
}

I do not understand why this difference in the format. I suppose the python package does some additional processing. Is that the case? Is there a way to get the same result on javascript?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda