1

I want to convert the data in pbf format obtained by ajax into osm format (xml) data in the browser.

Try using the pbf library of mapbox, but it didn't work. I'm not sure if there is a problem with my usage.

I tried to use the pbf library of mapbox, but I don't quite understand how its api is called. In the end, I didn't convert the obtained binary format data into osm format data.

xhr.onreadystatechange = function (e) {
    if (xhr.readyState == 4 && xhr.status == 200) {
        console.log("ok");

        var pbf = new Pbf(new Uint8Array(xhr.response));

        let i = 0,
            len = pbf.length;
        while (pbf.pos < len) {
            console.log(pbf.pos);
            console.log(pbf.readString());
        }
    }
};

If someone has good suggestions or methods, I hope I can exchange them.

more than
  • 11
  • 3
  • 4
    What have you tried so far and what specific issues are you getting? – I.T Delinquent Jul 01 '19 at 12:39
  • 2
    Please [edit] the code you have tried into your question – Matt Ellen Jul 01 '19 at 12:46
  • 2
    If I understand correctly https://github.com/mapbox/pbf is not meant for converting OSM PBF to OSM XML or vice versa. It is for reading/writing PBF. It is not clear why you want to process PBF in your browser. Your approach sounds wrong. What is your goal? – scai Jul 02 '19 at 10:18
  • My web map uses osm format data to draw the map. I hope to use the pbf format data to transfer between the browser and the server. – more than Jul 03 '19 at 01:49

0 Answers0