/// <summary> /// 返回经纬度所在的地面网格,以区域左下角为原点 /// </summary> /// <param name="lng"></param> /// <param name="lat"></param> /// <param name="gxid"></param> /// <param name="gyid"></param> /// <returns></returns> public bool LngLatToGGrid(double lng, double lat, ref int gxid, ref int gyid) { if (checkLLHInGrid(lng, lat, 0)) { //同划分网格一致 double dy = CJWDHelper.distance(lng, minlat, lng, lat); double dx = CJWDHelper.distance(minlong, lat, lng, lat); gxid = (int)(Math.Floor(dx * 1000.0 / ggridsize)); gyid = (int)(Math.Floor(dy * 1000.0 / ggridsize)); return(true); } return(false); }
/// <summary> /// 返回空间点(经纬度)所在的加速网格坐标 /// </summary> /// <param name="lng"></param> /// <param name="lat"></param> /// <param name="height">单位米</param> /// <param name="gxid"></param> /// <param name="gyid"></param> /// <param name="gzid">1,2,3</param> /// <returns></returns> public bool LngLatHeightToAccGrid(double lng, double lat, double height, ref int gxid, ref int gyid, ref int gzid) { bool ret; if (ret = checkLLHInGrid(lng, lat, height)) { //同划分网格的思路 double dy = CJWDHelper.distance(lng, minlat, lng, lat); double dx = CJWDHelper.distance(minlong, lat, lng, lat); gxid = (int)Math.Floor(dx * 1000.0 / agridsize); gyid = (int)Math.Floor(dy * 1000.0 / agridsize); height = Math.Round(height, 3); gzid = (height <= agridvsize ? 1 : (height <= (agridvsize << 1) ? 2 : 3)); //gzid = (int)Math.Ceiling(height / (double)agridvsize); //gzid = gzid < 4 ? gzid : 3 ; } return(ret); }
/// <summary> /// 初步获取点间距满足要求的路测点 /// </summary> /// <param name="points">从数据库读取的数据</param> /// <param name="num">选取的点的个数</param> /// <param name="distanceBT">点间距</param> /// <returns></returns> private DataTable ComputePointByD(DataTable points, int num, double distanceBT) { DataTable ans = reset.Clone(); ///若筛选出的数据小于num if (points.Rows.Count < num) { //MessageBox.Show(this, "ComputePointByD所筛选出的结果不足最小选点数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ans); } minLon = Convert.ToInt32(points.Rows[0]["Lon"]); minLat = Convert.ToInt32(points.Rows[0]["Lat"]); maxLon = minLon; maxLat = minLat; for (int i = 1; i < points.Rows.Count; i++) { //if (tb.Rows.Count == num) break;//找到指定数的点 int id = Convert.ToInt32(points.Rows[i]["ID"]); double Lon = Convert.ToDouble(points.Rows[i]["Lon"]); double Lat = Convert.ToDouble(points.Rows[i]["Lat"]); Boolean flag = true; //与之前的每个点进行比较 for (int j = ans.Rows.Count - 1; j >= 0; j--) { flag = true; double Lonf = Convert.ToDouble(ans.Rows[j]["Lon"]); double Latf = Convert.ToDouble(ans.Rows[j]["Lat"]); double dis = CJWDHelper.distance(Lon, Lat, Lonf, Latf) * 1000; if (dis < distanceBT) { flag = false; break; } } if (flag) { if (Lon > maxLon) { maxLon = Lon; } else if (minLon > Lon) { minLon = Lon; } if (Lat > maxLat) { maxLat = Lat; } else if (minLat > Lat) { minLat = Lat; } DataRow thisrow = ans.NewRow(); thisrow["Lon"] = Lon; thisrow["Lat"] = Lat; Point pt = new Point(Lon, Lat, 0); pt = PointConvertByProj.Instance.GetProjectPoint(pt); thisrow["x"] = pt.X; thisrow["y"] = pt.Y; thisrow["ReceivePW"] = Math.Pow(10, (Convert.ToDouble(points.Rows[i]["RSRP"]) / 10 - 3)); thisrow["CI"] = id; ans.Rows.Add(thisrow); } } if (ans.Rows.Count < num) { //MessageBox.Show(this, "选点数不足最小选点数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ans); } return(ans); }
public Result ComputeInfRSRP() { loadInfo.loadCountAdd(3); DTHandlerModel dt = new DTHandlerModel(); dt.UpdateDTDataForLoc(); loadInfo.loadHashAdd(1); #region 计算路测数据RSRP入库 //去除无效数据 IbatisHelper.ExecuteDelete("deleteNouseDTNoInf"); IbatisHelper.ExecuteDelete("deleteNouseDTInf"); DataTable dtnoinf = IbatisHelper.ExecuteQueryForDataTable("getDTNoInf", null); DataTable dtinf = IbatisHelper.ExecuteQueryForDataTable("getDTInf", null); if (dtinf.Rows.Count < 1 || dtnoinf.Rows.Count < 1) { return(new Result(false, "无路测数据")); } Hashtable htinf = new Hashtable(); htinf["InfName"] = this.infname; IbatisHelper.ExecuteDelete("deleteUINTF", htinf);//删除当前表里该干扰源对应的数据 bool[] flag = new bool[dtinf.Rows.Count]; for (int i = 0; i < dtnoinf.Rows.Count; i++) { double lon = Convert.ToDouble(dtnoinf.Rows[i]["Lon"].ToString()); double lat = Convert.ToDouble(dtnoinf.Rows[i]["Lat"].ToString()); double RSRP1 = Convert.ToDouble(dtnoinf.Rows[i]["RSRP"].ToString()); double SINR1 = Convert.ToDouble(dtnoinf.Rows[i]["SINR"].ToString()); int CInoinf = Convert.ToInt32(dtnoinf.Rows[i]["CI"].ToString()); int ID = Convert.ToInt32(dtnoinf.Rows[i]["ID"].ToString()); for (int j = 0; j < dtinf.Rows.Count; j++) { int CIinf = Convert.ToInt32(dtinf.Rows[j]["CI"].ToString()); double lon1 = Convert.ToDouble(dtinf.Rows[j]["Lon"].ToString()); double lat1 = Convert.ToDouble(dtinf.Rows[j]["Lat"].ToString()); if (flag[j] || CInoinf != CIinf) { if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 < 1)//若距离太近,则该点不要 { break; } else { continue; } } else { double RSRP2 = Convert.ToDouble(dtinf.Rows[j]["RSRP"].ToString()); double SINR2 = Convert.ToDouble(dtinf.Rows[j]["SINR"].ToString()); if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 <= 9) { double tmp = (Math.Pow(10, RSRP2 / 10) / Math.Pow(10, SINR2 / 10)) - (Math.Pow(10, RSRP1 / 10) / Math.Pow(10, SINR1 / 10)); if (tmp <= 0) { continue; } double UINTF = 10 * Math.Log10(tmp); DataRow newRow = reset.NewRow(); newRow["ID"] = ID; Point pt = new Point(lon, lat, 0); pt = PointConvertByProj.Instance.GetProjectPoint(pt); newRow["x"] = pt.X; newRow["y"] = pt.Y; newRow["Lon"] = lon; newRow["Lat"] = lat; newRow["RSRP"] = UINTF; newRow["InfName"] = this.infname; newRow["DtType"] = "路测"; reset.Rows.Add(newRow); flag[j] = true; break; } } } if (reset.Rows.Count == 5000) { DTHandlerModel.writeFinalResultToDB(reset, "tbUINTF"); } } dtinf.Clear(); dtnoinf.Clear(); loadInfo.loadHashAdd(1); #endregion #region 计算终端数据入库 IbatisHelper.ExecuteDelete("deleteNouseTerminalMI", null); Hashtable ht = new Hashtable(); ht["isInf"] = 0; //增加终端部分的RSRP处理 DataTable ternoinf = IbatisHelper.ExecuteQueryForDataTable("getTerminalMI", ht); ht["isInf"] = 1; DataTable terinf = IbatisHelper.ExecuteQueryForDataTable("getTerminalMI", ht); bool[] Tflag = new bool[ternoinf.Rows.Count]; for (int i = 0; i < ternoinf.Rows.Count; i++) { double lon = Convert.ToDouble(ternoinf.Rows[i]["Lon"].ToString()); double lat = Convert.ToDouble(ternoinf.Rows[i]["Lat"].ToString()); double RSRP1 = Convert.ToDouble(ternoinf.Rows[i]["RSRP"].ToString()); double SINR1 = Convert.ToDouble(ternoinf.Rows[i]["SINR"].ToString()); long IMSI = Convert.ToInt64(ternoinf.Rows[i]["IMSI"].ToString()); for (int j = 0; j < terinf.Rows.Count; j++) { long IMSIinf = Convert.ToInt64(terinf.Rows[j]["IMSI"].ToString()); double lon1 = Convert.ToDouble(terinf.Rows[j]["Lon"].ToString()); double lat1 = Convert.ToDouble(terinf.Rows[j]["Lat"].ToString()); if (Tflag[j] || IMSI != IMSIinf) { if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 < 1)//若距离太近,则该点不要 { break; } else { continue; } } else { double RSRP2 = Convert.ToDouble(terinf.Rows[j]["RSRP"].ToString()); double SINR2 = Convert.ToDouble(terinf.Rows[j]["SINR"].ToString()); if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 <= 9) { double tmp = (Math.Pow(10, RSRP2 / 10) / Math.Pow(10, SINR2 / 10)) - (Math.Pow(10, RSRP1 / 10) / Math.Pow(10, SINR1 / 10)); if (tmp <= 0) { continue; } double UINTF = 10 * Math.Log10(tmp); DataRow newRow = reset.NewRow(); newRow["ID"] = i; Point pt = new Point(lon, lat, 0); pt = PointConvertByProj.Instance.GetProjectPoint(pt); newRow["x"] = pt.X; newRow["y"] = pt.Y; newRow["Lon"] = lon; newRow["Lat"] = lat; newRow["RSRP"] = UINTF; newRow["InfName"] = this.infname; newRow["DtType"] = "终端"; reset.Rows.Add(newRow); Tflag[j] = true; break; } } } if (reset.Rows.Count == 5000) { DTHandlerModel.writeFinalResultToDB(reset, "tbUINTF"); } } if (reset.Rows.Count > 0) { DTHandlerModel.writeFinalResultToDB(reset, "tbUINTF"); } loadInfo.loadHashAdd(1); #endregion return(new Result(true, "成功")); }
private bool GetTotalintoTmp(DataTable dtInfo) { try { IbatisHelper.ExecuteDelete("deletetbtmpDTData", null); int ucount = 0; foreach (DataRow dtrow in dtInfo.Rows) { int id = int.Parse(dtrow["ID"].ToString()); double lon = double.Parse(dtrow["Lon"].ToString()); double lat = double.Parse(dtrow["Lat"].ToString()); int pci = int.Parse(dtrow["PCI"].ToString()); if (cellmap.ContainsKey(pci)) { List <UseCell> tmp = new List <UseCell>(cellmap[pci]); double dis = double.MaxValue; int minindex = 0; for (int i = 0; i < tmp.Count; i++) { //Debug.WriteLine("tmp"+i+" :" + tmp[i].x + "," + tmp[i].y); double curdis = CJWDHelper.distance(lon, lat, tmp[i].lon, tmp[i].lat) * 1000; if (curdis < dis) { dis = curdis; minindex = i; } if (dis < 0.5) { Debug.WriteLine("pt.x"); } } //找到对应的小区信息,添加到dtable中 Point pt = new Point(lon, lat, 0); pt = PointConvertByProj.Instance.GetProjectPoint(pt); DataRow dr = dtable.NewRow(); dr["ID"] = id; dr["x"] = pt.X; dr["y"] = pt.Y; dr["eNodeBID"] = tmp[minindex].eNodeB; dr["CellID"] = tmp[minindex].cellID; dr["SCell_Dist"] = dis; dtable.Rows.Add(dr); if (dtable.Rows.Count > 5000) { writeFinalResultToDB(dtable, "tbtmpDTData"); } } else { ucount++; continue; } } Debug.WriteLine(ucount + "条无效数据"); writeFinalResultToDB(dtable, "tbtmpDTData"); } catch (Exception e) { Debug.WriteLine(e.StackTrace); return(false); } return(true); }