本文整理汇总了C++中array2d::max方法的典型用法代码示例。如果您正苦于以下问题:C++ array2d::max方法的具体用法?C++ array2d::max怎么用?C++ array2d::max使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array2d
的用法示例。
在下文中一共展示了array2d::max方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output_ascii_data
int output_ascii_data(
const std::string filename,
const array2d<T> &output_grid,
int precision=8
){
std::ofstream fout;
std::string outputsep=" ";
int output_type=OUTPUT_DEM;
Timer write_time;
ProgressBar progress;
write_time.start();
diagnostic_arg("Opening ASCII output file \"%s\"...",filename.c_str());
fout.open(filename.c_str());
if(!fout.is_open()){
diagnostic("failed!\n");
exit(-1); //TODO: Need to make this safer! Don't just close after all that work!
}
diagnostic("succeeded.\n");
//OmniGlyph output
if(filename.substr(filename.length()-4)==".omg"){
outputsep="|";
output_type=OUTPUT_OMG;
diagnostic("Writing OmniGlyph file header...");
fout<<"Contents: Pixel array"<<std::endl;
fout<<std::endl;
fout<<"Width: "<<output_grid.width()<<std::endl;
fout<<"Height: "<<output_grid.height()<<std::endl;
fout<<std::endl;
fout<<"Spectral bands: 1"<<std::endl;
fout<<"Bits per band: 32"<<std::endl;
fout<<"Range of values: "<<output_grid.min()<<","<<output_grid.max()<<std::endl;
fout<<"Actual range: "<<output_grid.no_data<<","<<output_grid.max()<<std::endl; //TODO: Assumes no_data is a small negative value
fout<<"Gamma exponent: 0."<<std::endl;
fout<<"Resolution: 100 pixels per inch"<<std::endl;
fout<<std::endl;
fout<<"|"<<std::endl;
} else {
diagnostic("Writing ArcGrid ASCII file header...");
fout<<"ncols\t\t"<<output_grid.width()<<std::endl;
fout<<"nrows\t\t"<<output_grid.height()<<std::endl;
fout<<"xllcorner\t"<<std::fixed<<std::setprecision(precision)<<output_grid.xllcorner<<std::endl;
fout<<"yllcorner\t"<<std::fixed<<std::setprecision(precision)<<output_grid.yllcorner<<std::endl;
fout<<"cellsize\t"<<std::fixed<<std::setprecision(precision)<<output_grid.cellsize<<std::endl;
fout<<"NODATA_value\t"<<std::fixed<<std::setprecision(precision);
if(sizeof(T)==1) //TODO: Crude way of detecting chars and bools
fout<<(int)output_grid.no_data<<std::endl;
else
fout<<output_grid.no_data<<std::endl;
}
diagnostic("succeeded.\n");
diagnostic("%%Writing ArcGrid ASCII file data...\n");
progress.start( output_grid.width()*output_grid.height() );
fout.precision(precision);
fout.setf(std::ios::fixed);
for(int y=0;y<output_grid.height();y++){
progress.update( y*output_grid.width() );
if(output_type==OUTPUT_OMG)
fout<<"|";
for(int x=0;x<output_grid.width();x++)
if(sizeof(T)==1) //TODO: Crude way of detecting chars and bools
fout<<(int)output_grid(x,y)<<outputsep;
else
fout<<output_grid(x,y)<<outputsep;
fout<<std::endl;
}
diagnostic_arg(SUCCEEDED_IN,progress.stop());
fout.close();
write_time.stop();
diagnostic_arg("Write time was: %lf\n", write_time.accumulated());
return 0;
}