Artoria2e5 / PRCoords

Public Domain library for rectifying Chinese coordinates
https://artoria2e5.github.io/PRCoords/demo.html
GNU General Public License v3.0
151 stars 23 forks source link

"max, abs" can not call the method directly #4

Closed barrer closed 6 years ago

barrer commented 6 years ago

chrome version: 63.0 *It should be '`Math.`'.**

// generic "bored function" factory, Caijun 2014
// gcj: 4 calls to wgs_gcj; ~0.1mm acc
function __bored__(fwd, rev) {
    return function rev_bored(heck, checkChina = true) {
        var curr = rev(heck, checkChina)
        var prev = heck
        var diff = {lat: Infinity, lon: Infinity}

        // Wait till we hit fixed point or get bored
        var i = 0
        while (max(abs(diff.lat), abs(diff.lon)) > PRC_EPS && i++ < 10) {
            diff = _coord_diff(fwd(curr, checkChina), heck)
            prev = curr
            curr = _coord_diff(curr, diff)
        }

        return curr
    }
}
Artoria2e5 commented 6 years ago

Good catch. I was copying from the Mini PDF implementation which imported those things from Math

Should be fixed now.