package com.template.common.utils;

import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;
import java.util.*;

public class RandomTrackAlgorithm {

    public static BigDecimal makeRandom(float max, float min, int scale){
        BigDecimal cha = new BigDecimal(Math.random() * (max-min) + min);
        return cha.setScale(scale,BigDecimal.ROUND_HALF_UP);//保留 scale 位小数，并四舍五入
    }

    public static List<List<BigDecimal>> getPosition(){
        List<List<BigDecimal>> all = new ArrayList<>();
        // 生成随机坐标点
        BigDecimal x = null;
        BigDecimal y = null;
        for (int i = 0; i < 10; i++) {
            List<BigDecimal> list = new LinkedList<>();
            // 114.449557,28.109357
            x = makeRandom(0.001f,0.000001f,6).add(BigDecimal.valueOf(114.449557));
            y = makeRandom(0.001f,0.000001f,6).add(BigDecimal.valueOf(28.109357));
            list.add(x);
            list.add(y);
            all.add(list);
        }
        return all;
    }

}
