int main(int argc, char **argv){ if(argc!=2){ printf("%s <INPUT DEM>\n",argv[0]); return -1; } Timer overall,flat_resolution_timer; overall.start(); float_2d elevations; load_ascii_data(argv[1],elevations); char_2d flowdirs; d8_flow_directions(elevations,flowdirs); flat_resolution_timer.start(); int_2d flat_resolution_mask, labels; resolve_flats_barnes(elevations,flowdirs,flat_resolution_mask,labels); printf("%f seconds used to resolve flats.\n",flat_resolution_timer.lap()); //If you want to leave the DEM unaltered, use this command d8_flow_flats(flat_resolution_mask,labels,flowdirs); printf("%f seconds used to resolve flats and determine flow directions.\n",flat_resolution_timer.lap()); //If you want to alter the DEM to enforce drainage, use these commands instead /* flowdirs.init(-4); d8_flats_alter_dem(flat_resolution_mask, labels, elevations); d8_flow_directions(elevations,flowdirs); */ output_ascii_data("out_barnes",flowdirs,0); write_arrows("out_barnes_arrows",flowdirs); overall.stop(); printf("Barnes algorithm took %f seconds overall.\n",overall.accumulated()); return 0; }
int read_data(std::string filename, array2d<T> &grid){ if( filename.substr(filename.size()-3)=="flt" ) return read_floating_data(filename.substr(0,filename.size()-4), grid); else return load_ascii_data(filename, grid); }