/**********************************************************************
jldumpimg_lib.cc: dump image on screen or ASCII file
Author(s): Pieter.Kempeneers@ec.europa.eu
Copyright (C) 2016-2020 European Union (Joint Research Centre)
This file is part of jiplib.
jiplib is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jiplib is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with jiplib. If not, see .
***********************************************************************/
#include
#include
#include
#include "imageclasses/Jim.h"
#include "base/Optionjl.h"
#include "apps/AppFactory.h"
using namespace std;
using namespace app;
/**
* @param imgWriter output raster dumpimg dataset
* @return CE_None if successful, CE_Failure if failed
**/
CPLErr Jim::dumpImg(app::AppFactory& app){
Optionjl output_opt("o", "output", "Output ascii file (Default is empty: dump to standard output)");
Optionjl oformat_opt("of", "oformat", "Output format: matrix or list (x,y,z) form. Default is matrix", "matrix");
Optionjl geo_opt("geo", "geo", "Dump x and y in spatial reference system of raster dataset (for list form only)", false);
Optionjl band_opt("b", "band", "Band index to crop");
// Optionjl dstnodata_opt("dstnodata", "dstnodata", "nodata value for output if out of bounds.", 0);
Optionjl srcnodata_opt("srcnodata", "srcnodata", "Do not dump these no data values if oformat is in list form");
Optionjl force_opt("f", "force", "Force full dump even for large images (above 100 rows and cols)", false);
Optionjl verbose_opt("v", "verbose", "verbose", 0,2);
srcnodata_opt.setHide(1);
// dstnodata_opt.setHide(1);
bool doProcess;//stop process when program was invoked with help option (-h --help)
try{
doProcess=output_opt.retrieveOption(app);
oformat_opt.retrieveOption(app);
geo_opt.retrieveOption(app);
band_opt.retrieveOption(app);
srcnodata_opt.retrieveOption(app);
// dstnodata_opt.retrieveOption(app);
force_opt.retrieveOption(app);
verbose_opt.retrieveOption(app);
}
catch(string predefinedString){
std::cout << predefinedString << std::endl;
throw;
}
if(!doProcess){
cout << endl;
std::ostringstream helpStream;
helpStream << "short option -h shows basic options only, use long option --help to show all options" << std::endl;
throw(helpStream.str());//help was invoked, stop processing
}
ofstream outputStream;
if(output_opt.size())
outputStream.open(output_opt[0].c_str());
for(int inodata=0;inodata readBuffer(nrOfCol());
for(int iband=0;iband=0);
assert(band_opt[iband]10&&irow10&&icol