Get Pixel Precision - Node.js Environment

Node.js examples for Environment:Screen

Description

Get Pixel Precision

Demo Code



/**/*w w w  .ja v a  2  s.  co m*/
 * @param {Array.<number>} dataExtent
 * @param {Array.<number>} pixelExtent
 * @return {number}  precision
 */
number.getPixelPrecision = function (dataExtent, pixelExtent) {
    var log = Math.log;
    var LN10 = Math.LN10;
    var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
    var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
    return Math.max(
        -dataQuantity + sizeQuantity,
        0
    );
};

Related Tutorials