Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 1x 1x 1x 6x 6x 6x 6x 6x 89x 1067x 1067x 89x 83x 83x 83x 6x 1x | /** **************************************************************************************************** * File: geohashesWithinBBox.js * Project: geohash * @author Nick Soggin <iSkore@users.noreply.github.com> on 19-Feb-2019 *******************************************************************************************************/ 'use strict'; const getBBoxStartingPoint = require( './getBBoxStartingPoint' ), neighbor = require( './neighbor' ), { ENCODE_AUTO } = require( './variables' ); /** * geohashesWithinBBox * * Return all the geohashes between minLng, minLat, maxLng, maxLat at the specified precision * * @param {number} minLng - bbox min longitude * @param {number} minLat - bbox min latitude * @param {number} maxLng - bbox max longitude * @param {number} maxLat - bbox max latitude * @param {number} [precision=ENCODE_AUTO] - geohash precision * @returns {Array} - geohash array */ function geohashesWithinBBox( minLng, minLat, maxLng, maxLat, precision = ENCODE_AUTO ) { const hashBBox = getBBoxStartingPoint( minLng, minLat, maxLng, maxLat, precision ), hashList = []; const originalHash = hashBBox.hashSouthWest; hashList.push( originalHash ); for ( let lng = 0, lat = 0; lng <= hashBBox.lngStep; lng++ ) { for ( ; lat < hashBBox.latStep; lat++ ) { const northHash = neighbor( hashList[ hashList.length - 1 ], 'n' ); hashList.push( northHash ); } if ( lng + lat !== hashBBox.lngStep + hashBBox.latStep ) { const eastHash = neighbor( hashList[ hashList.length - 1 - lat ], 'e' ); lat = 0; hashList.push( eastHash ); } } return hashList; } module.exports = geohashesWithinBBox; |