From d3a12b192afc54eb51f640a8050644d4fddd9100 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 28 七月 2023 15:16:08 +0800
Subject: [PATCH] 后台代码
---
cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java | 22 +++++++---------------
1 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java b/cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java
index d25130a..92ac86d 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java
@@ -3,8 +3,10 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.dsh.other.util.httpClinet.HttpClientUtil;
+import com.dsh.other.util.httpClinet.HttpResult;
import org.springframework.stereotype.Component;
+
import java.io.BufferedReader;
import java.io.IOException;
@@ -25,10 +27,6 @@
public class GDMapGeocodingUtil {
private String key = "fb131ad2dbfb3f39d7d37d244b92aa2d";
-
- @Autowired
- private HttpClientUtil httpClientUtil;
-
/**
* 将行政区域名称转化为坐标
@@ -58,12 +56,10 @@
String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON";
url += "&address=" + province + (ToolUtil.isNotEmpty(city) ? city : "") + (ToolUtil.isNotEmpty(county) ? county : "") + (ToolUtil.isNotEmpty(address) ? address : "");
- HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json");
+ HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json");
JSONObject jsonObject = JSON.parseObject(httpResult.getData());
String status = jsonObject.getString("status");
List<String> list = new ArrayList<>();
-
-// gdInterfaceService.saveData("https://restapi.amap.com/v3/geocode/geo", "行政区域转经纬度");
if(status.equals("1")){
JSONArray geocodes = jsonObject.getJSONArray("geocodes");
@@ -82,12 +78,10 @@
public Map<String, Object> geocoding(String address) throws Exception{
Map<String, Object> map = new HashMap<>();
String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON&address=" + address;
- HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json");
+ HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json");
JSONObject jsonObject = JSON.parseObject(httpResult.getData());
String status = jsonObject.getString("status");
List<String> list = new ArrayList<>();
-
-// gdInterfaceService.saveData("https://restapi.amap.com/v3/geocode/geo", "行政区域转经纬度");
if(status.equals("1")){
JSONArray geocodes = jsonObject.getJSONArray("geocodes");
@@ -112,11 +106,9 @@
*/
public Map<String, String> geocode(String lon, String lan) throws Exception{
String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan;
- HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json");
+ HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json");
JSONObject jsonObject = JSON.parseObject(httpResult.getData());
Map<String, String> map = new HashMap<>();
-
-// gdInterfaceService.saveData("https://restapi.amap.com/v3/geocode/regeo", "经纬度转行政区域");
if(jsonObject.getString("status").equals("1")){
JSONObject regeocode = jsonObject.getJSONObject("regeocode");
@@ -147,7 +139,7 @@
*/
public Map<String, String> convert(String locations, String coordsys) throws Exception{
String url = "https://restapi.amap.com/v3/assistant/coordinate/convert?locations=" + locations + "&coordsys=" + coordsys + "&output=json&key=" + key;
- HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json");
+ HttpResult httpResult = HttpClientUtil.pushHttpRequset("GET", url, null, null, "json");
JSONObject jsonObject = JSON.parseObject(httpResult.getData());
Map<String, String> map = new HashMap<>();
if("1".equals(jsonObject.getString("status"))){
--
Gitblit v1.7.1