lib/query-builder.js
function heatmap() {
  var args = mlutil.asArray.apply(null, arguments);
  var argLen = args.length;
  if (argLen < 1) {
    throw new Error('no region or divisions for heat map');
  }

  var hmap = {};
  switch(argLen) {
  case 3:
    var first  = args[0];
    var second = args[1];
    var third  = args[2];
    var region = null;
    if (typeof first === 'object' && first !== null) {
      region = first;
      hmap.latdivs = second;
      hmap.londivs = third;
    } else if (typeof third === 'object' && third !== null) {
      region = third;
      hmap.latdivs = first;
      hmap.londivs = second;
    } else {
      throw new Error('no first or last region for heat map');
    }

    var keys = ['s', 'w', 'n', 'e'];
    for (var i=0; i < keys.length; i++) {
      var key   = keys[i];
      var value = region[key];
      if (value != null) {
        hmap[key] = value;
        continue;
      } else {
        var altKey = null;
        switch(key) {
        case 's':
          altKey = 'south';
          break;
        case 'w':
          altKey = 'west';
          break;
        case 'n':
          altKey = 'north';
          break;
        case 'e':
          altKey = 'east';
          break;
        }
        value = (altKey !== null) ? region[altKey] : null;
        if (value != null) {
          hmap[key] = value;
          continue;
        }
      }
      throw new Error('heat map does not have '+key+' key');
    }
    break;
  case 6:
    hmap.latdivs = args[0];
    hmap.londivs = args[1];
    hmap.s = args[2];
    hmap.w = args[3];
    hmap.n = args[4];
    hmap.e = args[5];
    break;
  default:
    throw new Error('could not assign parameters to heat map');
  }

  return {'heatmap': hmap};
}
function heatmap() {
  var args = mlutil.asArray.apply(null, arguments);
  var argLen = args.length;
  if (argLen < 1) {
    throw new Error('no region or divisions for heat map');
  }

  var hmap = {};
  switch(argLen) {
  case 3:
    var first  = args[0];
    var second = args[1];
    var third  = args[2];
    var region = null;
    if (typeof first === 'object' && first !== null) {
      region = first;
      hmap.latdivs = second;
      hmap.londivs = third;
    } else if (typeof third === 'object' && third !== null) {
      region = third;
      hmap.latdivs = first;
      hmap.londivs = second;
    } else {
      throw new Error('no first or last region for heat map');
    }

    var keys = ['s', 'w', 'n', 'e'];
    for (var i=0; i < keys.length; i++) {
      var key   = keys[i];
      var value = region[key];
      if (value != null) {
        hmap[key] = value;
        continue;
      } else {
        var altKey = null;
        switch(key) {
        case 's':
          altKey = 'south';
          break;
        case 'w':
          altKey = 'west';
          break;
        case 'n':
          altKey = 'north';
          break;
        case 'e':
          altKey = 'east';
          break;
        }
        value = (altKey !== null) ? region[altKey] : null;
        if (value != null) {
          hmap[key] = value;
          continue;
        }
      }
      throw new Error('heat map does not have '+key+' key');
    }
    break;
  case 6:
    hmap.latdivs = args[0];
    hmap.londivs = args[1];
    hmap.s = args[2];
    hmap.w = args[3];
    hmap.n = args[4];
    hmap.e = args[5];
    break;
  default:
    throw new Error('could not assign parameters to heat map');
  }

  return {'heatmap': hmap};
}
function heatmap ( ) { var args = mlutil . asArray . apply ( null , arguments ) ; var argLen = args . length ; if ( argLen < 1 ) { throw new Error ( 'no region or divisions for heat map' ) ; } var hmap = { } ; switch ( argLen ) { case 3 : var first = args [ 0 ] ; var second = args [ 1 ] ; var third = args [ 2 ] ; var region = null ; if ( typeof first === 'object' && first !== null ) { region = first ; hmap . latdivs = second ; hmap . londivs = third ; } else if ( typeof third === 'object' && third !== null ) { region = third ; hmap . latdivs = first ; hmap . londivs = second ; } else { throw new Error ( 'no first or last region for heat map' ) ; } var keys = [ 's' , 'w' , 'n' , 'e' ] ; for ( var i = 0 ; i < keys . length ; i ++ ) { var key = keys [ i ] ; var value = region [ key ] ; if ( value != null ) { hmap [ key ] = value ; continue ; } else { var altKey = null ; switch ( key ) { case 's' : altKey = 'south' ; break ; case 'w' : altKey = 'west' ; break ; case 'n' : altKey = 'north' ; break ; case 'e' : altKey = 'east' ; break ; } value = ( altKey !== null ) ? region [ altKey ] : null ; if ( value != null ) { hmap [ key ] = value ; continue ; } } throw new Error ( 'heat map does not have ' + key + ' key' ) ; } break ; case 6 : hmap . latdivs = args [ 0 ] ; hmap . londivs = args [ 1 ] ; hmap . s = args [ 2 ] ; hmap . w = args [ 3 ] ; hmap . n = args [ 4 ] ; hmap . e = args [ 5 ] ; break ; default : throw new Error ( 'could not assign parameters to heat map' ) ; } return { 'heatmap' : hmap } ; }
Specifies the buckets for a geospatial facet.
@typedef {object} queryBuilder.HeatMapParam
@since 1.0
 
Divides a geospatial box into a two-dimensional grid for calculating facets
based on document counts for each cell within the grid.
The coordinates of the box can be specified either by passing the return value
from the {@link queryBuilder#southWestNorthEast} function or as a list
of {queryBuilder.LatLon} coordinates in South, West, North, and East order.
@method
@since 1.0
@memberof queryBuilder#
@param {number} latdivs - the number of latitude divisions in the grid
@param {number} londivs - the number of longitude divisions in the grid
@param {queryBuilder.LatLon} south - the south coordinate of the box
@param {queryBuilder.LatLon} west - the west coordinate for the box
@param {queryBuilder.LatLon} north - the north coordinate for the box
@param {queryBuilder.LatLon} east - the east coordinate for the box
@returns {queryBuilder.HeatMapParam} the buckets for a geospatial facet
Specifies the buckets for a geospatial facet .