20 #include "base/Optionpk.h"
21 #include "imageclasses/ImgReaderGdal.h"
22 #include "algorithms/Egcs.h"
24 int main(
int argc,
char *argv[])
28 Optionpk<std::string> cell2bb_opt(
"c2b",
"cell2bb",
"convert cell code to geo coordinates of boundingbox (e.g. 32-AB)",
"");
29 Optionpk<std::string> cell2mid_opt(
"c2m",
"cell2mid",
"convert cell code to centre in geo coordinates (e.g. 32-AB)",
"");
30 Optionpk<bool> refpixel_opt(
"ref",
"ref",
"get reference pixel (lower left corner of centre of gravity pixel)",
false);
31 Optionpk<double> maskValue_opt(
"m",
"mask",
"mask value(s) for no data to calculate reference pixel in image",0);
33 Optionpk<bool> geo2cell_opt(
"g2c",
"geo2cell",
"get cell code for coordinates in x_opt and y_opt given the resolution in dx_opt",
false);
40 doProcess=image_opt.retrieveOption(argc,argv);
41 band_opt.retrieveOption(argc,argv);
42 cell2bb_opt.retrieveOption(argc,argv);
43 cell2mid_opt.retrieveOption(argc,argv);
44 geo2cell_opt.retrieveOption(argc,argv);
45 refpixel_opt.retrieveOption(argc,argv);
46 maskValue_opt.retrieveOption(argc,argv);
47 dx_opt.retrieveOption(argc,argv);
48 x_opt.retrieveOption(argc,argv);
49 y_opt.retrieveOption(argc,argv);
51 catch(std::string predefinedString){
52 std::cout << predefinedString << std::endl;
56 std::cout <<
"short option -h shows basic options only, use long option --help to show all options" << std::endl;
61 if(cell2bb_opt[0]!=
""){
62 int theULX, theULY, theLRX, theLRY;
63 egcs.setLevel(egcs.cell2level(cell2bb_opt[0]));
64 egcs.cell2bb(cell2bb_opt[0],theULX,theULY,theLRX,theLRY);
65 std::cout << std::setprecision(12) <<
"--ulx=" << theULX <<
" --uly=" << theULY <<
" --lrx=" << theLRX <<
" --lry=" << theLRY << std::endl;
67 if(cell2mid_opt[0]!=
""){
69 egcs.setLevel(egcs.cell2level(cell2mid_opt[0]));
70 egcs.cell2mid(cell2mid_opt[0],midX,midY);
71 std::cout << std::setprecision(12) <<
"-x=" << midX <<
" -y=" << midY << std::endl;
74 egcs.setLevel(egcs.res2level(dx_opt[0]));
75 std::cout << egcs.geo2cell(x_opt[0],y_opt[0]) << std::endl;
79 imgReader.open(image_opt[0]);
81 assert(band_opt[0]<imgReader.nrOfBand());
82 for(
int inodata=0;inodata<maskValue_opt.size();++inodata)
83 imgReader.pushNoDataValue(maskValue_opt[inodata]);
91 imgReader.getRefPix(refX,refY,band_opt[0]);
92 std::cout << std::setprecision(12) <<
"--x " << refX <<
" --y " << refY << std::endl;
93 egcs.setLevel(egcs.res2level(imgReader.getDeltaX()));
96 std::cout <<
"cell code at level " << egcs.getLevel() <<
" (resolution is " << egcs.getResolution() <<
"): " << egcs.geo2cell(refX,refY) << std::endl;