优化高德调用
This commit is contained in:
+12
-1
@@ -3,6 +3,7 @@ package com.fangjia.script.temp.shenjian.util
|
|||||||
import com.alibaba.fastjson.JSONArray
|
import com.alibaba.fastjson.JSONArray
|
||||||
import com.alibaba.fastjson.JSONObject
|
import com.alibaba.fastjson.JSONObject
|
||||||
import com.fangjia.core.util.DataUtil
|
import com.fangjia.core.util.DataUtil
|
||||||
|
import com.fangjia.core.util.HttpRequest
|
||||||
import com.fangjia.script.statistics.poi.AmapPoi
|
import com.fangjia.script.statistics.poi.AmapPoi
|
||||||
import com.fangjia.script.util.GeoHelper
|
import com.fangjia.script.util.GeoHelper
|
||||||
import com.fangjia.script.util.HttpRequestUtil
|
import com.fangjia.script.util.HttpRequestUtil
|
||||||
@@ -175,7 +176,17 @@ class GaoDeUtils {
|
|||||||
* 获取地址经纬度
|
* 获取地址经纬度
|
||||||
*/
|
*/
|
||||||
static def parserByGaode(def city, def address) {
|
static def parserByGaode(def city, def address) {
|
||||||
JSONObject json = GaoDeApiUtils.geo(city, address)
|
Map<String, String> params = new HashMap<String, String>()
|
||||||
|
params.put("key", GAO_DE_AK[keyUsed.intValue()])
|
||||||
|
params.put("city", city)
|
||||||
|
params.put("address", address)
|
||||||
|
String content
|
||||||
|
try {
|
||||||
|
content = new HttpRequest().get("https://restapi.amap.com/v3/geocode/geo", params, "utf-8")
|
||||||
|
} catch (Exception e) {
|
||||||
|
content = new HttpRequest().get("https://restapi.amap.com/v3/geocode/geo", params, "utf-8")
|
||||||
|
}
|
||||||
|
net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(content)
|
||||||
if (json && json.info && json.info == "OK") {
|
if (json && json.info && json.info == "OK") {
|
||||||
def ret = json.geocodes
|
def ret = json.geocodes
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|||||||
Reference in New Issue
Block a user