|
|
@@ -4,11 +4,13 @@ import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.fdkankan.manage.vo.response.AddressComponent;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
+@Slf4j
|
|
|
public class TianDiTuReverseUtil {
|
|
|
|
|
|
public static JSONObject reverseGeo(String lon, String lat,String api_url,String tk) {
|
|
|
@@ -21,16 +23,21 @@ public class TianDiTuReverseUtil {
|
|
|
|
|
|
String response = HttpUtil.get(fullUrl);
|
|
|
return JSON.parseObject(response);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info( "获取天地图地理位置错误", e);
|
|
|
return JSONObject.of("status", "-1", "msg", "网络请求异常");
|
|
|
}
|
|
|
}
|
|
|
// String points = gpsVo.getLongitude()+","+gpsVo.getLatitude();
|
|
|
|
|
|
public static AddressComponent getAddress(String lonLat,String api_url,String tk) {
|
|
|
- String[] split = lonLat.split(",");
|
|
|
- return getAddress(split[0],split[1],api_url,tk);
|
|
|
+ try {
|
|
|
+ String[] split = lonLat.split(",");
|
|
|
+ return getAddress(split[0],split[1],api_url,tk);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info( "获取天地图地理位置错误", e);
|
|
|
+ }
|
|
|
+ return new AddressComponent();
|
|
|
}
|
|
|
|
|
|
public static AddressComponent getAddress(String lon, String lat,String api_url,String tk) {
|