Skip to content

Instantly share code, notes, and snippets.

Jaakko Malkki mjaakko

Block or report user

Report or block mjaakko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mjaakko
mjaakko / bbox2geohashes.js
Last active Jul 18, 2018
Converts a bounding box to geohashes
View bbox2geohashes.js
//Converts a bounding box bounded by minLat and maxLat and minLng and maxLng to a list of geohashes (e.g. ["60;24/19/84", "60;24/19/85"]) used for MQTT topic filters
function bbox2geohashes(minLat, minLng, maxLat, maxLng) {
var deltaLat = maxLat - minLat;
var deltaLng = maxLng - minLng;
var geohashLevel = Math.max(Math.ceil(Math.abs(Math.log10(deltaLat))), Math.ceil(Math.abs(Math.log10(deltaLng))));
var delta = Math.pow(10, -geohashLevel);
var geohashes = [];
You can’t perform that action at this time.