| 1 | /********************************************************************** |
| 2 | testCreateImg.cc: test app creating random image for jiblib |
| 3 | Author(s): [email protected] |
| 4 | Copyright (C) 2016-2020 European Union (Joint Research Centre) |
| 5 | |
| 6 | This file is part of jiplib. |
| 7 | |
| 8 | jiplib is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | jiplib is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with jiplib. If not, see <https://www.gnu.org/licenses/>. |
| 20 | ***********************************************************************/ |
| 21 | #include <memory> |
| 22 | #include <string> |
| 23 | #include "base/Optionjl.h" |
| 24 | #include "algorithms/StatFactory.h" |
| 25 | #include "imageclasses/Jim.h" |
| 26 | |
| 27 | using namespace std; |
| 28 | using namespace statfactory; |
| 29 | |
| 30 | int main(int argc, char *argv[]) |
| 31 | { |
| 32 | Optionjl<string> output_opt("o", "output", "Output image file"); |
| 33 | Optionjl<string> oformat_opt("of", "oformat", "Output image format (see also gdal_translate).","GTiff"); |
| 34 | Optionjl<string> option_opt("co", "co", "Creation option for output file. Multiple options can be specified."); |
| 35 | Optionjl<unsigned long int> memory_opt("mem", "mem", "Buffer size (in MB) to read image data blocks in memory",0,1); |
| 36 | |
| 37 | memory_opt.setHide(1); |
| 38 | |
| 39 | bool doProcess;//stop process when program was invoked with help option (-h --help) |
| 40 | app::AppFactory app(argc,argv); |
| 41 | try{ |
| 42 | doProcess=output_opt.retrieveOption(app); |
| 43 | oformat_opt.retrieveOption(app); |
| 44 | option_opt.retrieveOption(app); |
| 45 | memory_opt.retrieveOption(app); |
| 46 | |
| 47 | if(doProcess&&output_opt.empty()){ |
| 48 | if(output_opt.empty()){ |
| 49 | std::cerr << "Error: no output file provided (use option -o). Use --help for help information" << std::endl; |
| 50 | exit(1); |
| 51 | } |
| 52 | } |
| 53 | Jim imgRaster(app); |
| 54 | imgRaster.setFile(output_opt[0],oformat_opt[0],memory_opt[0],option_opt); |
| 55 | // Jim imgRaster(output_opt[0],oformat_opt[0],memory_opt[0],option_opt); |
| 56 | // Jim::createImg(imgRaster,app); |
| 57 | imgRaster.close(); |
| 58 | } |
| 59 | catch(string helpString){ |
| 60 | cerr << helpString << endl; |
| 61 | cout << "Usage: testCreateImg --ncol columns --ncol rows [--nband bands] -o output" << endl; |
| 62 | return(1); |
| 63 | } |
| 64 | std::cout << "test1: done" << std::endl; |
| 65 | return(0); |
| 66 | } |