Geojson to Topojson in node.js

Viewed 1404

I have a shape file in my postGIS database.I have retrieved that into geojson in node.js by using the following code.

var moisql = 'SELECT *, (ST_AsGeoJSON(geom))  from xxx;'

Works fine..But my requirement is i have to convert this geojson file into "TOPOJSON".

SO i have this code:

topojsonOutput = topojson.topology({'collection': geojsonString});

But still i am retrieving geojson file as output..SO please guide me to achieve this..Thanks in advance.

Also when i googled i got this code:

var collection = {type: "FeatureCollection", features: […]}; // GeoJSON
var topology = topojson.topology({collection: collection}); // convert to TopoJSON
console.log(topology.objects.collection); // inspect TopoJSON  

But totally i can't understand this..What i have to give in place of features[..] and collections..

2 Answers
Related