public Result UpdateSelectPoints() { Hashtable ht = new Hashtable(); ht["fromName"] = this.virname; DataTable spinfo = IbatisHelper.ExecuteQueryForDataTable("GetSelectedPoint", ht); Point endavg = new Point(this.inflon, this.inflat, 0); PointConvertByProj.Instance.GetProjectPoint(endavg); if (spinfo.Rows.Count < 1) { return(new Result(false, "无初始选点数据")); } for (int i = 0; i < spinfo.Rows.Count; i++) { int ci = Convert.ToInt32(spinfo.Rows[i]["CI"].ToString()); double x = Convert.ToDouble(spinfo.Rows[i]["x"].ToString()); double y = Convert.ToDouble(spinfo.Rows[i]["y"].ToString()); Point start = new Point(x, y, 0); double Azimuth = LTE.Geometric.GeometricUtilities.getPolarCoord(start, endavg).theta / Math.PI * 180; Azimuth = GeometricUtilities.ConvertGeometricArithmeticAngle(Azimuth + 1); Hashtable htupdate = new Hashtable(); htupdate["fromName"] = this.virname; htupdate["CI"] = ci; htupdate["Azimuth"] = Azimuth; IbatisHelper.ExecuteUpdate("UpdatetbSelectedPointByCI", htupdate); } return(new Result(true, "更新成功")); }
/// <summary> /// 用于更新用于定位的两个路测表 /// </summary> /// <returns></returns> public Result UpdateDTDataForLoc() { IbatisHelper.ExecuteDelete("deleteNousetbDTInf", null); //去除无效路测数据 IbatisHelper.ExecuteDelete("deleteNousetbDTNoInf", null); //去除无效路测数据 //获取tbDTData数据,对每一行数据,计算得到需要的内容,然后 DataTable dtInfo = IbatisHelper.ExecuteQueryForDataTable("SelectTbDTInf", null); if (!GetTotalintoTmp(dtInfo)) { return(new Result(false, "更新失败,请查看日志")); } int count = IbatisHelper.ExecuteUpdate("UpdatetbDTInfByTmp", null); //更新的行数 IbatisHelper.ExecuteUpdate("UpdatetbDTInfByCell", null); //根据eNodeID和CI更新btsname,cellname Debug.WriteLine("tbDTInf一共更新:" + count + "条数据"); dtInfo.Clear(); dtInfo = IbatisHelper.ExecuteQueryForDataTable("SelectTbDTNoInf", null); if (!GetTotalintoTmp(dtInfo)) { return(new Result(false, "更新失败,请查看日志")); } count = IbatisHelper.ExecuteUpdate("UpdatetbDTNoInfByTmp", null); //更新的行数 IbatisHelper.ExecuteUpdate("UpdatetbDTNoInfByCell", null); //根据eNodeID和CI更新btsname,cellname Debug.WriteLine("tbDTNoInf一共更新:" + count + "条数据"); return(new Result(true, "更新成功")); }
public Result overlaygrass() { DataTable dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetShpState", null); // Ibatis 数据访问,判断用户是否做了渔网生成 if (dt1.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未进行渔网生成")); } // else // { return new Result(true, "用户未进行渔网生成"); } DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrass_overlayState", null); // Ibatis 数据访问,判断用户是否做了水面叠加分析,做了则删除它 if (dt2.Rows[0][0].ToString() == "1") //存在水面叠加图层 { try //更新加速场景表,前提条件表 { IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoGrass_overlay", null); IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null); IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridSceneDuetoGrass_overlay", null); } catch (Exception ex) { return(new Result(false, ex.ToString())); } } try { GisClient.Result res = GisClient.ServiceApi.getGisLayerService().overlaygrass(); if (res.Ok) { //更新tbDependTabled的Grass_overlay IbatisHelper.ExecuteUpdate("UpdatetbDependTableGrass_overlay", null); return(new Result(true, res.Msg)); } else { return(new Result(false, res.Msg)); } } catch (Exception e) { return(new Result(false, "远程调用失败" + e)); } finally { ServiceApi.CloseConn(); } }
public Result cluster() { DataTable dt11 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClustertoDBState", null); // Ibatis 数据访问,判断用户是否做了场景划分 if (dt11.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未进行场景划分")); } DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterShpState", null); // Ibatis 数据访问,判断用户是否做了结果图层 if (dt2.Rows[0][0].ToString() == "1") //做了结果图层 { try //更新前提条件表 { IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoClusterShp", null); IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null); } catch (Exception ex) { return(new Result(false, ex.ToString())); } } try { GisClient.Result res = GisClient.ServiceApi.getGisLayerService().cluster(); if (res.Ok) { //更新tbDependTabled的Grass_overlay IbatisHelper.ExecuteUpdate("UpdatetbDependTableClusterShp", null); return(new Result(true, res.Msg)); } else { return(new Result(false, res.Msg)); } } catch (Exception e) { return(new Result(false, "远程调用失败" + e)); } finally { ServiceApi.CloseConn(); } }
public Result part() { int cnt = 0; //初始化进度信息 LoadInfo loadInfo = new LoadInfo(); loadInfo.count = 3; loadInfo.loadCreate(); DataTable dt11 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuilding_overlayState", null); // Ibatis 数据访问,判断用户是否做了叠加分析 if (dt11.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未进行建筑物叠加分析")); } DataTable dt12 = DB.IbatisHelper.ExecuteQueryForDataTable("GetWater_overlayState", null); // Ibatis 数据访问,判断用户是否做了叠加分析 if (dt12.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未进行水面叠加分析")); } DataTable dt13 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrass_overlayState", null); // Ibatis 数据访问,判断用户是否做了叠加分析 if (dt13.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未进行草地叠加分析")); } DataTable dt23 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClustertoDBState", null); // Ibatis 数据访问,判断用户是否做了聚类分析,做了则删除它 if (dt23.Rows[0][0].ToString() == "1") //做了聚类分析 { try //更新加速场景表,前提条件表 { IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoClustertoDB", null); IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null); IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridSceneDuetoClustertoDB", null); } catch (Exception ex) { return(new Result(false, ex.ToString())); } } try { string xmlpath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "cluster.xml";//xml文件位置 //读xml文件获取参数 XDocument document = XDocument.Load(xmlpath); XElement root = document.Root; XElement ele = root.Element("parameter"); XElement para = ele.Element("range"); int range = Convert.ToInt32(para.Value.ToString()); //每次栅格扩展的个数,为了避免扩张时出现空隙,range为奇数 para = ele.Element("threshold"); double threshold = Convert.ToDouble(para.Value.ToString()); //簇的密度阈值 para = ele.Element("area"); int area = Convert.ToInt32(para.Value.ToString()); //簇最小的栅格数量 para = ele.Element("building_threshold"); double building_threshold = Convert.ToDouble(para.Value.ToString()); //建筑物栅格密度阈值 para = ele.Element("buildingseed_threshold"); double buildingseed_threshold = Convert.ToDouble(para.Value.ToString()); //建筑物扩展种子栅格密度阈值 para = ele.Element("buildingheight_threshold"); double buildingheight_threshold = Convert.ToDouble(para.Value.ToString()); //建筑物栅格向外扩展高度阈值 para = ele.Element("water_threshold"); double water_threshold = Convert.ToDouble(para.Value.ToString()); //水面栅格密度阈值 para = ele.Element("waterseed_threshold"); double waterseed_threshold = Convert.ToDouble(para.Value.ToString()); //水面扩展种子栅格密度阈值 para = ele.Element("grass_threshold"); double grass_threshold = Convert.ToDouble(para.Value.ToString()); //草地栅格密度阈值 para = ele.Element("grassseed_threshold"); double grassseed_threshold = Convert.ToDouble(para.Value.ToString()); //草地扩展种子栅格密度阈值 DataTable dt1; try { dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetRange", null); // Ibatis 数据访问,得到目标区域范围 } catch (Exception ex11) { return(new Result(false, "11111" + ex11.ToString())); } string minx_text = dt1.Rows[0][0].ToString(), miny_text = dt1.Rows[0][1].ToString(), maxx_text = dt1.Rows[0][2].ToString(), maxy_text = dt1.Rows[0][3].ToString(), gridsize_text = dt1.Rows[0][4].ToString(); double minx = double.Parse(minx_text);//最大最小大地坐标 double miny = double.Parse(miny_text); double maxx = double.Parse(maxx_text); double maxy = double.Parse(maxy_text); double cellsize = double.Parse(gridsize_text);//栅格边长 int ilength = (int)((maxy - miny) / cellsize), jlength = (int)((maxx - minx) / cellsize); int xmax = ilength - 1, ymax = jlength - 1; //xmax是i的上界,ymax是j的上界 short[,] a = new short[ilength, jlength]; //目标区域矩阵 short[,] b = new short[ilength, jlength]; //结果数据 short[,] tmp = new short[ilength, jlength]; //临时存放矩阵 int[,] c = new int[ilength, jlength]; //序号矩阵 int[,] bseed = new int[900000, 2]; //建筑物种子 int[,] wseed = new int[900000, 2]; //水面种子 int[,] gseed = new int[900000, 2]; //草地种子 int k = range / 2; //栅格范围 int[] sernum = new int[100000]; //序号的有效性,0可用,1不可用,从1开始 HashSet <int> meetcluster = new HashSet <int>(); int[] x = new int[4] { 0, 0, 1, -1 }; //x的增量,用于小面积去除 int[] y = new int[4] { 1, -1, 0, 0 }; //y的增量,用于小面积去除 int i, j, num, seednum = 0, seednum1 = 0, seednum2 = 0; double ratio; for (i = 0; i <= xmax; i++) { for (j = 0; j <= ymax; j++) { a[i, j] = 0; b[i, j] = 0; tmp[i, j] = 0; c[i, j] = 0; } } for (i = 0; i < 100000; i++) { sernum[i] = 0; } int pre, next; //a[pre,next] DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingRatio", null); // Ibatis 数据访问,找出建筑物栅格放入数组a for (i = 0; i < dt2.Rows.Count; i++) { pre = Convert.ToInt32(dt2.Rows[i][1].ToString()); next = Convert.ToInt32(dt2.Rows[i][0].ToString()); ratio = Convert.ToDouble(dt2.Rows[i][2].ToString()); if (ratio > building_threshold)//建筑物栅格密度阈值 { a[pre, next] = 1; } if (seednum == 0 && ratio > buildingseed_threshold)//建筑扩展种子栅格密度阈值 { bseed[seednum, 0] = pre; bseed[seednum, 1] = next; seednum++; } if (ratio > buildingseed_threshold && seednum < 900000 && seednum != 0)//控制数量 { if (!(pre >= bseed[seednum - 1, 0] - 5 && pre <= bseed[seednum - 1, 0] + 5 && next >= bseed[seednum - 1, 1] - 5 && next <= bseed[seednum - 1, 1] + 5)) { bseed[seednum, 0] = pre; bseed[seednum, 1] = next; seednum++; } } } Hashtable ht = new Hashtable();//建筑物扩展 ht["height"] = buildingheight_threshold; ht["minGXID"] = minx; ht["maxGXID"] = maxx; ht["minGYID"] = miny; ht["maxGYID"] = maxy; DataTable dt3 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingHeight", ht); // Ibatis 数据访问 string s; int error = 0; HashSet <string> h = new HashSet <string>(); Queue <string> q = new Queue <string>(); for (i = 0; i < dt3.Rows.Count; i++) { next = Convert.ToInt32((Convert.ToDouble(dt3.Rows[i][1].ToString()) - minx) / cellsize); pre = Convert.ToInt32((Convert.ToDouble(dt3.Rows[i][2].ToString()) - miny) / cellsize); s = pre.ToString() + "," + next.ToString(); q.Enqueue(s); int sem = 1; while (q.Count != 0) { s = q.Dequeue(); sem--; string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase); pre = Convert.ToInt32(sArray[0].ToString()); next = Convert.ToInt32(sArray[1].ToString()); if (!h.Contains(s) && isedge1(pre, next, xmax, ymax, a) && a[pre, next] == 1) { h.Add(s); } if (a[pre, next] == 1)//上下8个点,x上界是j的上界ymax { s = (pre - 1).ToString() + "," + (next + 1).ToString(); if (pre - 1 >= 0 && next + 1 <= ymax && a[pre - 1, next + 1] == 1 && isedge1(pre - 1, next + 1, xmax, ymax, a) && !h.Contains(s))//不越界+是建筑物+是边界点+不在hashset中 { q.Enqueue(s); sem++; } s = (pre).ToString() + "," + (next + 1).ToString(); if (next + 1 <= ymax && a[pre, next + 1] == 1 && isedge1(pre, next + 1, xmax, ymax, a) && !h.Contains(s)) { q.Enqueue(s); sem++; } s = (pre + 1).ToString() + "," + (next + 1).ToString(); if (pre + 1 <= xmax && next + 1 <= ymax && a[pre + 1, next + 1] == 1 && isedge1(pre + 1, next + 1, xmax, ymax, a) && !h.Contains(s)) { q.Enqueue(s); sem++; } s = (pre + 1).ToString() + "," + (next).ToString(); if (pre + 1 <= xmax && a[pre + 1, next] == 1 && isedge1(pre + 1, next, xmax, ymax, a) && !h.Contains(s)) { q.Enqueue(s); sem++; } s = (pre + 1).ToString() + "," + (next - 1).ToString(); if (pre + 1 <= xmax && next - 1 >= 0 && a[pre + 1, next - 1] == 1 && isedge1(pre + 1, next - 1, xmax, ymax, a) && !h.Contains(s)) { q.Enqueue(s); sem++; } s = (pre).ToString() + "," + (next - 1).ToString(); if (next - 1 >= 0 && a[pre, next - 1] == 1 && isedge1(pre, next - 1, xmax, ymax, a) && !h.Contains(s)) { q.Enqueue(s); sem++; } s = (pre - 1).ToString() + "," + (next - 1).ToString(); if (pre - 1 >= 0 && next - 1 >= 0 && a[pre - 1, next - 1] == 1 && isedge1(pre - 1, next - 1, xmax, ymax, a) && !h.Contains(s)) { q.Enqueue(s); sem++; } s = (pre - 1).ToString() + "," + (next).ToString(); if (pre - 1 >= 0 && a[pre - 1, next] == 1 && isedge1(pre - 1, next, xmax, ymax, a) && !h.Contains(s)) { q.Enqueue(s); sem++; } } else { error++; } if (q.Count > 100) { q.Clear(); break; } } foreach (var n in h) { string[] sArray = Regex.Split(n, ",", RegexOptions.IgnoreCase); pre = Convert.ToInt32(sArray[0].ToString()); next = Convert.ToInt32(sArray[1].ToString()); for (int i1 = Math.Max(0, pre - 1); i1 <= Math.Min(xmax, pre + 1); i1++) { for (int j1 = Math.Max(0, next - 1); j1 <= Math.Min(ymax, next + 1); j1++) { a[i1, j1] = 1; } } } h.Clear(); } DataTable dt4 = DB.IbatisHelper.ExecuteQueryForDataTable("GetWaterRatio", null); // Ibatis 数据访问,找出水面栅格放入数组a for (i = 0; i < dt4.Rows.Count; i++) { pre = Convert.ToInt32(dt4.Rows[i][1].ToString()); next = Convert.ToInt32(dt4.Rows[i][0].ToString()); ratio = Convert.ToDouble(dt4.Rows[i][2].ToString()); if (ratio > water_threshold)//水面栅格密度阈值 { a[pre, next] = 2; } if (ratio > waterseed_threshold && seednum1 < 900000)//水面扩展种子栅格密度阈值,且 { wseed[seednum1, 0] = pre; wseed[seednum1, 1] = next; seednum1++; } } DataTable dt5 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrassRatio", null); // Ibatis 数据访问,找出草地栅格放入数组a for (i = 0; i < dt5.Rows.Count; i++) { pre = Convert.ToInt32(dt5.Rows[i][1].ToString()); next = Convert.ToInt32(dt5.Rows[i][0].ToString()); ratio = Convert.ToDouble(dt5.Rows[i][2].ToString()); if (ratio > grass_threshold)//草地栅格密度阈值 { a[pre, next] = 3; } if (ratio > grassseed_threshold && seednum2 < 900000)//草地扩展种子栅格密度阈值 { gseed[seednum2, 0] = pre; gseed[seednum2, 1] = next; seednum2++; } } cnt++; loadInfo.cnt = cnt; loadInfo.loadUpdate(); //3种地物的聚类 for (i = 0; i < seednum; i++) { meetcluster.Clear(); vic(bseed[i, 0], bseed[i, 1], xmax, ymax, ref a, ref b, ref tmp, ref sernum, ref meetcluster, k, area, ref c, ilength, jlength, threshold); } for (i = 0; i < seednum1; i++) { meetcluster.Clear(); vic(wseed[i, 0], wseed[i, 1], xmax, ymax, ref a, ref b, ref tmp, ref sernum, ref meetcluster, k, area, ref c, ilength, jlength, threshold); } for (i = 0; i < seednum2; i++) { meetcluster.Clear(); vic(gseed[i, 0], gseed[i, 1], xmax, ymax, ref a, ref b, ref tmp, ref sernum, ref meetcluster, k, area, ref c, ilength, jlength, threshold); } cnt++; loadInfo.cnt = cnt; loadInfo.loadUpdate(); int jjj = 0; //已经标记序号的格子数 meetcluster.Clear(); //已经分配的簇号 int jj1 = 0, jj2 = 0; //jj1:聚类为空地的格子数,jj2:最大簇号 for (i = 0; i <= xmax; i++) { for (j = 0; j <= ymax; j++) { if (c[i, j] != 0) { jjj++; } if (tmp[i, j] != 0) { jj1++; } if (c[i, j] > jj2) { jj2 = c[i, j]; } if (c[i, j] != 0 && !meetcluster.Contains(c[i, j])) { meetcluster.Add(c[i, j]); } } } int nextclunum = jj2 + 1; short[,] vis = new short[ilength, jlength]; //标记是否访问过 short[,] vis1 = new short[ilength, jlength]; int gnum = 0; //空地个数 short firstmeetscene = 0; int firstmeetid = 0, firstmeetsem = 0; for (i = 0; i <= xmax; i++) { for (j = 0; j <= ymax; j++) { vis[i, j] = 0; vis1[i, j] = 0; } } for (i = 0; i <= xmax; i++) { for (j = 0; j <= ymax; j++) { if (c[i, j] == 0 && tmp[i, j] == 0) { firstmeetsem = 0; s = ""; gnum = 1; int count = 0; int i1, j1; Queue <string> q1 = new Queue <string>(); s = i.ToString() + "," + j.ToString(); q1.Enqueue(s); count++; vis1[i, j] = 1; while (q1.Count != 0) { s = q1.Dequeue(); count--; string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase); i1 = Convert.ToInt32(sArray[0].ToString()); j1 = Convert.ToInt32(sArray[1].ToString()); // c[i1, j1] = nextclunum; int newx, newy; for (int i11 = 0; i11 < 4; i11++) //该位置的相邻的4个元素 { newx = i1 + x[i11]; newy = j1 + y[i11]; if (newx < 0 || newx > xmax || newy < 0 || newy > ymax) { continue; //越界的坐标,直接跳过 } if (firstmeetsem == 0 && vis1[newx, newy] == 0 && c[newx, newy] != 0) //碰到的第一个簇 { firstmeetscene = tmp[newx, newy]; firstmeetid = c[newx, newy]; firstmeetsem = 1; } if (vis1[newx, newy] == 0 && c[newx, newy] == 0) //没有被访问且该元素值为1 { s = newx.ToString() + "," + newy.ToString(); q1.Enqueue(s); count++; vis1[newx, newy] = 1; gnum++; } } if (gnum >= area) { break; } } if (gnum >= area) { s = ""; int gcount = 0; int gi1, gj1; Queue <string> gq1 = new Queue <string>(); s = i.ToString() + "," + j.ToString(); gq1.Enqueue(s); gcount++; vis[i, j] = 1; while (gq1.Count != 0) { s = gq1.Dequeue(); gcount--; string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase); gi1 = Convert.ToInt32(sArray[0].ToString()); gj1 = Convert.ToInt32(sArray[1].ToString()); c[gi1, gj1] = nextclunum; int newx, newy; for (int i11 = 0; i11 < 4; i11++) //该位置的相邻的4个元素 { newx = gi1 + x[i11]; newy = gj1 + y[i11]; if (newx < 0 || newx > xmax || newy < 0 || newy > ymax) { continue; //越界的坐标,直接跳过 } if (vis[newx, newy] == 0 && c[newx, newy] == 0) //没有被访问且该元素值为1 { s = newx.ToString() + "," + newy.ToString(); gq1.Enqueue(s); gcount++; vis[newx, newy] = 1; } } } nextclunum++; } else { s = ""; int pcount = 0; int pi1, pj1; Queue <string> pq1 = new Queue <string>(); s = i.ToString() + "," + j.ToString(); pq1.Enqueue(s); pcount++; vis[i, j] = 1; while (pq1.Count != 0) { s = pq1.Dequeue(); pcount--; string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase); pi1 = Convert.ToInt32(sArray[0].ToString()); pj1 = Convert.ToInt32(sArray[1].ToString()); c[pi1, pj1] = firstmeetid; tmp[pi1, pj1] = firstmeetscene; int newx, newy; for (int i11 = 0; i11 < 4; i11++) //该位置的相邻的4个元素 { newx = pi1 + x[i11]; newy = pj1 + y[i11]; if (newx < 0 || newx > xmax || newy < 0 || newy > ymax) { continue; //越界的坐标,直接跳过 } if (vis[newx, newy] == 0 && c[newx, newy] == 0) //没有被访问且该元素值为1 { s = newx.ToString() + "," + newy.ToString(); pq1.Enqueue(s); pcount++; vis[newx, newy] = 1; } } } } } } } //制作字典 int rownumber = xmax + 1, columnnumber = ymax + 1; Dictionary <int, int> myDictionary = new Dictionary <int, int>(); for (i = 0; i < rownumber; i++) { for (j = 0; j < columnnumber; j++) { int gridID = i * columnnumber + j; myDictionary.Add(gridID, tmp[i, j]); } } try//批量更新 { DataTable dt = new DataTable(); dt.Columns.Add("x", Type.GetType("System.Int32")); dt.Columns.Add("y", Type.GetType("System.Int32")); dt.Columns.Add("scene", Type.GetType("System.Byte")); dt.Columns.Add("clusterid", Type.GetType("System.Int32")); foreach (var item in myDictionary.Keys) { dt.Rows.Add(new object[] { (item % (ymax + 1)).ToString(), (item / (ymax + 1)).ToString(), myDictionary[item].ToString(), c[item / columnnumber, item % columnnumber].ToString() }); if (dt.Rows.Count > 100000) { using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString)) { bcp.BatchSize = dt.Rows.Count; bcp.BulkCopyTimeout = 1000; bcp.DestinationTableName = "tbAccelerateGridSceneTmpCluster"; bcp.WriteToServer(dt); bcp.Close(); } dt.Clear(); IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridClusterByTmp", null); IbatisHelper.ExecuteDelete("DeletetbAccelerateGridSceneTmpCluster", null); } } using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString)) { bcp.BatchSize = dt.Rows.Count; bcp.BulkCopyTimeout = 1000; bcp.DestinationTableName = "tbAccelerateGridSceneTmpCluster"; bcp.WriteToServer(dt); bcp.Close(); } dt.Clear(); IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridClusterByTmp", null); IbatisHelper.ExecuteDelete("DeletetbAccelerateGridSceneTmpCluster", null); } catch (Exception ex2) { return(new Result(false, ex2.ToString())); } //更新tbDependTabled的ClustertoDB IbatisHelper.ExecuteUpdate("UpdatetbDependTableClustertoDB", null); cnt++; loadInfo.cnt = cnt; loadInfo.loadUpdate(); return(new Result(true, "场景划分完成")); } catch (Exception ex) { return(new Result(false, ex.ToString())); } }
public Result overlaybuilding() { DataTable dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetShpState", null); // Ibatis 数据访问,判断用户是否做了渔网生成 if (dt1.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未进行渔网生成")); } // else // { return new Result(true, "用户未进行渔网生成"); } DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuilding_overlayState", null); // Ibatis 数据访问,判断用户是否做了建筑物叠加分析,做了则删除它 if (dt2.Rows[0][0].ToString() == "1") //存在建筑物叠加图层 { /* * string[] de = new string[2];//聚类图层,建筑物叠加图层 * * DataTable dt3 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingOverlayPosition", null); // Ibatis 数据访问,得到建筑物叠加图层文件位置 * de[0] = dt3.Rows[0][0].ToString(); * * DataTable dt4 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterPosition", null); // Ibatis 数据访问,得到聚类图层文件位置 * de[1] = dt4.Rows[0][0].ToString(); * * string filepath; * * filepath = de[0];//删除建筑物叠加图层 * try * { * // File.Delete(filepath); * string fileName = System.IO.Path.GetFileName(filepath); * string[] a = fileName.Split('.'); * string name = a[0]; * string b = "\\" + name + ".shp"; * filepath = filepath.Replace(b, ""); * DirectoryInfo Folder = new DirectoryInfo(filepath); * foreach (FileInfo file in Folder.GetFiles()) * { * if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.'))) * { * file.Delete(); * } * } * } * catch (Exception ex) * { * return new Result(false, ex.ToString()); * } * * * filepath = de[1];//删除聚类图层 * try * { * // File.Delete(filepath); * string fileName = System.IO.Path.GetFileName(filepath); * string[] a = fileName.Split('.'); * string name = a[0]; * string b = "\\" + name + ".shp"; * filepath = filepath.Replace(b, ""); * DirectoryInfo Folder = new DirectoryInfo(filepath); * foreach (FileInfo file in Folder.GetFiles()) * { * if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.'))) * { * file.Delete(); * } * } * name = name + "_label"; * foreach (FileInfo file in Folder.GetFiles()) * { * if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.'))) * { * file.Delete(); * } * } * } * catch (Exception ex) * { * return new Result(false, ex.ToString()); * }*/ try//更新加速场景表,前提条件表 { IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoBuilding_overlay", null); IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null); IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridSceneDuetoBuilding_overlay", null); } catch (Exception ex) { return(new Result(false, ex.ToString())); } } try { GisClient.Result res = GisClient.ServiceApi.getGisLayerService().overlaybuilding(); if (res.Ok) { //更新tbDependTabled的Building_overlay IbatisHelper.ExecuteUpdate("UpdatetbDependTableBuilding_overlay", null); return(new Result(true, res.Msg)); } else { return(new Result(false, res.Msg)); } } catch (Exception e) { return(new Result(false, "远程调用失败" + e)); } finally { ServiceApi.CloseConn(); } }
// 虚拟路测场强填写 public static void DTStrength() { // 读取原始路测 DataTable tb1 = IbatisHelper.ExecuteQueryForDataTable("getDT1", null); int n = tb1.Rows.Count; List <DT> tbDT = new List <DT>(); for (int i = 0; i < tb1.Rows.Count; i++) { DT dt = new DT(); dt.id = Convert.ToInt32(tb1.Rows[i]["id"].ToString()); dt.roadID = Convert.ToInt32(tb1.Rows[i]["roadID"].ToString()); dt.ci = Convert.ToInt32(tb1.Rows[i]["ci"].ToString()); //dt.longitude = Convert.ToDouble(tb1.Rows[i]["longtitude"].ToString()); //dt.latitude = Convert.ToDouble(tb1.Rows[i]["latitude"].ToString()); dt.x = Convert.ToDouble(tb1.Rows[i]["x"].ToString()); dt.y = Convert.ToDouble(tb1.Rows[i]["y"].ToString()); tbDT.Add(dt); } // 得到网格编号,写入数据库 System.Data.DataTable tb = new System.Data.DataTable(); tb.Columns.Add("id"); tb.Columns.Add("dateTime"); tb.Columns.Add("GXID"); tb.Columns.Add("GYID"); tb.Columns.Add("ci"); tb.Columns.Add("RoadID"); tb.Columns.Add("x"); tb.Columns.Add("y"); tb.Columns.Add("longtitude"); tb.Columns.Add("latitude"); tb.Columns.Add("RecePowerDbm"); int xid = 0, yid = 0; for (int i = 0; i < tbDT.Count; i++) { GridHelper.getInstance().XYToGGrid(tbDT[i].x, tbDT[i].y, ref xid, ref yid); // 网格编号 //IPoint p = new PointClass(); Geometric.Point p = new Geometric.Point(); p.X = tbDT[i].x; p.Y = tbDT[i].y; p.Z = 0; LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(p); DateTime dt = DateTime.Now; System.Data.DataRow thisrow = tb.NewRow(); thisrow["id"] = tbDT[i].id; thisrow["dateTime"] = dt.ToLocalTime().ToString(); thisrow["GXID"] = xid; thisrow["GYID"] = yid; thisrow["ci"] = tbDT[i].ci; thisrow["RoadID"] = tbDT[i].roadID; thisrow["x"] = tbDT[i].x; thisrow["y"] = tbDT[i].y; thisrow["longtitude"] = Math.Round(p.X, 6); thisrow["latitude"] = Math.Round(p.Y, 6); thisrow["RecePowerDbm"] = 0; tb.Rows.Add(thisrow); } // 删除原始路测 IbatisHelper.ExecuteDelete("DeleteDT", null); using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString)) { bcp.BatchSize = tb.Rows.Count; bcp.BulkCopyTimeout = 1000; bcp.DestinationTableName = "tbDT"; bcp.WriteToServer(tb); bcp.Close(); } tb.Clear(); // 得到网格对应的路测数据 IbatisHelper.ExecuteUpdate("UpdateDT1", null); IbatisHelper.ExecuteUpdate("UpdateDT2", null); }
public Result makeFishnet() { DataTable dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGridRangeState", null); // Ibatis 数据访问,判断用户是否提供了网格范围 if (dt1.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未提供区域范围")); } // else // { return new Result(true, "用户提供区域范围"); } DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetShpState", null); // Ibatis 数据访问,判断用户是否做了渔网图层,做了则删除它 if (dt2.Rows[0][0].ToString() == "1") //存在渔网图层 { /* * string[] de = new string[5];//聚类图层,建筑物叠加图层,水面叠加图层,草地叠加图层,渔网图层及label图层 * DataTable dt3 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrassOverlayPosition", null); // Ibatis 数据访问,得到草地叠加图层文件位置 * de[0] = dt3.Rows[0][0].ToString(); * * DataTable dt4 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingOverlayPosition", null); // Ibatis 数据访问,得到建筑物叠加图层文件位置 * de[1] = dt4.Rows[0][0].ToString(); * * DataTable dt5 = DB.IbatisHelper.ExecuteQueryForDataTable("GetWaterOverlayPosition", null); // Ibatis 数据访问,得到水面叠加图层文件位置 * de[2] = dt5.Rows[0][0].ToString(); * * DataTable dt6 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterPosition", null); // Ibatis 数据访问,得到聚类图层文件位置 * de[3] = dt6.Rows[0][0].ToString(); * * DataTable dt7 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetPosition", null); // Ibatis 数据访问,得到渔网图层文件位置 * de[4] = dt7.Rows[0][0].ToString(); * * string filepath; * for(int i=0;i<3;i++)//删除建筑物叠加图层,水面叠加图层,草地叠加图层 * { * filepath = de[i]; * try * { * // File.Delete(filepath); * string fileName = System.IO.Path.GetFileName(filepath); * string[] a = fileName.Split('.'); * string name = a[0]; * string b = "\\" + name + ".shp"; * filepath = filepath.Replace(b, ""); * DirectoryInfo Folder = new DirectoryInfo(filepath); * foreach (FileInfo file in Folder.GetFiles()) * { * if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name+".shp"== file.Name.Substring(0, file.Name.LastIndexOf('.'))) * { * file.Delete(); * } * } * } * catch (Exception ex) * { * return new Result(false, ex.ToString()); * } * } * for (int i=3;i<5;i++) * { * filepath = de[i];//删除聚类图层,渔网图层及label图层 * try * { * // File.Delete(filepath); * string fileName = System.IO.Path.GetFileName(filepath); * string[] a = fileName.Split('.'); * string name = a[0]; * string b = "\\" + name + ".shp"; * filepath = filepath.Replace(b, ""); * DirectoryInfo Folder = new DirectoryInfo(filepath); * foreach (FileInfo file in Folder.GetFiles()) * { * if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.'))) * { * file.Delete(); * } * } * name = name + "_label"; * foreach (FileInfo file in Folder.GetFiles()) * { * if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.'))) * { * file.Delete(); * } * } * } * catch (Exception ex) * { * return new Result(false, ex.ToString()); * } * }*/ try//删除加速场景表,重置前提条件表 { IbatisHelper.ExecuteDelete("DeleteFishnet", null); IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null); IbatisHelper.ExecuteUpdate("UpdatetbDependTableDuetoFishnet", null); } catch (Exception ex) { return(new Result(false, ex.ToString())); } } try { GisClient.Result res = GisClient.ServiceApi.getGisLayerService().makeFishnet(); if (res.Ok) { //更新tbDependTabled的FishnetShp IbatisHelper.ExecuteUpdate("UpdatetbDependTableFishnetShp", null); return(new Result(true, res.Msg)); } else { return(new Result(false, res.Msg)); } } catch (Exception e) { return(new Result(false, "远程调用失败" + e)); } finally { ServiceApi.CloseConn(); } }
public Result AdjCoefficient() { int cnt = 0; //初始化进度信息 LoadInfo loadInfo = new LoadInfo(); loadInfo.count = 1; loadInfo.loadCreate(); DataTable dt11 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterShpState", null); // Ibatis 数据访问,判断用户是否做了图层生成 if (dt11.Rows[0][0].ToString() == "0") { return(new Result(false, "用户未进行图层生成")); } DataTable dt23 = DB.IbatisHelper.ExecuteQueryForDataTable("GetAdjcoefficienttoDBState", null); // Ibatis 数据访问,判断用户是否做了矫正系数,做了则删除它 if (dt23.Rows[0][0].ToString() == "1") //做了矫正系数 { try //更新矫正系数表,前提条件表 { IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null); IbatisHelper.ExecuteUpdate("UpdatetbDependTableDuetoAdjcoefficienttoDB", null); } catch (Exception ex) { return(new Result(false, ex.ToString())); } } string xmlpath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "coefficient.xml";//xml文件位置 //读xml文件获取参数 XDocument document = XDocument.Load(xmlpath); XElement root = document.Root; XElement ele = root.Element("parameter"); double DirectCoefficient_Scene0, ReflectCoefficientA_Scene0, ReflectCoefficientB_Scene0, ReflectCoefficientC_Scene0, DiffracteCoefficientA_Scene0, DiffracteCoefficientB_Scene0, DiffracteCoefficientC_Scene0; double DirectCoefficient_Scene1, ReflectCoefficientA_Scene1, ReflectCoefficientB_Scene1, ReflectCoefficientC_Scene1, DiffracteCoefficientA_Scene1, DiffracteCoefficientB_Scene1, DiffracteCoefficientC_Scene1; double DirectCoefficient_Scene2, ReflectCoefficientA_Scene2, ReflectCoefficientB_Scene2, ReflectCoefficientC_Scene2, DiffracteCoefficientA_Scene2, DiffracteCoefficientB_Scene2, DiffracteCoefficientC_Scene2; double DirectCoefficient_Scene3, ReflectCoefficientA_Scene3, ReflectCoefficientB_Scene3, ReflectCoefficientC_Scene3, DiffracteCoefficientA_Scene3, DiffracteCoefficientB_Scene3, DiffracteCoefficientC_Scene3; //scene0 XElement para = ele.Element("DirectCoefficient_Scene0"); DirectCoefficient_Scene0 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientA_Scene0"); ReflectCoefficientA_Scene0 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientB_Scene0"); ReflectCoefficientB_Scene0 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientC_Scene0"); ReflectCoefficientC_Scene0 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientA_Scene0"); DiffracteCoefficientA_Scene0 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientB_Scene0"); DiffracteCoefficientB_Scene0 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientC_Scene0"); DiffracteCoefficientC_Scene0 = Convert.ToDouble(para.Value.ToString()); //scene1 para = ele.Element("DirectCoefficient_Scene1"); DirectCoefficient_Scene1 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientA_Scene1"); ReflectCoefficientA_Scene1 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientB_Scene1"); ReflectCoefficientB_Scene1 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientC_Scene1"); ReflectCoefficientC_Scene1 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientA_Scene1"); DiffracteCoefficientA_Scene1 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientB_Scene1"); DiffracteCoefficientB_Scene1 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientC_Scene1"); DiffracteCoefficientC_Scene1 = Convert.ToDouble(para.Value.ToString()); //scene2 para = ele.Element("DirectCoefficient_Scene2"); DirectCoefficient_Scene2 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientA_Scene2"); ReflectCoefficientA_Scene2 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientB_Scene2"); ReflectCoefficientB_Scene2 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientC_Scene2"); ReflectCoefficientC_Scene2 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientA_Scene2"); DiffracteCoefficientA_Scene2 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientB_Scene2"); DiffracteCoefficientB_Scene2 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientC_Scene2"); DiffracteCoefficientC_Scene2 = Convert.ToDouble(para.Value.ToString()); //scene3 para = ele.Element("DirectCoefficient_Scene3"); DirectCoefficient_Scene3 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientA_Scene3"); ReflectCoefficientA_Scene3 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientB_Scene3"); ReflectCoefficientB_Scene3 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("ReflectCoefficientC_Scene3"); ReflectCoefficientC_Scene3 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientA_Scene3"); DiffracteCoefficientA_Scene3 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientB_Scene3"); DiffracteCoefficientB_Scene3 = Convert.ToDouble(para.Value.ToString()); para = ele.Element("DiffracteCoefficientC_Scene3"); DiffracteCoefficientC_Scene3 = Convert.ToDouble(para.Value.ToString()); DataTable dt = new DataTable();//入库 dt.Columns.Add("scene", Type.GetType("System.Byte")); dt.Columns.Add("DirectCoefficient", Type.GetType("System.Double")); dt.Columns.Add("ReflectCoefficientA", Type.GetType("System.Double")); dt.Columns.Add("ReflectCoefficientB", Type.GetType("System.Double")); dt.Columns.Add("ReflectCoefficientC", Type.GetType("System.Double")); dt.Columns.Add("DiffracteCoefficientA", Type.GetType("System.Double")); dt.Columns.Add("DiffracteCoefficientB", Type.GetType("System.Double")); dt.Columns.Add("DiffracteCoefficientC", Type.GetType("System.Double")); dt.Rows.Add(new object[] { "0", DirectCoefficient_Scene0.ToString(), ReflectCoefficientA_Scene0.ToString(), ReflectCoefficientB_Scene0.ToString(), ReflectCoefficientC_Scene0.ToString(), DiffracteCoefficientA_Scene0.ToString(), DiffracteCoefficientB_Scene0.ToString(), DiffracteCoefficientC_Scene0.ToString() }); dt.Rows.Add(new object[] { "1", DirectCoefficient_Scene1.ToString(), ReflectCoefficientA_Scene1.ToString(), ReflectCoefficientB_Scene1.ToString(), ReflectCoefficientC_Scene1.ToString(), DiffracteCoefficientA_Scene1.ToString(), DiffracteCoefficientB_Scene1.ToString(), DiffracteCoefficientC_Scene1.ToString() }); dt.Rows.Add(new object[] { "2", DirectCoefficient_Scene2.ToString(), ReflectCoefficientA_Scene2.ToString(), ReflectCoefficientB_Scene2.ToString(), ReflectCoefficientC_Scene2.ToString(), DiffracteCoefficientA_Scene2.ToString(), DiffracteCoefficientB_Scene2.ToString(), DiffracteCoefficientC_Scene2.ToString() }); dt.Rows.Add(new object[] { "3", DirectCoefficient_Scene3.ToString(), ReflectCoefficientA_Scene3.ToString(), ReflectCoefficientB_Scene3.ToString(), ReflectCoefficientC_Scene3.ToString(), DiffracteCoefficientA_Scene3.ToString(), DiffracteCoefficientB_Scene3.ToString(), DiffracteCoefficientC_Scene3.ToString() }); try { using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString)) { bcp.BatchSize = dt.Rows.Count; bcp.BulkCopyTimeout = 1000; bcp.DestinationTableName = "tbAdjtest"; bcp.WriteToServer(dt); bcp.Close(); } IbatisHelper.ExecuteDelete("UpdatetbDependTableAdjcoefficienttoDB", null); cnt++; loadInfo.cnt = cnt; loadInfo.loadUpdate(); return(new Result(true, "成功")); } catch (Exception e) { return(new Result(false, "失败")); } }