| | |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.enums.GaoDeEnum; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.vo.GaoDeMap; |
| | | import com.ruoyi.common.core.vo.Path; |
| | | import com.ruoyi.common.core.vo.PolylineData; |
| | | import com.ruoyi.common.core.vo.Steps; |
| | | import com.ruoyi.common.core.vo.*; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 功能描述: 根据地址获取城市code |
| | | * |
| | | * @param address d地址 |
| | | * @return 两个定位点之间的距离 |
| | | */ |
| | | public static Result<CityInfoVO> getAddressInfo(String address) { |
| | | // 返回起始地startAddr与目的地endAddr之间的距离,单位:米 |
| | | String queryUrl = "https://restapi.amap.com/v3/geocode/geo?address=" + address |
| | | + "&key=" + GAO_DE_KEY; |
| | | String queryResult = getResponse(queryUrl); |
| | | GaoDeAddressInfoVO data = JSONObject.parseObject(queryResult, GaoDeAddressInfoVO.class); |
| | | List<Geocodes> geocodes = data.getGeocodes(); |
| | | Geocodes info = geocodes.get(0); |
| | | String adcode = info.getAdcode(); |
| | | String city = info.getCity(); |
| | | return Result.succeed(new CityInfoVO(city, adcode), "距离计算成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 功能描述: 发送请求 |
| | | * |
| | | * @param serverUrl 请求地址 |