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

Output is working now, need to add saving to shapefile though

parent 92725de7
No related branches found
No related tags found
No related merge requests found
Showing
with 116 additions and 153 deletions
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
...@@ -11,6 +11,7 @@ using DotSpatial.Controls; ...@@ -11,6 +11,7 @@ using DotSpatial.Controls;
using DotSpatial.Topology; using DotSpatial.Topology;
using DotSpatial.Serialization; using DotSpatial.Serialization;
using DotSpatial.Data; using DotSpatial.Data;
using DotSpatial.Symbology;
...@@ -130,6 +131,109 @@ namespace MES_Wind ...@@ -130,6 +131,109 @@ namespace MES_Wind
Coordinate chkcords = new Coordinate(); Coordinate chkcords = new Coordinate();
return points; return points;
} }
public IFeatureSet main_layer_function(IMapLineLayer pwlines, IFeatureSet pwlineSet, IMapRasterLayer u_raster,
IMapRasterLayer v_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["PW_ID"].ToString());
int year = int.Parse(featureData["Year"].ToString());
double height = double.Parse(featureData["height_m"].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
{
segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_raster, v_raster, clim5_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
{//case if powerline is multiline
MultiLineString multiline = feature.BasicGeometry as MultiLineString;
if (multiline != null)
{
foreach (IGeometry line in multiline.Geometries)
{
IList<Coordinate> points = line.Coordinates;
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
{
segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_raster, v_raster, clim5_raster, height);
}
bool linechek = false;
foreach (CheckPoint chkpnt in lineCheckList)
{
if (chkpnt.Ifbroken == true)
{ linechek = true; }
}
if (linechek == true)
{
IFeature lineFeature = result_layer.AddFeature(linestr);
}
lineCheckList.AddRange(segmentCheckList);
}
fullCheckList.AddRange(lineCheckList);
}
MessageBox.Show("Works");
}
}
}
return result_layer;
}
public double interpol(Coordinate coords, IMapRasterLayer raster) public double interpol(Coordinate coords, IMapRasterLayer raster)
{ {
const bool normalX = true; const bool normalX = true;
...@@ -201,6 +305,7 @@ namespace MES_Wind ...@@ -201,6 +305,7 @@ namespace MES_Wind
map1.AddLayer(file_path + "clim5_test.asc"); map1.AddLayer(file_path + "clim5_test.asc");
map1.AddLayer(file_path + "clim10_test.asc"); map1.AddLayer(file_path + "clim10_test.asc");
map1.AddLayer(file_path + "powerlines.shp"); map1.AddLayer(file_path + "powerlines.shp");
map1.AddLayer(file_path + "powerstations.shp");
map1.ZoomToMaxExtent(); map1.ZoomToMaxExtent();
} }
...@@ -252,7 +357,7 @@ namespace MES_Wind ...@@ -252,7 +357,7 @@ namespace MES_Wind
return; return;
} }
//use the first raster layer in the map //this makes raster layers list in map1 ordered!
u_rasterLayer = map1.GetRasterLayers()[0]; u_rasterLayer = map1.GetRasterLayers()[0];
v_rasterLayer = map1.GetRasterLayers()[1]; v_rasterLayer = map1.GetRasterLayers()[1];
clim5_rasterLayer = map1.GetRasterLayers()[2]; clim5_rasterLayer = map1.GetRasterLayers()[2];
...@@ -268,85 +373,20 @@ namespace MES_Wind ...@@ -268,85 +373,20 @@ namespace MES_Wind
pwlLayer = map1.GetLineLayers()[0]; pwlLayer = map1.GetLineLayers()[0];
//copy line layer FeatureSet //copy line layer FeatureSet
IFeatureSet pwlineSet = pwlLayer.DataSet; IFeatureSet pwlineSet = pwlLayer.DataSet;
//get the powerstations layer
IMapPointLayer pwstLayer = default(IMapPointLayer);
pwstLayer = map1.GetPointLayers()[0];
// new FeatureSet for resulting broken powerlines // new FeatureSet for resulting broken powerlines
//IFeatureSet brklineSet = new FeatureSet(FeatureType.Line); //IFeatureSet brklineSet = new FeatureSet(FeatureType.Line);
//DataTable dt = pwlineSet.DataTable; //DataTable dt = pwlineSet.DataTable;
List<CheckPoint> fullCheckList = new List<CheckPoint>(); IFeatureSet brk_info = new FeatureSet(FeatureType.Line);
foreach (IFeature feature in pwlineSet.Features) brk_info = main_layer_function(pwlLayer, pwlineSet, u_rasterLayer, v_rasterLayer, clim10_rasterLayer, clim5_rasterLayer);
{
List<CheckPoint> lineCheckList = new List<CheckPoint>();
//get associated attributes
DataRow featureData = feature.DataRow;
int id = int.Parse(featureData["PW_ID"].ToString());
int year = int.Parse(featureData["Year"].ToString());
double height = double.Parse(featureData["height_m"].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_rasterLayer, v_rasterLayer, clim10_rasterLayer, height);
}
else
{
segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_rasterLayer, v_rasterLayer, clim5_rasterLayer, height);
}
lineCheckList.AddRange(segmentCheckList);
}
fullCheckList.AddRange(lineCheckList);
}
else
{//case if powerline is multiline
MultiLineString multiline = feature.BasicGeometry as MultiLineString;
if ( multiline != null){
foreach (IGeometry line in multiline.Geometries)
{
IList<Coordinate> points = line.Coordinates;
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_rasterLayer, v_rasterLayer, clim10_rasterLayer, height);
}
else
{
segmentCheckList = CalcBrkPoint(x1, y1, x2, y2, distThreshold, u_rasterLayer, v_rasterLayer, clim5_rasterLayer, height);
}
lineCheckList.AddRange(segmentCheckList);
}
fullCheckList.AddRange(lineCheckList);
}
MessageBox.Show("Works");
}
}
}
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) catch (Exception ex)
... ...
......
...@@ -192,83 +192,6 @@ C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.exe ...@@ -192,83 +192,6 @@ C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.exe
C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.pdb C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.pdb
C:\MES_Wind\MES_Wind\bin\Debug\MES_Wind.exe C:\MES_Wind\MES_Wind\bin\Debug\MES_Wind.exe
C:\MES_Wind\MES_Wind\bin\Debug\MES_Wind.pdb C:\MES_Wind\MES_Wind\bin\Debug\MES_Wind.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Analysis.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Analysis.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Compatibility.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Compatibility.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Controls.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Controls.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Data.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Data.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Data.Forms.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Data.Forms.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Extensions.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Extensions.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Modeling.Forms.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Modeling.Forms.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Mono.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Mono.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Positioning.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Positioning.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Positioning.Design.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Positioning.Design.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Positioning.Forms.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Positioning.Forms.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Projections.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Projections.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Projections.Forms.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Projections.Forms.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Serialization.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Serialization.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Symbology.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Symbology.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Symbology.Forms.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Symbology.Forms.xml
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Topology.pdb
C:\MES_Wind\MES_Wind\bin\Debug\DotSpatial.Topology.xml
C:\MES_Wind\MES_Wind\bin\Debug\ZedGraph.xml
C:\MES_Wind\MES_Wind\bin\Debug\de-DE\DotSpatial.Controls.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\it-IT\DotSpatial.Controls.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\pt-BR\DotSpatial.Controls.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-CN\DotSpatial.Controls.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-CN\DotSpatial.Data.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-CN\DotSpatial.Modeling.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-MO\DotSpatial.Modeling.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\cs\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\de\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\de-DE\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\el\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\it-IT\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\ja-JP\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\lt\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\nl\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\pt\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\pt-BR\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\ro\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\th\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\vi-VN\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-CN\DotSpatial.Projections.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\de-DE\DotSpatial.Symbology.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\cs\DotSpatial.Symbology.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\de-DE\DotSpatial.Symbology.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\en-US\DotSpatial.Symbology.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\it\DotSpatial.Symbology.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\it-IT\DotSpatial.Symbology.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\pt-BR\DotSpatial.Symbology.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-CN\DotSpatial.Symbology.Forms.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\de\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\es\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\fr\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\hu\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\it\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\ja\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\pt\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\ru\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\sk\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\sv\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\tr\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-CN\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\bin\Debug\zh-tw\ZedGraph.resources.dll
C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.csprojResolveAssemblyReference.cache C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.csprojResolveAssemblyReference.cache
C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.frmGraph.resources C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.frmGraph.resources
C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.frmMain.resources C:\MES_Wind\MES_Wind\obj\Debug\MES_Wind.frmMain.resources
... ...
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment