IcePoiSearchClient.java
2.13 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
60
package com.glsx.ice.iceClient;
import Ice.Communicator;
import Ice.StringHolder;
import com.glsx.config.SystemProperty;
import com.glsx.ice.poisearch.IPOISearchNearPrx;
import com.glsx.ice.poisearch.IPOISearchNearPrxHelper;
import com.glsx.ice.poisearch.geopoint;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@Slf4j
public class IcePoiSearchClient {
// ice接口服务器地址
private static String ICE_URL = SystemProperty.getProperty("ice.poisearchUrl");
static Communicator ic = Ice.Util.initialize();
static Ice.ObjectPrx base = ic.stringToProxy(ICE_URL).ice_timeout(Integer.parseInt(SystemProperty.getProperty("ice.connectTimeout")));
static IPOISearchNearPrx poiSearchNearPrx = IPOISearchNearPrxHelper.checkedCast(base);
/**
* 通过逆地址解析
*
* @param lat
* @param lng
* @return
*/
public static String getReverseGeocoding(float lat, float lng) {
String resultAddress = null;
//请求和响应对象
geopoint ptCenterGeopoint = new geopoint();
ptCenterGeopoint.lng = lng;
ptCenterGeopoint.lat = lat;
StringHolder poiSearchHolder = new StringHolder();
try {
if (poiSearchNearPrx == null) {
log.error("mapGeoConvert ice添加服务异常 servicePre is null");
return resultAddress;
}
int geoRes = poiSearchNearPrx.ReverseGeocoding(ptCenterGeopoint, poiSearchHolder);
if (geoRes != 0) { // 结果为 0 表示调用成功
return resultAddress;
}
if (poiSearchHolder.value == null
|| StringUtils.isEmpty(poiSearchHolder.value)) {
return resultAddress;
}
resultAddress = poiSearchHolder.value;
} catch (Ice.LocalException e) {
log.error("mapGeoConvert ice localexception" + e.getMessage(), e);
} catch (Exception e) {
log.error("mapGeoConvert ice exception" + e.getMessage(), e);
}
log.info("mapGeoConvert ice添加接口调用结束");
return resultAddress;
}
}