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
//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 = []; | |