All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.graphhopper.maps.js.tools.math.js Maven / Gradle / Ivy

There is a newer version: 10.0
Show newest version
module.exports.getCenter = function (bounds) {
    var center = {
        lat: 0,
        lng: 0
    };
    if (bounds.initialized) {
        center.lat = (bounds.minLat + bounds.maxLat) / 2;
        center.lng = (bounds.minLon + bounds.maxLon) / 2;
    }
    return center;
};

module.exports.floor = function (val, precision) {
    if (!precision)
        precision = 1e6;
    return Math.floor(val * precision) / precision;
};

module.exports.round = function (val, precision) {
    if (precision === undefined)
        precision = 1e6;
    return Math.round(val * precision) / precision;
};






© 2015 - 2024 Weber Informatics LLC | Privacy Policy