Skip to content

Instantly share code, notes, and snippets.

@zmofei
Last active April 1, 2021 10:07
Show Gist options
  • Save zmofei/36b74a17199a34496685e04758eeb1c6 to your computer and use it in GitHub Desktop.
Save zmofei/36b74a17199a34496685e04758eeb1c6 to your computer and use it in GitHub Desktop.
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
crlfDelay: Infinity
});
const dt = '2021-04-01';
let sequentialId = +new Date(dt);
let ct = 0;
rl.on('line', line => {
sequentialId++;
let feature;
try {
feature = JSON.parse(line);
process.stdout.write(
JSON.stringify({
id: sequentialId,
tags: {
"source": "ne",
"landuse": "residential",
},
"geojson": JSON.stringify(feature.geometry),
dt,
osmium_id: sequentialId,
type: 'way',
changeset: sequentialId,
timestamp: '2021-04-01 00:00:00',
version: 0
}) + '\n'
);
ct++;
} catch (error) {
console.error(error);
console.error(schema);
console.error(
feature && feature.properties && feature.properties.elcode
? feature.properties.elcode
: '<no elcode>'
);
console.error('\n');
}
});
rl.on('close', () => {
console.error(`Transformed ${ct} features`);
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment