Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我自己又写了 打卡位置浮动的方法。希望也添加这个功能上去 #20

Open
lalblc opened this issue Dec 28, 2022 · 1 comment

Comments

@lalblc
Copy link

lalblc commented Dec 28, 2022

// 使经纬度值偏移
function skew($a){
    $num = floatval ($a);
    $num += floatval('0.00000'.rand(0,9)); // 添加随机数
    $str = strval($num); 


    // 设置为小数点6位
    $dian = explode('.',$str)[1];
    $len = 6-strlen($dian);
    if(0 != $len){
        if(0 > $len){
            // 去除多余的小数
            $str = str_split($str,strlen($str)+$len)[0];
        }else{
            // 精度不够,在后面用 0 补位
            $str .= implode("0",array_pad([],$len+1,''));
            
        }
    }

    return $str;
}

// 微调经纬度
$longitude = skew(env('MOGUDING_LONGITUDE', ''));
$latitude = skew(env('MOGUDING_LATITUDE', ''));
@openai8
Copy link

openai8 commented Oct 24, 2023

为什么要浮动,请问现在代码还可以用吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants