| | |
| | | String encodedPostStr = UriUtils.encodeQueryParam(postStr, StandardCharsets.UTF_8); |
| | | String url = TIAN_DI_TU_URL + "?postStr=" + encodedPostStr + "&type=geocode&tk=" + TIAN_DI_TU_KEY; |
| | | URI uri = URI.create(url); |
| | | log.info("天地图逆地理编码请求地址:{}", url); |
| | | String response = REST_TEMPLATE.getForObject(uri, String.class); |
| | | if (StringUtil.isBlank(response)) { |
| | | return null; |
| | | } |
| | | try { |
| | | log.debug("天地图逆地理编码结果:{}", response); |
| | | log.info("天地图逆地理编码结果:{}", response); |
| | | JsonNode root = OBJECT_MAPPER.readTree(response); |
| | | String address = root.path("result").path("formatted_address").asText(); |
| | | return StringUtil.isBlank(address) ? null : address; |