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

Dummy tested files added. data from external files casted to prmwind class...

Dummy tested files added. data from external files casted to prmwind  class (didn't wrote casting it back yet). Graph algorithm reworked to take into account dummy stations i.e. "poles" for future compability with linelayer data.
parent dd2e75c1
No related branches found
No related tags found
No related merge requests found
Showing
with 182 additions and 3 deletions
File added
File added
File added
File added
File added
<MapWinGIS OcxVersion="4.8" FileType="LayerFile" FileVersion="0" Description="">
<Layer LayerType="Shapefile" LayerName="powerstations" LayerVisible="1" LayerKey="" Filename="">
<ShapefileClass>
<DefaultDrawingOptions FillColor="4286521" LineColor="9868950" />
<ShapefileCategoriesClass />
<LabelsClass Alignment="5" Generated="0" AvoidCollisions="0" Positioning="0" TextRenderingHint="5" />
<ChartsClass />
</ShapefileClass>
</Layer>
</MapWinGIS>
File added
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">40</MDI>
<MDI key="STATISTICS_MEAN">9.0279719451695</MDI>
<MDI key="STATISTICS_MINIMUM">-16.645999908447</MDI>
<MDI key="STATISTICS_STDDEV">11,7818241119385</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
MES_Wind/bin/Debug/MES_test_new/u_test.bmp

7.82 KiB

11166.74500000000100
0.00000000000000
0.00000000000000
-11166.74500000000100
3608169.24349999990000
6065519.13949999960000
[tkImageCom]
ImageFile C:\gitlab_wind\MES_Wind\MES_test_new\u_test.bmp
<ColoringScheme SchemeType="Grid" GridName="u_test" GroupName="Data Layers">
<GridColoringScheme AmbientIntensity="0,7" Key="" LightSourceAzimuth="90" LightSourceElevation="45" LightSourceIntensity="0,7" NoDataColor="-16777216" ImageLayerFillTransparency="1" ImageUpsamplingMethod="None" ImageDownsamplingMethod="None">
<Break Caption="" LowValue="-16,646" HighValue="11,677" LowColor="-9851936" HighColor="-6100240" ColoringType="0" GradientModel="1" />
<Break Caption="" LowValue="11,677" HighValue="40" LowColor="-6100240" HighColor="-1" ColoringType="0" GradientModel="1" />
</GridColoringScheme>
</ColoringScheme>
\ No newline at end of file
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",3857]]
\ No newline at end of file
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">19.999000549316</MDI>
<MDI key="STATISTICS_MEAN">7.0301203373863</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">5,49227428436279</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
...@@ -12,6 +12,7 @@ using DotSpatial.Topology; ...@@ -12,6 +12,7 @@ using DotSpatial.Topology;
using DotSpatial.Serialization; using DotSpatial.Serialization;
using DotSpatial.Data; using DotSpatial.Data;
using DotSpatial.Symbology; using DotSpatial.Symbology;
using MES_Wind_prm;
...@@ -50,6 +51,24 @@ namespace MES_Wind ...@@ -50,6 +51,24 @@ namespace MES_Wind
/// <returns>List of booleans with coordinates if any of them are true, line is broken</returns> /// <returns>List of booleans with coordinates if any of them are true, line is broken</returns>
/// <remarks></remarks> /// <remarks></remarks>
#endregion #endregion
List<PRM_coordinate> DotspLinestringToPrm(LineString dtlinestr)
{
List<PRM_coordinate> prmlinestring = new List<PRM_coordinate>();
IList<Coordinate> linepoints = dtlinestr.Coordinates;
foreach(Coordinate linepoint in linepoints)
{
PRM_coordinate point = new PRM_coordinate(linepoint.X,linepoint.Y);
prmlinestring.Add(point);
}
return prmlinestring;
}
PRM_coordinate DotspPointToPRM(IPoint ftpoint)
{
PRM_coordinate prpoint = new PRM_coordinate();
prpoint.X = ftpoint.X;
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) 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>(); List<CheckPoint> lineCheckPoint = new List<CheckPoint>();
...@@ -299,8 +318,8 @@ namespace MES_Wind ...@@ -299,8 +318,8 @@ 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 + "clim15_test.asc"); map1.AddLayer(file_path + "clim15_test.asc");
map1.AddLayer(file_path + "ЛЭП_polyline.shp"); map1.AddLayer(file_path + "powerlines.shp");
map1.AddLayer(file_path + "Подстанции_точки_point.shp"); map1.AddLayer(file_path + "powerstations.shp");
map1.ZoomToMaxExtent(); map1.ZoomToMaxExtent();
} }
...@@ -374,6 +393,123 @@ namespace MES_Wind ...@@ -374,6 +393,123 @@ namespace MES_Wind
//get the powerstations layer //get the powerstations layer
IMapPointLayer pwstLayer = default(IMapPointLayer); IMapPointLayer pwstLayer = default(IMapPointLayer);
pwstLayer = map1.GetPointLayers()[0]; pwstLayer = map1.GetPointLayers()[0];
// copy point layer FeatureSet
IFeatureSet pwpointsSet = pwstLayer.DataSet;
//Start to cast raster to PRM classes
// prognostic wind massives first
List<List<PRM_raster_cell_prognostic>> prog_wind= new List<List<PRM_raster_cell_prognostic>>();
PRM_coordinate dummy_coord = new PRM_coordinate();
Coordinate dummy_rcoord = new Coordinate();
PRM_raster_cell_prognostic dummy_prognostic = new PRM_raster_cell_prognostic(dummy_coord,0,0);
int rcount_prog = u_rasterLayer.DataSet.NumRows;
int ccount_prog = u_rasterLayer.DataSet.NumColumns;
for (int i =0; i< ccount_prog; i++)
{
List<PRM_raster_cell_prognostic> prog_wind_row = new List<PRM_raster_cell_prognostic>();
for (int j =0; j< rcount_prog; j++ )
{
dummy_prognostic.velocityX = u_rasterLayer.DataSet.Value[j, i];
dummy_prognostic.velocityY = v_rasterLayer.DataSet.Value[j, i];
dummy_rcoord = u_rasterLayer.Bounds.CellCenter_ToProj(j,i);
dummy_coord.X = dummy_rcoord.X;
dummy_coord.Y = dummy_rcoord.Y;
dummy_prognostic.coords = dummy_coord;
prog_wind_row.Add(dummy_prognostic);
}
prog_wind.Add(prog_wind_row);
//prog_wind_row.Clear();
}
//Get cell info and Affine transform coefficients from prognostic wind rasters
PRM_cell_size prog_cell = new PRM_cell_size(u_rasterLayer.DataSet.CellWidth, u_rasterLayer.DataSet.CellHeight);
double[] prog_aff = u_rasterLayer.Bounds.AffineCoefficients;
//Now we create climate raster class
List<List<PRM_raster_cell_climate>> clim_wind = new List<List<PRM_raster_cell_climate>>();
PRM_raster_cell_climate dummy_clim = new PRM_raster_cell_climate(dummy_coord, 0, 0, 0);
int rcount_clim = clim5_rasterLayer.DataSet.NumRows;
int ccount_clim = clim5_rasterLayer.DataSet.NumColumns;
for (int i = 0; i < ccount_clim; i++)
{
List<PRM_raster_cell_climate> clim_wind_row = new List<PRM_raster_cell_climate>();
for (int j = 0; j < rcount_clim; j++)
{
dummy_clim.wind5 = clim5_rasterLayer.DataSet.Value[j, i];
dummy_clim.wind10 = clim10_rasterLayer.DataSet.Value[j, i] ; // Important: substract 3 to this to get powerlines broken
dummy_clim.wind15 = clim15_rasterLayer.DataSet.Value[j, i];
dummy_rcoord = clim15_rasterLayer.Bounds.CellCenter_ToProj(j,i);
dummy_coord.X = dummy_rcoord.X;
dummy_coord.Y = dummy_rcoord.Y;
dummy_clim.coords = dummy_coord;
clim_wind_row.Add(dummy_clim);
}
clim_wind.Add(clim_wind_row);
//clim_wind_row.Clear();
}
//Get cell info and affine transform coeff from climate rasters
PRM_cell_size clim_cell = new PRM_cell_size(clim5_rasterLayer.DataSet.CellWidth, clim5_rasterLayer.DataSet.CellHeight);
double[] clim_aff = clim5_rasterLayer.Bounds.AffineCoefficients;
// create PRM_line list to pass to PRM_wind from loaded line layer
List<PRM_Line> powerlinesToPRM = new List<PRM_Line>();
foreach (IFeature feature in pwlineSet.Features)
{
PRM_Line dummyline = new PRM_Line();
DataRow featureData = feature.DataRow;
dummyline.identifier = feature.Fid;
dummyline.year = int.Parse(featureData["Year"].ToString());
dummyline.height = double.Parse(featureData["HeightOffs"].ToString());
dummyline.power = int.Parse(featureData["Power"].ToString());
dummyline.pointFromID = int.Parse(featureData["PointFrom"].ToString());
dummyline.pointToID = int.Parse(featureData["PointTo"].ToString());
LineString ftline = feature.BasicGeometry as LineString;
dummyline.coords = DotspLinestringToPrm(ftline);
powerlinesToPRM.Add(dummyline);
}
//create PRM_station list to pass to PRM_wind from loaded point layer
List<PRM_Station> powerpointsToPRM = new List<PRM_Station>();
foreach (IFeature ftpoint in pwpointsSet.Features)
{
PRM_Station dummystation = new PRM_Station();
DataRow featureData = ftpoint.DataRow;
dummystation.identifier = ftpoint.Fid;
dummystation.name = featureData["Name"].ToString();
dummystation.power = int.Parse(featureData["Power"].ToString());
int issr = int.Parse(featureData["IsSource"].ToString());
if (issr == 0)
{
dummystation.issource = false;
}
else
{
if (issr == 1)
{
dummystation.issource = true;
}
else
{
MessageBox.Show("Some enteties in Column IsSource of powerstation datatable are not strict ones or zeros");
}
}
dummystation.type = featureData["Type"].ToString();
IPoint ftpt = ftpoint.BasicGeometry as IPoint;
dummystation.coords = DotspPointToPRM(ftpt);
powerpointsToPRM.Add(dummystation);
}
//Create a PRM_wind class and add all the properties from above
PRM_wind prmwind = new PRM_wind();
prmwind.powerlines = powerlinesToPRM;
prmwind.powerstations = powerpointsToPRM;
prmwind.prognostic_cells = prog_wind;
prmwind.prognostic_cellsize = prog_cell;
prmwind.prognostic_AffineCoefficients = prog_aff;
prmwind.climate_cells = clim_wind;
prmwind.climate_cellsize = clim_cell;
prmwind.climate_AffineCoefficients = clim_aff;
//Calculate which lines are broken
List<PRM_Line> prmBrokenLines = prmwind.brokenPowerLinesAfterCheck();
prmwind.mainpowercheck();
// new FeatureSet for resulting broken powerlines // new FeatureSet for resulting broken powerlines
//IFeatureSet brklineSet = new FeatureSet(FeatureType.Line); //IFeatureSet brklineSet = new FeatureSet(FeatureType.Line);
......
No preview for this file type
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.
Finish editing this message first!
Please register or to comment