diff --git a/MES_Wind/bin/Debug/MES_Wind.exe b/MES_Wind/bin/Debug/MES_Wind.exe index 8c49d82653fbb5dd15d03c3b1ffbc9462fadf205..2f3dcfa7e1360c16960fcf84090cb1cfac7d734d 100644 Binary files a/MES_Wind/bin/Debug/MES_Wind.exe and b/MES_Wind/bin/Debug/MES_Wind.exe differ diff --git a/MES_Wind/bin/Debug/MES_Wind.pdb b/MES_Wind/bin/Debug/MES_Wind.pdb index dad778f8a8b4158553be4594f0020e85203cda89..04fae3c7eb1029c9dd0ee7d57283cef1edaba979 100644 Binary files a/MES_Wind/bin/Debug/MES_Wind.pdb and b/MES_Wind/bin/Debug/MES_Wind.pdb differ diff --git a/MES_Wind/frmMain.cs b/MES_Wind/frmMain.cs index ba4ef388bc39fef4d695f2e24c654cf168893f9c..73c68586203f8c6b268b25167009a57d2c1eeba2 100644 --- a/MES_Wind/frmMain.cs +++ b/MES_Wind/frmMain.cs @@ -18,15 +18,82 @@ namespace MES_Wind { public partial class frmMain : Form { + [Export("Shell", typeof(ContainerControl))] private static ContainerControl Shell; + #region "Control variables" + double distThreshold = 500; + #endregion + public frmMain() { + InitializeComponent(); if (DesignMode) return; Shell = this; appManager1.LoadExtensions(); } + #region + /// <summary> + /// This function is used to check if the segment of powerline is broken. + /// Based on the given line segment's start and endpoint, it divides the line on + /// suitable subsegments defined by threshold length - dThreshold + /// </summary> + /// <param name="startX">Line segement's start X point</param> + /// <param name="startY">Line segement's start Y point</param> + /// <param name="endX">Line segement's end X point</param> + /// <param name="endY">Line segement's end Y point</param> + /// <param name="dThreshold">Line segment length threshold</param> + /// <param name="Uwind_raster">Raster Layer for progmostic wind X coord</param> + /// <param name="Vwind_raster">Raster Layer for progmostic wind Y coord</param> + /// <returns>List of booleans with coordinates if any of them are true, line is broken</returns> + /// <remarks></remarks> +#endregion + public List<CheckPoint> CalcBrkPoint(double startX, double startY, double endX, double endY, double dThreshold, IMapRasterLayer Uwind_raster, IMapRasterLayer Vwind_raster) + { + List<CheckPoint> lineCheckPoint = new List<CheckPoint>(); + double uwind = 0; + double vwind = 0; + double umod = 0; + double anglewind = 0; + double distance = Math.Sqrt((endX - startX) * (endX - startX) + (endY - startY) * (endY - startY)); + double distpropD = distance / dThreshold; + int distpropI = Convert.ToInt32(distpropD); + double curX = startX; + double curY = startY; + CheckPoint chkpnt = new CheckPoint(); + if (distpropI > 1) + { + double constXdiff = (endX - startX) / distpropI; + double constYdiff = (endY - startY) / distpropI; + for (int j = 1; j < distpropI + 1; j++) + { + if (j == 1) + { + curX = startX + constXdiff / 2; + curY = startY + constXdiff / 2; + } + else + { + curX = curX + constXdiff; + curY = curY + constYdiff; + } + Coordinate coords = new Coordinate(curX,curY); + RcIndex rowColumnU = Uwind_raster.DataSet.Bounds.ProjToCell(coords); + uwind = Uwind_raster.DataSet.Value[rowColumnU.Row, rowColumnU.Column]; + RcIndex rowColumnV = Vwind_raster.DataSet.Bounds.ProjToCell(coords); + vwind = Vwind_raster.DataSet.Value[rowColumnV.Row, rowColumnV.Column]; + umod = Math.Sqrt(uwind*uwind + vwind*vwind); + anglewind = Math.Atan2(uwind,vwind); + chkpnt.X = curX; + chkpnt.Y = curY; + chkpnt.Ifbroken = false; + lineCheckPoint.Add(chkpnt); + } + } + return lineCheckPoint; + } + private void bntLoadWindX_Click(object sender, EventArgs e) { @@ -104,15 +171,33 @@ namespace MES_Wind // new FeatureSet for resulting broken powerlines IFeatureSet brklineSet = new FeatureSet(FeatureType.Line); DataTable dt = pwlineSet.DataTable; + List<CheckPoint> fullCheckList = new List<CheckPoint>(); foreach (IFeature feature in pwlineSet.Features) { - + List<CheckPoint> lineCheckList = new List<CheckPoint>(); LineString linestr = feature.BasicGeometry as LineString; if (linestr != null) { // case if powerline consists of one line // get coordinates list IList<Coordinate> points = linestr.Coordinates; IFeature brklineFeature = brklineSet.AddFeature(linestr); + //get associated attributes + DataRow featureData = feature.DataRow; + int id = int.Parse(featureData["PW_ID"].ToString()); + int year = int.Parse(featureData["Year"].ToString()); + // cycle throw all points in line + for (int i=1; i< points.Count; i++) + { + List<CheckPoint> segmentCheckList = new List<CheckPoint>(); + double x1 = points[i - 1].X; + double y1 = points[i - 1].Y; + double x2 = points[i].X; + double y2 = points[i].Y; + segmentCheckList = CalcBrkPoint(x1,y1,x2,y2,distThreshold,u_rasterLayer,v_rasterLayer); + lineCheckList.AddRange(segmentCheckList); + } + + fullCheckList.AddRange(lineCheckList); brklineFeature.CopyAttributes(feature); } else @@ -141,11 +226,21 @@ namespace MES_Wind } } public class PathPoint + { + public double X1; + public double Y1; + public double X2; + public double Y2; + public double Distance; + public double Uwind; + public double Vwind; + public int Year; + } + public class CheckPoint { public double X; public double Y; - public double Distance; - public double RstValue; + public bool Ifbroken; } } diff --git a/MES_Wind/obj/Debug/MES_Wind.exe b/MES_Wind/obj/Debug/MES_Wind.exe index 8c49d82653fbb5dd15d03c3b1ffbc9462fadf205..2f3dcfa7e1360c16960fcf84090cb1cfac7d734d 100644 Binary files a/MES_Wind/obj/Debug/MES_Wind.exe and b/MES_Wind/obj/Debug/MES_Wind.exe differ diff --git a/MES_Wind/obj/Debug/MES_Wind.pdb b/MES_Wind/obj/Debug/MES_Wind.pdb index dad778f8a8b4158553be4594f0020e85203cda89..04fae3c7eb1029c9dd0ee7d57283cef1edaba979 100644 Binary files a/MES_Wind/obj/Debug/MES_Wind.pdb and b/MES_Wind/obj/Debug/MES_Wind.pdb differ diff --git a/MES_Wind/testx.asc.aux.xml b/MES_Wind/testx.asc.aux.xml new file mode 100644 index 0000000000000000000000000000000000000000..e839c6a7553a9a649bc5a8aa3f45e9f42632283e --- /dev/null +++ b/MES_Wind/testx.asc.aux.xml @@ -0,0 +1,10 @@ +<PAMDataset> + <PAMRasterBand band="1"> + <Metadata> + <MDI key="STATISTICS_MAXIMUM">10</MDI> + <MDI key="STATISTICS_MEAN">2.2305699982413</MDI> + <MDI key="STATISTICS_MINIMUM">-4.1609997749329</MDI> + <MDI key="STATISTICS_STDDEV">3,03557538986206</MDI> + </Metadata> + </PAMRasterBand> +</PAMDataset> diff --git a/MES_Wind/testy.asc.aux.xml b/MES_Wind/testy.asc.aux.xml new file mode 100644 index 0000000000000000000000000000000000000000..95cf56cac90eb581a44bb49648616dc71fa92eec --- /dev/null +++ b/MES_Wind/testy.asc.aux.xml @@ -0,0 +1,10 @@ +<PAMDataset> + <PAMRasterBand band="1"> + <Metadata> + <MDI key="STATISTICS_MAXIMUM">10</MDI> + <MDI key="STATISTICS_MEAN">3.4739124851488</MDI> + <MDI key="STATISTICS_MINIMUM">0</MDI> + <MDI key="STATISTICS_STDDEV">2,81997513771057</MDI> + </Metadata> + </PAMRasterBand> +</PAMDataset>