IcePoiSearchFTRClient.java
2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.glsx.ice.iceClient;
import Ice.Communicator;
import com.glsx.ice.POI.IPOISearchFTRPrx;
import com.glsx.ice.POI.IPOISearchFTRPrxHelper;
import com.glsx.ice.POI.geocoding_result;
import com.glsx.ice.POI.geocoding_resultHolder;
import com.glsx.utils.SystemProperty;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.Map;
@Slf4j
public class IcePoiSearchFTRClient {
// ice接口服务器地址
private static String ICE_URL = SystemProperty.getProperty("ice.poiSearchFTRUrl");
static Communicator ic = Ice.Util.initialize();
static Ice.ObjectPrx base = ic.stringToProxy(ICE_URL).ice_timeout(Integer.parseInt(SystemProperty.getProperty("ice.connectTimeout")));
static IPOISearchFTRPrx ipoiSearchFTRPrx = IPOISearchFTRPrxHelper.checkedCast(base);
/**
* 通过逆地址解析
*
* @return
*/
public static Map<String, Object> Geocoding(String address) {
//请求和响应对象
geocoding_resultHolder res = new geocoding_resultHolder();
try {
if (ipoiSearchFTRPrx == null) {
log.error("mapGeoConvert ice添加服务异常 servicePre is null");
return null;
}
ipoiSearchFTRPrx.Geocoding(address, res);
Map<String, Object> map = null;
if (res != null && res.value != null) {
geocoding_result val = res.value;
map = new HashMap<>();
//POI层级 0~7
map.put("level", val.level);
//可信度,分度越高越可信
map.put("confidence", val.confidence);
//经度
map.put("lng", val.pt.lng / 1000000D);
//纬度
map.put("lat", val.pt.lat / 1000000D);
return map;
}
} catch (Ice.LocalException e) {
log.error("Geocoding ice localexception" + e.getMessage(), e);
} catch (Exception e) {
log.error("Geocoding ice exception" + e.getMessage(), e);
}
log.info("Geocoding ice添加接口调用结束");
return null;
}
}