本文整理汇总了C++中array2d::edge_grid方法的典型用法代码示例。如果您正苦于以下问题:C++ array2d::edge_grid方法的具体用法?C++ array2d::edge_grid怎么用?C++ array2d::edge_grid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array2d
的用法示例。
在下文中一共展示了array2d::edge_grid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static int d8_FlowDir(const array2d<T> &elevations, const int x, const int y){
T minimum_elevation=elevations(x,y);
int flowdir=NO_FLOW;
if (elevations.edge_grid(x,y)){
if(x==0 && y==0)
return 2;
else if(x==0 && y==elevations.height()-1)
return 8;
else if(x==elevations.width()-1 && y==0)
return 4;
else if(x==elevations.width()-1 && y==elevations.height()-1)
return 6;
else if(x==0)
return 1;
else if(x==elevations.width()-1)
return 5;
else if(y==0)
return 3;
else if(y==elevations.height()-1)
return 7;
}
/*NOTE: Since the very edges of the DEM are defined to always flow outwards,
if they have defined elevations, it is not necessary to check if a neighbour
is IN_GRID in the following
NOTE: It is assumed that the no_data datum is an extremely negative
number, such that all water which makes it to the edge of the DEM's region
of defined elevations is sucked directly off the grid, rather than piling up
on the edges.*/
for(int n=1;n<=8;n++)
if(
elevations(x+dx[n],y+dy[n])<minimum_elevation
|| (elevations(x+dx[n],y+dy[n])==minimum_elevation
&& flowdir>0 && flowdir%2==0 && n%2==1)
){
minimum_elevation=elevations(x+dx[n],y+dy[n]);
flowdir=n;
}
return flowdir;
}