/// <summary> /// 获取完整的园区初始化xml /// </summary> /// <param name="floor"></param> /// <param name="parkName"></param> /// <returns></returns> public static InitInfo CreateParkInitInfoByFloors(string parkName, string buildingName, params TopoInfo[] floors) { InitInfo initInfo = new InitInfo(); TopoInfo root = new TopoInfo("根节点", AreaTypes.区域); initInfo.TopoInfo = root; TopoInfo park = new TopoInfo(parkName, AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置 root.AddChild(park); TopoInfo group = new TopoInfo("生产区域", AreaTypes.分组);//todo:可以扩展成园区、大楼手动设置 park.AddChild(group); TopoInfo building = CreateBuildingInitInfoByFloors(buildingName, floors); group.AddChild(building); BoundInfo parkBound = building.BoundInfo.CloneByXml(); parkBound.SetRectangle(); parkBound.Scale(2);//园区默认是比大楼周围一圈 park.BoundInfo = parkBound; park.BoundInfo.IsRelative = false; return(initInfo); }
/// <summary> /// 获取完整的园区初始化xml /// </summary> /// <param name="floor"></param> /// <param name="parkName"></param> /// <returns></returns> public static TopoInfo CreateBuildingInitInfoByFloors(string buildingName, params TopoInfo[] floors) { TopoInfo building = new TopoInfo(buildingName, AreaTypes.大楼); //park.AddChild(building); if (floors.Length > 0) { TopoInfo firstFloor = null; foreach (var floor in floors) { if (firstFloor == null) { firstFloor = floor; } building.AddChild(floor); } BoundInfo buildBound = firstFloor.BoundInfo.CloneByXml(); buildBound.SetRectangle(); //比例调整 buildBound.Scale(1.05f); //比例调整 building.BoundInfo = buildBound; //大楼默认和楼层一致 building.BoundInfo.IsRelative = false; //BoundInfo parkBound = building.BoundInfo.CloneByXml(); //parkBound.SetRectangle(); //parkBound.Scale(2);//园区默认是比大楼周围一圈 //park.BoundInfo = parkBound; } return(building); }
private static InitInfo CreateInitInfo(TopoInfo floor, string parkName) { InitInfo initInfo = new InitInfo(); TopoInfo root = new TopoInfo("根节点", AreaTypes.区域); initInfo.TopoInfo = root; TopoInfo park = new TopoInfo(parkName, AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置 root.AddChild(park); //TopoInfo group = new TopoInfo("分组1", AreaTypes.分组); //park.AddChild(group); TopoInfo building = new TopoInfo("大楼1", AreaTypes.大楼); park.AddChild(building); building.AddChild(floor); BoundInfo buildBound = floor.BoundInfo.CloneByXml(); buildBound.SetRectangle(); //比例调整 buildBound.Scale(1.05f); //比例调整 building.BoundInfo = buildBound; //大楼默认和楼层一致 BoundInfo parkBound = building.BoundInfo.CloneByXml(); parkBound.SetRectangle(); parkBound.Scale(2);//园区默认是比大楼周围一圈 park.BoundInfo = parkBound; return(initInfo); }
private void InitTopoChildren(PhysicalTopology root, TopoInfo topoInfo) { foreach (TopoInfo childInfo in topoInfo.Children) { PhysicalTopology childNode = AddTopoNode(childInfo.Name, childInfo.KKS, root, childInfo.Type); SetInitBound(childInfo.BoundInfo, childNode); InitTopoChildren(childNode, childInfo); } }
public void IsGeoTiff_Test() { // Opens a GeoTiff with elevation data. IsGeoTiff should return true. Then opens Tiff with color RGB values. IsGeoTiff should return false string goodTiffName = testingFolder + "Findlay Topo.tif"; string badTiffName = testingFolder + "DEM JM.tif"; TopoInfo topo = new TopoInfo(); Check_class check = new Check_class(); GdalConfiguration.ConfigureGdal(); Gdal.AllRegister(); Dataset GDAL_obj; // Test function with GeoTiff file try { GDAL_obj = Gdal.Open(goodTiffName, Access.GA_ReadOnly); } catch { return; } int width = GDAL_obj.RasterXSize; int height = GDAL_obj.RasterYSize; Band GD_Raster = GDAL_obj.GetRasterBand(1); double[] buff = new double[width * height]; GD_Raster.ReadRaster(0, 0, width, height, buff, width, height, 0, 0); bool isGeoTiff = check.IsGeoTIFF(buff); Assert.AreSame(true, isGeoTiff); // Test function with a TIF (color RGB) file try { GDAL_obj = Gdal.Open(goodTiffName, Access.GA_ReadOnly); } catch { return; } width = GDAL_obj.RasterXSize; height = GDAL_obj.RasterYSize; GD_Raster = GDAL_obj.GetRasterBand(1); buff = new double[width * height]; GD_Raster.ReadRaster(0, 0, width, height, buff, width, height, 0, 0); isGeoTiff = check.IsGeoTIFF(buff); Assert.AreSame(false, isGeoTiff); }
public static void GetRoomsInfoEx() { DateTime start = DateTime.Now; TopoInfo floor = GetFloorInfoEx(); DateTime end = DateTime.Now; TimeSpan t = end - start; string xml = XmlSerializeHelper.GetXmlText(floor); Gui.TextReport(floor.Name + "|" + t, xml, 700, 500); }
private void InitTopoChildren(Area root, TopoInfo topoInfo, int level) { foreach (TopoInfo childInfo in topoInfo.Children) { if (level < 3) { Log.Info("InitNode:" + childInfo.Name); } var childNode = AddTopoNode(childInfo.Name, childInfo.KKS, root, childInfo.Type); SetInitBound(childInfo.BoundInfo, childNode); InitTopoChildren(childNode, childInfo, level++); } }
private static TopoInfo GetTopoInfo(string name, AreaTypes type, params PointInfo[] pis) { BoundInfo boundInfo = NewBoundInfo(); boundInfo.Points.AddRange(pis); TopoInfo topoInfo = new TopoInfo(); topoInfo.BoundInfo = boundInfo; topoInfo.Name = name; topoInfo.Type = type; return(topoInfo); }
public void InitTopo(TopoInfo topoInfo) { Log.InfoStart("InitTopo"); ClearTopoTable(); PhysicalTopology root = new PhysicalTopology() { Name = topoInfo.Name, Type = topoInfo.Type }; PhysicalTopologys.Add(root); InitTopoChildren(root, topoInfo); Log.InfoEnd("InitTopo"); }
/// <summary> Goes through each met and turbine site and check elev at 8 points +/- 12000 m. If elev = -999, return false </summary> public bool NewTopo(TopoInfo topo, MetCollection metList, TurbineCollection turbList) { bool goodToGo = true; for (int i = 0; i < metList.ThisCount; i++) { goodToGo = TopoCheck(topo, metList.metItem[i].UTMX, metList.metItem[i].UTMY, metList.metItem[i].name, true); } for (int i = 0; i < turbList.TurbineCount; i++) { goodToGo = TopoCheck(topo, turbList.turbineEsts[i].UTMX, turbList.turbineEsts[i].UTMY, turbList.turbineEsts[i].name, true); } return(goodToGo); }
public static void GetRoomInfo() { DateTime start = DateTime.Now; TopoInfo topoInfo = GetRoomEx(); DateTime end = DateTime.Now; TimeSpan t = end - start; string xml = ""; if (topoInfo != null) { xml = XmlSerializeHelper.GetXmlText(topoInfo, true); } Gui.TextReport(topoInfo.Name + "|" + t, xml, 700, 500); }
public void InitTopo(TopoInfo topoInfo) { Log.InfoStart(LogTags.DbInit, "InitTopo"); ClearTopoTable(); Area root = new Area() { Name = topoInfo.Name, Type = topoInfo.Type }; Areas.Add(root); Log.InfoStart(LogTags.DbInit, "InitTopoChildren"); InitTopoChildren(root, topoInfo, 0); Log.InfoStart(LogTags.DbInit, "InitTopoChildren"); Log.InfoEnd("InitTopo"); }
/// <summary> Checks the distance between the mets/turbines and edges of topo data to make sure they all fit within defined radii. </summary> /// <returns> Returns false if outside bounds.</returns> public bool NewTurbOrMet(TopoInfo topo, string metname, double UTMX, double UTMY, bool showMsg) { bool goodToGo = true; if (topo.gotTopo) { goodToGo = TopoCheck(topo, UTMX, UTMY, metname, showMsg); } if (topo.gotSR) { goodToGo = LandCoverCheck(topo, UTMX, UTMY, metname, showMsg); } return(goodToGo); }
private static List <TopoInfo> GetFloorList(string buildingName, int buildingFloorCount) { List <TopoInfo> floors = new List <TopoInfo>(); for (int i = 0; i < buildingFloorCount; i++) { string floorLayer = string.Format("{0}{1}楼", buildingName, (i + 1)); TopoInfo floor = GetOneFloorOpt(floorLayer);//大楼X if (floor.GetCount() > 0) { floors.Add(floor); } } return(floors); }
/// <summary> Goes through each met and turbine site and check land cover at 8 points +/- 12000 m. If elev = -999, return false </summary> public bool NewLandCover(TopoInfo topo, MetCollection metList, TurbineCollection turbList) { // Go through each met and turbine site and check land cover at 8 points +/- 12000 m. If elev = -999, return false bool goodToGo = true; for (int i = 0; i < metList.ThisCount; i++) { goodToGo = LandCoverCheck(topo, metList.metItem[i].UTMX, metList.metItem[i].UTMY, metList.metItem[i].name, true); } for (int i = 0; i < turbList.TurbineCount; i++) { goodToGo = LandCoverCheck(topo, turbList.turbineEsts[i].UTMX, turbList.turbineEsts[i].UTMY, turbList.turbineEsts[i].name, true); } return(goodToGo); }
public static TopoInfo GetFloorInfo() { roomCount = 0; TopoInfo floor = GetFloor(); string txt = ""; do { TopoInfo topoInfo = GetRoom();//一个点弄错了要从头开始 if (topoInfo == null) { break; //这里是出口 } floor.AddChild(topoInfo); }while (string.IsNullOrEmpty(txt) || txt != "n"); //while (true); return(floor); }
private static TopoInfo GetFloor() { string txt = Interaction.GetString("输入楼层名称"); if (string.IsNullOrEmpty(txt)) { txt = "楼层1"; } var p1 = Interaction.GetPoint("楼层坐标1"); PointInfo pi1 = GetPointInfo(p1); var p2 = Interaction.GetPoint("楼层坐标2"); PointInfo pi2 = GetPointInfo(p2); TopoInfo topoInfo = GetTopoInfo(txt, AreaTypes.楼层, pi1, pi2); Interaction.WriteLine(string.Format("{0} {1} {2}\n", pi1, pi2, txt)); //Interaction.WriteLine(""); return(topoInfo); }
public static TopoInfo GetFloorInfoEx() { roomCount = 0; TopoInfo floor = GetFloorEx(); //string xml1 = XmlSerializeHelper.GetXmlText(floor); //Gui.TextReport("楼层", xml1, 700, 500); string txt = ""; do { TopoInfo topoInfo = GetRoomEx();//一个点弄错了要从头开始 if (topoInfo == null) { break; //这里是出口 } floor.AddChild(topoInfo); txt = Interaction.GetString("继续?(y)"); }while (string.IsNullOrEmpty(txt) || txt != "n"); //while (true); return(floor); }
private static TopoInfo GetFloorEx() { string txt = Interaction.GetString("输入楼层名称"); if (string.IsNullOrEmpty(txt)) { txt = "楼层1"; } int pCout = 0; List <PointInfo> pis = new List <PointInfo>(); while (true) { pCout++; var p1 = Interaction.GetPoint("楼层坐标" + pCout); if (double.IsNaN(p1.X)) { if (pis.Count >= 2) { break; //出口 } else { continue; } } PointInfo pi1 = GetPointInfo(p1); pis.Add(pi1); } //var p2 = Interaction.GetPoint("楼层坐标2"); //PointInfo pi2 = GetPointInfo(p2); TopoInfo topoInfo = GetTopoInfo(txt, AreaTypes.楼层, pis); Interaction.WriteLine(string.Format("{0} {1} {2}\n", pis.First(), pis.Last(), txt)); //Interaction.WriteLine(""); return(topoInfo); }
public static void GetInitInfo() { DateTime start = DateTime.Now; string txt = Interaction.GetString("输入园区名称"); if (string.IsNullOrEmpty(txt)) { txt = "园区"; } TopoInfo floor = GetFloorInfo(); InitInfo initInfo = CreateInitInfo(floor, txt); DateTime end = DateTime.Now; TimeSpan t = end - start; string xml = XmlSerializeHelper.GetXmlText(initInfo); Gui.TextReport(floor.Name + "|" + t, xml, 700, 500); }
private static TopoInfo GetRoom() { roomCount++; var p1 = Interaction.GetPoint("房间坐标1"); if (double.IsNaN(p1.X)) { return(null); //这里是出口 } var p2 = Interaction.GetPoint("房间坐标2"); if (double.IsNaN(p2.X)) { return(null); //这里是出口 } string room = GetText(p1, p2); if (string.IsNullOrEmpty(room)) { room = Interaction.GetString("输入房间名称"); if (string.IsNullOrEmpty(room)) { room = "房间_" + roomCount; } } PointInfo pi1 = GetPointInfo(p1); PointInfo pi2 = GetPointInfo(p2); TopoInfo topoInfo = GetTopoInfo(room, AreaTypes.机房, pi1, pi2); Interaction.WriteLine(string.Format("{0} {1} {2}", pi1, pi2, room)); Interaction.WriteLine(""); //string xml = XmlSerializeHelper.GetXmlText(topoInfo); //Gui.TextReport("房间:" + txt, xml, 700, 500); return(topoInfo); }
public static void GetOneFloorWithRoot(string floorLayer, string parkName) { DateTime start = DateTime.Now; TopoInfo floor = GetOneFloorOpt(floorLayer); string xml = ""; if (!string.IsNullOrEmpty(parkName)) { InitInfo initInfo = GetRoomsCommand.CreateParkInitInfoByFloors(parkName, floorLayer, floor); xml = XmlSerializeHelper.GetXmlText(initInfo); MyTool.TextReport("获取一个楼层和园区", xml, 700, 500); } else { xml = XmlSerializeHelper.GetXmlText(floor, true); MyTool.TextReport("获取一个楼层", xml, 700, 500); } DateTime end = DateTime.Now; TimeSpan t = end - start; }
/// <summary> /// Thickness:厚度,层高 /// IsRelative="true" /// BottomHeight:离地面高度,0层为0,6.5层为:6500 /// </summary> /// <param name="name"></param> //获取楼层内的房间 //add by qclei 2020-07-10 public static void GetAllFloors(string buildingName, int buildingFloorCount, string parkName) { DateTime start = DateTime.Now; List <TopoInfo> floors = GetFloorList(buildingName, buildingFloorCount); string xml = ""; if (!string.IsNullOrEmpty(parkName)) { InitInfo initInfo = GetRoomsCommand.CreateParkInitInfoByFloors(parkName, buildingName, floors.ToArray()); xml = XmlSerializeHelper.GetXmlText(initInfo); MyTool.TextReport("获取整个大楼和园区", xml, 700, 500); } else { TopoInfo initInfo = GetRoomsCommand.CreateBuildingInitInfoByFloors(buildingName, floors.ToArray()); xml = XmlSerializeHelper.GetXmlText(initInfo, true); MyTool.TextReport("获取整个大楼", xml, 700, 500); } DateTime end = DateTime.Now; TimeSpan t = end - start; }
public bool InitTopoFromXml() { Log.InfoStart("InitTopoFromXml"); try { string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\InitInfo.xml"; if (!File.Exists(initFile)) { return(false); } InitInfo initInfo = XmlSerializeHelper.LoadFromFile <InitInfo>(initFile); TopoInfo topoInfo = initInfo.TopoInfo; InitTopo(topoInfo); Log.InfoEnd("InitTopoFromXml"); return(true); } catch (Exception ex) { Log.Error("InitTopoFromXml", ex); Log.InfoEnd("InitTopoFromXml"); return(false); } }
/// <summary> Checks land cover at 8 points +/- 12000 m from UTMX/Y. If land cover = -999 or if outside range, return false </summary> public bool LandCoverCheck(TopoInfo topo, double UTMX, double UTMY, string siteName, bool showMessage) { bool goodToGo = true; int maxDist = 12000; double X_Loc = 0; double Y_Loc = 0; int[] indices = topo.GetXYIndices("Land Cover", UTMX, UTMY, "Plot"); // Site location if (indices[0] == -888) { goodToGo = false; return(goodToGo); } // Check that there is land cover data if (indices[0] == -999 && indices[1] == -999) { goodToGo = false; if (showMessage) { MessageBox.Show("Land Cover data not loaded.", "Continuum 3"); } return(goodToGo); } for (int i = 0; i <= 8; i++) { if (i == 0) // North { X_Loc = UTMX; Y_Loc = UTMY + maxDist; } else if (i == 1) // Northeast { X_Loc = UTMX + maxDist * 0.7071; Y_Loc = UTMY + maxDist * 0.7071; } else if (i == 2) // East { X_Loc = UTMX + maxDist; Y_Loc = UTMY; } else if (i == 3) // Southeast { X_Loc = UTMX + maxDist * 0.7071; Y_Loc = UTMY - maxDist * 0.7071; } else if (i == 4) // South { X_Loc = UTMX; Y_Loc = UTMY - maxDist; } else if (i == 5) // Southwest { X_Loc = UTMX - maxDist * 0.7071; Y_Loc = UTMY - maxDist * 0.7071; } else if (i == 6) // West { X_Loc = UTMX - maxDist; Y_Loc = UTMY; } else if (i == 7) // Northwest { X_Loc = UTMX - maxDist * 0.7071; Y_Loc = UTMY + maxDist * 0.7071; } indices = topo.GetXYIndices("Land Cover", X_Loc, Y_Loc, "Plot"); if (indices[0] == -888) { goodToGo = false; return(goodToGo); } if (indices[0] < 0 || indices[0] >= topo.LC_NumXY.X.plot.num || indices[1] < 0 || indices[1] >= topo.LC_NumXY.Y.plot.num) { goodToGo = false; if (showMessage == true) { MessageBox.Show("Site: " + siteName + " is outside range of land cover data.", "Continuum 3"); } return(goodToGo); } if (topo.landCover[indices[0], indices[1]] == -999) { goodToGo = false; if (showMessage == true) { MessageBox.Show("Site: " + siteName + " is outside range of land cover data.", "Continuum 3"); } return(goodToGo); } } return(goodToGo); }
private static TopoInfo GetRoomEx() { roomCount++; int pCout = 0; List <Point3d> ps = new List <Point3d>(); List <PointInfo> pis = new List <PointInfo>(); double pMinX = double.MaxValue; double pMinY = double.MaxValue; double pMaxX = double.MinValue; double pMaxY = double.MinValue; int ibegin = 0; Point3d lineBegin = new Point3d(); while (true) { pCout++; var p1 = Interaction.GetPoint("房间坐标" + pCout); if (double.IsNaN(p1.X)) { if (pis.Count >= 2) { break; //出口 } else { continue; } } ps.Add(p1); PointInfo pi1 = GetPointInfo(p1); if (ibegin == 0) { lineBegin = p1; ibegin = 1; } else { var leftLine = Draw.Line(lineBegin, p1); lineBegin = p1; // leftLine.SetLayer("aaa"); leftLine.QOpenForWrite <Entity>(line => line.ColorIndex = 3); var arrow = Modify.Group(new[] { leftLine }); } pis.Add(pi1); if (p1.X < pMinX) { pMinX = p1.X; } if (p1.Y < pMinY) { pMinY = p1.Y; } if (p1.Y > pMaxY) { pMaxY = p1.Y; } if (p1.X > pMaxX) { pMaxX = p1.X; } } Point3d pMin = Point3d.Origin; Point3d pMax = Point3d.Origin; if (pis.Count == 2) { pMin = ps[0]; pMax = ps[1]; } else { pMin = new Point3d(pMinX, pMinY, 0); pMax = new Point3d(pMaxX, pMaxY, 0); } string room = GetText(pMin, pMax); if (string.IsNullOrEmpty(room)) { room = Interaction.GetString("输入房间名称"); if (string.IsNullOrEmpty(room)) { room = "房间_" + roomCount; } } TopoInfo topoInfo = GetTopoInfo(room, AreaTypes.机房, pis); Interaction.WriteLine(string.Format("{0} {1} {2}", pis.First(), pis.Last(), room)); Interaction.WriteLine(""); //string xml = XmlSerializeHelper.GetXmlText(topoInfo); //Gui.TextReport("房间:" + txt, xml, 700, 500); return(topoInfo); }
public void InitTopo(TopoInfo topoInfo) { db.InitTopo(topoInfo); }
private void InitTopoChildren(Area root, TopoInfo topoInfo, int level) { try { List <TopoInfo> childList1 = new List <TopoInfo>(); //没有子节点的 List <TopoInfo> childList2 = new List <TopoInfo>(); //有子节点的 for (int i = 0; i < topoInfo.Children.Count; i++) { TopoInfo childInfo = topoInfo.Children[i]; if (childInfo.Children == null || childInfo.Children.Count == 0) { childList1.Add(childInfo); } else { childList2.Add(childInfo); } //if (level <= 3) //{ // Log.Info(LogTags.DbInit, "InitNode:" + childInfo.Name); //} //else //{ //} } //List<Area> areas = new List<Area>(); //foreach (TopoInfo childInfo in childList1) //{ // var childNode = AddTopoNode(childInfo.Name, childInfo.KKS, root, childInfo.Type); // SetInitBound(childInfo.BoundInfo, childNode); //} //foreach (TopoInfo childInfo in childList2) //{ // var childNode = AddTopoNode(childInfo.Name, childInfo.KKS, root, childInfo.Type); // SetInitBound(childInfo.BoundInfo, childNode); // childInfo.Area = childNode; //} //foreach (TopoInfo childInfo in childList2) //{ // InitTopoChildren(childInfo.Area, childInfo, level++); //} for (int i = 0; i < topoInfo.Children.Count; i++) { TopoInfo childInfo = topoInfo.Children[i]; var childNode = AddTopoNode(childInfo.Name, childInfo.KKS, root, childInfo.Type); SetInitBound(childInfo.BoundInfo, childNode); childInfo.Area = childNode; Log.Info(LogTags.DbInit, string.Format("InitNode:{0}->{1}(index:{2}/count:{3})", topoInfo.Name, childInfo.Name, i, topoInfo.Children.Count)); } for (int i = 0; i < topoInfo.Children.Count; i++) { TopoInfo childInfo = topoInfo.Children[i]; InitTopoChildren(childInfo.Area, childInfo, level++); } } catch (Exception e) { Log.Error(LogTags.DbInit, "InitTopo"); } }
/// <summary> Checks if the 8 points +/- specified distance from specified UTMX/Y on specified grid (plot vs calcs) fall within bounds. /// </summary> /// <returns> Returns 100 if all points are within defined area and returns index of point outside range if all are not available. </returns> public int NewNodeCheck(TopoInfo topo, double UTMX, double UTMY, int minDist, string plotOrCalcs) { int goodToGo = 100; double X_Loc = 0; double Y_Loc = 0; int[] topoIndices = topo.GetXYIndices("Topo", UTMX, UTMY, plotOrCalcs); // topoElevs indices at site location int[] landCoverIndices = topo.GetXYIndices("Land cover", UTMX, UTMY, plotOrCalcs); // landCover indices at site location bool[] indexChecks = new bool[8]; // Check that there is topography data if (topoIndices[0] == -999 && topoIndices[1] == -999) { goodToGo = -999; return(goodToGo); } if (topo.gotSR && landCoverIndices[0] == -999 && landCoverIndices[1] == -999) { goodToGo = -999; return(goodToGo); } if (topoIndices[0] == -888) { goodToGo = -888; return(goodToGo); } if (landCoverIndices[0] == -888) { goodToGo = -888; return(goodToGo); } for (int i = 0; i < 8; i++) { indexChecks[i] = true; if (i != 1 && i != 3 && i != 5 && i != 7) // only looking at N, E, S, W { if (i == 0) // North { X_Loc = UTMX; Y_Loc = UTMY + minDist; } else if (i == 1) // Northeast { X_Loc = UTMX + minDist * 0.7071; Y_Loc = UTMY + minDist * 0.7071; } else if (i == 2) // East { X_Loc = UTMX + minDist; Y_Loc = UTMY; } else if (i == 3) // Southeast { X_Loc = UTMX + minDist * 0.7071; Y_Loc = UTMY - minDist * 0.7071; } else if (i == 4) // South { X_Loc = UTMX; Y_Loc = UTMY - minDist; } else if (i == 5) // Southwest { X_Loc = UTMX - minDist * 0.7071; Y_Loc = UTMY - minDist * 0.7071; } else if (i == 6) // West { X_Loc = UTMX - minDist; Y_Loc = UTMY; } else if (i == 7) // Northwest { X_Loc = UTMX - minDist * 0.7071; Y_Loc = UTMY + minDist * 0.7071; } topoIndices = topo.GetXYIndices("Topo", X_Loc, Y_Loc, plotOrCalcs); int numXTopo = 0; int numYTopo = 0; if (plotOrCalcs == "Plot") { numXTopo = topo.topoNumXY.X.plot.num; numYTopo = topo.topoNumXY.Y.plot.num; } else if (plotOrCalcs == "Calcs") { numXTopo = topo.topoNumXY.X.calcs.num; numYTopo = topo.topoNumXY.Y.calcs.num; } if (topoIndices[0] < 0 || topoIndices[0] >= numXTopo || topoIndices[1] < 0 || topoIndices[1] >= numYTopo) { indexChecks[i] = false; } if (indexChecks[i] == true) { if (plotOrCalcs == "Plot") { if (topo.topoElevs[topoIndices[0], topoIndices[1]] == -999) { indexChecks[i] = false; } } } if (topo.gotSR) { landCoverIndices = topo.GetXYIndices("Land cover", X_Loc, Y_Loc, plotOrCalcs); int numXLC = 0; int numYLC = 0; if (plotOrCalcs == "Plot") { numXLC = topo.LC_NumXY.X.plot.num; numYLC = topo.LC_NumXY.Y.plot.num; } else if (plotOrCalcs == "Calcs") { numXLC = topo.LC_NumXY.X.calcs.num; numYLC = topo.LC_NumXY.Y.calcs.num; } if (landCoverIndices[0] < 0 || landCoverIndices[0] >= numXLC || landCoverIndices[1] < 0 || landCoverIndices[1] >= numYLC) { indexChecks[i] = false; } if (indexChecks[i] == true) { if (plotOrCalcs == "Plot") { if (topo.landCover[landCoverIndices[0], landCoverIndices[1]] == -999) { indexChecks[i] = false; } } } } } } // Go through array of booleans to figure out which way to move location bool allFalse = true; for (int i = 0; i < 8; i++) { if (i != 1 && i != 3 && i != 5 && i != 7) // only looking at N, E, S, W { if (indexChecks[i] != true) { int oppSect = i - 4; if (oppSect < 0) { oppSect = oppSect + 8; } if (indexChecks[oppSect] == true) { return(i); } } else { allFalse = false; } } } // If false at all locations, figure out which way to move based on distance to four corners if (allFalse == true) { double distToMinXMinY = topo.CalcDistanceBetweenPoints(UTMX, UTMY, topo.topoNumXY.X.all.min, topo.topoNumXY.Y.all.min); double distToMinXMaxY = topo.CalcDistanceBetweenPoints(UTMX, UTMY, topo.topoNumXY.X.all.min, topo.topoNumXY.Y.all.max); double distToMaxXMinY = topo.CalcDistanceBetweenPoints(UTMX, UTMY, topo.topoNumXY.X.all.max, topo.topoNumXY.Y.all.min); double distToMaxXMaxY = topo.CalcDistanceBetweenPoints(UTMX, UTMY, topo.topoNumXY.X.all.max, topo.topoNumXY.Y.all.max); if (distToMinXMinY > distToMinXMaxY && distToMinXMinY > distToMaxXMinY && distToMinXMinY > distToMaxXMaxY) { goodToGo = 1; // Furthest from Min X/Y } else if (distToMinXMaxY > distToMinXMinY && distToMinXMaxY > distToMaxXMinY && distToMinXMaxY > distToMaxXMaxY) { goodToGo = 3; // Furthest from MinX and MaxY } else if (distToMaxXMinY > distToMinXMinY && distToMaxXMinY > distToMinXMaxY && distToMaxXMinY > distToMaxXMaxY) { goodToGo = 5; // Furthest from Max X/Y } else { goodToGo = 7; // Furthest from Max X and Min Y } } return(goodToGo); }
public bool InitTopoFromXml() { Log.InfoStart(LogTags.DbInit, "InitTopoFromXml"); try { string initFile = InitPaths.GetInitInfo(); if (!File.Exists(initFile)) { Log.Error("InitTopoFromXml找不到文件:" + initFile); return(false); } InitInfo initInfo = XmlSerializeHelper.LoadFromFile <InitInfo>(initFile); if (initInfo == null) { Log.Error("解析失败:" + XmlSerializeHelper.ExceptionText); } TopoInfo topoInfo = initInfo.TopoInfo; //if(!string.IsNullOrEmpty(parkName)) // for (int i = 0; i < topoInfo.Children.Count; i++) // { // var child = topoInfo.Children[i]; // if (child.Name != parkName) // { // topoInfo.Children.RemoveAt(i); // i--; // } // } var nodes = topoInfo.GetAllTopos(); foreach (TopoInfo node in nodes) { if (node.Type != AreaTypes.园区) { if (node.BoundInfo != null) { if (node.BoundInfo.Points != null) { foreach (PointInfo point in node.BoundInfo.Points) { LocationContext.Transform(point);//设置位置偏移 } } } } } foreach (TopoInfo node in nodes) { if (node.Type == AreaTypes.大楼) { if (node.IsCommon == true) { var floor1 = node.Children[0]; if (floor1.IsCommon == true) { List <TopoInfo> commonList = floor1.Children.FindAll(i => i.IsCommon); for (int i = 1; i < node.Children.Count; i++)//拷贝第一层的柱子给下面所有层 { var floor = node.Children[i]; IList <TopoInfo> cloneList = ConvertHelper.CloneObjectList(commonList); foreach (TopoInfo item in cloneList) { floor.Children.Add(item); } } } } } } InitTopo(topoInfo); Log.InfoEnd("InitTopoFromXml"); return(true); } catch (Exception ex) { Log.Error(LogTags.DbInit, "InitTopoFromXml:" + ex); Log.InfoEnd("InitTopoFromXml"); return(false); } }