diff --git a/.gitignore b/.gitignore index 7181cbc0f6ee536119919fcd822d085ccee229f4..f47df41edd5ba0c511ac9bb660a1b57b374894a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ MES_Wind/obj/ MES_Wind/bin/ *.suo -PRMLibrary/bin/ -PRMLibrary/obj/ +WindStressPRM/bin/ +WindStressPRM/obj/ diff --git a/MES_Wind.sln b/MES_Wind.sln index 411c4638ff2b6b676979136975266046e9e1c1d3..f1ef55dcda4e01bd5def2b52dba1e577e3cece51 100644 --- a/MES_Wind.sln +++ b/MES_Wind.sln @@ -8,7 +8,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MES_Wind", "MES_Wind\MES_Wi EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3BFCE63D-6DC2-4DC4-AAB9-72ECF2AC2EB5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PRMLibrary", "PRMLibrary\PRMLibrary.csproj", "{599B5E9B-293A-4866-A50F-6BB7DC36A81C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindStressPRM", "WindStressPRM\WindStressPRM.csproj", "{599B5E9B-293A-4866-A50F-6BB7DC36A81C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/MES_Wind/MES_Wind.csproj b/MES_Wind/MES_Wind.csproj index 28b4b35ee5d9150588dd04fe2c6d8a36b79915d9..94029fd44e1b228a8e117096e282cda2c345ae01 100644 --- a/MES_Wind/MES_Wind.csproj +++ b/MES_Wind/MES_Wind.csproj @@ -127,9 +127,9 @@ </Compile> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\PRMLibrary\PRMLibrary.csproj"> + <ProjectReference Include="..\WindStressPRM\WindStressPRM.csproj"> <Project>{599B5E9B-293A-4866-A50F-6BB7DC36A81C}</Project> - <Name>PRMLibrary</Name> + <Name>WindStressPRM</Name> </ProjectReference> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> diff --git a/MES_Wind/frmMain.cs b/MES_Wind/frmMain.cs index b57006acc48c4db490c4261d47796314fae80952..7d5fe73fc6ed304c15aef7c737b86166aaec4277 100644 --- a/MES_Wind/frmMain.cs +++ b/MES_Wind/frmMain.cs @@ -47,22 +47,20 @@ namespace MES_Wind /// <returns>List of booleans with coordinates if any of them are true, line is broken</returns> /// <remarks></remarks> #endregion - List<PRMLibrary.Coordinate> DotspLinestringToPrm(LineString dtlinestr) + List<WindStressPRM.Coordinate> DotspLinestringToPrm(LineString dtlinestr) { - List<PRMLibrary.Coordinate> prmlinestring = new List<PRMLibrary.Coordinate>(); + List<WindStressPRM.Coordinate> prmlinestring = new List<WindStressPRM.Coordinate>(); IList<Coordinate> linepoints = dtlinestr.Coordinates; foreach(Coordinate linepoint in linepoints) { - PRMLibrary.Coordinate point = new PRMLibrary.Coordinate(linepoint.X, linepoint.Y); + WindStressPRM.Coordinate point = new WindStressPRM.Coordinate(linepoint.X, linepoint.Y); prmlinestring.Add(point); } return prmlinestring; } - PRMLibrary.Coordinate DotspPointToPRM(IPoint ftpoint) + WindStressPRM.Coordinate DotspPointToPRM(IPoint ftpoint) { - PRMLibrary.Coordinate prpoint = new PRMLibrary.Coordinate(); - prpoint.X = ftpoint.X; - prpoint.Y = ftpoint.Y; + WindStressPRM.Coordinate prpoint = new WindStressPRM.Coordinate(ftpoint.X, ftpoint.Y); return prpoint; } @@ -133,57 +131,50 @@ namespace MES_Wind IFeatureSet pwpointsSet = pwstLayer.DataSet; //Start to cast raster to PRM classes // prognostic wind massives first - List<List<PRMLibrary.PrognosticCell>> prognosticWind = new List<List<PRMLibrary.PrognosticCell>>(); + List<List<WindStressPRM.PrognosticCell>> prognosticWind = new List<List<WindStressPRM.PrognosticCell>>(); int rcountPrognostic = uRasterLayer.DataSet.NumRows; int ccountPrognostic = uRasterLayer.DataSet.NumColumns; for (int i =0; i< rcountPrognostic; i++) { - List<PRMLibrary.PrognosticCell> progWindRow = new List<PRMLibrary.PrognosticCell>(); + List<WindStressPRM.PrognosticCell> progWindRow = new List<WindStressPRM.PrognosticCell>(); for (int j =0; j< ccountPrognostic; j++ ) { - PRMLibrary.PrognosticCell dummyPrognosticCell = new PRMLibrary.PrognosticCell(); - dummyPrognosticCell.velocityX = uRasterLayer.DataSet.Value[j, i]; - dummyPrognosticCell.velocityY = vRasterLayer.DataSet.Value[j, i]; - Coordinate dummyRCoords = uRasterLayer.Bounds.CellCenter_ToProj(j,i); - PRMLibrary.Coordinate cellCoords =new PRMLibrary.Coordinate(dummyRCoords.X,dummyRCoords.Y); - dummyPrognosticCell.coords = cellCoords; + Coordinate dummyRCoords = uRasterLayer.Bounds.CellCenter_ToProj(j,i); + WindStressPRM.Coordinate cellCoords =new WindStressPRM.Coordinate(dummyRCoords.X,dummyRCoords.Y); + WindStressPRM.PrognosticCell dummyPrognosticCell = new WindStressPRM.PrognosticCell(cellCoords, uRasterLayer.DataSet.Value[j, i], vRasterLayer.DataSet.Value[j, i]); progWindRow.Add(dummyPrognosticCell); } prognosticWind.Add(progWindRow); //prog_wind_row.Clear(); } //Get cell info and Affine transform coefficients from prognostic wind rasters - PRMLibrary.CellSize progcellsize = new PRMLibrary.CellSize(uRasterLayer.DataSet.CellWidth, uRasterLayer.DataSet.CellHeight); + WindStressPRM.CellSize progcellsize = new WindStressPRM.CellSize(uRasterLayer.DataSet.CellWidth, uRasterLayer.DataSet.CellHeight); double[] prog_aff = uRasterLayer.Bounds.AffineCoefficients; //Now we create climate raster class - List<List<PRMLibrary.ClimateCell>> climWind = new List<List<PRMLibrary.ClimateCell>>(); + List<List<WindStressPRM.ClimateCell>> climWind = new List<List<WindStressPRM.ClimateCell>>(); int rowCountClim = clim5RasterLayer.DataSet.NumRows; int columnCountClim = clim5RasterLayer.DataSet.NumColumns; for (int i = 0; i < rowCountClim; i++) { - List<PRMLibrary.ClimateCell> climWindRow = new List<PRMLibrary.ClimateCell>(); + List<WindStressPRM.ClimateCell> climWindRow = new List<WindStressPRM.ClimateCell>(); for (int j = 0; j < columnCountClim; j++) { - PRMLibrary.ClimateCell dummyClim = new PRMLibrary.ClimateCell(); - dummyClim.wind5 = clim5RasterLayer.DataSet.Value[j, i]; - dummyClim.wind10 = clim10RasterLayer.DataSet.Value[j, i] ; // Important: substract 3 to this to get powerlines broken - dummyClim.wind15 = clim15RasterLayer.DataSet.Value[j, i]; Coordinate dummyCellCoords = clim15RasterLayer.Bounds.CellCenter_ToProj(j,i); - PRMLibrary.Coordinate dummyClimCoords = new PRMLibrary.Coordinate(dummyCellCoords.X,dummyCellCoords.Y); - dummyClim.coords = dummyClimCoords; + WindStressPRM.Coordinate dummyClimCoords = new WindStressPRM.Coordinate(dummyCellCoords.X,dummyCellCoords.Y); + WindStressPRM.ClimateCell dummyClim = new WindStressPRM.ClimateCell(dummyClimCoords, clim5RasterLayer.DataSet.Value[j, i], clim10RasterLayer.DataSet.Value[j, i], clim15RasterLayer.DataSet.Value[j, i]); climWindRow.Add(dummyClim); } climWind.Add(climWindRow); //clim_wind_row.Clear(); } //Get cell info and affine transform coeff from climate rasters - PRMLibrary.CellSize climCellsize = new PRMLibrary.CellSize(clim5RasterLayer.DataSet.CellWidth, clim5RasterLayer.DataSet.CellHeight); + WindStressPRM.CellSize climCellsize = new WindStressPRM.CellSize(clim5RasterLayer.DataSet.CellWidth, clim5RasterLayer.DataSet.CellHeight); double[] climAffinecoeffs = clim5RasterLayer.Bounds.AffineCoefficients; // create PRM_line list to pass to PRM_wind from loaded line layer - List<PRMLibrary.Powerline> powerlinesToPRM = new List<PRMLibrary.Powerline>(); + List<WindStressPRM.Powerline> powerlinesToPRM = new List<WindStressPRM.Powerline>(); foreach (IFeature feature in pwlineSet.Features) { - PRMLibrary.Powerline dummyline = new PRMLibrary.Powerline(); + WindStressPRM.Powerline dummyline = new WindStressPRM.Powerline(); DataRow featureData = feature.DataRow; dummyline.identifier = feature.Fid; dummyline.year = int.Parse(featureData["Year"].ToString()); @@ -196,10 +187,10 @@ namespace MES_Wind powerlinesToPRM.Add(dummyline); } //create PRM_station list to pass to PRM_wind from loaded point layer - List<PRMLibrary.PowerStation> powerpointsToPRM = new List<PRMLibrary.PowerStation>(); + List<WindStressPRM.PowerStation> powerpointsToPRM = new List<WindStressPRM.PowerStation>(); foreach (IFeature featurepoint in pwpointsSet.Features) { - PRMLibrary.PowerStation dummystation = new PRMLibrary.PowerStation(); + WindStressPRM.PowerStation dummystation = new WindStressPRM.PowerStation(); DataRow featureData = featurepoint.DataRow; dummystation.identifier = featurepoint.Fid; dummystation.name = featureData["Name"].ToString(); @@ -227,8 +218,8 @@ namespace MES_Wind } //Create a PRM_wind class and add all the properties from above - PRMLibrary.Module prmwind = new PRMLibrary.Module(); - PRMLibrary.Input input = new PRMLibrary.Input(); + WindStressPRM.StressPowerChecker prmwind = new WindStressPRM.StressPowerChecker(); + WindStressPRM.Input input = new WindStressPRM.Input(); input.powerLines = powerlinesToPRM; input.powerStations = powerpointsToPRM; input.prognosticCells = prognosticWind; @@ -237,6 +228,7 @@ namespace MES_Wind input.climateCells = climWind; input.climateCellSize = climCellsize; input.climateAffineCoefficients = climAffinecoeffs; +<<<<<<< HEAD PRMLibrary.Output output = prmwind.CheckPower(input); // new FeatureSets for resulting broken powerlines IFeatureSet brokenklineSet = new FeatureSet(FeatureType.Line); @@ -252,6 +244,11 @@ namespace MES_Wind { } +======= + WindStressPRM.Output output = prmwind.CheckPower(input); + // new FeatureSet for resulting broken powerlines + //IFeatureSet brklineSet = new FeatureSet(FeatureType.Line); +>>>>>>> origin/anton //DataTable dt = pwlineSet.DataTable; //IFeatureSet brk_info = new FeatureSet(FeatureType.Line); //brk_info = main_layer_function(pwlLayer, pwlineSet, u_rasterLayer, v_rasterLayer, clim15_rasterLayer, clim10_rasterLayer, clim5_rasterLayer); diff --git a/PRMLibrary/Properties/AssemblyInfo.cs b/WindStressPRM/Properties/AssemblyInfo.cs similarity index 95% rename from PRMLibrary/Properties/AssemblyInfo.cs rename to WindStressPRM/Properties/AssemblyInfo.cs index d224a2babbb2da611a6db6e04e268524b89f5d54..e67c70a84528d687f62c7a69112a5dfd81c484b9 100644 --- a/PRMLibrary/Properties/AssemblyInfo.cs +++ b/WindStressPRM/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ using System.Runtime.InteropServices; // Управление общими сведениями о сборке осуществляется с помощью // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, // связанные со сборкой. -[assembly: AssemblyTitle("PRMLibrary")] +[assembly: AssemblyTitle("WindStressPRM")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PRMLibrary")] +[assembly: AssemblyProduct("WindStressPRM")] [assembly: AssemblyCopyright("Copyright © 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/PRMLibrary/PRMLibrary.cs b/WindStressPRM/WindStressPRM.cs similarity index 97% rename from PRMLibrary/PRMLibrary.cs rename to WindStressPRM/WindStressPRM.cs index 6c23ced81a8fd273b68b6f68cab8117882663024..5b9c408a975b14861ec80944d32f35d9c0fbcd0c 100644 --- a/PRMLibrary/PRMLibrary.cs +++ b/WindStressPRM/WindStressPRM.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace PRMLibrary +namespace WindStressPRM { /// <summary> /// Index class for raster lists in list @@ -29,10 +29,6 @@ namespace PRMLibrary this.Row = Row; this.Col = Col; } - /// <summary> - /// default constructor - /// </summary> - public Index() : this(0, 0) { } } /// <summary> /// Coordinate pair @@ -57,10 +53,6 @@ namespace PRMLibrary this.X = X; this.Y = Y; } - /// <summary> - /// default constructor - /// </summary> - public Coordinate() : this(0, 0) { } } /// <summary> /// Cell obj for regular prognostic wind field @@ -91,10 +83,6 @@ namespace PRMLibrary this.velocityX = vX; this.velocityY = vY; } - /// <summary> - /// default constructor - /// </summary> - public PrognosticCell() : this(new Coordinate(), 0, 0) { } } /// <summary> /// Cell obj for climate wind regular data @@ -131,10 +119,6 @@ namespace PRMLibrary this.wind10 = w10; this.wind15 = w15; } - /// <summary> - /// default constructor - /// </summary> - public ClimateCell() : this(new Coordinate(), 0, 0, 0) { } } /// <summary> /// Cell Size parameters @@ -282,7 +266,7 @@ namespace PRMLibrary /// <summary> /// default constructor /// </summary> - public PowerStation() : this(new Coordinate(), -1, "", 0, "", false) { } + public PowerStation() : this(new Coordinate(0, 0), -1, "", 0, "", false) { } } enum FunctionType @@ -360,7 +344,7 @@ namespace PRMLibrary /// <summary> /// main calculations class /// </summary> - public class Module + public class StressPowerChecker { /// <summary> /// Input Data @@ -374,7 +358,7 @@ namespace PRMLibrary { this.input = input; //Calculate which lines are broken - List<PRMLibrary.Powerline> prmBrokenLines = brokenPowerLinesAfterCheck(); + List<WindStressPRM.Powerline> prmBrokenLines = brokenPowerLinesAfterCheck(); //get the graph PreparingPowerItems(); //start from source points @@ -538,7 +522,7 @@ namespace PRMLibrary double distance = Math.Sqrt((coord2.X - coord1.X) * (coord2.X - coord1.X) + (coord2.Y - coord1.Y) * (coord2.Y - coord1.Y)); double distpropD = distance / input.dist_threshold; List<Coordinate> pointlist = new List<Coordinate>(); - Coordinate midpoint = new Coordinate(); + Coordinate midpoint = new Coordinate(0, 0); int distpropI = Convert.ToInt32(distpropD); if (distpropI > 1) { @@ -682,9 +666,8 @@ namespace PRMLibrary if (iRow < 0 || iCol < 0 || iRow >= countInList(functionType, true) || iCol >= countInList(functionType, false)) { - return new Index(); + throw new Exception("projectionToCell method trying to find uncorrect index"); } - return new Index(iRow, iCol); } private Coordinate cellToProjection(Index index, FunctionType functionType) diff --git a/PRMLibrary/PRMLibrary.csproj b/WindStressPRM/WindStressPRM.csproj similarity index 97% rename from PRMLibrary/PRMLibrary.csproj rename to WindStressPRM/WindStressPRM.csproj index caa9e9a123d1a887cf986af161057ada6e275123..91e4f655339764de6896b998653193f5308d382e 100644 --- a/PRMLibrary/PRMLibrary.csproj +++ b/WindStressPRM/WindStressPRM.csproj @@ -35,7 +35,7 @@ <Reference Include="Microsoft.CSharp" /> </ItemGroup> <ItemGroup> - <Compile Include="PRMLibrary.cs" /> + <Compile Include="WindStressPRM.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />