/// <summary> /// 谷歌硬件解析 /// </summary> /// <param name="entity"></param> /// <returns></returns> public static LocData GetLatLngFromGoogleLBSWIFIRequestEntity(GoogleLBSWIFIRequestEntity entity) { LocData locReturn = null; try { HttpUtil httpUtil = new HttpUtil(); var postData = JsonHelper.ToJson(entity); string Key = ConfigurationManager.AppSettings["GoogleGeoKey"].ToString(); string url = "https://www.googleapis.com/geolocation/v1/geolocate?key=" + Key; var responseData = httpUtil.PostRequest(url, postData); log4net.LogManager.GetLogger(typeof(GoogleParse).FullName).Info(responseData); GoogleLoction loca = JsonHelper.JSONToObject <GoogleLoction>(responseData); if (loca != null && loca.location != null) { locReturn = new LocData(); locReturn.lat = loca.location.lat; locReturn.lng = loca.location.lng; locReturn.accuracy = loca.accuracy; } } catch (Exception ex) { log4net.LogManager.GetLogger(typeof(GoogleParse).FullName).Error("GetLatLngFromGoogleLBSWIFIRequestEntity 操作失败:" + ex.Message, ex); } return(locReturn); }
/// <summary> /// WIFI,基站数据转google解析数据 /// </summary> /// <param name="lbsList"></param> /// <param name="WifiList"></param> /// <returns></returns> public static GoogleLBSWIFIRequestEntity GetGoogleWifiAccessPointsFromWiFiItem(List <LBSDataItem> lbsList, List <WiFiItem> WifiList) { GoogleLBSWIFIRequestEntity ret = new GoogleLBSWIFIRequestEntity(); ret.homeMobileCountryCode = Convert.ToInt32(lbsList[0].mcc); ret.homeMobileNetworkCode = Convert.ToInt32(lbsList[0].mnc); ret.cellTowers = new List <GoogleCellTowers>(); for (int i = 0; i < lbsList.Count; i++) { var item = new GoogleCellTowers(); item.cellId = lbsList[i].cellid; item.locationAreaCode = lbsList[i].lac; item.mobileCountryCode = Convert.ToInt32(lbsList[i].mcc.Trim()); item.mobileNetworkCode = Convert.ToInt32(lbsList[i].mnc.Trim()); item.signalStrength = -int.Parse(lbsList[i].signal.ToString()); ret.cellTowers.Add(item); } if (WifiList != null) { List <GoogleWifiAccessPoints> wifi = new List <GoogleWifiAccessPoints>(); for (int i = 0; i < WifiList.Count; i++) { GoogleWifiAccessPoints point = new GoogleWifiAccessPoints(); point.macAddress = WifiList[i].Mac; point.signalStrength = WifiList[i].SignalValue; wifi.Add(point); } ret.wifiAccessPoints = wifi; } return(ret); }