Skip to content

Instantly share code, notes, and snippets.

@TobyEalden
Forked from iendjinn/index.js
Last active October 4, 2016 13:46
Show Gist options
  • Save TobyEalden/62a899c6225b2bae5ef68febd5a1cfa1 to your computer and use it in GitHub Desktop.
Save TobyEalden/62a899c6225b2bae5ef68febd5a1cfa1 to your computer and use it in GitHub Desktop.
var topojson = require("topojson");
//var TDXApi = require("nqm-api-tdx");
var fs = require("fs");
function propertyTransform(feature) {
return feature.properties;
}
function databot(input, output, context) {
output.progress(0);
const config = {
commandHost: context.commandHost,
queryHost: context.queryHost,
accessToken: context.authToken
};
const api = context.tdxApi;
api.getDatasetData(input.geojsonFileId, null, null, {limit:50000}, (err, response) => {
if(err) {
output.error("Failed to get data - %s", err.message);
process.exit(1);
}
else {
output.progress(50);
var topology = topojson.topology({collection: response});
topojson.simplify(topology, {quantization: 1e4, simplify: 1e-8, "property-transform": propertyTransform});
fs.writeFile("test.json", JSON.stringify(topology), (err) => {
if(err) {
output.error("Failed to write file - %s", err.message);
process.exit(1);
} else {
output.progress(100);
process.exit(0);
}
});
}
});
}
{
"name": "nqm-geojson-simplifier-bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/IGlautier/nqm-geojson-simplifier-bot.git"
},
"author": "IGlautier",
"license": "ISC",
"bugs": {
"url": "https://github.com/IGlautier/nqm-geojson-simplifier-bot/issues"
},
"homepage": "https://github.com/IGlautier/nqm-geojson-simplifier-bot#readme",
"dependencies": {
"nqm-api-tdx": "^0.1.4",
"topojson": "^1.6.27"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment