mapbox / geobuf

A compact binary encoding for geographic data.
ISC License
967 stars 84 forks source link

Properties are being removed from FeatureCollection #102

Open mrisney opened 5 years ago

mrisney commented 5 years ago

I have created a .pbf file, but when I decode it, all the properties are removed from each feature. I used the Getools geobuf libraries to do this, encoded and decoded successfully, I am gzipping the outputsream,

File file = new File("/Projects/geobufs/test.pbf"); GeobufFeatureCollection geobufFeatureCollection = new GeobufFeatureCollection();

    InputStream inputStream = new FileInputStream(file);
    SimpleFeatureCollection decodedFeatureCollection = geobufFeatureCollection.decode(inputStream);
    inputStream.close();

    FeatureJSON fjson = new FeatureJSON(new GeometryJSON(DECIMALS));
    StringWriter writer = new StringWriter();
    fjson.writeFeatureCollection(decodedFeatureCollection, writer);
    String geoJSON = writer.toString();
    logger.info(geoJSON);

I download the file

var geobuffURL = "http://localhost:8080/geobuffer/test.pbf";

       var oReq = new XMLHttpRequest();
       oReq.open("GET", geobuffURL, true);
       oReq.responseType = "arraybuffer";
       oReq.onload = function(oEvent) {
            var data = new Pbf(new Uint8Array(oReq.response))
            console.log(data)
            var geoJSON = geobuf.decode(data);

            console.log(JSON.stringify(geoJSON));
            //var layer = L.geoJson( geobuf.decode(data)).addTo(map);
        }
        oReq.send();

and it strips the properties from the geoJSON.

I am attaching both the geojson, and the pbf I encoded.

test.files.zip

avatarneil commented 1 year ago

I'm running into this issue as well. Happy to take a look and pop open a PR if the maintainers would like!