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

- removed useless sources and code

parent 9d57c4cf
No related branches found
No related tags found
No related merge requests found
......@@ -124,7 +124,6 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Interface.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
......
No preview for this file type
No preview for this file type
......@@ -65,242 +65,18 @@ namespace MES_Wind
prpoint.Y = ftpoint.Y;
return prpoint;
}
public List<CheckPoint> CalcBrkPoint(double startX, double startY, double endX, double endY, double dThreshold, IMapRasterLayer Uwind_raster, IMapRasterLayer Vwind_raster, IMapRasterLayer clim_layer, double h)
{
List<CheckPoint> lineCheckPoint = new List<CheckPoint>();
double uwind = 0;
double vwind = 0;
double umod = 0;
double sinwind = 0;
double anglewind = 0;
double angleline = Math.Atan2((endY - startY),(endX - startX));
double climwind = 0;
double distance = Math.Sqrt((endX - startX) * (endX - startX) + (endY - startY) * (endY - startY));
double distpropD = distance / dThreshold;
int distpropI = Convert.ToInt32(distpropD);
double curX = startX;
double curY = startY;
CheckPoint chkpnt = new CheckPoint();
if (distpropI > 1)
{
double constXdiff = (endX - startX) / distpropI;
double constYdiff = (endY - startY) / distpropI;
for (int j = 1; j < distpropI + 1; j++)
{
if (j == 1)
{
curX = startX + constXdiff / 2;
curY = startY + constXdiff / 2;
}
else
{
curX = curX + constXdiff;
curY = curY + constYdiff;
}
Coordinate coords = new Coordinate(curX,curY);
uwind = interpol(coords, Uwind_raster);
vwind = interpol(coords, Vwind_raster);
climwind = interpol(coords, clim_layer);
umod = Math.Sqrt(uwind*uwind + vwind*vwind);
anglewind = Math.Atan2(vwind,uwind) - angleline;
sinwind = Math.Sin(anglewind);
double C_height = 1.0;
if (umod < 20)
{ //wind is too low
chkpnt.Ifbroken = false;
}
else
{ // calculate prognostic and threshold windstress
double p1 = -0.00078501;
double p2 = 0.13431;
double p3 = -2.11112;
double p4 = 19.548;
double qpr = p1 * umod * umod * umod + p2 * umod * umod + p3 * umod + p4;
double qcl = p1 * climwind * climwind * climwind + p2 * climwind * climwind + p3 * climwind + p4;
double Ppr = qpr * C_height * sinwind * sinwind;
double Pcl = qcl * C_height * 1.0;
if (Ppr >= Pcl)
{
chkpnt.Ifbroken = true;
}
else
{
chkpnt.Ifbroken = false;
}
}
chkpnt.X = curX;
chkpnt.Y = curY;
lineCheckPoint.Add(chkpnt);
}
}
else
{
}
return lineCheckPoint;
}
public IFeatureSet brokenpoints(List<CheckPoint> chklist)
{
IFeatureSet points = new FeatureSet(FeatureType.Point);
Coordinate chkcords = new Coordinate();
return points;
}
public IFeatureSet main_layer_function(IMapLineLayer pwlines, IFeatureSet pwlineSet, IMapRasterLayer u_raster,
IMapRasterLayer v_raster, IMapRasterLayer clim15_raster, IMapRasterLayer clim10_raster, IMapRasterLayer clim5_raster)
{
IFeatureSet result_layer = new FeatureSet(FeatureType.Line);
List<CheckPoint> fullCheckList = new List<CheckPoint>();
foreach (IFeature feature in pwlineSet.Features)
{
List<CheckPoint> lineCheckList = new List<CheckPoint>();
//get associated attributes
DataRow featureData = feature.DataRow;
int id = int.Parse(featureData["Shape_ID"].ToString());
int year = int.Parse(featureData["Year"].ToString());
double height = double.Parse(featureData["HeightOffs"].ToString());
int power = int.Parse(featureData["Power"].ToString());
LineString linestr = feature.BasicGeometry as LineString;
if (linestr != null)
{ // case if powerline consists of one line
// get coordinates list
IList<Coordinate> points = linestr.Coordinates;
// cycle throw all points in line
for (int i = 1; i < points.Count; i++)
{
List<CheckPoint> segmentCheckList = new List<CheckPoint>();
double x1 = points[i - 1].X;
double y1 = points[i - 1].Y;
double x2 = points[i].X;
double y2 = points[i].Y;
if (power > 5 && power < 330)
{
segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_raster, v_raster, clim10_raster, height);
}
else
{
if (power < 5)
{
segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_raster, v_raster, clim5_raster, height);
}
else
{
segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_raster, v_raster, clim15_raster, height);
}
}
lineCheckList.AddRange(segmentCheckList);
}
bool linechek = false;
foreach (CheckPoint chkpnt in lineCheckList)
{
if (chkpnt.Ifbroken == true)
{ linechek = true; }
}
if (linechek == true)
{
IFeature lineFeature = result_layer.AddFeature(linestr);
}
fullCheckList.AddRange(lineCheckList);
}
else {
MessageBox.Show("shit you trying to feed it is not a simple line");
}
}
return result_layer;
}
public double interpol(Coordinate coords, IMapRasterLayer raster)
{
const bool normalX = true;
const bool normalY = false;
RcIndex rc = raster.DataSet.Bounds.ProjToCell(coords);
Coordinate center = raster.DataSet.Bounds.CellCenter_ToProj(rc.Row, rc.Column);
double xDiff = coords.X - center.X;
double yDiff = coords.Y - center.Y;
//calculate second index
int row2, col2;
if ((xDiff >= 0 && normalX ) || (!normalX && xDiff < 0))
{
row2 = rc.Row >= raster.DataSet.EndRow ? rc.Row - 1 : rc.Row + 1;
}
else
{
row2 = rc.Row > 0 ? rc.Row - 1 : rc.Row + 1;
}
if ( (yDiff >= 0 && normalY) || (!normalY && yDiff < 0))
{
col2 = rc.Column >= raster.DataSet.EndColumn ? rc.Column - 1 : rc.Column + 1;
}
else
{
col2 = rc.Column > 0 ? rc.Column - 1 : rc.Column + 1;
}
// indexes and values at bounds
RcIndex rcBotLeft = new RcIndex(Math.Min(row2, rc.Row), Math.Min(col2, rc.Column));
RcIndex rcBotRight = new RcIndex(Math.Max(row2, rc.Row), Math.Min(col2, rc.Column));
RcIndex rcTopLeft = new RcIndex(Math.Min(row2, rc.Row), Math.Max(col2, rc.Column));
RcIndex rcTopRight = new RcIndex(Math.Max(row2, rc.Row), Math.Max(col2, rc.Column));
double valBotLeft = raster.DataSet.Value[rcBotLeft.Row, rcBotLeft.Column];
double valBotRight = raster.DataSet.Value[rcBotRight.Row, rcBotRight.Column];
double valTopLeft = raster.DataSet.Value[rcTopLeft.Row, rcTopLeft.Column];
double valTopRight = raster.DataSet.Value[rcTopRight.Row, rcTopRight.Column];
Coordinate origin = raster.DataSet.CellToProj(rcBotLeft.Row, rcBotLeft.Column);
//Coordinate last = raster.DataSet.CellToProj(rcTopRight.Row, rcTopRight.Column);//test only
// sizes for cell
double hx = raster.DataSet.Bounds.CellWidth;
double hy = raster.DataSet.Bounds.CellHeight;
// coefficients
double px = (coords.X - origin.X) / hx;
double py = (coords.Y - origin.Y) / hy;
// inverse directions
px *= normalX ? 1 : -1;
py *= normalY ? 1 : -1;
// interpolation
double top = (1 - px) * valTopLeft + px * valTopRight;
double bot = (1 - px) * valBotLeft + px * valBotRight;
double rval = (1 - py) * bot + py * top;
return rval;
}
// so, we start at source power Point; actually call this foreach source point
public void checkPowerPoint(PowerPointObject sourcePoint)
{
if (!sourcePoint.powerIsON) {
// so we have source without power
MessageBox.Show("checkPowerPoint called with disabled source point");
return;
}
// looking for unbroken lines and switch power for this point
foreach (PowerLineObject line in sourcePoint.lines) {
if (!line.broken && !line.toPoint.powerIsON) {
// switch power and check on subpoints.
line.toPoint.powerIsON = true;
checkPowerPoint(line.toPoint);
}
// else we have broken line or already switched power point
}
}
// find all disabled power points
public List<PowerPointObject> findDisabledPoints(List<PowerPointObject> pPoints)
{
List<PowerPointObject> result = new List<PowerPointObject>();
foreach (PowerPointObject point in pPoints) {
if (!point.powerIsON) {
// if disabled, we add it
result.Add(point);
}
}
return result;
}
private void bntLoadWindX_Click(object sender, EventArgs e)
{
map1.AddLayer();
map1.ZoomToMaxExtent();
}
private void btnLoadWindY_Click(object sender, EventArgs e)
......@@ -368,7 +144,6 @@ namespace MES_Wind
MessageBox.Show("Please add a raster layer");
return;
}
//this makes raster layers list in map1 ordered!
u_rasterLayer = map1.GetRasterLayers()[0];
v_rasterLayer = map1.GetRasterLayers()[1];
......@@ -482,7 +257,7 @@ namespace MES_Wind
}
else
{
MessageBox.Show("Some enteties in Column IsSource of powerstation datatable are not strict ones or zeros");
MessageBox.Show("Some entities in Column IsSource of powerstation datatable are not strict ones or zeros");
}
}
dummystation.type = featureData["Type"].ToString();
......@@ -507,13 +282,13 @@ namespace MES_Wind
// 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);
//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";
}
catch (Exception ex)
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment