All files / geonet-geohash/src geohashesWithinBBoxToGeoJSON.js

100% Statements 5/5
100% Branches 1/1
100% Functions 1/1
100% Lines 5/5

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                1x 1x 1x                               3x           1x  
/** ****************************************************************************************************
 * File: geohashesWithinBBoxToGeoJSON.js
 * Project: geohash
 * @author Nick Soggin <iSkore@users.noreply.github.com> on 19-Feb-2019
 *******************************************************************************************************/
'use strict';
 
const
	geohashesWithinBBox = require( './geohashesWithinBBox' ),
	toGeoJSON           = require( './toGeoJSON' ),
	{ ENCODE_AUTO }     = require( './variables' );
 
/**
 * geohashesWithinBBoxToGeoJSON
 *
 * Return GeoJSON FeatureCollection of all 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 {{features: any[], type: string}}
 * GeoJSON of geohashes within a bbox
 */
function geohashesWithinBBoxToGeoJSON( minLng, minLat, maxLng, maxLat, precision = ENCODE_AUTO ) {
	return {
		type: 'FeatureCollection',
		features: geohashesWithinBBox( minLng, minLat, maxLng, maxLat, precision ).map( toGeoJSON )
	};
}
 
module.exports = geohashesWithinBBoxToGeoJSON;