package com.sheep.gamegroup.util;

import android.content.Context;
import android.location.Location;

import com.alibaba.fastjson.JSONObject;
import com.baidu.location.BDLocation;
import com.sheep.jiuyan.samllsheep.SheepApp;

/**
 * Created by ljy on 2018/5/11.
 */

public class LocationUtils {

    private static LocationUtils locationUtils;

    public static LocationUtils getInstance(){
        if(locationUtils == null){
            locationUtils = new LocationUtils();
        }
        return locationUtils;
    }

    /**
     * Longitude:经度
     * Latitude:纬度
     * 获取经纬度
     */
    public String getLongitudeLatitude(){
        BDLocation location = SheepApp.getInstance().getCurLocation();
        if(location == null)
            return "";
        return location.getLongitude() + "," +location.getLatitude();
    }
    /**
     * 获取定位
     */
    public JSONObject getLocationJSONObject(){
        BDLocation location = SheepApp.getInstance().getCurLocation();
        JSONObject jsonObject = new JSONObject();
        if(location != null) {
            jsonObject.put("longitude", location.getLongitude());
            jsonObject.put("latitude", location.getLatitude());
            jsonObject.put("addrStr", location.getAddrStr());
        }
        return jsonObject;
    }
}
