Last active
June 26, 2017 22:15
-
-
Save hackergrrl/100fcac53b433f89fecdc9916d87acd3 to your computer and use it in GitHub Desktop.
Convert a version ID to an OSM document (osm-p2p-db)
This file contains hidden or 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
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