Skip to content

Instantly share code, notes, and snippets.

@hackergrrl
Last active June 26, 2017 22:15
Show Gist options
  • Save hackergrrl/100fcac53b433f89fecdc9916d87acd3 to your computer and use it in GitHub Desktop.
Save hackergrrl/100fcac53b433f89fecdc9916d87acd3 to your computer and use it in GitHub Desktop.
Convert a version ID to an OSM document (osm-p2p-db)
function getOsmDocFromVersionId (osmdb, version, done) {
osmdb.get(version, function (err, node) {
if (err) done(err)
else done(null, getOsmDocFromHyperlogNode(node))
})
}
function getOsmDocFromHyperlogNode (node) {
if (node.value && node.v) return node.value.v // Returns the OSM document (has 'type', 'lat', 'lon', etc)
if (node.value && node.d) return null // This document is a deletion marker for an older document
else return null // Shouldn't happen; malformed or unrelated data in the DB
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment