Skip to content

Instantly share code, notes, and snippets.

@bingomanatee
Created August 21, 2011 17:53
Show Gist options
  • Save bingomanatee/1160915 to your computer and use it in GitHub Desktop.
Save bingomanatee/1160915 to your computer and use it in GitHub Desktop.
Updating a series of tiles
/**
* scale = 128
* i_limit = c.5600
* j_limit = c.11000
*/
for (var i = 0; i < i_limit; i += scale)
for (var j = 0; j < j_limit; j += scale) {
// if (i > i_limit) continue;
// if (j > j_limit) continue;
var heights = _chunk(image_data, i, i + scale, j, j + scale);
// _chunk produces a 128 x 128 set of ints (nested arrays, 128 128-value arrays
var query = {min_image_i: i, min_image_j: j, image: image._id};
var set_heights = {"$set": {heights: heights}};
mit_model.update(query, _stub, set_heights);
// note my model's update profile is slightly rearranged - update(filter, callback, document)
}
callback();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment