diff --git a/.vs/MES_Wind/v14/.suo b/.vs/MES_Wind/v14/.suo index 08af522f7c927f14408dee4f1187fe6ae765e6a0..87fcafd1eb854dce0464bf5323c584772e4af090 100644 Binary files a/.vs/MES_Wind/v14/.suo and b/.vs/MES_Wind/v14/.suo differ diff --git a/MES_Wind/MES_Wind.csproj b/MES_Wind/MES_Wind.csproj index df94646df24d9001c51d73c81c312957d99de3b3..a5ce0cb1ad02c42c75157ac2b90cfd2f78a1142d 100644 --- a/MES_Wind/MES_Wind.csproj +++ b/MES_Wind/MES_Wind.csproj @@ -111,6 +111,7 @@ <Compile Include="frmMain.Designer.cs"> <DependentUpon>frmMain.cs</DependentUpon> </Compile> + <Compile Include="PRM_wind.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <EmbeddedResource Include="frmGraph.resx"> diff --git a/MES_Wind/PRM_wind.cs b/MES_Wind/PRM_wind.cs new file mode 100644 index 0000000000000000000000000000000000000000..0e319692a2d622fa9edddf0eb8072fca0540b8fe --- /dev/null +++ b/MES_Wind/PRM_wind.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace MES_Wind +{ + public class PRM_coordinate + { + public double X; + public double Y; + + public PRM_coordinate(double X, double Y) + { + this.X = X; + this.Y = Y; + } + public PRM_coordinate() : this(0, 0) { } + } + public class PRM_raster_cell_prognostic + { + public double velocityX; + public double velocityY; + public PRM_coordinate coords; + } + public class PRM_raster_cell_climate + { + public double wind5; + public double wind10; + public double wind15; + public PRM_coordinate coords; + } + public struct PRM_cell_size + { + public double width; + public double height; + } + class PRM_Line + { + public int identifier { get; private set; } + public int year; + public double height; + public int power; + public List<PRM_coordinate> coords { get; private set; } + public bool isbroken; + } + public class PRM_Station + { + int identifier; + //TODO + } + class PRM_wind + { + //prognistic raster info + List<List<PRM_raster_cell_prognostic>> prognostic_cells; + PRM_cell_size prognostic_cellsize; + + //climate raster info + List<List<PRM_raster_cell_climate>> climate_cells; + PRM_cell_size climate_cellsize; + + //lines collection + List<PRM_Line> powerlines; + + #region "control parameters" + public double dist_threshold; + #endregion + + + List<PRM_Line> brokenPowerLinesAfterCheck() + { + foreach (PRM_Line curve in powerlines) + { + // get coordinates list + List<PRM_coordinate> points = curve.coords; + + List<bool> checkList = new List<bool>(); + // 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; + bool result = linearLineIsBroken(points[i - 1], points[i], curve.height, curve.power, curve.power > 5 && curve.power < 330); + checkList.Add(result); + } + foreach (bool chkpnt in checkList) + { + if (chkpnt == true) + { + curve.isbroken = true; + } + } + } + if (powerlines.Count == 0) + { + throw new Exception("shit you trying to feed it is not a simple line"); + //return null; + } + return null; + } + + bool linearLineIsBroken(PRM_coordinate coord1, PRM_coordinate coord2, double heightLine, int powerLine, bool useClimate10) + { + double distance = Math.Sqrt((coord2.X - coord1.X) * (coord2.X - coord1.X) + (coord2.Y - coord1.Y) * (coord2.Y - coord1.Y)); + double distpropD = distance / dist_threshold; + int distpropI = Convert.ToInt32(distpropD); + if (distpropI > 1) + { + double constXdiff = (coord2.X - coord1.X) / distpropI; + double constYdiff = (coord2.Y - coord1.Y) / distpropI; + PRM_coordinate subCoord1 = new PRM_coordinate(coord1.X, coord1.Y); + PRM_coordinate subCoord2 = new PRM_coordinate(coord1.X + constXdiff, coord1.Y + constXdiff); + for (int j = 0; j < distpropI; j++) + { + if (j > 0) + { + // move to next center + subCoord1.X = subCoord2.X; + subCoord1.Y = subCoord2.Y; + subCoord2.X = subCoord1.X + constXdiff; + subCoord2.Y = subCoord1.Y + constYdiff; + } + bool result = linearLineIsBroken(subCoord1, subCoord2, heightLine, powerLine, useClimate10); + if (result) + { + return result; + } + } + } + else + { + double uwind = 0; // interpol(coords, Uwind_raster); + double vwind = 0; // interpol(coords, Vwind_raster); + double climwind = 0; // interpol(coords, clim_layer); + double umod = Math.Sqrt(uwind * uwind + vwind * vwind); ; + double angleline = Math.Atan2((coord2.Y - coord1.Y), (coord2.X - coord1.X)); + double anglewind = Math.Atan2(vwind, uwind) - angleline; + double sinwind = Math.Sin(anglewind); + double C_height = 1.0; + if (umod < 20) + { //wind is too low + return false; + } + else + { // calculate prognostic and threshold windstress + double p1 = -0.00078501; + double p2 = 0.13431; + double p3 = -2.11112; + double p4 = 19.548; + double qpr = p1 * umod * umod * umod + p2 * umod * umod + p3 * umod + p4; + double qcl = p1 * climwind * climwind * climwind + p2 * climwind * climwind + p3 * climwind + p4; + double Ppr = qpr * C_height * sinwind * sinwind; + double Pcl = qcl * C_height * 1.0; + if (Ppr >= Pcl) + { + // here line is broken + return true; + } + } + } + return false; + } + + + } +} diff --git a/MES_Wind/bin/Debug/MES_Wind.vshost.exe b/MES_Wind/bin/Debug/MES_Wind.vshost.exe index 6b241bcd65a4769673693b96129ef13ae25e17ec..8f90da475a8319aa76856e089ccc9e517eeb134a 100644 Binary files a/MES_Wind/bin/Debug/MES_Wind.vshost.exe and b/MES_Wind/bin/Debug/MES_Wind.vshost.exe differ diff --git a/MES_Wind/frmMain.cs b/MES_Wind/frmMain.cs index 8b5ba58da8ebe6e2b668af0812fef4d6d4ea85c8..7a172c360dc3744618efbbbb81908435ec3bc9c1 100644 --- a/MES_Wind/frmMain.cs +++ b/MES_Wind/frmMain.cs @@ -183,52 +183,8 @@ namespace MES_Wind fullCheckList.AddRange(lineCheckList); } - else - {//case if powerline is multiline - MultiLineString multiline = feature.BasicGeometry as MultiLineString; - if (multiline != null) - { - - foreach (IGeometry line in multiline.Geometries) - { - IList<Coordinate> points = line.Coordinates; - 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; - if (power > 5 && power < 330) - { - segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_raster, v_raster, clim10_raster, height); - } - else - { - segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_raster, v_raster, clim5_raster, height); - } - bool linechek = false; - foreach (CheckPoint chkpnt in lineCheckList) - { - if (chkpnt.Ifbroken == true) - { linechek = true; } - } - if (linechek == true) - { - IFeature lineFeature = result_layer.AddFeature(linestr); - } - lineCheckList.AddRange(segmentCheckList); - } - - - fullCheckList.AddRange(lineCheckList); - - } - - MessageBox.Show("Works"); - } - - + else { + MessageBox.Show("shit you trying to feed it is not a simple line"); } } @@ -382,6 +338,7 @@ namespace MES_Wind IMapRasterLayer v_rasterLayer = default(IMapRasterLayer); IMapRasterLayer clim5_rasterLayer = default(IMapRasterLayer); IMapRasterLayer clim10_rasterLayer = default(IMapRasterLayer); + if (map1.GetRasterLayers().Count() == 1) { MessageBox.Show("Please add a raster layer"); @@ -427,17 +384,6 @@ 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; diff --git a/MES_Wind/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/MES_Wind/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 7cf58ab2b496264ee3362bef88ddbb563a0ac98a..15af49b1dfb60189d9d6571b791bd6be84bdd821 100644 Binary files a/MES_Wind/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/MES_Wind/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/MES_Wind/obj/Debug/MES_Wind.csproj.FileListAbsolute.txt b/MES_Wind/obj/Debug/MES_Wind.csproj.FileListAbsolute.txt index c7e6d7a11a9a43fd34b85444b41a447e8c6aaa08..c57f88ac95a5f1aca30e469bb9fc1516e8fe51dd 100644 --- a/MES_Wind/obj/Debug/MES_Wind.csproj.FileListAbsolute.txt +++ b/MES_Wind/obj/Debug/MES_Wind.csproj.FileListAbsolute.txt @@ -206,3 +206,5 @@ C:\Users\Geophyslab-laptop\Documents\MES_Wind2\MES_Wind\obj\Debug\MES_Wind.Prope C:\Users\Geophyslab-laptop\Documents\MES_Wind2\MES_Wind\obj\Debug\MES_Wind.csproj.GenerateResource.Cache C:\Users\Geophyslab-laptop\Documents\MES_Wind2\MES_Wind\bin\Debug\MES_Wind.exe C:\Users\Geophyslab-laptop\Documents\MES_Wind2\MES_Wind\bin\Debug\MES_Wind.pdb +C:\gitlab_wind\MES_Wind\obj\Debug\MES_Wind.exe +C:\gitlab_wind\MES_Wind\obj\Debug\MES_Wind.pdb