| | |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.common.core.utils.HttpUtils; |
| | | import com.xiaopeng.map.mangodb.service.XpGeoFencingPolygonService; |
| | | import com.xiaopeng.map.utils.mangoUtils.MongoGeoFenceUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | private String key = "66ae577f63898dae3016d599fda57221"; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | |
| | | @Autowired |
| | | private XpGeoFencingPolygonService xpGeoFencingPolygonService; |
| | | |
| | |
| | | String data = jsonObject.getString("data"); |
| | | |
| | | JSONObject jsonObject1 = JSON.parseObject(data); |
| | | //TODO routeId的逻辑提取逻辑还没改 |
| | | String routeID = jsonObject1.getString("routeID"); |
| | | JSONArray path = jsonObject1.getJSONArray("paths"); |
| | | for (Object o : path) { |
| | | JSONObject jsonObject2 = (JSONObject) o; |
| | | |
| | | String routeID = jsonObject2.getString("routeID"); |
| | | String points = jsonObject2.getString("points"); |
| | | String[] split = points.split(";"); |
| | | int temp=0; |
| | |
| | | return jsonObject.getString("data"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据经纬度获取行政区域信息 |
| | | * @param lon |
| | | * @param lan |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, String> geocode(String lon, String lan) { |
| | | String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan; |
| | | String forObject = HttpUtils.sendGet(url); |
| | | JSONObject jsonObject = JSON.parseObject(forObject); |
| | | Map<String, String> map = new HashMap<>(); |
| | | if(jsonObject.getString("status").equals("1")){ |
| | | JSONObject regeocode = jsonObject.getJSONObject("regeocode"); |
| | | JSONObject addressComponent = regeocode.getJSONObject("addressComponent"); |
| | | String address = regeocode.getString("formatted_address"); |
| | | map.put("address", address); |
| | | String code = addressComponent.getString("adcode"); |
| | | String province = addressComponent.getString("province"); |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | map.put("province", province); |
| | | map.put("provinceCode", code.substring(0, 2) + "0000"); |
| | | map.put("city", city); |
| | | map.put("cityCode", code.substring(0, 4) + "00"); |
| | | map.put("district", district); |
| | | map.put("districtCode", code); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | } |