Skip to content
Snippets Groups Projects
Commit 86e234dc authored by Антон Кудряшов's avatar Антон Кудряшов
Browse files

- fixed lists of lists with generic matrix

parent c5d5ac90
No related branches found
No related tags found
No related merge requests found
......@@ -118,22 +118,25 @@ namespace MES_Wind
return;
}
pwlLayer = map1.GetLineLayers()[0];
//copy line layer FeatureSet
// copy line layer FeatureSet
IFeatureSet pwlineSet = pwlLayer.DataSet;
//get the powerstations layer
// get the powerstations layer
IMapPointLayer pwstLayer = default(IMapPointLayer);
pwstLayer = map1.GetPointLayers()[0];
// copy point layer FeatureSet
IFeatureSet pwpointsSet = pwstLayer.DataSet;
//Start to cast raster to PRM classes
// Start to cast raster to PRM classes
// prognostic wind massives first
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++)
WindStressPRM.Matrix<WindStressPRM.PrognosticCell> prognosticMatrix = new WindStressPRM.Matrix<WindStressPRM.PrognosticCell>();
prognosticMatrix.Cells = new WindStressPRM.PrognosticCell[rcountPrognostic, ccountPrognostic];
prognosticMatrix.Size = new WindStressPRM.CellSize(uRasterLayer.DataSet.CellWidth, uRasterLayer.DataSet.CellHeight);
prognosticMatrix.AffineCoefficients = uRasterLayer.Bounds.AffineCoefficients;
// fill cells of prognostic matrix
for (int i = 0; i < rcountPrognostic; i++)
{
List<WindStressPRM.PrognosticCell> progWindRow = new List<WindStressPRM.PrognosticCell>();
for (int j =0; j< ccountPrognostic; j++ )
for (int j = 0; j < ccountPrognostic; j++)
{
Coordinate dummyRCoords = uRasterLayer.Bounds.CellCenter_ToProj(i,j);
WindStressPRM.Coordinate cellCoords =new WindStressPRM.Coordinate(dummyRCoords.X,dummyRCoords.Y);
......@@ -146,21 +149,19 @@ namespace MES_Wind
vValue = Double.NaN;
}
WindStressPRM.PrognosticCell dummyPrognosticCell = new WindStressPRM.PrognosticCell(cellCoords, uValue, vValue);
progWindRow.Add(dummyPrognosticCell);
prognosticMatrix.Cells[i, j] = dummyPrognosticCell;
}
prognosticWind.Add(progWindRow);
//prog_wind_row.Clear();
}
//Get cell info and Affine transform coefficients from prognostic wind rasters
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<WindStressPRM.ClimateCell>> climWind = new List<List<WindStressPRM.ClimateCell>>();
int rowCountClim = clim5RasterLayer.DataSet.NumRows;
int columnCountClim = clim5RasterLayer.DataSet.NumColumns;
WindStressPRM.Matrix<WindStressPRM.ClimateCell> climateMatrix = new WindStressPRM.Matrix<WindStressPRM.ClimateCell>();
climateMatrix.Cells = new WindStressPRM.ClimateCell[rowCountClim, columnCountClim];
climateMatrix.Size = new WindStressPRM.CellSize(clim5RasterLayer.DataSet.CellWidth, clim5RasterLayer.DataSet.CellHeight);
climateMatrix.AffineCoefficients = clim5RasterLayer.Bounds.AffineCoefficients;
// fill cells of climate matrix
for (int i = 0; i < rowCountClim; i++)
{
List<WindStressPRM.ClimateCell> climWindRow = new List<WindStressPRM.ClimateCell>();
for (int j = 0; j < columnCountClim; j++)
{
Coordinate dummyCellCoords = clim15RasterLayer.Bounds.CellCenter_ToProj(i,j);
......@@ -182,14 +183,9 @@ namespace MES_Wind
clim15 = Double.NaN;
}
WindStressPRM.ClimateCell dummyClim = new WindStressPRM.ClimateCell(dummyClimCoords, clim5, clim10, clim15);
climWindRow.Add(dummyClim);
climateMatrix.Cells[i, j] = dummyClim;
}
climWind.Add(climWindRow);
//clim_wind_row.Clear();
}
//Get cell info and affine transform coeff from climate rasters
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<WindStressPRM.Powerline> powerlinesToPRM = new List<WindStressPRM.Powerline>();
foreach (IFeature feature in pwlineSet.Features)
......@@ -231,39 +227,34 @@ namespace MES_Wind
MessageBox.Show("Some entities in Column IsSource of powerstation datatable are not strict ones or zeros");
}
}
//casting stationtype
if (featureData["Sttype"].ToString().Trim().ToUpper() == "POLE")
{
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Pole;
}
else if (featureData["Sttype"].ToString().Trim().ToUpper() == "TRANS")
{
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Trans;
}
else if (featureData["Sttype"].ToString().Trim().ToUpper() == "ENDPOINT")
{
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Endstat;
}
else
{
throw new System.Exception("Point in powerstation layer has unrecognised type");
}
//casting stationtype
if (featureData["Sttype"].ToString().Trim().ToUpper() == "POLE")
{
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Pole;
}
else if (featureData["Sttype"].ToString().Trim().ToUpper() == "TRANS")
{
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Trans;
}
else if (featureData["Sttype"].ToString().Trim().ToUpper() == "ENDPOINT")
{
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Endstat;
}
else
{
throw new System.Exception("Point in powerstation layer has unrecognised type");
}
IPoint featurepointcoords = featurepoint.BasicGeometry as IPoint;
dummystation.Coordinate = DotspPointToPRM(featurepointcoords);
powerpointsToPRM.Add(dummystation);
}
//Create a PRM_wind class and add all the properties from above
WindStressPRM.StressPowerChecker prmwind = new WindStressPRM.StressPowerChecker();
WindStressPRM.Input input = new WindStressPRM.Input();
input.PowerLines = powerlinesToPRM;
input.PowerStations = powerpointsToPRM;
input.PrognosticCells = prognosticWind;
input.PrognosticCellSize = progcellsize;
input.PrognosticAffineCoefficients = prog_aff;
input.ClimateCells = climWind;
input.ClimateCellSize = climCellsize;
input.ClimateAffineCoefficients = climAffinecoeffs;
input.PrognosticCells = prognosticMatrix;
input.ClimateCells = climateMatrix;
WindStressPRM.Output output = prmwind.CheckPower(input);
// new FeatureSet for resulting disabled points
IFeatureSet disabledPointSet = new FeatureSet(FeatureType.Point);
......@@ -310,17 +301,16 @@ namespace MES_Wind
disabledLineLayer.Symbolizer = lineSymbol;
disabledLineLayer.LegendText = "Disabled Lines";
// new FeatureSet for resulting broken powerlines
//IFeatureSet brklineSet = new FeatureSet(FeatureType.Line);
//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);
// new FeatureSet for resulting broken powerlines
//IFeatureSet brklineSet = new FeatureSet(FeatureType.Line);
//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);
//IMapLineLayer brk_info_layer = (MapLineLayer)map1.Layers.Add(brk_info);
//LineSymbolizer symbol = new LineSymbolizer(Color.Red, 3);
//brk_info_layer.Symbolizer = symbol;
//brk_info_layer.LegendText = "Broken powerlines";
//IMapLineLayer brk_info_layer = (MapLineLayer)map1.Layers.Add(brk_info);
//LineSymbolizer symbol = new LineSymbolizer(Color.Red, 3);
//brk_info_layer.Symbolizer = symbol;
//brk_info_layer.LegendText = "Broken powerlines";
}
}
public class CheckPoint
......
......@@ -9,6 +9,10 @@ namespace WindStressPRM
/// <typeparam name="T"></typeparam>
public class Matrix<T>
{
/// <summary>
/// AffineCoefficients for matrix from raster projection
/// </summary>
public double[] AffineCoefficients { get; set; }
/// <summary>
/// Size of cell. In meters
/// </summary>
......
......@@ -394,33 +394,13 @@ namespace WindStressPRM
/// prognistic raster info
/// массив прогностического ветра
/// </summary>
public List<List<PrognosticCell>> PrognosticCells { get; set; }
/// <summary>
/// prognostic raster cell info
/// параметры ячеек регулярной сетки прогностического ветра
/// </summary>
public CellSize PrognosticCellSize { get; set; }
/// <summary>
/// affine coefficients from prognostic raster projections
/// коэффициенты аффиного проеобразования из проекции массива прогностического ветра
/// </summary>
public double[] PrognosticAffineCoefficients { get; set; }
public Matrix<PrognosticCell> PrognosticCells { get; set; }
/// <summary>
/// climate raster array
/// массив климатических полей скорости ветра заданной повторяемости
/// </summary>
public List<List<ClimateCell>> ClimateCells { get; set; }
/// <summary>
/// climate raster cell info
/// параметры ячеек регулярной сетки климатических полей скорости ветра заданной повторяемости
/// </summary>
public CellSize ClimateCellSize { get; set; }
/// <summary>
/// affine coefficients from climate raster projection
/// коэффициенты аффинного преобразования из проекции массива климатических полей скорости ветра заданной повторяемости
/// </summary>
public double[] ClimateAffineCoefficients { get; set; }
public Matrix<ClimateCell> ClimateCells { get; set; }
/// <summary>
/// lines list
......@@ -734,13 +714,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return Input.PrognosticAffineCoefficients;
return Input.PrognosticCells.AffineCoefficients;
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return Input.ClimateAffineCoefficients;
return Input.ClimateCells.AffineCoefficients;
}
default:
break;
......@@ -790,13 +770,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return Input.PrognosticCells[index.Row][index.Col].Coordinate;
return Input.PrognosticCells.Cells[index.Row, index.Col].Coordinate;
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return Input.ClimateCells[index.Row][index.Col].Coordinate;
return Input.ClimateCells.Cells[index.Row, index.Col].Coordinate;
}
default:
break;
......@@ -811,13 +791,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return forRows ? Input.PrognosticCells.Count : Input.PrognosticCells[0].Count;
return forRows ? Input.PrognosticCells.RowsCount() : Input.PrognosticCells.ColumnCount();
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return forRows ? Input.ClimateCells.Count : Input.ClimateCells[0].Count;
return forRows ? Input.ClimateCells.RowsCount() : Input.ClimateCells.ColumnCount();
}
default:
break;
......@@ -831,23 +811,23 @@ namespace WindStressPRM
{
case FunctionType.FunctionVelocityX:
{
return Input.PrognosticCells[index.Row][index.Col].VelocityX;
return Input.PrognosticCells.Cells[index.Row, index.Col].VelocityX;
}
case FunctionType.FunctionVelocityY:
{
return Input.PrognosticCells[index.Row][index.Col].VelocityY;
return Input.PrognosticCells.Cells[index.Row, index.Col].VelocityY;
}
case FunctionType.FunctionClimate5:
{
return Input.ClimateCells[index.Row][index.Col].Wind5;
return Input.ClimateCells.Cells[index.Row, index.Col].Wind5;
}
case FunctionType.FunctionClimate10:
{
return Input.ClimateCells[index.Row][index.Col].Wind10;
return Input.ClimateCells.Cells[index.Row, index.Col].Wind10;
}
case FunctionType.FunctionClimate15:
{
return Input.ClimateCells[index.Row][index.Col].Wind15;
return Input.ClimateCells.Cells[index.Row, index.Col].Wind15;
}
default:
break;
......@@ -862,13 +842,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return Input.PrognosticCellSize;
return Input.PrognosticCells.Size;
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return Input.ClimateCellSize;
return Input.ClimateCells.Size;
}
default:
break;
......
......@@ -8,8 +8,8 @@
<ProjectGuid>{599B5E9B-293A-4866-A50F-6BB7DC36A81C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PRMLibrary</RootNamespace>
<AssemblyName>PRMLibrary</AssemblyName>
<RootNamespace>WindStressPRM</RootNamespace>
<AssemblyName>WindStressPRM</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
......@@ -35,6 +35,7 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Matrix.cs" />
<Compile Include="WindStressPRM.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment