25 #include <sys/types.h> 27 #include "base/Optionpk.h" 28 #include "base/Vector2d.h" 29 #include "algorithms/Filter2d.h" 30 #include "imageclasses/ImgReaderGdal.h" 31 #include "imageclasses/ImgWriterGdal.h" 84 int main(
int argc,
char **argv) {
88 Optionpk<double> saa_opt(
"saa",
"saa",
"Sun azimuth angle (N=0 E=90 S=180 W=270).");
89 Optionpk<int> flag_opt(
"f",
"flag",
"Flag to put in image if pixel shadow", 0);
90 Optionpk<std::string> otype_opt(
"ot",
"otype",
"Data type for output image ({Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFloat64}). Empty string: inherit type from input image",
"");
91 Optionpk<string> oformat_opt(
"of",
"oformat",
"Output image format (see also gdal_translate).",
"GTiff");
92 Optionpk<string> colorTable_opt(
"ct",
"ct",
"color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid)");
93 Optionpk<string> option_opt(
"co",
"co",
"Creation option for output file. Multiple options can be specified.");
94 Optionpk<double> scale_opt(
"s",
"scale",
"scale used for input dsm: height=scale*input+offset");
95 Optionpk<double> offset_opt(
"off",
"offset",
"offset used for input dsm: height=scale*input+offset");
96 Optionpk<short> verbose_opt(
"v",
"verbose",
"verbose mode if > 0", 0,2);
99 offset_opt.setHide(1);
103 doProcess=input_opt.retrieveOption(argc,argv);
104 output_opt.retrieveOption(argc,argv);
105 sza_opt.retrieveOption(argc,argv);
106 saa_opt.retrieveOption(argc,argv);
107 flag_opt.retrieveOption(argc,argv);
108 scale_opt.retrieveOption(argc,argv);
109 offset_opt.retrieveOption(argc,argv);
110 option_opt.retrieveOption(argc,argv);
111 otype_opt.retrieveOption(argc,argv);
112 oformat_opt.retrieveOption(argc,argv);
113 colorTable_opt.retrieveOption(argc,argv);
114 verbose_opt.retrieveOption(argc,argv);
116 catch(
string predefinedString){
117 std::cout << predefinedString << std::endl;
122 cout <<
"Usage: pkdsm2shadow -i input.txt -o output [-sza angle] [-saa angle]" << endl;
124 std::cout <<
"short option -h shows basic options only, use long option --help to show all options" << std::endl;
130 assert(input_opt.size());
131 assert(output_opt.size());
132 input.
open(input_opt[0]);
135 if(offset_opt.size())
139 GDALDataType theType=GDT_Unknown;
141 cout <<
"possible output data types: ";
142 for(
int iType = 0; iType < GDT_TypeCount; ++iType){
144 cout <<
" " << GDALGetDataTypeName((GDALDataType)iType);
145 if( GDALGetDataTypeName((GDALDataType)iType) != NULL
146 && EQUAL(GDALGetDataTypeName((GDALDataType)iType),
147 otype_opt[0].c_str()))
148 theType=(GDALDataType) iType;
150 if(theType==GDT_Unknown)
154 std::cout << std::endl <<
"Output pixel type: " << GDALGetDataTypeName(theType) << endl;
157 if(oformat_opt.size())
158 imageType=oformat_opt[0];
160 if(option_opt.findSubstring(
"INTERLEAVE=")==option_opt.end()){
161 string theInterleave=
"INTERLEAVE=";
163 option_opt.push_back(theInterleave);
168 catch(
string errorstring){
169 cout << errorstring << endl;
182 std::cout<<
"class values: ";
183 if(colorTable_opt.size())
185 filter2d.shadowDsm(input,output,sza_opt[0],saa_opt[0],input.
getDeltaX(),flag_opt[0]);
void setOffset(double theOffset, int band=0)
Set offset for a specific band when writing the raster data values. The scaling and offset are applie...
void close(void)
Set the memory (in MB) to cache a number of rows in memory.
int nrOfCol(void) const
Get the number of columns of this dataset.
void setColorTable(const std::string &filename, int band=0)
Set the color table using an (ASCII) file with 5 columns (value R G B alpha)
int nrOfRow(void) const
Get the number of rows of this dataset.
GDALColorTable * getColorTable(int band=0) const
Get the GDAL color table for this dataset as an instance of the GDALColorTable class.
CPLErr setGeoTransform(double *gt)
Set the geotransform data for this dataset.
double getDeltaX(void) const
Get the pixel cell spacing in x.
void open(const std::string &filename, const ImgReaderGdal &imgSrc, const std::vector< std::string > &options=std::vector< std::string >())
Open an image for writing, copying image attributes from a source image. Image is directly written to...
std::string getProjection(void) const
Get the projection string (deprecated, use getProjectionRef instead)
GDALDataType getDataType(int band=0) const
Get the GDAL datatype for this dataset.
CPLErr setProjection(const std::string &projection)
Set the projection for this dataset in well known text (wkt) format.
void close(void)
Close the image.
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.
void open(const std::string &filename, const GDALAccess &readMode=GA_ReadOnly)
Open an image.
int nrOfBand(void) const
Get the number of bands of this dataset.
void setScale(double theScale, int band=0)
Set scale for a specific band when writing the raster data values. The scaling and offset are applied...
std::string getInterleave() const
Get the band coding (interleave)