| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | 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; |
| | |
| | | @Lazy |
| | | public class GDMapGeocodingUtil { |
| | | |
| | | private String key = "f11b217cdbb08cd780919ed7398c5504"; |
| | | private String key = "66ae577f63898dae3016d599fda57221"; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | |
| | | params.put("start", start.getLongitude() + "," + start.getLatitude()); |
| | | params.put("end", end.getLongitude() + "," + end.getLatitude()); |
| | | params.put("routeUserType",2); |
| | | params.put("voidPolygons", avoidRoads); |
| | | if(avoidRoads!=null && !avoidRoads.isEmpty()){ |
| | | params.put("voidPolygons", avoidRoads); |
| | | } |
| | | if(routePlanRule!=null){ |
| | | params.put("strategy", routePlanRule); |
| | | } |
| | | |
| | | String forObject = restTemplate.getForObject(url, String.class, params); |
| | | JSONObject jsonObject = JSON.parseObject(forObject); |
| | | String post = HttpUtils.post(url, JSON.toJSONString(params)); |
| | | System.out.println("高德地图返回结果:"+ post); |
| | | // String forObject = restTemplate.getForObject(url, String.class, params); |
| | | JSONObject jsonObject = JSON.parseObject(post); |
| | | String data = jsonObject.getString("data"); |
| | | |
| | | JSONObject jsonObject1 = JSON.parseObject(data); |
| | | String routeID = jsonObject1.getString("routeID"); |
| | | JSONArray path = jsonObject1.getJSONArray("path"); |
| | | JSONArray path = jsonObject1.getJSONArray("paths"); |
| | | for (Object o : path) { |
| | | JSONObject jsonObject2 = (JSONObject) o; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 线路还原接口 |
| | | * 车端使用的数据 |
| | | * @param routeID |
| | | * @return |
| | | */ |
| | | public String routed(String routeID){ |
| | | String url = "https://tsapi.amap.com/v1/route/query/routeid?key=" + key; |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("routeID", routeID); |
| | | params.put("sdkVersion", ""); |
| | | params.put("encoderVersion", "5.1"); |
| | | String post = HttpUtils.post(url, JSON.toJSONString(params)); |
| | | System.out.println("高德地图返回结果:"+ post); |
| | | JSONObject jsonObject = JSON.parseObject(post); |
| | | return jsonObject.getString("data"); |
| | | } |
| | | |
| | | } |