public List<string> GetPositions(LatLon[] array) { List<string> lsLocation = new List<string>(); try { var mapService = new PES.GPS.MapService.MapSearchService.MapService(); IList<LocationInfo> list = mapService.InverseGeocoding(array); if (list.Count == 0) { Logger.Error(string.Format("PositionService.GetPositions(LatLon[] array)获取位置失败")); } else { for (int i = 0; i < list.Count;i++ ) { lsLocation.Add(list[i].ToString()); } } } catch (Exception ex) { Logger.Error(string.Format("PositionService.GetPositions(LatLon[] array)获取位置失败,error:{0}", ex.Message), ex); } return lsLocation; }
public IList<LocationInfo> GetPosition(IList<LatLon> ltLatLon) { try { var mapService = new PES.GPS.MapService.MapSearchService.MapService(); return mapService.InverseGeocoding(ltLatLon.ToArray()); } catch (Exception ex) { Logger.Error(string.Format("PositionService.GetPosition(IList<LatLon> ltLatLon)获取位置失败,error:{0}", ex.Message), ex); return new List<LocationInfo>(); } }
public string GetPosition(string latlon) { string position = string.Empty; try { var mapService = new PES.GPS.MapService.MapSearchService.MapService(); var locationInfo = mapService.InverseGeocoding(latlon); if (locationInfo == null) { Logger.Error(string.Format("PositionService.GetPosition(string latlon),latlon:{0}获取位置失败", latlon)); } else { position = locationInfo.ToString(); } } catch (Exception ex) { Logger.Error(string.Format("PositionService.GetPosition(string latlon),latlon:{0}获取位置失败,error:{1}", latlon, ex.Message), ex); } return position; }
/// <summary> /// 将客户端获取到得加密坐标位置转换格式(如:31.89938,117.25877;31.89586,117.26057;) /// </summary> /// <param name="encodeLatLon"></param> /// <returns></returns> public string ConvertToPoints(string encodeLatLon) { if (string.IsNullOrEmpty(encodeLatLon)) return string.Empty; var latlonList = new PES.GPS.MapService.MapSearchService.MapService().DecodeArray(encodeLatLon); if (latlonList != null && latlonList.Count > 0) { StringBuilder ss = new StringBuilder(); foreach (var item in latlonList) ss.AppendFormat("{0},{1};", item.Latitude, item.Longitude); return ss.ToString(); } return string.Empty; }