feat:门店经纬度更新
This commit is contained in:
@@ -3,6 +3,7 @@ package com.cool.store.utils;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -16,6 +17,7 @@ import java.net.URL;
|
|||||||
* @Description:
|
* @Description:
|
||||||
* @date 2024-04-23 11:26
|
* @date 2024-04-23 11:26
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class GeoMapUtil {
|
public class GeoMapUtil {
|
||||||
|
|
||||||
private static final String AMAP_API_URL = "https://restapi.amap.com/v3/geocode/regeo";
|
private static final String AMAP_API_URL = "https://restapi.amap.com/v3/geocode/regeo";
|
||||||
@@ -64,14 +66,19 @@ public class GeoMapUtil {
|
|||||||
if (geoJson==null){
|
if (geoJson==null){
|
||||||
return new AddressInfo();
|
return new AddressInfo();
|
||||||
}
|
}
|
||||||
JSONObject addressComponent = geoJson.getJSONObject("addressComponent");
|
try {
|
||||||
// 根据实际响应结构解析省市区街道信息,此处仅为示例
|
JSONObject addressComponent = geoJson.getJSONObject("addressComponent");
|
||||||
String province = (String) addressComponent.get("province");
|
// 根据实际响应结构解析省市区街道信息,此处仅为示例
|
||||||
String city = addressComponent.get("city") instanceof String?(String) addressComponent.get("city"):province;
|
String province = (String) addressComponent.get("province");
|
||||||
String district = addressComponent.get("district") instanceof String?(String) addressComponent.get("district"):city;
|
String city = addressComponent.get("city") instanceof String?(String) addressComponent.get("city"):province;
|
||||||
String township =addressComponent.get("township") instanceof String?(String) addressComponent.get("township"):district;
|
String district = addressComponent.get("district") instanceof String?(String) addressComponent.get("district"):city;
|
||||||
String address = geoJson.getString("formatted_address");
|
String township =addressComponent.get("township") instanceof String?(String) addressComponent.get("township"):district;
|
||||||
return new AddressInfo(province, city, district, township, address);
|
String address = geoJson.getString("formatted_address");
|
||||||
|
new AddressInfo(province, city, district, township, address);
|
||||||
|
}catch (Exception exception){
|
||||||
|
log.info("高德数据获取异常{}",exception.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
Reference in New Issue
Block a user