
// 新建GUID
const newGUID = () => {
    let d = new Date().getTime();
    let uid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
        let r = (d + Math.random() * 16) % 16 | 0;
        d = Math.floor(d / 16);
        return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
    });
    return uid;
}

const copy = (obj) => {
    return JSON.parse(JSON.stringify(obj));
}

const getGeoJson = (name, dataName) => {
    const dataDefault = require('@/helper/data.js');
    const dataService = dataDefault.default;
    const region = dataService.get(dataName);
    return {
        type: "Feature",
        geometry: {
            type: "MultiPolygon",
            coordinates: region
        },
        properties: {
            name: name
        }
    }
}


// px to vh
const vh = function (px) {
    return window.innerHeight * px / 1080;
}

export default {
    newGUID,
    copy,
    getGeoJson,
    vh
}
