Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MES_Wind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Debolskiy Andrey
MES_Wind
Commits
3e9f8ce8
Commit
3e9f8ce8
authored
8 years ago
by
Debolskiy Andrey
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into second_round_andrey
# Conflicts: # WindStressPRM/WindStressPRM.cs
parents
60dee1ff
4bd177f8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
MES_Wind/frmMain.cs
+29
-29
29 additions, 29 deletions
MES_Wind/frmMain.cs
WindStressPRM/WindStressPRM.cs
+222
-134
222 additions, 134 deletions
WindStressPRM/WindStressPRM.cs
with
251 additions
and
163 deletions
MES_Wind/frmMain.cs
+
29
−
29
View file @
3e9f8ce8
...
@@ -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
.
i
dentifier
=
feature
.
Fid
;
dummyline
.
I
dentifier
=
feature
.
Fid
;
dummyline
.
y
ear
=
int
.
Parse
(
featureData
[
"Year"
].
ToString
());
dummyline
.
Y
ear
=
int
.
Parse
(
featureData
[
"Year"
].
ToString
());
dummyline
.
h
eight
=
double
.
Parse
(
featureData
[
"HeightOffs"
].
ToString
());
dummyline
.
H
eight
=
double
.
Parse
(
featureData
[
"HeightOffs"
].
ToString
());
dummyline
.
p
ower
=
int
.
Parse
(
featureData
[
"Power"
].
ToString
());
dummyline
.
P
ower
=
int
.
Parse
(
featureData
[
"Power"
].
ToString
());
dummyline
.
p
ointFromID
=
int
.
Parse
(
featureData
[
"PointFrom"
].
ToString
());
dummyline
.
P
ointFromID
=
int
.
Parse
(
featureData
[
"PointFrom"
].
ToString
());
dummyline
.
p
ointToID
=
int
.
Parse
(
featureData
[
"PointTo"
].
ToString
());
dummyline
.
P
ointToID
=
int
.
Parse
(
featureData
[
"PointTo"
].
ToString
());
LineString
featureline
=
feature
.
BasicGeometry
as
LineString
;
LineString
featureline
=
feature
.
BasicGeometry
as
LineString
;
dummyline
.
c
oords
=
DotspLinestringToPrm
(
featureline
);
dummyline
.
C
oord
inate
s
=
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
.
i
dentifier
=
featurepoint
.
Fid
;
dummystation
.
I
dentifier
=
featurepoint
.
Fid
;
dummystation
.
n
ame
=
featureData
[
"Name"
].
ToString
();
dummystation
.
N
ame
=
featureData
[
"Name"
].
ToString
();
dummystation
.
p
ower
=
int
.
Parse
(
featureData
[
"Power"
].
ToString
());
dummystation
.
P
ower
=
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
.
iss
ource
=
false
;
dummystation
.
IsS
ource
=
false
;
}
}
else
else
{
{
if
(
issr
==
1
)
if
(
issr
==
1
)
{
{
dummystation
.
iss
ource
=
true
;
dummystation
.
IsS
ource
=
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
.
s
tation
t
ype
.
p
ole
;
dummystation
.
Station
type
=
WindStressPRM
.
PowerStation
.
S
tation
T
ype
.
P
ole
;
}
}
else
if
(
featureData
[
"Type"
].
ToString
().
Trim
().
ToUpper
()
==
"TRANS"
)
else
if
(
featureData
[
"Type"
].
ToString
().
Trim
().
ToUpper
()
==
"TRANS"
)
{
{
dummystation
.
type
=
WindStressPRM
.
PowerStation
.
s
tation
t
ype
.
t
rans
;
dummystation
.
Station
type
=
WindStressPRM
.
PowerStation
.
S
tation
T
ype
.
T
rans
;
}
}
else
if
(
featureData
[
"Type"
].
ToString
().
Trim
().
ToUpper
()
==
"ENDSTAT"
)
else
if
(
featureData
[
"Type"
].
ToString
().
Trim
().
ToUpper
()
==
"ENDSTAT"
)
{
{
dummystation
.
type
=
WindStressPRM
.
PowerStation
.
s
tation
t
ype
.
e
ndstat
;
dummystation
.
Station
type
=
WindStressPRM
.
PowerStation
.
S
tation
T
ype
.
E
ndstat
;
}
}
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
.
c
oord
s
=
DotspPointToPRM
(
featurepointcoords
);
dummystation
.
C
oord
inate
=
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
.
p
owerLines
=
powerlinesToPRM
;
input
.
P
owerLines
=
powerlinesToPRM
;
input
.
p
owerStations
=
powerpointsToPRM
;
input
.
P
owerStations
=
powerpointsToPRM
;
input
.
p
rognosticCells
=
prognosticWind
;
input
.
P
rognosticCells
=
prognosticWind
;
input
.
p
rognosticCellSize
=
progcellsize
;
input
.
P
rognosticCellSize
=
progcellsize
;
input
.
p
rognosticAffineCoefficients
=
prog_aff
;
input
.
P
rognosticAffineCoefficients
=
prog_aff
;
input
.
c
limateCells
=
climWind
;
input
.
C
limateCells
=
climWind
;
input
.
c
limateCellSize
=
climCellsize
;
input
.
C
limateCellSize
=
climCellsize
;
input
.
c
limateAffineCoefficients
=
climAffinecoeffs
;
input
.
C
limateAffineCoefficients
=
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
.
d
isabledStations
)
foreach
(
WindStressPRM
.
PowerStation
disabledStation
in
output
.
D
isabledStations
)
{
{
Coordinate
coords
=
new
Coordinate
(
disabledStation
.
c
oord
s
.
X
,
disabledStation
.
c
oord
s
.
Y
);
Coordinate
coords
=
new
Coordinate
(
disabledStation
.
C
oord
inate
.
X
,
disabledStation
.
C
oord
inate
.
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
.
d
isabledLines
)
foreach
(
WindStressPRM
.
Powerline
disabledLine
in
output
.
D
isabledLines
)
{
{
List
<
Coordinate
>
lineArray
=
new
List
<
Coordinate
>();
List
<
Coordinate
>
lineArray
=
new
List
<
Coordinate
>();
foreach
(
WindStressPRM
.
Coordinate
prmcoordinate
in
disabledLine
.
c
oords
)
foreach
(
WindStressPRM
.
Coordinate
prmcoordinate
in
disabledLine
.
C
oord
inate
s
)
{
{
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
.
i
dentifier
;
lineID
=
disabledLine
.
I
dentifier
;
lineFeature
.
DataRow
[
"ID"
]
=
lineID
;
lineFeature
.
DataRow
[
"ID"
]
=
lineID
;
}
}
//add resulting layer to the map
//add resulting layer to the map
...
...
This diff is collapsed.
Click to expand it.
WindStressPRM/WindStressPRM.cs
+
222
−
134
View file @
3e9f8ce8
...
@@ -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
v
elocityX
;
public
double
V
elocityX
;
/// <summary>
/// <summary>
/// V - component of wind velocity, m/s
/// V - component of wind velocity, m/s
/// V - компонента скорости ветра, м/с
/// V - компонента скорости ветра, м/с
/// </summary>
/// </summary>
public
double
v
elocityY
;
public
double
V
elocityY
;
/// <summary>
/// <summary>
/// Cell center coordinates
/// Cell center coordinates
/// Координаты центра ячейки
/// Координаты центра ячейки
/// </summary>
/// </summary>
public
Coordinate
c
oord
s
;
public
Coordinate
C
oord
inate
;
/// <summary>
/// <summary>
/// designated constructor
/// designated constructor
/// </summary>
/// </summary>
...
@@ -115,9 +118,9 @@ namespace WindStressPRM
...
@@ -115,9 +118,9 @@ namespace WindStressPRM
}
}
else
else
{
{
this
.
c
oord
s
=
coord
;
this
.
C
oord
inate
=
coord
;
this
.
v
elocityX
=
vX
;
this
.
V
elocityX
=
vX
;
this
.
v
elocityY
=
vY
;
this
.
V
elocityY
=
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
w
ind5
;
public
double
W
ind5
;
/// <summary>
/// <summary>
/// once-in-10-years frequency wind, m/s
/// once-in-10-years frequency wind, m/s
/// скорость ветра повторяемости один раз в 10 лет, м/с
/// скорость ветра повторяемости один раз в 10 лет, м/с
/// </summary>
/// </summary>
public
double
w
ind10
;
public
double
W
ind10
;
/// <summary>
/// <summary>
/// once-in-15-years frequency wind, m/s
/// once-in-15-years frequency wind, m/s
/// скорость ветра повторяемости один раз в 15 лет, м/с
/// скорость ветра повторяемости один раз в 15 лет, м/с
/// </summary>
/// </summary>
public
double
w
ind15
;
public
double
W
ind15
;
/// <summary>
/// <summary>
/// Cell center coordinate pair
/// Cell center coordinate pair
/// Координаты центра ячейки
/// Координаты центра ячейки
/// </summary>
/// </summary>
public
Coordinate
c
oord
s
;
public
Coordinate
C
oord
inate
;
/// <summary>
/// <summary>
/// designated constructor
/// designated constructor
/// </summary>
/// </summary>
...
@@ -176,10 +182,10 @@ namespace WindStressPRM
...
@@ -176,10 +182,10 @@ namespace WindStressPRM
}
}
else
else
{
{
this
.
c
oord
s
=
coord
;
this
.
C
oord
inate
=
coord
;
this
.
w
ind5
=
w5
;
this
.
W
ind5
=
w5
;
this
.
w
ind10
=
w10
;
this
.
W
ind10
=
w10
;
this
.
w
ind15
=
w15
;
this
.
W
ind15
=
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
w
idth
;
public
double
W
idth
;
/// <summary>
/// <summary>
/// высота ячейки (расстояние между соседними по долготе центрами ячеек)
/// высота ячейки (расстояние между соседними по долготе центрами ячеек)
/// </summary>
/// </summary>
public
double
h
eight
;
public
double
H
eight
;
/// <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
.
w
idth
=
wdh
;
this
.
W
idth
=
wdh
;
this
.
h
eight
=
hgh
;
this
.
H
eight
=
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
i
dentifier
{
get
;
set
;
}
public
int
I
dentifier
{
get
;
set
;
}
/// <summary>
/// <summary>
/// year of construction
/// year of construction
/// год постройки ЛЭП
/// год постройки ЛЭП
/// </summary>
/// </summary>
public
int
y
ear
;
public
int
Y
ear
;
/// <summary>
/// <summary>
/// average height of cable span between two poles, meters
/// average height of cable span between two poles, meters
/// средняя высота пролета, м
/// средняя высота пролета, м
/// </summary>
/// </summary>
public
double
h
eight
;
public
double
H
eight
;
/// <summary>
/// <summary>
/// power kW for switches
/// power kW for switches
/// Мощность ЛЭП, кВт
/// Мощность ЛЭП, кВт
/// </summary>
/// </summary>
public
int
p
ower
;
public
int
P
ower
;
/// <summary>
/// <summary>
/// Line vertices coordinate list
/// Line vertices coordinate list
/// список координат вершин ЛЭП как линейного объекта
/// список координат вершин ЛЭП как линейного объекта
/// </summary>
/// </summary>
public
List
<
Coordinate
>
c
oords
{
get
;
set
;
}
public
List
<
Coordinate
>
C
oord
inate
s
{
get
;
set
;
}
/// <summary>
/// <summary>
/// assigned powerstation/pole
/// assigned powerstation/pole
/// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)
/// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)
/// </summary>
/// </summary>
public
int
p
ointFromID
;
public
int
P
ointFromID
;
/// <summary>
/// <summary>
/// assigned powerstation/pole
/// assigned powerstation/pole
/// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)
/// идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)
/// </summary>
/// </summary>
public
int
p
ointToID
;
public
int
P
ointToID
;
/// <summary>
/// <summary>
/// broken/not broken switch
/// broken/not broken switch
/// сломана (true) или нет (false) линяя
/// сломана (true) или нет (false) линяя
/// </summary>
/// </summary>
public
bool
isb
roken
;
public
bool
IsB
roken
;
/// <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
.
c
oords
=
coordinates
;
this
.
C
oord
inate
s
=
coordinates
;
this
.
i
dentifier
=
id
;
this
.
I
dentifier
=
id
;
this
.
y
ear
=
year
;
this
.
Y
ear
=
year
;
this
.
h
eight
=
height
;
this
.
H
eight
=
height
;
this
.
p
ower
=
power
;
this
.
P
ower
=
power
;
this
.
isb
roken
=
false
;
this
.
IsB
roken
=
false
;
this
.
ison
=
false
;
this
.
IsON
=
false
;
this
.
p
ointFromID
=
fromID
;
this
.
P
ointFromID
=
fromID
;
this
.
p
ointToID
=
toID
;
this
.
P
ointToID
=
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
i
dentifier
;
public
int
I
dentifier
;
/// <summary>
/// <summary>
/// Coordinates
/// Coordinates
/// </summary>
/// </summary>
public
Coordinate
c
oord
s
;
public
Coordinate
C
oord
inate
;
/// <summary>
/// <summary>
/// station name field
/// station name field
/// название подстанции
/// название подстанции
/// </summary>
/// </summary>
public
string
n
ame
;
public
string
N
ame
;
/// <summary>
/// <summary>
/// power, kW
/// power, kW
/// мощность, кВт
/// мощность, кВт
/// </summary>
/// </summary>
public
int
p
ower
;
public
int
P
ower
;
/// <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
s
tation
t
ype
type
;
public
S
tation
T
ype
Station
type
;
/// <summary>
/// <summary>
/// is point a source?
/// is point a source?
/// является ли подстаниция источником питания (в случае ТЭЦ или питания от внешних для рассматриваемой цепи ЛЭП)
/// является ли подстаниция источником питания (в случае ТЭЦ или питания от внешних для рассматриваемой цепи ЛЭП)
/// </summary>
/// </summary>
public
bool
iss
ource
;
public
bool
IsS
ource
;
/// <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
>
l
ine
l
ist
;
public
List
<
Powerline
>
L
ine
L
ist
;
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
,
s
tation
t
ype
sttype
,
bool
issource
)
public
PowerStation
(
Coordinate
crds
,
int
id
,
string
stname
,
int
stpower
,
S
tation
T
ype
sttype
,
bool
issource
)
{
{
this
.
c
oord
s
=
crds
;
this
.
C
oord
inate
=
crds
;
this
.
i
dentifier
=
id
;
this
.
I
dentifier
=
id
;
this
.
n
ame
=
stname
;
this
.
N
ame
=
stname
;
this
.
p
ower
=
stpower
;
this
.
P
ower
=
stpower
;
this
.
type
=
sttype
;
this
.
Station
type
=
sttype
;
this
.
iss
ource
=
issource
;
this
.
IsS
ource
=
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
>>
p
rognosticCells
{
get
;
set
;}
public
List
<
List
<
PrognosticCell
>>
P
rognosticCells
{
get
;
set
;
}
/// <summary>
/// <summary>
/// prognostic raster cell info
/// prognostic raster cell info
/// параметры ячеек регулярной сетки прогностического ветра
/// параметры ячеек регулярной сетки прогностического ветра
/// </summary>
/// </summary>
public
CellSize
p
rognosticCellSize
{
get
;
set
;
}
public
CellSize
P
rognosticCellSize
{
get
;
set
;
}
/// <summary>
/// <summary>
/// affine coefficients from prognostic raster projections
/// affine coefficients from prognostic raster projections
/// коэффициенты аффиного проеобразования из проекции массива прогностического ветра
/// коэффициенты аффиного проеобразования из проекции массива прогностического ветра
/// </summary>
/// </summary>
public
double
[]
p
rognosticAffineCoefficients
{
get
;
set
;
}
public
double
[]
P
rognosticAffineCoefficients
{
get
;
set
;
}
/// <summary>
/// <summary>
/// climate raster array
/// climate raster array
/// массив климатических полей скорости ветра заданной повторяемости
/// массив климатических полей скорости ветра заданной повторяемости
/// </summary>
/// </summary>
public
List
<
List
<
ClimateCell
>>
c
limateCells
{
get
;
set
;
}
public
List
<
List
<
ClimateCell
>>
C
limateCells
{
get
;
set
;
}
/// <summary>
/// <summary>
/// climate raster cell info
/// climate raster cell info
/// параметры ячеек регулярной сетки климатических полей скорости ветра заданной повторяемости
/// параметры ячеек регулярной сетки климатических полей скорости ветра заданной повторяемости
/// </summary>
/// </summary>
public
CellSize
c
limateCellSize
{
get
;
set
;
}
public
CellSize
C
limateCellSize
{
get
;
set
;
}
/// <summary>
/// <summary>
/// affine coefficients from climate raster projection
/// affine coefficients from climate raster projection
/// коэффициенты аффинного преобразования из проекции массива климатических полей скорости ветра заданной повторяемости
/// коэффициенты аффинного преобразования из проекции массива климатических полей скорости ветра заданной повторяемости
/// </summary>
/// </summary>
public
double
[]
c
limateAffineCoefficients
{
get
;
set
;
}
public
double
[]
C
limateAffineCoefficients
{
get
;
set
;
}
/// <summary>
/// <summary>
/// lines list
/// lines list
/// список ЛЭП
/// список ЛЭП
/// </summary>
/// </summary>
public
List
<
Powerline
>
p
owerLines
{
get
;
set
;
}
public
List
<
Powerline
>
P
owerLines
{
get
;
set
;
}
/// <summary>
/// <summary>
/// stations/poles list
/// stations/poles list
/// список точечных объектов - трансформаторных подстанций/столбов/понижающих(конечных) подстанций
/// список точечных объектов - трансформаторных подстанций/столбов/понижающих(конечных) подстанций
/// </summary>
/// </summary>
public
List
<
PowerStation
>
p
owerStations
{
get
;
set
;
}
public
List
<
PowerStation
>
P
owerStations
{
get
;
set
;
}
/// <summary>
/// <summary>
/// maximum distance for line segment, meters
/// maximum distance for line segment, meters
/// максимальное расстояние между точками ЛЭП, для которых проверяется сломаются/несломаются под действием ветра
/// максимальное расстояние между точками ЛЭП, для которых проверяется сломаются/несломаются под действием ветра
/// </summary>
/// </summary>
public
double
d
ist
_t
hreshold
public
double
D
ist
T
hreshold
{
{
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
>
d
isabledStations
{
get
;
set
;
}
public
List
<
PowerStation
>
D
isabledStations
{
get
;
set
;
}
/// <summary>
/// <summary>
/// broken lines list
/// broken lines list
/// Список прогнозируемых сломанных ЛЭП в результате ветрового воздействия
/// Список прогнозируемых сломанных ЛЭП в результате ветрового воздействия
/// </summary>
/// </summary>
public
List
<
Powerline
>
d
isabledLines
{
get
;
set
;
}
public
List
<
Powerline
>
D
isabledLines
{
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
i
nput
;
private
Input
I
nput
;
/// <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
.
i
nput
=
input
;
this
.
I
nput
=
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
.
p
owerStations
)
foreach
(
PowerStation
pwstation
in
input
.
P
owerStations
)
{
{
if
(
pwstation
.
iss
ource
)
if
(
pwstation
.
IsS
ource
)
{
{
CheckPowerPointsForStation
(
pwstation
);
CheckPowerPointsForStation
(
pwstation
);
}
}
}
}
//fill output
//fill output
Output
output
=
new
Output
();
Output
output
=
new
Output
();
output
.
d
isabledStations
=
new
List
<
PowerStation
>();
output
.
D
isabledStations
=
new
List
<
PowerStation
>();
output
.
d
isabledLines
=
new
List
<
Powerline
>();
output
.
D
isabledLines
=
new
List
<
Powerline
>();
foreach
(
Powerline
line
in
input
.
p
owerLines
)
foreach
(
Powerline
line
in
input
.
P
owerLines
)
{
{
if
(
line
.
isb
roken
)
if
(
line
.
IsB
roken
)
{
{
output
.
d
isabledLines
.
Add
(
line
);
output
.
D
isabledLines
.
Add
(
line
);
}
}
}
}
foreach
(
PowerStation
powerStation
in
input
.
p
owerStations
)
foreach
(
PowerStation
powerStation
in
input
.
P
owerStations
)
{
{
//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
.
s
tation
t
ype
.
p
ole
))
if
(!
powerStation
.
IsON
&&
!(
powerStation
.
Station
type
==
PowerStation
.
S
tation
T
ype
.
P
ole
))
{
{
output
.
d
isabledStations
.
Add
(
powerStation
);
output
.
D
isabledStations
.
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
.
l
ine
l
ist
)
foreach
(
Powerline
line
in
sourcepoint
.
L
ine
L
ist
)
{
{
if
(!
line
.
isb
roken
&&
!
line
.
ison
)
if
(!
line
.
IsB
roken
&&
!
line
.
IsON
)
{
{
line
.
ison
=
true
;
line
.
IsON
=
true
;
foreach
(
PowerStation
powerStation
in
i
nput
.
p
owerStations
)
foreach
(
PowerStation
powerStation
in
I
nput
.
P
owerStations
)
{
{
if
(
powerStation
.
i
dentifier
!=
sourcepoint
.
i
dentifier
&&
(
powerStation
.
i
dentifier
==
line
.
p
ointFromID
||
powerStation
.
i
dentifier
==
line
.
p
ointToID
))
if
(
powerStation
.
I
dentifier
!=
sourcepoint
.
I
dentifier
&&
(
powerStation
.
I
dentifier
==
line
.
P
ointFromID
||
powerStation
.
I
dentifier
==
line
.
P
ointToID
))
{
{
if
(!(
sourcepoint
.
type
==
PowerStation
.
s
tation
t
ype
.
p
ole
))
{
if
(!(
sourcepoint
.
Station
type
==
PowerStation
.
S
tation
T
ype
.
P
ole
))
{
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
.
l
ine
l
ist
)
foreach
(
Powerline
powerline
in
powerStation
.
L
ine
L
ist
)
{
{
if
(
powerline
.
isb
roken
)
{
if
(
powerline
.
IsB
roken
)
{
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
i
nput
.
p
owerStations
)
foreach
(
PowerStation
powerStation
in
I
nput
.
P
owerStations
)
{
{
if
(
powerStation
.
iss
ource
==
true
)
{
if
(
powerStation
.
IsS
ource
==
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
i
nput
.
p
owerLines
)
foreach
(
Powerline
line
in
I
nput
.
P
owerLines
)
{
{
//we also switch OFF all lines
//we also switch OFF all lines
line
.
ison
=
false
;
line
.
IsON
=
false
;
if
(
line
.
p
ointFromID
==
powerStation
.
i
dentifier
||
line
.
p
ointToID
==
powerStation
.
i
dentifier
)
{
if
(
line
.
P
ointFromID
==
powerStation
.
I
dentifier
||
line
.
P
ointToID
==
powerStation
.
I
dentifier
)
{
lines
.
Add
(
line
);
lines
.
Add
(
line
);
}
}
}
}
powerStation
.
l
ine
l
ist
=
lines
;
powerStation
.
L
ine
L
ist
=
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
i
nput
.
p
owerLines
)
foreach
(
Powerline
powerCurve
in
I
nput
.
P
owerLines
)
{
{
// get coordinates list
// get coordinates list
List
<
Coordinate
>
points
=
powerCurve
.
c
oords
;
List
<
Coordinate
>
points
=
powerCurve
.
C
oord
inate
s
;
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
.
h
eight
,
powerCurve
.
p
ower
);
bool
result
=
linearLineIsBroken
(
points
[
i
-
1
],
points
[
i
],
powerCurve
.
H
eight
,
powerCurve
.
P
ower
);
checkList
.
Add
(
result
);
checkList
.
Add
(
result
);
}
}
foreach
(
bool
chkpnt
in
checkList
)
foreach
(
bool
chkpnt
in
checkList
)
{
{
if
(
chkpnt
==
true
)
if
(
chkpnt
==
true
)
{
{
powerCurve
.
isb
roken
=
true
;
powerCurve
.
IsB
roken
=
true
;
}
}
}
}
if
(
powerCurve
.
isb
roken
)
if
(
powerCurve
.
IsB
roken
)
{
{
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
/
i
nput
.
d
ist
_t
hreshold
;
double
distpropD
=
distance
/
I
nput
.
D
ist
T
hreshold
;
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
i
nput
.
p
rognosticAffineCoefficients
;
return
I
nput
.
P
rognosticAffineCoefficients
;
}
}
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate15
:
case
FunctionType
.
FunctionClimate15
:
{
{
return
i
nput
.
c
limateAffineCoefficients
;
return
I
nput
.
C
limateAffineCoefficients
;
}
}
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
i
nput
.
p
rognosticCells
[
index
.
Row
][
index
.
Col
].
c
oord
s
;
return
I
nput
.
P
rognosticCells
[
index
.
Row
][
index
.
Col
].
C
oord
inate
;
}
}
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate15
:
case
FunctionType
.
FunctionClimate15
:
{
{
return
i
nput
.
c
limateCells
[
index
.
Row
][
index
.
Col
].
c
oord
s
;
return
I
nput
.
C
limateCells
[
index
.
Row
][
index
.
Col
].
C
oord
inate
;
}
}
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
?
i
nput
.
p
rognosticCells
.
Count
:
i
nput
.
p
rognosticCells
[
0
].
Count
;
return
forRows
?
I
nput
.
P
rognosticCells
.
Count
:
I
nput
.
P
rognosticCells
[
0
].
Count
;
}
}
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate15
:
case
FunctionType
.
FunctionClimate15
:
{
{
return
forRows
?
i
nput
.
c
limateCells
.
Count
:
i
nput
.
c
limateCells
[
0
].
Count
;
return
forRows
?
I
nput
.
C
limateCells
.
Count
:
I
nput
.
C
limateCells
[
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
i
nput
.
p
rognosticCells
[
index
.
Row
][
index
.
Col
].
v
elocityX
;
return
I
nput
.
P
rognosticCells
[
index
.
Row
][
index
.
Col
].
V
elocityX
;
}
}
case
FunctionType
.
FunctionVelocityY
:
case
FunctionType
.
FunctionVelocityY
:
{
{
return
i
nput
.
p
rognosticCells
[
index
.
Row
][
index
.
Col
].
v
elocityY
;
return
I
nput
.
P
rognosticCells
[
index
.
Row
][
index
.
Col
].
V
elocityY
;
}
}
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate5
:
{
{
return
i
nput
.
c
limateCells
[
index
.
Row
][
index
.
Col
].
w
ind5
;
return
I
nput
.
C
limateCells
[
index
.
Row
][
index
.
Col
].
W
ind5
;
}
}
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate10
:
{
{
return
i
nput
.
c
limateCells
[
index
.
Row
][
index
.
Col
].
w
ind10
;
return
I
nput
.
C
limateCells
[
index
.
Row
][
index
.
Col
].
W
ind10
;
}
}
case
FunctionType
.
FunctionClimate15
:
case
FunctionType
.
FunctionClimate15
:
{
{
return
i
nput
.
c
limateCells
[
index
.
Row
][
index
.
Col
].
w
ind15
;
return
I
nput
.
C
limateCells
[
index
.
Row
][
index
.
Col
].
W
ind15
;
}
}
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
i
nput
.
p
rognosticCellSize
;
return
I
nput
.
P
rognosticCellSize
;
}
}
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate5
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate10
:
case
FunctionType
.
FunctionClimate15
:
case
FunctionType
.
FunctionClimate15
:
{
{
return
i
nput
.
c
limateCellSize
;
return
I
nput
.
C
limateCellSize
;
}
}
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
).
w
idth
;
double
hx
=
cellSizeForFunction
(
functionType
).
W
idth
;
double
hy
=
cellSizeForFunction
(
functionType
).
h
eight
;
double
hy
=
cellSizeForFunction
(
functionType
).
H
eight
;
// 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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment