Advertisement
Guest User

Untitled

a guest
Sep 6th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. db.pre('w', function (ch, add) {
  2.   for (i = 0; i < ch.value.nd.length; i++ ) {
  3.     db.get('n' + ch.value.nd[i].$.ref, function (err, value) {
  4.       if (err) return
  5.       var val = JSON.parse(value);
  6.       var coord = {
  7.         lat: parseFloat(val.$.lat),
  8.         lon: parseFloat(val.$.lon)
  9.       };
  10.       var precision = 16;
  11.       var qtree = quadtree.encode(coord, precision);
  12.       // Index tiles down to zoom level 16
  13.       if (ch.key.match(/w/)) console.log(ch.key);
  14.       add({
  15.         key: ''+qtree+'~'+ch.key,
  16.         value: ch.value,
  17.         type: 'put',
  18.         prefix: qt,
  19.         valueEncoding: 'json'
  20.       });
  21.     });
  22.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement