JuliaIO / ProtoBuf.jl

Julia protobuf implementation
Other
205 stars 55 forks source link

Decoding protobuf message from mapbox API #198

Closed captchanjack closed 2 years ago

captchanjack commented 2 years ago

Hi,

I'm new to the world of protocol buffers, looking for some guidance here.

I have a fairly simple use case which is to decode protobuf messages from the mapbox API into GeoJSON format.

How would I approach this problem? Would I need to define a custom Julia struct according to this mapbox pbf specification? Or is there a simpler, more generic way of decoding the protobuf message into a Dict of some sort.

Essentially I would like to replicate what this python library is doing!

Thanks in advance...

Drvi commented 2 years ago

Hi!

You'd have to

  1. find the .proto files that define the messages you want to decode. (Maybe it's just this one?)
  2. call protojl on them (see the docstring for more info)
  3. include the generated julia code
  4. call decode(ProtoDecoder(io_you_want_to_decode), TheGeneratedStructYouExpectToGetFromIO)

Basically what the example in the README does. Note that there is a new, breaking version of ProtoBuf.jl now.

At that point you should have your data in memory as Julia structs and you'd need to use a different package to translate them to GeoJSON format, possibly this one https://github.com/JuliaGeo/GeoJSON.jl.

Closing for now, but do reach out if you feel like the new docs could've been clearer on some of the above.