Last active
April 1, 2021 10:07
-
-
Save zmofei/36b74a17199a34496685e04758eeb1c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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