[ltoma@dover:\~] ./viewshed test2.asc test2vis.asc 5 7This will read elevation grid test2.asc, compute the viewshed of viewpoint at row=5 and col=7 and save it as grid test2vis.asc. A point in the viewshed grid can have one or three values: NODATA (if the input point is NODATA), 0 if the point is not visible and 1 if the point is visible.
To start, implement the straightforward O(n \sqrt n) algorithm discussed in class, with linear interpolation.
Test grids are available here. The location of these files is: /mnt/research/gis/DATA/DEM/. If you are on one of the linux machines on campus, you can access these files directly at the specified path. Do NOT copy them to your directory, some are rather large ---- just work with them from the specified path.
For this assignment I am providing very little structure. Feel free to design your code as you like.
My only suggestion is that you split the viewshed function into (at least) two functions: one that computes whether a specific point (i,j) is visible from (vprow,vpcol); and one that calls this function in a loop, for every point (i,j):
void compute_viewshed (Grid* eg, Grid * vg, int vprow, int vpcol) { ... for (i=0; i< g->nrows; i++) { for (j=0; j< g-> ncols; j++) { set (vg, i, j) = is_visible(eg, vprow, vpcol, i, j); }//for j }//for i ... }