本文整理汇总了C#中System.Coordinate.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinate.ToList方法的具体用法?C# Coordinate.ToList怎么用?C# Coordinate.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Coordinate
的用法示例。
在下文中一共展示了Coordinate.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Finds the average slope in the given polygons.
/// </summary>
/// <param name="poly">The Polygon.</param>
/// <param name="output">The Raster.</param>
/// <param name="progress">The progress handler.</param>
public bool Execute(IFeatureSet poly, int noOfRow, int noOfCol, int selectionIndex, IRaster output, ICancelProgressHandler cancelProgressHandler)
{
//Validates the input and output data
if (poly == null || output == null)
{
return false;
}
if (poly.FeatureType != FeatureTypes.Polygon)
return false;
//double CellSize = poly.Envelope.Width / 255;
//int noOfRow = Convert.ToInt32(poly.Envelope.Height / CellSize);
//int noOfCol = Convert.ToInt32(poly.Envelope.Width / CellSize);
output=Raster.Create(output.Filename,"",noOfCol,noOfRow,1,typeof(int),new string[] { "" });
RasterBounds bound = new RasterBounds(noOfRow, noOfCol, poly.Envelope);
output.Bounds=bound;
output.NoDataValue = -1;
int current, previous = 0;
double area = 0.0, previousArea = 0.0;
double hCellWidth = output.CellWidth / 2;
double hCellHeight = output.CellHeight / 2;
ICoordinate[] coordinateCell=new Coordinate[4];
int polyIndex = -1;
bool cover = false;
//IEnvelope env=null;
for (int i = 0; i < output.NumRows; i++)
{
current = Convert.ToInt32(i*100 / output.NumRows);
//only update when increment in percentage
if (current > previous+5)
{
cancelProgressHandler.Progress("", current, current.ToString() + "% progress completed");
previous = current;
}
for (int j = 0; j < output.NumColumns; j++)
{
polyIndex = -1;
area = 0.0;
previousArea = 0.0;
cover=false;
ICoordinate cordinate=null;
cordinate = output.CellToProj(i, j);
//make the center of cell as point geometry
IPoint pt=new Point(cordinate);
for(int f=0;f<poly.Features.Count;f++)
{
if (selectionIndex == 0)
{
if (poly.Features[f].Covers(pt))
{
output.Value[i, j] = f;
cover = true;
break;
}
if (cancelProgressHandler.Cancel == true)
return false;
}
else //process area based selection
{
ICoordinate tempCo = new Coordinate(cordinate.X - hCellWidth, cordinate.Y - hCellHeight);
coordinateCell[0] = tempCo;
tempCo = new Coordinate(cordinate.X + hCellWidth, cordinate.Y - hCellHeight);
coordinateCell[1] = tempCo;
tempCo = new Coordinate(cordinate.X + hCellWidth, cordinate.Y + hCellHeight);
coordinateCell[2] = tempCo;
tempCo = new Coordinate(cordinate.X - hCellWidth, cordinate.Y + hCellHeight);
coordinateCell[3] = tempCo;
List<ICoordinate> ListCellCordinate = new List<ICoordinate>();
ListCellCordinate = coordinateCell.ToList<ICoordinate>();
IFeature cell = new Feature(FeatureTypes.Polygon, ListCellCordinate);
IFeature commonFeature=poly.Features[f].Intersection(cell);
if (commonFeature == null)
continue;
area=commonFeature.Area();
if (area > previousArea)
{
polyIndex = f;
cover = true;
previousArea = area;
}
if (cancelProgressHandler.Cancel == true)
return false;
}
}
if (cover == true)
//.........这里部分代码省略.........