| | |
| | | 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.config.MapApiProperties; |
| | | import com.xiaopeng.map.mangodb.service.XpGeoFencingPolygonService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Lazy |
| | | public class GDMapGeocodingUtil { |
| | | |
| | | private String key = "66ae577f63898dae3016d599fda57221"; |
| | | |
| | | |
| | | @Autowired |
| | | private XpGeoFencingPolygonService xpGeoFencingPolygonService; |
| | | |
| | | @Autowired |
| | | private MapApiProperties mapApiProperties; |
| | | |
| | | |
| | | /** |
| | |
| | | public RouteVo getDistanceAndTime(LonLatDto start, LonLatDto end,ArrayList<JSONObject> avoidRoads,String fenceId,Integer routePlanRule, List<HistoryPointDto> history) { |
| | | RouteVo routeVo = new RouteVo(); |
| | | |
| | | String url = "https://tsapi.amap.com/v1/route/price?key=" + key + "&extensions=all&start=" + start.getLongitude() + "," + start.getLatitude(); |
| | | String url = mapApiProperties.getUrls().getRoutePrice() + "?key=" + mapApiProperties.getApiKey() + "&extensions=all&start=" + start.getLongitude() + "," + start.getLatitude(); |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("extensions", "all"); |
| | | params.put("start", start.getLongitude() + "," + start.getLatitude()); |
| | |
| | | * @throws Exception |
| | | */ |
| | | public List<RouteVo> getDistanceAndTimeList(LonLatDto start, LonLatDto end,ArrayList<JSONObject> avoidRoads,String fenceId,Integer routePlanRule, List<HistoryPointDto> history) { |
| | | String url = "https://tsapi.amap.com/v1/route/price?key=" + key + "&extensions=all&start=" + start.getLongitude() + "," + start.getLatitude(); |
| | | String url = mapApiProperties.getUrls().getRoutePrice() + "?key=" + mapApiProperties.getApiKey() + "&extensions=all&start=" + start.getLongitude() + "," + start.getLatitude(); |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("extensions", "all"); |
| | | params.put("start", start.getLongitude() + "," + start.getLatitude()); |
| | |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | String url = "https://tsapi.amap.com/v1/route/price?key=" + "66ae577f63898dae3016d599fda57221" + "&extensions=all&start=" + "113.384932" + "," + "23.155455"; |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("extensions", "all"); |
| | | params.put("start", "113.384932" + "," + "23.155455"); |
| | | params.put("end", "113.388209" + "," + "23.163455"); |
| | | params.put("routeUserType", 2); |
| | | log.info("高德地图接口:{}", url); |
| | | log.info("高德地图参数:{}", params); |
| | | String post = HttpUtils.post(url, JSON.toJSONString(params)); |
| | | log.info("高德地图返回结果:" + post); |
| | | JSONObject jsonObject = JSON.parseObject(post); |
| | | System.out.println(jsonObject); |
| | | } |
| | | |
| | | |
| | | class ArrayPointsTask extends RecursiveTask<Long> { |
| | | //最大定位集合阈值 |
| | | private final int THRESHOLD = 10; |
| | |
| | | * @return |
| | | */ |
| | | public String routed(String routeID) { |
| | | String url = "https://tsapi.amap.com/v1/route/query/routeid?key=" + key; |
| | | String url = mapApiProperties.getUrls().getRouteQuery() + "?key=" + mapApiProperties.getApiKey(); |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("routeID", routeID); |
| | | params.put("sdkVersion", "9.850.152.3.532"); |
| | |
| | | * @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 url = mapApiProperties.getUrls().getReverseGeocode() + "?key=" + mapApiProperties.getApiKey() + "&location=" + lon + "," + lan; |
| | | String forObject = HttpUtils.sendGet(url); |
| | | JSONObject jsonObject = JSON.parseObject(forObject); |
| | | Map<String, String> map = new HashMap<>(); |