Skip to content
Snippets Groups Projects
Commit 3e9f8ce8 authored by Debolskiy Andrey's avatar Debolskiy Andrey :bicyclist_tone5:
Browse files

Merge branch 'master' into second_round_andrey

# Conflicts:
#	WindStressPRM/WindStressPRM.cs
parents 60dee1ff 4bd177f8
Branches
No related tags found
No related merge requests found
...@@ -180,14 +180,14 @@ namespace MES_Wind ...@@ -180,14 +180,14 @@ namespace MES_Wind
{ {
WindStressPRM.Powerline dummyline = new WindStressPRM.Powerline(); WindStressPRM.Powerline dummyline = new WindStressPRM.Powerline();
DataRow featureData = feature.DataRow; DataRow featureData = feature.DataRow;
dummyline.identifier = feature.Fid; dummyline.Identifier = feature.Fid;
dummyline.year = int.Parse(featureData["Year"].ToString()); dummyline.Year = int.Parse(featureData["Year"].ToString());
dummyline.height = double.Parse(featureData["HeightOffs"].ToString()); dummyline.Height = double.Parse(featureData["HeightOffs"].ToString());
dummyline.power = int.Parse(featureData["Power"].ToString()); dummyline.Power = int.Parse(featureData["Power"].ToString());
dummyline.pointFromID = int.Parse(featureData["PointFrom"].ToString()); dummyline.PointFromID = int.Parse(featureData["PointFrom"].ToString());
dummyline.pointToID = int.Parse(featureData["PointTo"].ToString()); dummyline.PointToID = int.Parse(featureData["PointTo"].ToString());
LineString featureline = feature.BasicGeometry as LineString; LineString featureline = feature.BasicGeometry as LineString;
dummyline.coords = DotspLinestringToPrm(featureline); dummyline.Coordinates = DotspLinestringToPrm(featureline);
powerlinesToPRM.Add(dummyline); powerlinesToPRM.Add(dummyline);
} }
//create PRM_station list to pass to PRM_wind from loaded point layer //create PRM_station list to pass to PRM_wind from loaded point layer
...@@ -196,19 +196,19 @@ namespace MES_Wind ...@@ -196,19 +196,19 @@ namespace MES_Wind
{ {
WindStressPRM.PowerStation dummystation = new WindStressPRM.PowerStation(); WindStressPRM.PowerStation dummystation = new WindStressPRM.PowerStation();
DataRow featureData = featurepoint.DataRow; DataRow featureData = featurepoint.DataRow;
dummystation.identifier = featurepoint.Fid; dummystation.Identifier = featurepoint.Fid;
dummystation.name = featureData["Name"].ToString(); dummystation.Name = featureData["Name"].ToString();
dummystation.power = int.Parse(featureData["Power"].ToString()); dummystation.Power = int.Parse(featureData["Power"].ToString());
int issr = int.Parse(featureData["IsSource"].ToString()); int issr = int.Parse(featureData["IsSource"].ToString());
if (issr == 0) if (issr == 0)
{ {
dummystation.issource = false; dummystation.IsSource = false;
} }
else else
{ {
if (issr == 1) if (issr == 1)
{ {
dummystation.issource = true; dummystation.IsSource = true;
} }
else else
{ {
...@@ -218,45 +218,45 @@ namespace MES_Wind ...@@ -218,45 +218,45 @@ namespace MES_Wind
//casting stationtype //casting stationtype
if (featureData["Type"].ToString().Trim().ToUpper() == "POLE") if (featureData["Type"].ToString().Trim().ToUpper() == "POLE")
{ {
dummystation.type = WindStressPRM.PowerStation.stationtype.pole; dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Pole;
} }
else if (featureData["Type"].ToString().Trim().ToUpper() == "TRANS") else if (featureData["Type"].ToString().Trim().ToUpper() == "TRANS")
{ {
dummystation.type = WindStressPRM.PowerStation.stationtype.trans; dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Trans;
} }
else if (featureData["Type"].ToString().Trim().ToUpper() == "ENDSTAT") else if (featureData["Type"].ToString().Trim().ToUpper() == "ENDSTAT")
{ {
dummystation.type = WindStressPRM.PowerStation.stationtype.endstat; dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Endstat;
} }
else else
{ {
throw new System.Exception("Point in powerstation layer has unrecognised type"); throw new System.Exception("Point in powerstation layer has unrecognised type");
} }
IPoint featurepointcoords = featurepoint.BasicGeometry as IPoint; IPoint featurepointcoords = featurepoint.BasicGeometry as IPoint;
dummystation.coords = DotspPointToPRM(featurepointcoords); dummystation.Coordinate = DotspPointToPRM(featurepointcoords);
powerpointsToPRM.Add(dummystation); powerpointsToPRM.Add(dummystation);
} }
//Create a PRM_wind class and add all the properties from above //Create a PRM_wind class and add all the properties from above
WindStressPRM.StressPowerChecker prmwind = new WindStressPRM.StressPowerChecker(); WindStressPRM.StressPowerChecker prmwind = new WindStressPRM.StressPowerChecker();
WindStressPRM.Input input = new WindStressPRM.Input(); WindStressPRM.Input input = new WindStressPRM.Input();
input.powerLines = powerlinesToPRM; input.PowerLines = powerlinesToPRM;
input.powerStations = powerpointsToPRM; input.PowerStations = powerpointsToPRM;
input.prognosticCells = prognosticWind; input.PrognosticCells = prognosticWind;
input.prognosticCellSize = progcellsize; input.PrognosticCellSize = progcellsize;
input.prognosticAffineCoefficients = prog_aff; input.PrognosticAffineCoefficients = prog_aff;
input.climateCells = climWind; input.ClimateCells = climWind;
input.climateCellSize = climCellsize; input.ClimateCellSize = climCellsize;
input.climateAffineCoefficients = climAffinecoeffs; input.ClimateAffineCoefficients = climAffinecoeffs;
WindStressPRM.Output output = prmwind.CheckPower(input); WindStressPRM.Output output = prmwind.CheckPower(input);
// new FeatureSet for resulting disabled points // new FeatureSet for resulting disabled points
IFeatureSet disabledPointSet = new FeatureSet(FeatureType.Point); IFeatureSet disabledPointSet = new FeatureSet(FeatureType.Point);
disabledPointSet.Projection = map1.Projection; disabledPointSet.Projection = map1.Projection;
DataColumn pointcolumn = new DataColumn("ID"); DataColumn pointcolumn = new DataColumn("ID");
disabledPointSet.DataTable.Columns.Add(pointcolumn); disabledPointSet.DataTable.Columns.Add(pointcolumn);
foreach (WindStressPRM.PowerStation disabledStation in output.disabledStations) foreach (WindStressPRM.PowerStation disabledStation in output.DisabledStations)
{ {
Coordinate coords = new Coordinate(disabledStation.coords.X, disabledStation.coords.Y); Coordinate coords = new Coordinate(disabledStation.Coordinate.X, disabledStation.Coordinate.Y);
DotSpatial.Topology.Point disabledPoint = new DotSpatial.Topology.Point(coords); DotSpatial.Topology.Point disabledPoint = new DotSpatial.Topology.Point(coords);
Feature disabledPointFeature = new Feature(disabledPoint); Feature disabledPointFeature = new Feature(disabledPoint);
//disabledPointFeature.DataRow["ID"] = disabledStation.identifier; //disabledPointFeature.DataRow["ID"] = disabledStation.identifier;
...@@ -275,17 +275,17 @@ namespace MES_Wind ...@@ -275,17 +275,17 @@ namespace MES_Wind
DataColumn lineIDcolumn = new DataColumn("ID"); DataColumn lineIDcolumn = new DataColumn("ID");
disabledLineSet.DataTable.Columns.Add(lineIDcolumn); disabledLineSet.DataTable.Columns.Add(lineIDcolumn);
int lineID = 0; int lineID = 0;
foreach (WindStressPRM.Powerline disabledLine in output.disabledLines) foreach (WindStressPRM.Powerline disabledLine in output.DisabledLines)
{ {
List<Coordinate> lineArray = new List<Coordinate>(); List<Coordinate> lineArray = new List<Coordinate>();
foreach (WindStressPRM.Coordinate prmcoordinate in disabledLine.coords) foreach (WindStressPRM.Coordinate prmcoordinate in disabledLine.Coordinates)
{ {
Coordinate lineVerticeCoords = new Coordinate(prmcoordinate.X, prmcoordinate.Y); Coordinate lineVerticeCoords = new Coordinate(prmcoordinate.X, prmcoordinate.Y);
lineArray.Add(lineVerticeCoords); lineArray.Add(lineVerticeCoords);
} }
LineString lineGeometry = new LineString(lineArray); LineString lineGeometry = new LineString(lineArray);
IFeature lineFeature = disabledLineSet.AddFeature(lineGeometry); IFeature lineFeature = disabledLineSet.AddFeature(lineGeometry);
lineID = disabledLine.identifier; lineID = disabledLine.Identifier;
lineFeature.DataRow["ID"] = lineID; lineFeature.DataRow["ID"] = lineID;
} }
//add resulting layer to the map //add resulting layer to the map
......
...@@ -73,10 +73,13 @@ namespace WindStressPRM ...@@ -73,10 +73,13 @@ namespace WindStressPRM
public bool CheckValue() public bool CheckValue()
{ {
bool checker = true; bool checker = true;
if (X != null) { checker = true; } if (X != null && Y != null)
else { checker = false; } {
if (Y != null) { checker = true; } checker = true;
else { checker = false; } }
else {
checker = false;
}
return checker; return checker;
} }
} }
...@@ -90,17 +93,17 @@ namespace WindStressPRM ...@@ -90,17 +93,17 @@ namespace WindStressPRM
/// U - component of wind velocity, m/s /// U - component of wind velocity, m/s
/// U - компонента скорости ветра, м/с /// U - компонента скорости ветра, м/с
/// </summary> /// </summary>
public double velocityX; public double VelocityX;
/// <summary> /// <summary>
/// V - component of wind velocity, m/s /// V - component of wind velocity, m/s
/// V - компонента скорости ветра, м/с /// V - компонента скорости ветра, м/с
/// </summary> /// </summary>
public double velocityY; public double VelocityY;
/// <summary> /// <summary>
/// Cell center coordinates /// Cell center coordinates
/// Координаты центра ячейки /// Координаты центра ячейки
/// </summary> /// </summary>
public Coordinate coords; public Coordinate Coordinate;
/// <summary> /// <summary>
/// designated constructor /// designated constructor
/// </summary> /// </summary>
...@@ -115,9 +118,9 @@ namespace WindStressPRM ...@@ -115,9 +118,9 @@ namespace WindStressPRM
} }
else else
{ {
this.coords = coord; this.Coordinate = coord;
this.velocityX = vX; this.VelocityX = vX;
this.velocityY = vY; this.VelocityY = vY;
} }
} }
/// <summary> /// <summary>
...@@ -128,10 +131,13 @@ namespace WindStressPRM ...@@ -128,10 +131,13 @@ namespace WindStressPRM
{ {
bool checker = false; bool checker = false;
///Скорость ветра на высоте 10м от поверхности на Земле не может превышать 70м/c ///Скорость ветра на высоте 10м от поверхности на Земле не может превышать 70м/c
if (Math.Abs(velocityX) < 70) { checker = true; } if (Math.Abs(VelocityX) < 70 && Math.Abs(VelocityY) < 70)
else { checker = false; } {
if (Math.Abs(velocityY) < 70) { checker = true; } checker = true;
else { checker = false; } }
else {
checker = false;
}
return checker; return checker;
} }
} }
...@@ -145,22 +151,22 @@ namespace WindStressPRM ...@@ -145,22 +151,22 @@ namespace WindStressPRM
/// once-in-5-years frequency wind, m/s /// once-in-5-years frequency wind, m/s
/// скорость ветра повторяемости один раз в 5 лет, м/с /// скорость ветра повторяемости один раз в 5 лет, м/с
/// </summary> /// </summary>
public double wind5; public double Wind5;
/// <summary> /// <summary>
/// once-in-10-years frequency wind, m/s /// once-in-10-years frequency wind, m/s
/// скорость ветра повторяемости один раз в 10 лет, м/с /// скорость ветра повторяемости один раз в 10 лет, м/с
/// </summary> /// </summary>
public double wind10; public double Wind10;
/// <summary> /// <summary>
/// once-in-15-years frequency wind, m/s /// once-in-15-years frequency wind, m/s
/// скорость ветра повторяемости один раз в 15 лет, м/с /// скорость ветра повторяемости один раз в 15 лет, м/с
/// </summary> /// </summary>
public double wind15; public double Wind15;
/// <summary> /// <summary>
/// Cell center coordinate pair /// Cell center coordinate pair
/// Координаты центра ячейки /// Координаты центра ячейки
/// </summary> /// </summary>
public Coordinate coords; public Coordinate Coordinate;
/// <summary> /// <summary>
/// designated constructor /// designated constructor
/// </summary> /// </summary>
...@@ -176,10 +182,10 @@ namespace WindStressPRM ...@@ -176,10 +182,10 @@ namespace WindStressPRM
} }
else else
{ {
this.coords = coord; this.Coordinate = coord;
this.wind5 = w5; this.Wind5 = w5;
this.wind10 = w10; this.Wind10 = w10;
this.wind15 = w15; this.Wind15 = w15;
} }
} }
/// <summary> /// <summary>
...@@ -189,8 +195,13 @@ namespace WindStressPRM ...@@ -189,8 +195,13 @@ namespace WindStressPRM
public bool CheckValue() public bool CheckValue()
{ {
bool checker = true; bool checker = true;
if (Math.Abs(wind5) < 70 && Math.Abs(wind10) < 70 && Math.Abs(wind15) < 70) { checker = true; } if (Math.Abs(Wind5) < 70 && Math.Abs(Wind10) < 70 && Math.Abs(Wind15) < 70)
else { checker = false; } {
checker = true;
}
else {
checker = false;
}
return checker; return checker;
} }
} }
...@@ -203,11 +214,11 @@ namespace WindStressPRM ...@@ -203,11 +214,11 @@ namespace WindStressPRM
/// <summary> /// <summary>
/// ширина ячейки (расстояние между соседними по широте центрами ячеек) /// ширина ячейки (расстояние между соседними по широте центрами ячеек)
/// </summary> /// </summary>
public double width; public double Width;
/// <summary> /// <summary>
/// высота ячейки (расстояние между соседними по долготе центрами ячеек) /// высота ячейки (расстояние между соседними по долготе центрами ячеек)
/// </summary> /// </summary>
public double height; public double Height;
/// <summary> /// <summary>
/// designated constructor /// designated constructor
/// </summary> /// </summary>
...@@ -215,8 +226,8 @@ namespace WindStressPRM ...@@ -215,8 +226,8 @@ namespace WindStressPRM
/// <param name="hgh">Cell Height</param> /// <param name="hgh">Cell Height</param>
public CellSize(double wdh, double hgh) public CellSize(double wdh, double hgh)
{ {
this.width = wdh; this.Width = wdh;
this.height = hgh; this.Height = hgh;
if (!(this.CheckValue())) if (!(this.CheckValue()))
{ {
throw new System.ArgumentException("Cell width or height values are incorrect!"); throw new System.ArgumentException("Cell width or height values are incorrect!");
...@@ -229,7 +240,10 @@ namespace WindStressPRM ...@@ -229,7 +240,10 @@ namespace WindStressPRM
public bool CheckValue() public bool CheckValue()
{ {
bool checker = true; bool checker = true;
if (width > 0 && height > 0) { checker = true; } if (Width > 0 && Height > 0)
{
checker = true;
}
else { checker = false; } else { checker = false; }
return checker; return checker;
} }
...@@ -244,47 +258,47 @@ namespace WindStressPRM ...@@ -244,47 +258,47 @@ namespace WindStressPRM
/// unique id /// unique id
/// уникальный идентификатор /// уникальный идентификатор
/// </summary> /// </summary>
public int identifier { get; set; } public int Identifier { get; set; }
/// <summary> /// <summary>
/// year of construction /// year of construction
/// год постройки ЛЭП /// год постройки ЛЭП
/// </summary> /// </summary>
public int year; public int Year;
/// <summary> /// <summary>
/// average height of cable span between two poles, meters /// average height of cable span between two poles, meters
/// средняя высота пролета, м /// средняя высота пролета, м
/// </summary> /// </summary>
public double height; public double Height;
/// <summary> /// <summary>
/// power kW for switches /// power kW for switches
/// Мощность ЛЭП, кВт /// Мощность ЛЭП, кВт
/// </summary> /// </summary>
public int power; public int Power;
/// <summary> /// <summary>
/// Line vertices coordinate list /// Line vertices coordinate list
/// список координат вершин ЛЭП как линейного объекта /// список координат вершин ЛЭП как линейного объекта
/// </summary> /// </summary>
public List<Coordinate> coords { get; set; } public List<Coordinate> Coordinates { get; set; }
/// <summary> /// <summary>
/// assigned powerstation/pole /// assigned powerstation/pole
/// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция) /// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)
/// </summary> /// </summary>
public int pointFromID; public int PointFromID;
/// <summary> /// <summary>
/// assigned powerstation/pole /// assigned powerstation/pole
/// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция) /// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)
/// </summary> /// </summary>
public int pointToID; public int PointToID;
/// <summary> /// <summary>
/// broken/not broken switch /// broken/not broken switch
/// сломана (true) или нет (false) линяя /// сломана (true) или нет (false) линяя
/// </summary> /// </summary>
public bool isbroken; public bool IsBroken;
/// <summary> /// <summary>
/// power on switch /// power on switch
/// получает (true) или нет (false) линия питание /// получает (true) или нет (false) линия питание
/// </summary> /// </summary>
public bool ison; public bool IsON;
private int MissingIdValue = -1; private int MissingIdValue = -1;
public Powerline() public Powerline()
{ {
...@@ -304,17 +318,19 @@ namespace WindStressPRM ...@@ -304,17 +318,19 @@ namespace WindStressPRM
/// <param name="fromID"></param> /// <param name="fromID"></param>
public Powerline(List<Coordinate> coordinates, int id, int year, double height, int power, int toID, int fromID) public Powerline(List<Coordinate> coordinates, int id, int year, double height, int power, int toID, int fromID)
{ {
this.coords = coordinates; this.Coordinates = coordinates;
this.identifier = id; this.Identifier = id;
this.year = year; this.Year = year;
this.height = height; this.Height = height;
this.power = power; this.Power = power;
this.isbroken = false; this.IsBroken = false;
this.ison = false; this.IsON = false;
this.pointFromID = fromID; this.PointFromID = fromID;
this.pointToID = toID; this.PointToID = toID;
if (!(this.CheckValue())) if (!(this.CheckValue()))
{ throw new System.ArgumentException("Powerline object wasn't initialized correctly"); } {
throw new System.ArgumentException("Powerline object wasn't initialized correctly");
}
} }
/// <summary> /// <summary>
/// проверка валидности полей /// проверка валидности полей
...@@ -323,8 +339,10 @@ namespace WindStressPRM ...@@ -323,8 +339,10 @@ namespace WindStressPRM
public bool CheckValue() public bool CheckValue()
{ {
bool checker = true; bool checker = true;
if ( identifier>= 0 && Math.Abs(year - 1985) < 45 && Math.Abs(height - 15)<15 && power > 0 && power < 1000 && pointFromID >=0 && pointToID >=0) if ( Identifier >= 0 && Math.Abs(Year - 1985) < 45 && Math.Abs(Height - 15)<15 && Power > 0 && Power < 1000 && PointFromID >=0 && PointToID >=0)
{ checker = true; } {
checker = true;
}
else { checker = false; } else { checker = false; }
return checker; return checker;
} }
...@@ -339,45 +357,48 @@ namespace WindStressPRM ...@@ -339,45 +357,48 @@ namespace WindStressPRM
/// unique id /// unique id
/// уникальный идентификатор подстанции/столба /// уникальный идентификатор подстанции/столба
/// </summary> /// </summary>
public int identifier; public int Identifier;
/// <summary> /// <summary>
/// Coordinates /// Coordinates
/// </summary> /// </summary>
public Coordinate coords; public Coordinate Coordinate;
/// <summary> /// <summary>
/// station name field /// station name field
/// название подстанции /// название подстанции
/// </summary> /// </summary>
public string name; public string Name;
/// <summary> /// <summary>
/// power, kW /// power, kW
/// мощность, кВт /// мощность, кВт
/// </summary> /// </summary>
public int power; public int Power;
/// <summary> /// <summary>
/// type of point - trans/pole/endpoint /// type of point - trans/pole/endpoint
/// тип станции - трансформаторная подстанция/столб/понижающая(конечная)подстанция /// тип станции - трансформаторная подстанция/столб/понижающая(конечная)подстанция
/// </summary> /// </summary>
public enum stationtype {pole, trans, endstat}; public enum StationType
{
Pole, Trans, Endstat
};
/// <summary> /// <summary>
/// тип подстанции /// тип подстанции
/// </summary> /// </summary>
public stationtype type; public StationType Stationtype;
/// <summary> /// <summary>
/// is point a source? /// is point a source?
/// является ли подстаниция источником питания (в случае ТЭЦ или питания от внешних для рассматриваемой цепи ЛЭП) /// является ли подстаниция источником питания (в случае ТЭЦ или питания от внешних для рассматриваемой цепи ЛЭП)
/// </summary> /// </summary>
public bool issource; public bool IsSource;
/// <summary> /// <summary>
/// power on switch /// power on switch
/// поступает (true) или нет (false) на подстанцию питание /// поступает (true) или нет (false) на подстанцию питание
/// </summary> /// </summary>
public bool ison; public bool IsON;
/// <summary> /// <summary>
/// asigned powerlines list /// asigned powerlines list
/// список оканчивающихся/начинающихся на подстанции ЛЭП /// список оканчивающихся/начинающихся на подстанции ЛЭП
/// </summary> /// </summary>
public List<Powerline> linelist; public List<Powerline> LineList;
public PowerStation() public PowerStation()
{ {
//default constructor //default constructor
...@@ -392,21 +413,23 @@ namespace WindStressPRM ...@@ -392,21 +413,23 @@ namespace WindStressPRM
/// <param name="sttype"></param> /// <param name="sttype"></param>
/// <param name="issource"></param> /// <param name="issource"></param>
/// <param name="ison"></param> /// <param name="ison"></param>
public PowerStation(Coordinate crds, int id, string stname, int stpower, stationtype sttype, bool issource) public PowerStation(Coordinate crds, int id, string stname, int stpower, StationType sttype, bool issource)
{ {
this.coords = crds; this.Coordinate = crds;
this.identifier = id; this.Identifier = id;
this.name = stname; this.Name = stname;
this.power = stpower; this.Power = stpower;
this.type = sttype; this.Stationtype = sttype;
this.issource = issource; this.IsSource = issource;
this.ison = false; this.IsON = false;
} }
public bool CheckValue() public bool CheckValue()
{ {
bool checker = true; bool checker = true;
if (identifier >=0 && power >0 && power < 1000 ) if (Identifier >=0 && Power >0 && Power < 1000 )
{ checker = true; } {
checker = true;
}
else { checker = false; } else { checker = false; }
return checker; return checker;
...@@ -430,55 +453,67 @@ namespace WindStressPRM ...@@ -430,55 +453,67 @@ namespace WindStressPRM
/// prognistic raster info /// prognistic raster info
/// массив прогностического ветра /// массив прогностического ветра
/// </summary> /// </summary>
public List<List<PrognosticCell>> prognosticCells {get; set;} public List<List<PrognosticCell>> PrognosticCells { get; set; }
/// <summary> /// <summary>
/// prognostic raster cell info /// prognostic raster cell info
/// параметры ячеек регулярной сетки прогностического ветра /// параметры ячеек регулярной сетки прогностического ветра
/// </summary> /// </summary>
public CellSize prognosticCellSize { get; set; } public CellSize PrognosticCellSize { get; set; }
/// <summary> /// <summary>
/// affine coefficients from prognostic raster projections /// affine coefficients from prognostic raster projections
/// коэффициенты аффиного проеобразования из проекции массива прогностического ветра /// коэффициенты аффиного проеобразования из проекции массива прогностического ветра
/// </summary> /// </summary>
public double[] prognosticAffineCoefficients { get; set; } public double[] PrognosticAffineCoefficients { get; set; }
/// <summary> /// <summary>
/// climate raster array /// climate raster array
/// массив климатических полей скорости ветра заданной повторяемости /// массив климатических полей скорости ветра заданной повторяемости
/// </summary> /// </summary>
public List<List<ClimateCell>> climateCells { get; set; } public List<List<ClimateCell>> ClimateCells { get; set; }
/// <summary> /// <summary>
/// climate raster cell info /// climate raster cell info
/// параметры ячеек регулярной сетки климатических полей скорости ветра заданной повторяемости /// параметры ячеек регулярной сетки климатических полей скорости ветра заданной повторяемости
/// </summary> /// </summary>
public CellSize climateCellSize { get; set; } public CellSize ClimateCellSize { get; set; }
/// <summary> /// <summary>
/// affine coefficients from climate raster projection /// affine coefficients from climate raster projection
/// коэффициенты аффинного преобразования из проекции массива климатических полей скорости ветра заданной повторяемости /// коэффициенты аффинного преобразования из проекции массива климатических полей скорости ветра заданной повторяемости
/// </summary> /// </summary>
public double[] climateAffineCoefficients { get; set; } public double[] ClimateAffineCoefficients { get; set; }
/// <summary> /// <summary>
/// lines list /// lines list
/// список ЛЭП /// список ЛЭП
/// </summary> /// </summary>
public List<Powerline> powerLines { get; set; } public List<Powerline> PowerLines { get; set; }
/// <summary> /// <summary>
/// stations/poles list /// stations/poles list
/// список точечных объектов - трансформаторных подстанций/столбов/понижающих(конечных) подстанций /// список точечных объектов - трансформаторных подстанций/столбов/понижающих(конечных) подстанций
/// </summary> /// </summary>
public List<PowerStation> powerStations { get; set; } public List<PowerStation> PowerStations { get; set; }
/// <summary> /// <summary>
/// maximum distance for line segment, meters /// maximum distance for line segment, meters
/// максимальное расстояние между точками ЛЭП, для которых проверяется сломаются/несломаются под действием ветра /// максимальное расстояние между точками ЛЭП, для которых проверяется сломаются/несломаются под действием ветра
/// </summary> /// </summary>
public double dist_threshold public double DistThreshold
{ {
get get
{ {
return 500; return 500;
} }
} }
/// <summary>
/// missing raster value for cells, if you haven't normal value use this one.
/// потерянное значение для растрового объекта; Если Вы не имеете данных - используйте это значение
/// </summary>
public double kMissingRasterValue
{
get
{
return -9999;
}
}
} }
/// <summary> /// <summary>
/// Output /// Output
...@@ -489,12 +524,12 @@ namespace WindStressPRM ...@@ -489,12 +524,12 @@ namespace WindStressPRM
/// stations list without power /// stations list without power
/// Список подстанций на которые не поступит питание в результате предсказанных поломок ЛЭП в сети /// Список подстанций на которые не поступит питание в результате предсказанных поломок ЛЭП в сети
/// </summary> /// </summary>
public List<PowerStation> disabledStations { get; set; } public List<PowerStation> DisabledStations { get; set; }
/// <summary> /// <summary>
/// broken lines list /// broken lines list
/// Список прогнозируемых сломанных ЛЭП в результате ветрового воздействия /// Список прогнозируемых сломанных ЛЭП в результате ветрового воздействия
/// </summary> /// </summary>
public List<Powerline> disabledLines { get; set; } public List<Powerline> DisabledLines { get; set; }
} }
/// <summary> /// <summary>
/// main calculations class /// main calculations class
...@@ -504,7 +539,7 @@ namespace WindStressPRM ...@@ -504,7 +539,7 @@ namespace WindStressPRM
/// <summary> /// <summary>
/// Input Data /// Input Data
/// </summary> /// </summary>
private Input input; private Input Input;
/// <summary> /// <summary>
/// Main function for power graph algorithm /// Main function for power graph algorithm
...@@ -512,36 +547,36 @@ namespace WindStressPRM ...@@ -512,36 +547,36 @@ namespace WindStressPRM
/// </summary> /// </summary>
public Output CheckPower(Input input) public Output CheckPower(Input input)
{ {
this.input = input; this.Input = input;
//Calculate which lines are broken //Calculate which lines are broken
List<WindStressPRM.Powerline> prmBrokenLines = brokenPowerLinesAfterCheck(); List<WindStressPRM.Powerline> prmBrokenLines = brokenPowerLinesAfterCheck();
//get the graph //get the graph
PreparingPowerItems(); PreparingPowerItems();
//start from source points //start from source points
foreach (PowerStation pwstation in input.powerStations) foreach (PowerStation pwstation in input.PowerStations)
{ {
if (pwstation.issource) if (pwstation.IsSource)
{ {
CheckPowerPointsForStation(pwstation); CheckPowerPointsForStation(pwstation);
} }
} }
//fill output //fill output
Output output = new Output(); Output output = new Output();
output.disabledStations = new List<PowerStation>(); output.DisabledStations = new List<PowerStation>();
output.disabledLines = new List<Powerline>(); output.DisabledLines = new List<Powerline>();
foreach (Powerline line in input.powerLines) foreach (Powerline line in input.PowerLines)
{ {
if (line.isbroken) if (line.IsBroken)
{ {
output.disabledLines.Add(line); output.DisabledLines.Add(line);
} }
} }
foreach (PowerStation powerStation in input.powerStations) foreach (PowerStation powerStation in input.PowerStations)
{ {
//stations of type pole can be disabled if the line is broken //stations of type pole can be disabled if the line is broken
if (!powerStation.ison && !(powerStation.type == PowerStation.stationtype.pole)) if (!powerStation.IsON && !(powerStation.Stationtype == PowerStation.StationType.Pole))
{ {
output.disabledStations.Add(powerStation); output.DisabledStations.Add(powerStation);
} }
} }
return output; return output;
...@@ -552,39 +587,39 @@ namespace WindStressPRM ...@@ -552,39 +587,39 @@ namespace WindStressPRM
/// <param name="sourcepoint"> powered station to search next powered station from</param> /// <param name="sourcepoint"> powered station to search next powered station from</param>
private void CheckPowerPointsForStation(PowerStation sourcepoint) private void CheckPowerPointsForStation(PowerStation sourcepoint)
{ {
if (!sourcepoint.ison) if (!sourcepoint.IsON)
{ {
throw new Exception("CheckPowerPointsForStation is called from disabled sourcepoint"); throw new Exception("CheckPowerPointsForStation is called from disabled sourcepoint");
} }
// if the point is not a pole - i.e. we know // if the point is not a pole - i.e. we know
// it can redistribute power within connected lines // it can redistribute power within connected lines
// we turn it ON if any of the connected lines are powered // we turn it ON if any of the connected lines are powered
foreach (Powerline line in sourcepoint.linelist) foreach (Powerline line in sourcepoint.LineList)
{ {
if (!line.isbroken && !line.ison) if (!line.IsBroken && !line.IsON)
{ {
line.ison = true; line.IsON = true;
foreach (PowerStation powerStation in input.powerStations) foreach (PowerStation powerStation in Input.PowerStations)
{ {
if (powerStation.identifier != sourcepoint.identifier && (powerStation.identifier == line.pointFromID || powerStation.identifier == line.pointToID)) if (powerStation.Identifier != sourcepoint.Identifier && (powerStation.Identifier == line.PointFromID || powerStation.Identifier == line.PointToID))
{ {
if (!(sourcepoint.type == PowerStation.stationtype.pole)) { if (!(sourcepoint.Stationtype == PowerStation.StationType.Pole)) {
powerStation.ison = true; powerStation.IsON = true;
CheckPowerPointsForStation(powerStation); CheckPowerPointsForStation(powerStation);
} }
else { else {
// if line is a pole we have to check if it's actually able to // if line is a pole we have to check if it's actually able to
// get electricity to other points i.e. no connected lines are broken // get electricity to other points i.e. no connected lines are broken
bool powerLineCheck = false; bool powerLineCheck = false;
foreach (Powerline powerline in powerStation.linelist) foreach (Powerline powerline in powerStation.LineList)
{ {
if (powerline.isbroken) { if (powerline.IsBroken) {
powerLineCheck = true; powerLineCheck = true;
} }
} }
if (!powerLineCheck) if (!powerLineCheck)
{ {
powerStation.ison = true; powerStation.IsON = true;
CheckPowerPointsForStation(powerStation); CheckPowerPointsForStation(powerStation);
} }
} }
...@@ -602,26 +637,26 @@ namespace WindStressPRM ...@@ -602,26 +637,26 @@ namespace WindStressPRM
{ {
//First we make sure that all the sources are ON //First we make sure that all the sources are ON
//and all non sources are OFF //and all non sources are OFF
foreach (PowerStation powerStation in input.powerStations) foreach (PowerStation powerStation in Input.PowerStations)
{ {
if (powerStation.issource == true) { if (powerStation.IsSource == true) {
powerStation.ison = true; powerStation.IsON = true;
} }
else { else {
powerStation.ison = false; powerStation.IsON = false;
} }
// for each power station we create a list of powerlines it is attached to // for each power station we create a list of powerlines it is attached to
List<Powerline> lines = new List<Powerline>(); List<Powerline> lines = new List<Powerline>();
foreach (Powerline line in input.powerLines) foreach (Powerline line in Input.PowerLines)
{ {
//we also switch OFF all lines //we also switch OFF all lines
line.ison = false; line.IsON = false;
if (line.pointFromID == powerStation.identifier || line.pointToID == powerStation.identifier) { if (line.PointFromID == powerStation.Identifier || line.PointToID == powerStation.Identifier) {
lines.Add(line); lines.Add(line);
} }
} }
powerStation.linelist = lines; powerStation.LineList = lines;
} }
} }
/// <summary> /// <summary>
...@@ -632,10 +667,10 @@ namespace WindStressPRM ...@@ -632,10 +667,10 @@ namespace WindStressPRM
{ {
List<Powerline> brokenLines = new List<Powerline>(); List<Powerline> brokenLines = new List<Powerline>();
// actually there are curves in powerLines // actually there are curves in powerLines
foreach (Powerline powerCurve in input.powerLines) foreach (Powerline powerCurve in Input.PowerLines)
{ {
// get coordinates list // get coordinates list
List<Coordinate> points = powerCurve.coords; List<Coordinate> points = powerCurve.Coordinates;
List<bool> checkList = new List<bool>(); List<bool> checkList = new List<bool>();
// cycle throw all points in line // cycle throw all points in line
...@@ -645,17 +680,17 @@ namespace WindStressPRM ...@@ -645,17 +680,17 @@ namespace WindStressPRM
double y1 = points[i - 1].Y; double y1 = points[i - 1].Y;
double x2 = points[i].X; double x2 = points[i].X;
double y2 = points[i].Y; double y2 = points[i].Y;
bool result = linearLineIsBroken(points[i - 1], points[i], powerCurve.height, powerCurve.power); bool result = linearLineIsBroken(points[i - 1], points[i], powerCurve.Height, powerCurve.Power);
checkList.Add(result); checkList.Add(result);
} }
foreach (bool chkpnt in checkList) foreach (bool chkpnt in checkList)
{ {
if (chkpnt == true) if (chkpnt == true)
{ {
powerCurve.isbroken = true; powerCurve.IsBroken = true;
} }
} }
if (powerCurve.isbroken) if (powerCurve.IsBroken)
{ {
brokenLines.Add(powerCurve); brokenLines.Add(powerCurve);
} }
...@@ -677,7 +712,7 @@ namespace WindStressPRM ...@@ -677,7 +712,7 @@ namespace WindStressPRM
private bool linearLineIsBroken(Coordinate coord1, Coordinate coord2, double heightLine, int power) private bool linearLineIsBroken(Coordinate coord1, Coordinate coord2, double heightLine, int power)
{ {
double distance = Math.Sqrt((coord2.X - coord1.X) * (coord2.X - coord1.X) + (coord2.Y - coord1.Y) * (coord2.Y - coord1.Y)); 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; double distpropD = distance / Input.DistThreshold;
List<Coordinate> pointlist = new List<Coordinate>(); List<Coordinate> pointlist = new List<Coordinate>();
Coordinate midpoint = new Coordinate(0, 0); Coordinate midpoint = new Coordinate(0, 0);
int distpropI = Convert.ToInt32(distpropD); int distpropI = Convert.ToInt32(distpropD);
...@@ -778,13 +813,13 @@ namespace WindStressPRM ...@@ -778,13 +813,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX: case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY: case FunctionType.FunctionVelocityY:
{ {
return input.prognosticAffineCoefficients; return Input.PrognosticAffineCoefficients;
} }
case FunctionType.FunctionClimate5: case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10: case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15: case FunctionType.FunctionClimate15:
{ {
return input.climateAffineCoefficients; return Input.ClimateAffineCoefficients;
} }
default: default:
break; break;
...@@ -834,13 +869,13 @@ namespace WindStressPRM ...@@ -834,13 +869,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX: case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY: case FunctionType.FunctionVelocityY:
{ {
return input.prognosticCells[index.Row][index.Col].coords; return Input.PrognosticCells[index.Row][index.Col].Coordinate;
} }
case FunctionType.FunctionClimate5: case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10: case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15: case FunctionType.FunctionClimate15:
{ {
return input.climateCells[index.Row][index.Col].coords; return Input.ClimateCells[index.Row][index.Col].Coordinate;
} }
default: default:
break; break;
...@@ -855,13 +890,13 @@ namespace WindStressPRM ...@@ -855,13 +890,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX: case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY: case FunctionType.FunctionVelocityY:
{ {
return forRows ? input.prognosticCells.Count : input.prognosticCells[0].Count; return forRows ? Input.PrognosticCells.Count : Input.PrognosticCells[0].Count;
} }
case FunctionType.FunctionClimate5: case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10: case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15: case FunctionType.FunctionClimate15:
{ {
return forRows ? input.climateCells.Count : input.climateCells[0].Count; return forRows ? Input.ClimateCells.Count : Input.ClimateCells[0].Count;
} }
default: default:
break; break;
...@@ -875,23 +910,23 @@ namespace WindStressPRM ...@@ -875,23 +910,23 @@ namespace WindStressPRM
{ {
case FunctionType.FunctionVelocityX: case FunctionType.FunctionVelocityX:
{ {
return input.prognosticCells[index.Row][index.Col].velocityX; return Input.PrognosticCells[index.Row][index.Col].VelocityX;
} }
case FunctionType.FunctionVelocityY: case FunctionType.FunctionVelocityY:
{ {
return input.prognosticCells[index.Row][index.Col].velocityY; return Input.PrognosticCells[index.Row][index.Col].VelocityY;
} }
case FunctionType.FunctionClimate5: case FunctionType.FunctionClimate5:
{ {
return input.climateCells[index.Row][index.Col].wind5; return Input.ClimateCells[index.Row][index.Col].Wind5;
} }
case FunctionType.FunctionClimate10: case FunctionType.FunctionClimate10:
{ {
return input.climateCells[index.Row][index.Col].wind10; return Input.ClimateCells[index.Row][index.Col].Wind10;
} }
case FunctionType.FunctionClimate15: case FunctionType.FunctionClimate15:
{ {
return input.climateCells[index.Row][index.Col].wind15; return Input.ClimateCells[index.Row][index.Col].Wind15;
} }
default: default:
break; break;
...@@ -906,13 +941,13 @@ namespace WindStressPRM ...@@ -906,13 +941,13 @@ namespace WindStressPRM
case FunctionType.FunctionVelocityX: case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY: case FunctionType.FunctionVelocityY:
{ {
return input.prognosticCellSize; return Input.PrognosticCellSize;
} }
case FunctionType.FunctionClimate5: case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10: case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15: case FunctionType.FunctionClimate15:
{ {
return input.climateCellSize; return Input.ClimateCellSize;
} }
default: default:
break; break;
...@@ -957,10 +992,63 @@ namespace WindStressPRM ...@@ -957,10 +992,63 @@ namespace WindStressPRM
double valTopLeft = valueForFunction(functionType, rcTopLeft); double valTopLeft = valueForFunction(functionType, rcTopLeft);
double valTopRight = valueForFunction(functionType, rcTopRight); double valTopRight = valueForFunction(functionType, rcTopRight);
Coordinate origin = cellToProjection(rcBotLeft, functionType); Coordinate origin = cellToProjection(rcBotLeft, functionType);
//PRM_coordinate last = cellToProjection(rcTopRight, functionType);//test only bool testBotLeft = valBotLeft == Input.kMissingRasterValue;
bool testBotRight = valBotRight == Input.kMissingRasterValue;
bool testTopLeft = valTopLeft == Input.kMissingRasterValue;
bool testTopRight = valTopRight == Input.kMissingRasterValue;
if (testBotLeft || testBotRight || testTopLeft || testTopRight)
{
// tests indicates that value at test-cell is missed.
if (testTopRight && testTopLeft && testBotLeft && testBotRight)
{
throw new Exception("Current value in such a bad place, you need to fill these place with raster values");
}
int count = 0;
if (testBotLeft)
{
valBotLeft = 0;
count++;
}
if (testBotRight)
{
valBotRight = 0;
count++;
}
if (testTopLeft)
{
valTopLeft = 0;
count++;
}
if (testTopRight)
{
valTopRight = 0;
count++;
}
//of course there is count not 0;
if (count == 0) {
throw new Exception("Interpolation Logic Error");
}
double average = (valTopLeft + valTopRight + valBotLeft + valBotRight)/count;
if (testBotLeft)
{
valBotLeft = average;
}
if (testBotRight)
{
valBotRight = average;
}
if (testTopLeft)
{
valTopLeft = average;
}
if (testTopRight)
{
valTopRight = average;
}
}
// sizes for cell // sizes for cell
double hx = cellSizeForFunction(functionType).width; double hx = cellSizeForFunction(functionType).Width;
double hy = cellSizeForFunction(functionType).height; double hy = cellSizeForFunction(functionType).Height;
// coefficients // coefficients
double px = (coords.X - origin.X) / hx; double px = (coords.X - origin.X) / hx;
double py = (coords.Y - origin.Y) / hy; double py = (coords.Y - origin.Y) / hy;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment