tobinbradley/dirt-simple-postgis-http-api

GoeBuf feature

Closed this issue · 3 comments

Hi,

Any plans for adding Geobuf (lossless) feature !,

Geobuf provides nearly lossless compression of GeoJSON data into protocol buffers. Advantages over using GeoJSON alone:
as mentioned in :
https://github.com/mapbox/geobuf

as I know there is a function in PostGIS : ST_AsGeobuf
https://postgis.net/docs/ST_AsGeobuf.html

I hope if it can be added in future release as a route

Thanks

The "Note that the encoding schema is not stable yet — it may still change as we get community feedback and discover new ways to improve it." in the Geobuf README bit is a little worrying. But it seems simple enough to add.

Will do. It shouldn't take very long.

It's done. It's pretty obscure - to even test it requires several libraries:

const geobuf = require("geobuf")
const Pbf = require("pbf")
const fs = require("fs")

var request = require('request').defaults({ encoding: null });
request.get("http://localhost:3001/v1/geobuf/annexations?geom_column=geometry&columns=munic_name,year", function (err, res, body) {
      //process exif here
    var geojson = geobuf.decode(new Pbf(body))
    console.log(geojson)

    fs.writeFile("output.json", JSON.stringify(geojson), 'utf8', function (err) {
      if (err) {
        console.log("An error occured while writing JSON Object to File.");
        return console.log(err);
      }

      console.log("JSON file has been saved.");
    });

});

Works though. I can pull up the converted GeoJSON file in QGIS.

It works like a charm.

Thanks for your awesome work.