| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef _JIM_H_ |
| 27 |
#define _JIM_H_ |
| 28 |
|
| 29 |
#include <cfloat> |
| 30 |
#include <typeinfo> |
| 31 |
#include <fstream> |
| 32 |
#include <sstream> |
| 33 |
#include <string> |
| 34 |
#include <vector> |
| 35 |
#include <list> |
| 36 |
#include <algorithm> |
| 37 |
#include <utility> |
| 38 |
#include <memory> |
| 39 |
#include <assert.h> |
| 40 |
#include "gdal_priv.h" |
| 41 |
#include "gdalwarper.h" |
| 42 |
#include "gdal_version.h" |
| 43 |
#include "base/Vector2d.h" |
| 44 |
#include "JimList.h" |
| 45 |
#include "apps/AppFactory.h" |
| 46 |
#include "config_jiplib.h" |
| 47 |
|
| 48 |
#if MIALLIB == 1 |
| 49 |
extern "C" { |
| 50 |
#include "miallib_swig.h" |
| 51 |
#include "miallib_convolve.h" |
| 52 |
#include "miallib_dem.h" |
| 53 |
#include "miallib_dist.h" |
| 54 |
#include "miallib_erodil.h" |
| 55 |
#include "miallib_format.h" |
| 56 |
#include "miallib_geodesy.h" |
| 57 |
#include "miallib_geometry.h" |
| 58 |
#include "miallib_hmt.h" |
| 59 |
#include "miallib_imem.h" |
| 60 |
#include "miallib_io.h" |
| 61 |
#include "miallib_label.h" |
| 62 |
#include "miallib_miscel.h" |
| 63 |
#include "miallib_opclo.h" |
| 64 |
#include "miallib_pointop.h" |
| 65 |
#include "miallib_proj.h" |
| 66 |
#include "miallib_segment.h" |
| 67 |
#include "miallib_stats.h" |
| 68 |
#include "op.h" |
| 69 |
} |
| 70 |
#endif |
| 71 |
|
| 72 |
#include <Python.h> |
| 73 |
|
| 74 |
|
| 75 |
namespace app{ |
| 76 |
class AppFactory; |
| 77 |
} |
| 78 |
|
| 79 |
#if MIALLIB |
| 80 |
enum JIPLIBDataType {JDT_Unknown=0, JDT_Int64=14, JDT_UInt64=15, JDT_Word=16}; |
| 81 |
#endif |
| 82 |
|
| 83 |
namespace cover{ |
| 84 |
enum COVER_TYPE {ALL_TOUCHED=0, ALL_COVERED=1, ALL_CENTER=2}; |
| 85 |
} |
| 86 |
|
| 87 |
enum DATA_ACCESS { READ_ONLY = 0, UPDATE = 1, WRITE = 3}; |
| 88 |
enum RESAMPLE { NEAR = 0, BILINEAR = 1, BICUBIC = 2 }; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
template<typename T1> GDALDataType type2GDAL(){ |
| 102 |
if (typeid(T1) == typeid(char)) |
| 103 |
return GDT_Byte; |
| 104 |
else if (typeid(T1) == typeid(unsigned char)) |
| 105 |
return GDT_Byte; |
| 106 |
else if (typeid(T1) == typeid(unsigned short)) |
| 107 |
return GDT_UInt16; |
| 108 |
else if (typeid(T1) == typeid(short)) |
| 109 |
return GDT_Int16; |
| 110 |
else if (typeid(T1) == typeid(int)) |
| 111 |
return GDT_Int32; |
| 112 |
else if (typeid(T1) == typeid(unsigned int)) |
| 113 |
return GDT_UInt32; |
| 114 |
else if (typeid(T1) == typeid(long)) |
| 115 |
return GDT_Int32; |
| 116 |
else if (typeid(T1) == typeid(unsigned long)) |
| 117 |
return GDT_UInt32; |
| 118 |
else if (typeid(T1) == typeid(float)) |
| 119 |
return GDT_Float32; |
| 120 |
else if (typeid(T1) == typeid(double)) |
| 121 |
return GDT_Float64; |
| 122 |
else |
| 123 |
return GDT_Unknown; |
| 124 |
}; |
| 125 |
|
| 126 |
static GDALDataType string2GDAL(const std::string &typeString){ |
| 127 |
std::map<std::string,GDALDataType> typeMap; |
| 128 |
typeMap["Byte"]=GDT_Byte; |
| 129 |
typeMap["UInt16"]=GDT_UInt16; |
| 130 |
typeMap["Int16"]=GDT_Int16; |
| 131 |
typeMap["UInt32"]=GDT_UInt32; |
| 132 |
typeMap["Int32"]=GDT_Int32; |
| 133 |
typeMap["Float32"]=GDT_Float32; |
| 134 |
typeMap["Float64"]=GDT_Float64; |
| 135 |
typeMap["GDT_Byte"]=GDT_Byte; |
| 136 |
typeMap["GDT_UInt16"]=GDT_UInt16; |
| 137 |
typeMap["GDT_Int16"]=GDT_Int16; |
| 138 |
typeMap["GDT_UInt32"]=GDT_UInt32; |
| 139 |
typeMap["GDT_Int32"]=GDT_Int32; |
| 140 |
typeMap["GDT_Float32"]=GDT_Float32; |
| 141 |
typeMap["GDT_Float64"]=GDT_Float64; |
| 142 |
typeMap["int8"]=GDT_Byte; |
| 143 |
typeMap["uint8"]=GDT_Byte; |
| 144 |
typeMap["int16"]=GDT_Int16; |
| 145 |
typeMap["uint16"]=GDT_UInt16; |
| 146 |
typeMap["uint32"]=GDT_UInt32; |
| 147 |
typeMap["int32"]=GDT_Int32; |
| 148 |
typeMap["float32"]=GDT_Float32; |
| 149 |
typeMap["float64"]=GDT_Float64; |
| 150 |
typeMap["Int8"]=GDT_Byte; |
| 151 |
typeMap["UInt8"]=GDT_Byte; |
| 152 |
typeMap["UInt8"]=GDT_Byte; |
| 153 |
typeMap["UInt16"]=GDT_UInt16; |
| 154 |
typeMap["Int16"]=GDT_Int16; |
| 155 |
typeMap["UInt32"]=GDT_UInt32; |
| 156 |
typeMap["Int32"]=GDT_Int32; |
| 157 |
typeMap["Float32"]=GDT_Float32; |
| 158 |
typeMap["Float64"]=GDT_Float64; |
| 159 |
if(typeMap.count(typeString)) |
| 160 |
return(typeMap[typeString]); |
| 161 |
else |
| 162 |
return(GDT_Unknown); |
| 163 |
} |
| 164 |
|
| 165 |
static JIPLIBDataType string2JDT(const std::string &typeString){ |
| 166 |
std::map<std::string,JIPLIBDataType> typeMap; |
| 167 |
typeMap["UInt64"]=JDT_UInt64; |
| 168 |
typeMap["Int64"]=JDT_Int64; |
| 169 |
typeMap["JDT_UInt64"]=JDT_UInt64; |
| 170 |
typeMap["JDT_Int64"]=JDT_Int64; |
| 171 |
typeMap["JDT_Word"]=JDT_Word; |
| 172 |
if(typeMap.count(typeString)) |
| 173 |
return(typeMap[typeString]); |
| 174 |
else |
| 175 |
return(JDT_Unknown); |
| 176 |
} |
| 177 |
|
| 178 |
static int getDataType(const std::string &typeString){ |
| 179 |
|
| 180 |
|
| 181 |
std::map<std::string,int> typeMap; |
| 182 |
typeMap["Byte"]=GDT_Byte; |
| 183 |
typeMap["UInt16"]=GDT_UInt16; |
| 184 |
typeMap["Int16"]=GDT_Int16; |
| 185 |
typeMap["UInt32"]=GDT_UInt32; |
| 186 |
typeMap["Int32"]=GDT_Int32; |
| 187 |
typeMap["Float32"]=GDT_Float32; |
| 188 |
typeMap["Float64"]=GDT_Float64; |
| 189 |
typeMap["GDT_Byte"]=GDT_Byte; |
| 190 |
typeMap["GDT_UInt16"]=GDT_UInt16; |
| 191 |
typeMap["GDT_Int16"]=GDT_Int16; |
| 192 |
typeMap["GDT_UInt32"]=GDT_UInt32; |
| 193 |
typeMap["GDT_Int32"]=GDT_Int32; |
| 194 |
typeMap["GDT_Float32"]=GDT_Float32; |
| 195 |
typeMap["GDT_Float64"]=GDT_Float64; |
| 196 |
typeMap["Int64"]=JDT_Int64; |
| 197 |
typeMap["UInt64"]=JDT_UInt64; |
| 198 |
typeMap["JDT_Int64"]=JDT_Int64; |
| 199 |
typeMap["JDT_UInt64"]=JDT_UInt64; |
| 200 |
typeMap["JDT_Word"]=JDT_Word; |
| 201 |
typeMap["int8"]=GDT_Byte; |
| 202 |
typeMap["uint8"]=GDT_Byte; |
| 203 |
typeMap["int16"]=GDT_Int16; |
| 204 |
typeMap["uint16"]=GDT_UInt16; |
| 205 |
typeMap["uint32"]=GDT_UInt32; |
| 206 |
typeMap["int32"]=GDT_Int32; |
| 207 |
typeMap["float32"]=GDT_Float32; |
| 208 |
typeMap["float64"]=GDT_Float64; |
| 209 |
typeMap["Int8"]=GDT_Byte; |
| 210 |
typeMap["UInt8"]=GDT_Byte; |
| 211 |
typeMap["UInt8"]=GDT_Byte; |
| 212 |
typeMap["UInt16"]=GDT_UInt16; |
| 213 |
typeMap["Int16"]=GDT_Int16; |
| 214 |
typeMap["UInt32"]=GDT_UInt32; |
| 215 |
typeMap["Int32"]=GDT_Int32; |
| 216 |
typeMap["Float32"]=GDT_Float32; |
| 217 |
typeMap["Float64"]=GDT_Float64; |
| 218 |
if(typeMap.count(typeString)) |
| 219 |
return(typeMap[typeString]); |
| 220 |
else |
| 221 |
return(GDT_Unknown); |
| 222 |
} |
| 223 |
|
| 224 |
static std::size_t getDataTypeSizeBytes(const std::string &typeString){ |
| 225 |
int typeInt=getDataType(typeString); |
| 226 |
switch (typeInt){ |
| 227 |
case JDT_UInt64: |
| 228 |
case JDT_Int64: |
| 229 |
return(static_cast<std::size_t>(8)); |
| 230 |
case JDT_Word: |
| 231 |
return(static_cast<std::size_t>(1)); |
| 232 |
default:{ |
| 233 |
if(typeInt==GDT_Unknown){ |
| 234 |
std::string errorString="Error: data type not supported"; |
| 235 |
throw(errorString); |
| 236 |
} |
| 237 |
return static_cast<std::size_t>(GDALGetDataTypeSizeBytes(static_cast<GDALDataType>(typeInt))); |
| 238 |
} |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
static GDALRIOResampleAlg getGDALResampleIO(const std::string &resampleString){ |
| 243 |
|
| 244 |
std::map<std::string,GDALRIOResampleAlg> resampleMap; |
| 245 |
|
| 246 |
resampleMap["NearestNeighbour"]=GRIORA_NearestNeighbour; |
| 247 |
resampleMap["Bilinear"] = GRIORA_Bilinear; |
| 248 |
resampleMap["Cubic"]=GRIORA_Cubic; |
| 249 |
resampleMap["CubicSpline"]=GRIORA_CubicSpline; |
| 250 |
resampleMap["Lanczos"]=GRIORA_Lanczos; |
| 251 |
resampleMap["Average"]=GRIORA_Average; |
| 252 |
resampleMap["Mode"]=GRIORA_Mode; |
| 253 |
resampleMap["Gauss"]=GRIORA_Gauss; |
| 254 |
resampleMap["GRIORA_NearestNeighbour"]=GRIORA_NearestNeighbour; |
| 255 |
resampleMap["GRIORA_Bilinear"] = GRIORA_Bilinear; |
| 256 |
resampleMap["GRIORA_Cubic"]=GRIORA_Cubic; |
| 257 |
resampleMap["GRIORA_CubicSpline"]=GRIORA_CubicSpline; |
| 258 |
resampleMap["GRIORA_Lanczos"]=GRIORA_Lanczos; |
| 259 |
resampleMap["GRIORA_Average"]=GRIORA_Average; |
| 260 |
resampleMap["GRIORA_Mode"]=GRIORA_Mode; |
| 261 |
resampleMap["GRIORA_Gauss"]=GRIORA_Gauss; |
| 262 |
if(resampleMap.count(resampleString)) |
| 263 |
return(resampleMap[resampleString]); |
| 264 |
else |
| 265 |
return(GRIORA_NearestNeighbour); |
| 266 |
} |
| 267 |
|
| 268 |
static GDALResampleAlg getGDALResampleAlg(const std::string &resampleString){ |
| 269 |
|
| 270 |
std::map<std::string,GDALResampleAlg> resampleMap; |
| 271 |
|
| 272 |
resampleMap["near"]=GRA_NearestNeighbour; |
| 273 |
resampleMap["bilinear"]=GRA_Bilinear; |
| 274 |
resampleMap["cubic"]=GRA_Cubic; |
| 275 |
resampleMap["cubicspline"]=GRA_CubicSpline; |
| 276 |
resampleMap["lanczos"]=GRA_Lanczos; |
| 277 |
resampleMap["average"]=GRA_Average; |
| 278 |
resampleMap["mode"]=GRA_Mode; |
| 279 |
resampleMap["max"]=GRA_Max; |
| 280 |
resampleMap["min"]=GRA_Min; |
| 281 |
resampleMap["med"]=GRA_Med; |
| 282 |
resampleMap["q1"]=GRA_Q1; |
| 283 |
resampleMap["q3"]=GRA_Q3; |
| 284 |
|
| 285 |
#if GDAL_VERSION_MAJOR > 3 |
| 286 |
resampleMap["sum"]=GRA_Sum; |
| 287 |
#endif |
| 288 |
if(resampleMap.count(resampleString)) |
| 289 |
return(resampleMap[resampleString]); |
| 290 |
else |
| 291 |
return(GRA_NearestNeighbour); |
| 292 |
} |
| 293 |
|
| 294 |
class JimList; |
| 295 |
class VectorOgr; |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
class Jim : public std::enable_shared_from_this<Jim> |
| 302 |
{ |
| 303 |
public: |
| 304 |
|
| 305 |
Jim(); |
| 306 |
|
| 307 |
|
| 308 |
Jim(void* dataPointer, int ncol, int nrow, const GDALDataType& dataType); |
| 309 |
Jim(std::vector<void*> dataPointers, int ncol, int nrow, const GDALDataType& dataType); |
| 310 |
Jim(void* dataPointer, int ncol, int nrow, int nplane, const GDALDataType& dataType); |
| 311 |
Jim(std::vector<void*> dataPointers, int ncol, int nrow, int nplane, const GDALDataType& dataType); |
| 312 |
|
| 313 |
#if MIALLIB == 1 |
| 314 |
Jim(IMAGE *mia); |
| 315 |
#endif |
| 316 |
|
| 317 |
Jim(const std::string& filename, bool readData=true, unsigned int memory=0); |
| 318 |
|
| 319 |
Jim(const std::string& filename, const Jim& imgSrc, unsigned int memory=0, const std::vector<std::string>& options=std::vector<std::string>()); |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
Jim(Jim& imgSrc, bool copyData=true); |
| 324 |
|
| 325 |
Jim(const std::string& filename, int ncol, int nrow, int nband, const GDALDataType& dataType, const std::string& imageType, unsigned int memory=0, const std::vector<std::string>& options=std::vector<std::string>()); |
| 326 |
|
| 327 |
Jim(int ncol, int nrow, int nband, int nplane, const GDALDataType& dataType); |
| 328 |
|
| 329 |
Jim(int ncol, int nrow, int nband, const GDALDataType& dataType); |
| 330 |
|
| 331 |
Jim(app::AppFactory &theApp); |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
virtual ~Jim(void); |
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
static std::shared_ptr<Jim> createImg(); |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
static std::shared_ptr<Jim> createImg(const std::shared_ptr<Jim> pSrc, bool copyData=true); |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
static std::shared_ptr<Jim> createImg(app::AppFactory &theApp); |
| 390 |
static std::shared_ptr<Jim> createImg(const std::string filename, bool readData=true, unsigned int memory=0); |
| 391 |
|
| 392 |
bool writeMode(){return(m_access==WRITE);}; |
| 393 |
|
| 394 |
DATA_ACCESS getAccess(){return m_access;}; |
| 395 |
|
| 396 |
CPLErr setAccess(DATA_ACCESS theAccess){m_access=theAccess;return CE_None;}; |
| 397 |
|
| 398 |
CPLErr setAccess(std::string accessString){ |
| 399 |
if(accessString=="READ_ONLY"){ |
| 400 |
m_access=READ_ONLY; |
| 401 |
return CE_None; |
| 402 |
} |
| 403 |
if(accessString=="UPDATE"){ |
| 404 |
m_access=UPDATE; |
| 405 |
return CE_None; |
| 406 |
} |
| 407 |
if(accessString=="WRITE"){ |
| 408 |
m_access=WRITE; |
| 409 |
return CE_None; |
| 410 |
} |
| 411 |
else |
| 412 |
return CE_Failure; |
| 413 |
} |
| 414 |
|
| 415 |
bool isInit(){return(m_data.size()>0);}; |
| 416 |
|
| 417 |
CPLErr setScale(double theScale, int band=0){ |
| 418 |
if(m_scale.size()!=nrOfBand()){ |
| 419 |
m_scale.resize(nrOfBand()); |
| 420 |
for(int iband=0;iband<nrOfBand();++iband) |
| 421 |
m_scale[iband]=1.0; |
| 422 |
} |
| 423 |
m_scale[band]=theScale; |
| 424 |
return CE_None; |
| 425 |
}; |
| 426 |
|
| 427 |
CPLErr setOffset(double theOffset, int band=0){ |
| 428 |
if(m_offset.size()!=nrOfBand()){ |
| 429 |
m_offset.resize(nrOfBand()); |
| 430 |
for(int iband=0;iband<nrOfBand();++iband) |
| 431 |
m_offset[iband]=0.0; |
| 432 |
} |
| 433 |
m_offset[band]=theOffset; |
| 434 |
return(CE_None); |
| 435 |
}; |
| 436 |
|
| 437 |
CPLErr setExternalData(bool flag){m_externalData=flag; return CE_None;}; |
| 438 |
bool getExternalData() const {return(m_externalData);}; |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
CPLErr close(); |
| 443 |
|
| 444 |
CPLErr write(); |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
CPLErr write(app::AppFactory &theApp); |
| 454 |
|
| 455 |
std::string getFileName() const {return m_filename;}; |
| 456 |
|
| 457 |
int nrOfCol() const { return m_ncol;}; |
| 458 |
|
| 459 |
int nrOfRow() const { return m_nrow;}; |
| 460 |
|
| 461 |
int nrOfBand() const { return m_nband;}; |
| 462 |
#ifdef SWIG |
| 463 |
%pythonprepend nrOfPlane() "\"\"\"HELP.METHOD.Jim.nrOfPlane()\"\"\"" |
| 464 |
#endif |
| 465 |
|
| 466 |
int nrOfPlane() const { return m_nplane;}; |
| 467 |
|
| 468 |
bool isGeoRef() const {std::vector<double> gt(6);getGeoTransform(gt);if(gt.size()!=6) return false;else if(gt[5]<0) return true;else return false;}; |
| 469 |
|
| 470 |
std::string getProjection() const; |
| 471 |
|
| 472 |
std::string getProjectionRef() const; |
| 473 |
|
| 474 |
|
| 475 |
const OGRSpatialReference getSpatialRef() const{ |
| 476 |
OGRSpatialReference thisSpatialRef(getProjectionRef().c_str()); |
| 477 |
return thisSpatialRef; |
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
void getGeoTransform(double& gt0, double& gt1, double& gt2, double& gt3, double& gt4, double& gt5) const{std::vector<double> gt(6); getGeoTransform(gt);if (gt.size()==6){gt0=gt[0];gt1=gt[1];gt2=gt[2];gt3=gt[3];gt4=gt[4];gt5=gt[5];}}; |
| 489 |
|
| 490 |
|
| 491 |
void getGeoTransform(std::vector<double>& gt) const; |
| 492 |
void getGeoTransform(double* gt) const; |
| 493 |
|
| 494 |
CPLErr setGeoTransform(const std::vector<double>& gt); |
| 495 |
CPLErr setGeoTransform(double* gt); |
| 496 |
|
| 497 |
CPLErr copyGeoReference(const Jim& imgSrc); |
| 498 |
CPLErr copyGeoTransform(const Jim& imgSrc); |
| 499 |
|
| 500 |
void setProjection(const std::string& projection){setProjectionProj4(projection);}; |
| 501 |
|
| 502 |
void setProjectionProj4(const std::string& projection); |
| 503 |
|
| 504 |
void getBoundingBox(double& ulx, double& uly, double& lrx, double& lry, OGRCoordinateTransformation *poCT=0) const; |
| 505 |
|
| 506 |
void getBoundingBox(std::vector<double> &bbvector, OGRCoordinateTransformation *poCT=0) const; |
| 507 |
|
| 508 |
void getBoundingBox(OGRPolygon *bbPolygon, OGRCoordinateTransformation *poCT=0) const; |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
void getCenterPos(double& centerX, double& centerY) const; |
| 513 |
|
| 514 |
double getUlx() const {double ulx, uly, lrx,lry;getBoundingBox(ulx,uly,lrx,lry);return(ulx);}; |
| 515 |
|
| 516 |
double getUly() const {double ulx, uly, lrx,lry;getBoundingBox(ulx,uly,lrx,lry);return(uly);}; |
| 517 |
|
| 518 |
double getLrx() const {double ulx, uly, lrx,lry;getBoundingBox(ulx,uly,lrx,lry);return(lrx);}; |
| 519 |
|
| 520 |
double getLry() const {double ulx, uly, lrx,lry;getBoundingBox(ulx,uly,lrx,lry);return(lry);}; |
| 521 |
|
| 522 |
double getScale(std::size_t band=0){ |
| 523 |
if(m_scale.size()<=band) |
| 524 |
return(1.0); |
| 525 |
else |
| 526 |
return(m_scale[band]); |
| 527 |
}; |
| 528 |
|
| 529 |
void getScale(std::vector<double>& scale) const {scale=m_scale;}; |
| 530 |
|
| 531 |
double getOffset(std::size_t band=0){ |
| 532 |
if(m_offset.size()<=band) |
| 533 |
return(0.0); |
| 534 |
else |
| 535 |
return(m_offset[band]); |
| 536 |
}; |
| 537 |
|
| 538 |
void getOffset(std::vector<double>& offset) const {offset=m_offset;}; |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
void getNoDataValues(std::vector<double>& noDataValues) const; |
| 543 |
|
| 544 |
CPLErr printNoDataValues() const{ |
| 545 |
if(m_noDataValues.size()){ |
| 546 |
for(int i=0;i<m_noDataValues.size();++i) |
| 547 |
std::cout << m_noDataValues[i] << " "; |
| 548 |
std::cout << std::endl; |
| 549 |
return(CE_None); |
| 550 |
} |
| 551 |
else |
| 552 |
return(CE_Warning); |
| 553 |
}; |
| 554 |
|
| 555 |
bool isNoData(double value) const{if(m_noDataValues.empty()) return false;else return find(m_noDataValues.begin(),m_noDataValues.end(),value)!=m_noDataValues.end();}; |
| 556 |
|
| 557 |
CPLErr pushNoDataValue(double noDataValue); |
| 558 |
|
| 559 |
CPLErr setNoDataValue(double nodata){clearNoData(); pushNoDataValue(nodata);if(m_noDataValues.empty()) return(CE_Failure);else return(CE_None);}; |
| 560 |
|
| 561 |
CPLErr setNoData(const std::vector<double>& nodata){m_noDataValues=nodata; if(nodata.size() != m_noDataValues.size()) return(CE_Failure);else return(CE_None);}; |
| 562 |
|
| 563 |
CPLErr setNoData(const std::list<double>& nodata){ |
| 564 |
clearNoData(); |
| 565 |
std::list<double>::const_iterator lit=nodata.begin(); |
| 566 |
while(lit!=nodata.end()) |
| 567 |
pushNoDataValue(*(lit++)); |
| 568 |
if(nodata.size() != m_noDataValues.size()) |
| 569 |
return(CE_Failure); |
| 570 |
else return(CE_None); |
| 571 |
}; |
| 572 |
void setData(double value); |
| 573 |
void setData(double value, int band); |
| 574 |
void setData(double value, double ulx, double uly, double lrx, double lry, int band=0, double dx=0, double dy=0, bool nogeo=false); |
| 575 |
|
| 576 |
CPLErr clearNoData(int band=0){m_noDataValues.clear();if(m_access!=READ_ONLY&&getRasterBand(band)) getRasterBand(band)->DeleteNoDataValue();return(CE_None);} |
| 577 |
|
| 578 |
CPLErr GDALSetNoDataValue(double noDataValue, int band=0) {if(getRasterBand(band)) return getRasterBand(band)->SetNoDataValue(noDataValue);else return(CE_Warning);}; |
| 579 |
|
| 580 |
bool covers(double x, double y, OGRCoordinateTransformation *poCT=NULL) const; |
| 581 |
|
| 582 |
bool covers(double ulx, double uly, double lrx, double lry, std::string coverType="ALL_TOUCHED", OGRCoordinateTransformation *poCT=NULL) const; |
| 583 |
|
| 584 |
bool covers(const std::shared_ptr<Jim> imgRaster, std::string coverType="ALL_TOUCHED") const{ |
| 585 |
OGRSpatialReference thisSpatialRef(getProjectionRef().c_str()); |
| 586 |
OGRSpatialReference thatSpatialRef(imgRaster->getProjectionRef().c_str()); |
| 587 |
OGRCoordinateTransformation *that2this = OGRCreateCoordinateTransformation(&thatSpatialRef, &thisSpatialRef); |
| 588 |
if(thisSpatialRef.IsSame(&thatSpatialRef)){ |
| 589 |
that2this=0; |
| 590 |
} |
| 591 |
else{ |
| 592 |
if(!that2this){ |
| 593 |
std::ostringstream errorStream; |
| 594 |
errorStream << "Error: cannot create OGRCoordinateTransformation that to this" << std::endl; |
| 595 |
throw(errorStream.str()); |
| 596 |
} |
| 597 |
} |
| 598 |
|
| 599 |
double img_ulx,img_uly,img_lrx,img_lry; |
| 600 |
imgRaster->getBoundingBox(img_ulx,img_uly,img_lrx,img_lry,that2this); |
| 601 |
return covers(img_ulx,img_uly,img_lrx,img_lry,coverType); |
| 602 |
}; |
| 603 |
|
| 604 |
bool geo2image(double x, double y, double& i, double& j, OGRCoordinateTransformation *poCT=NULL) const; |
| 605 |
|
| 606 |
bool image2geo(double i, double j, double& x, double& y, OGRCoordinateTransformation *poCT=NULL) const; |
| 607 |
|
| 608 |
double getDeltaX() const {std::vector<double> gt(6);getGeoTransform(gt);return gt[1];}; |
| 609 |
|
| 610 |
double getDeltaY() const {std::vector<double> gt(6);getGeoTransform(gt);return -gt[5];}; |
| 611 |
|
| 612 |
GDALDataType getDataTypeDS(int band=0) const; |
| 613 |
|
| 614 |
int getDataType(int band=0) const; |
| 615 |
GDALDataType getGDALDataType(int band=0) const; |
| 616 |
std::size_t getDataTypeSizeBytes(int band=0) const; |
| 617 |
|
| 618 |
|
| 619 |
void* getDataPointer(int band=0){return(m_data[band]);}; |
| 620 |
|
| 621 |
void freeMem(); |
| 622 |
|
| 623 |
CPLErr copyData(void* data, int band=0); |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
GDALRasterBand* getRasterBand(int band=0) const; |
| 630 |
|
| 631 |
GDALColorTable* getColorTable(int band=0) const; |
| 632 |
|
| 633 |
std::string getDriverDescription() const; |
| 634 |
|
| 635 |
std::string getImageType() const{return getDriverDescription();}; |
| 636 |
|
| 637 |
std::string getInterleave() const; |
| 638 |
|
| 639 |
std::string getCompression() const; |
| 640 |
|
| 641 |
GDALDataset* getDataset(){return m_gds;}; |
| 642 |
|
| 643 |
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 13, 0) |
| 644 |
CSLConstList getMetadata() const; |
| 645 |
#else |
| 646 |
char** getMetadata() const; |
| 647 |
#endif |
| 648 |
|
| 649 |
void getMetadata(std::list<std::string>& metadata) const; |
| 650 |
|
| 651 |
std::string getDescription() const; |
| 652 |
|
| 653 |
std::string getMetadataItem() const; |
| 654 |
|
| 655 |
std::string getImageDescription() const; |
| 656 |
int getBlockSize() const{return m_blockSize;}; |
| 657 |
int getBlockSizeX(int band=0) |
| 658 |
{ |
| 659 |
int blockSizeX=0; |
| 660 |
int blockSizeY=0; |
| 661 |
if(getRasterBand(band)) |
| 662 |
getRasterBand(band)->GetBlockSize( &blockSizeX, &blockSizeY ); |
| 663 |
return blockSizeX; |
| 664 |
} |
| 665 |
int getBlockSizeY(int band=0) |
| 666 |
{ |
| 667 |
int blockSizeX=0; |
| 668 |
int blockSizeY=0; |
| 669 |
if(getRasterBand(band)) |
| 670 |
getRasterBand(band)->GetBlockSize( &blockSizeX, &blockSizeY ); |
| 671 |
return blockSizeY; |
| 672 |
} |
| 673 |
int nrOfBlockX(int band=0) |
| 674 |
{ |
| 675 |
int blockSizeX=0; |
| 676 |
int blockSizeY=0; |
| 677 |
int nXBlocks=0; |
| 678 |
if(getRasterBand(band)){ |
| 679 |
getRasterBand(band)->GetBlockSize( &blockSizeX, &blockSizeY ); |
| 680 |
nXBlocks = (nrOfCol() + blockSizeX - 1) / blockSizeX; |
| 681 |
} |
| 682 |
return nXBlocks; |
| 683 |
} |
| 684 |
int nrOfBlockY(int band=0) |
| 685 |
{ |
| 686 |
int blockSizeX=0; |
| 687 |
int blockSizeY=0; |
| 688 |
int nYBlocks=0; |
| 689 |
if(getRasterBand(band)){ |
| 690 |
getRasterBand(band)->GetBlockSize( &blockSizeX, &blockSizeY ); |
| 691 |
nYBlocks = (nrOfRow() + blockSizeY - 1) / blockSizeY; |
| 692 |
} |
| 693 |
return nYBlocks; |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
std::string jim2json(); |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
std::shared_ptr<Jim> clone(bool copyData=true); |
| 703 |
std::shared_ptr<Jim> getShared(){return(std::dynamic_pointer_cast<Jim>(shared_from_this()));}; |
| 704 |
|
| 705 |
CPLErr readDataDS(int band, int ds_band); |
| 706 |
|
| 707 |
CPLErr readData(int band){return readDataDS(band,band);}; |
| 708 |
|
| 709 |
CPLErr readData(); |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
template<typename T> CPLErr readData(T& value, int col, int row, int band=0); |
| 714 |
template<typename T> CPLErr readData3D(T& value, std::size_t col, std::size_t row, std::size_t plane, std::size_t band=0); |
| 715 |
template<typename T> CPLErr readData3D(std::vector<T>& buffer, std::size_t minCol, std::size_t maxCol, std::size_t row, std::size_t plane, std::size_t band=0); |
| 716 |
|
| 717 |
double readData(int col, int row, int band=0){ |
| 718 |
double value; |
| 719 |
readData(value, col, row, band); |
| 720 |
return(value); |
| 721 |
}; |
| 722 |
double readData3D(std::size_t col, std::size_t row, std::size_t plane, std::size_t band=0){ |
| 723 |
double value; |
| 724 |
readData3D(value, col, row, plane, band); |
| 725 |
return(value); |
| 726 |
}; |
| 727 |
|
| 728 |
template<typename T> CPLErr readData(std::vector<T>& buffer, int minCol, int maxCol, int row, int band=0); |
| 729 |
|
| 730 |
template<typename T> CPLErr readData(std::vector<T>& buffer, int minCol, int maxCol, double row, int band, RESAMPLE resample); |
| 731 |
|
| 732 |
template<typename T> CPLErr readDataBlock(Vector2d<T>& buffer2d, int minCol, int maxCol, int minRow, int maxRow, int band=0); |
| 733 |
template<typename T> CPLErr readDataBlock3D(Vector2d<T>& buffer2d, std::size_t minCol, std::size_t maxCol, std::size_t minRow, std::size_t maxRow, std::size_t plane, std::size_t band=0); |
| 734 |
|
| 735 |
template<typename T> CPLErr readDataBlock(std::vector<T>& buffer , int minCol, int maxCol, int minRow, int maxRow, int band=0); |
| 736 |
template<typename T> CPLErr readDataBlock3D(std::vector<T>& buffer , std::size_t minCol, std::size_t maxCol, std::size_t minRow, std::size_t maxRow, std::size_t plane, std::size_t band=0); |
| 737 |
|
| 738 |
template<typename T> CPLErr readData(std::vector<T>& buffer, int row, int band=0); |
| 739 |
|
| 740 |
template<typename T> CPLErr readData(std::vector<T>& buffer, double row, int band, RESAMPLE resample); |
| 741 |
|
| 742 |
void getMinMax(int startCol, int endCol, int startRow, int endRow, int band, double& minValue, double& maxValue); |
| 743 |
|
| 744 |
void getMinMax(double& minValue, double& maxValue, int band=0); |
| 745 |
|
| 746 |
double getMin(int& col, int& row, int band=0); |
| 747 |
|
| 748 |
double getMin(int band=0){int theCol=0;int theRow=0;return(getMin(theCol,theRow,band));}; |
| 749 |
|
| 750 |
double getMax(int& col, int& row, int band=0); |
| 751 |
|
| 752 |
double getMax(int band=0){int theCol=0;int theRow=0;return(getMax(theCol,theRow,band));}; |
| 753 |
|
| 754 |
double getHistogram(std::vector<double>& histvector, double& min, double& max, int& nbin, int theBand=0, bool kde=false); |
| 755 |
|
| 756 |
void getRefPix(double& refX, double &refY, int band=0); |
| 757 |
|
| 758 |
void getRange(std::vector<short>& range, int band=0); |
| 759 |
|
| 760 |
unsigned long int getNvalid(int band=0); |
| 761 |
|
| 762 |
unsigned long int getNinvalid(int band=0); |
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
CPLErr open(const std::string& filename, bool readData=true, unsigned int memory=0); |
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
CPLErr open(const std::string& filename, const Jim& imgSrc, const std::vector<std::string>& options=std::vector<std::string>()); |
| 771 |
|
| 772 |
CPLErr open(const std::string& filename, const Jim& imgSrc, unsigned int memory, const std::vector<std::string>& options=std::vector<std::string>()); |
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
CPLErr open(const std::string& filename, int ncol, int nrow, int nband, const GDALDataType& dataType, const std::string& imageType, unsigned int memory=0, const std::vector<std::string>& options=std::vector<std::string>()); |
| 777 |
|
| 778 |
CPLErr open(int ncol, int nrow, int nband, const GDALDataType& dataType); |
| 779 |
|
| 780 |
CPLErr open(int ncol, int nrow, int nband, int nplane, const GDALDataType& dataType); |
| 781 |
|
| 782 |
CPLErr open(Jim& imgSrc, bool copyData=true); |
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
CPLErr open(void* dataPointer, int ncol, int nrow, const GDALDataType& dataType); |
| 787 |
|
| 788 |
CPLErr open(void* dataPointer, int ncol, int nrow, int nplane, const GDALDataType& dataType, bool copyData=true); |
| 789 |
|
| 790 |
CPLErr open(std::vector<void*> dataPointers, int ncol, int nrow, int nplane, const GDALDataType& dataType, bool copyData=true); |
| 791 |
|
| 792 |
CPLErr open(std::vector<void*> dataPointers, int ncol, int nrow, const GDALDataType& dataType); |
| 793 |
|
| 794 |
CPLErr open(app::AppFactory &app); |
| 795 |
|
| 796 |
|
| 797 |
CPLErr setImageDescription(const std::string& imageDescription){m_gds->SetMetadataItem( "TIFFTAG_IMAGEDESCRIPTION",imageDescription.c_str()); return(CE_None);}; |
| 798 |
|
| 799 |
|
| 800 |
template<typename T> CPLErr writeData(const T& value, int col, int row, int band=0); |
| 801 |
|
| 802 |
template<typename T> CPLErr writeData(std::vector<T>& buffer, int minCol, int maxCol, int row, int band=0); |
| 803 |
|
| 804 |
template<typename T> CPLErr writeData(std::vector<T>& buffer, int row, int band=0); |
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
template<typename T> CPLErr writeDataBlock(Vector2d<T>& buffer2d, int minCol, int maxCol, int minRow, int maxRow, int band=0); |
| 813 |
template<typename T> CPLErr writeDataBlock(T value, int minCol, int maxCol, int minRow, int maxRow, int band=0); |
| 814 |
|
| 815 |
CPLErr setFile(const std::string& filename, const std::string& imageType, unsigned int memory=0, const std::vector<std::string>& options=std::vector<std::string>()); |
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
CPLErr setColorTable(const std::string& filename, int band=0); |
| 820 |
|
| 821 |
CPLErr setColorTable(GDALColorTable* colorTable, int band=0); |
| 822 |
|
| 823 |
CPLErr setMetadata(char** metadata); |
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
void d_rasterizeBuf(VectorOgr& ogrReader, app::AppFactory &app); |
| 828 |
void d_rasterizeBuf(VectorOgr& ogrReader, double burnValue, const std::vector<std::string>& eoption=std::vector<std::string>(), const std::vector<std::string>& layernames=std::vector<std::string>()); |
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
void setThreshold(Jim& imgWriter, double t1, double t2); |
| 834 |
void setThresholdMin(Jim& imgWriter, double minThreshold); |
| 835 |
void setThresholdMax(Jim& imgWriter, double maxThreshold); |
| 836 |
|
| 837 |
void setAbsThreshold(Jim& imgWriter, double t1, double t2); |
| 838 |
void setAbsThresholdMin(Jim& imgWriter, double minThreshold); |
| 839 |
void setAbsThresholdMax(Jim& imgWriter, double maxThreshold); |
| 840 |
|
| 841 |
std::shared_ptr<Jim> setThreshold(double t1, double t2); |
| 842 |
|
| 843 |
std::shared_ptr<Jim> setAbsThreshold(double t1, double t2); |
| 844 |
|
| 845 |
void setThreshold(Jim& imgWriter, double t1, double t2, double value); |
| 846 |
void setThresholdMin(Jim& imgWriter, double minThreshold, double value); |
| 847 |
void setThresholdMax(Jim& imgWriter, double maxThreshold, double value); |
| 848 |
|
| 849 |
void setAbsThreshold(Jim& imgWriter, double t1, double t2, double value); |
| 850 |
void setAbsThresholdMin(Jim& imgWriter, double minThreshold, double value); |
| 851 |
void setAbsThresholdMax(Jim& imgWriter, double maxThreshold, double value); |
| 852 |
|
| 853 |
std::shared_ptr<Jim> setThreshold(double t1, double t2, double value); |
| 854 |
|
| 855 |
std::shared_ptr<Jim> setAbsThreshold(double t1, double t2, double value); |
| 856 |
|
| 857 |
void setThreshold(Jim& imgWriter, app::AppFactory &theApp); |
| 858 |
|
| 859 |
std::shared_ptr<Jim> setThreshold(app::AppFactory &theApp); |
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
#if MIALLIB == 1 |
| 864 |
bool isEqual(std::shared_ptr<Jim> refImg); |
| 865 |
#endif |
| 866 |
|
| 867 |
std::shared_ptr<Jim> eq(std::shared_ptr<Jim> refJim); |
| 868 |
std::shared_ptr<Jim> eq(double value); |
| 869 |
void eq(Jim& refJim, Jim& imgWriter); |
| 870 |
void eq(double value, Jim& imgWriter); |
| 871 |
|
| 872 |
std::shared_ptr<Jim> ne(std::shared_ptr<Jim> refJim); |
| 873 |
std::shared_ptr<Jim> ne(double value); |
| 874 |
void ne(Jim& refJim, Jim& imgWriter); |
| 875 |
void ne(double value, Jim& imgWriter); |
| 876 |
|
| 877 |
std::shared_ptr<Jim> lt(std::shared_ptr<Jim> refJim); |
| 878 |
std::shared_ptr<Jim> lt(double value); |
| 879 |
void lt(Jim& refJim, Jim& imgWriter); |
| 880 |
void lt(double value, Jim& imgWriter); |
| 881 |
template<typename T> void lt_t(Jim& other, Jim& imgWriter); |
| 882 |
template<typename T> void lt_t(double value, Jim& imgWriter); |
| 883 |
|
| 884 |
std::shared_ptr<Jim> le(std::shared_ptr<Jim> refJim); |
| 885 |
std::shared_ptr<Jim> le(double value); |
| 886 |
void le(Jim& refJim, Jim& imgWriter); |
| 887 |
void le(double value, Jim& imgWriter); |
| 888 |
|
| 889 |
std::shared_ptr<Jim> gt(std::shared_ptr<Jim> refJim); |
| 890 |
std::shared_ptr<Jim> gt(double value); |
| 891 |
void gt(Jim& refJim, Jim& imgWriter); |
| 892 |
void gt(double value, Jim& imgWriter); |
| 893 |
|
| 894 |
std::shared_ptr<Jim> ge(std::shared_ptr<Jim> refJim); |
| 895 |
std::shared_ptr<Jim> ge(double value); |
| 896 |
void ge(Jim& refJim, Jim& imgWriter); |
| 897 |
void ge(double value, Jim& imgWriter); |
| 898 |
|
| 899 |
|
| 900 |
std::shared_ptr<Jim> createct(app::AppFactory& app); |
| 901 |
|
| 902 |
void createct(Jim& imgWriter, app::AppFactory& app); |
| 903 |
|
| 904 |
void convert(Jim& imgWriter, app::AppFactory& app); |
| 905 |
std::shared_ptr<Jim> convertDataType(const GDALDataType& dataType); |
| 906 |
std::shared_ptr<Jim> convertDataType(const std::string dataTypeString){return convertDataType(string2GDAL(dataTypeString));}; |
| 907 |
void convertDataType(Jim& imgWriter, const GDALDataType& dataType); |
| 908 |
template<typename T1, typename T2> void convertDataType_t(Jim& imgWriter); |
| 909 |
|
| 910 |
std::shared_ptr<Jim> hillShade(Jim& sza, Jim& saa); |
| 911 |
void hillShade(Jim& imgWriter, Jim& sza, Jim& saa); |
| 912 |
template<typename T1, typename T2> void hillShade_t(Jim& imgWriter, Jim& sza, Jim& saa); |
| 913 |
|
| 914 |
void crop(Jim& imgWriter, app::AppFactory& app); |
| 915 |
|
| 916 |
void cropOgr(VectorOgr& sampleReader, Jim& imgWriter, app::AppFactory& app); |
| 917 |
|
| 918 |
void cropDS(Jim& imgWriter, app::AppFactory& app); |
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
std::shared_ptr<Jim> stackBand(Jim& imgSrc, app::AppFactory& app); |
| 924 |
std::shared_ptr<Jim> stackBand(Jim& imgSrc){app::AppFactory theApp;return stackBand(imgSrc,theApp);}; |
| 925 |
|
| 926 |
void stackBand(Jim& imgSrc, Jim& imgWriter, app::AppFactory& app); |
| 927 |
void stackBand(Jim& imgSrc, Jim& imgWriter){app::AppFactory theApp;return stackBand(imgSrc,imgWriter,theApp);}; |
| 928 |
|
| 929 |
void d_stackBand(Jim& imgSrc, app::AppFactory& app); |
| 930 |
void d_stackBand(Jim& imgSrc){app::AppFactory theApp; d_stackBand(imgSrc,theApp);}; |
| 931 |
|
| 932 |
void d_stackPlane(Jim& imgSrc, app::AppFactory& app); |
| 933 |
void d_stackPlane(Jim& imgSrc){app::AppFactory theApp; d_stackPlane(imgSrc,theApp);}; |
| 934 |
|
| 935 |
std::shared_ptr<Jim> cropBand(app::AppFactory& app); |
| 936 |
std::shared_ptr<Jim> cropBand(){app::AppFactory theApp;return cropBand(theApp);}; |
| 937 |
|
| 938 |
std::shared_ptr<Jim> cropPlane(app::AppFactory& app); |
| 939 |
std::shared_ptr<Jim> cropPlane(){app::AppFactory theApp;return cropPlane(theApp);}; |
| 940 |
void cropBand(Jim& imgWriter, app::AppFactory& app); |
| 941 |
void cropBand(Jim& imgWriter){app::AppFactory theApp;return cropBand(imgWriter,theApp);}; |
| 942 |
|
| 943 |
void d_cropBand(app::AppFactory& app); |
| 944 |
void d_cropBand(){app::AppFactory theApp;d_cropBand(theApp);}; |
| 945 |
void cropPlane(Jim& imgWriter, app::AppFactory& app); |
| 946 |
void cropPlane(Jim& imgWriter){app::AppFactory theApp;return cropPlane(imgWriter,theApp);}; |
| 947 |
|
| 948 |
void d_cropPlane(app::AppFactory& app); |
| 949 |
void d_cropPlane(){app::AppFactory theApp;d_cropPlane(theApp);}; |
| 950 |
|
| 951 |
std::shared_ptr<Jim> convert(app::AppFactory& app); |
| 952 |
|
| 953 |
std::shared_ptr<Jim> crop(app::AppFactory& app); |
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
std::shared_ptr<Jim> cropOgr(VectorOgr& sampleReader, app::AppFactory& app); |
| 958 |
|
| 959 |
std::shared_ptr<Jim> warp(app::AppFactory& theApp); |
| 960 |
|
| 961 |
void warp(Jim& imgWriter, app::AppFactory &theApp); |
| 962 |
|
| 963 |
std::shared_ptr<VectorOgr> polygonize(app::AppFactory& app, std::shared_ptr<Jim>mask=nullptr); |
| 964 |
|
| 965 |
void polygonize(VectorOgr& ogrWriter, app::AppFactory& app, std::shared_ptr<Jim> mask=nullptr); |
| 966 |
|
| 967 |
CPLErr extractOgr(VectorOgr& sampleReader, VectorOgr& ogrWriter, app::AppFactory& app); |
| 968 |
|
| 969 |
std::shared_ptr<VectorOgr> extractOgr(VectorOgr& sampleReader, app::AppFactory& app); |
| 970 |
|
| 971 |
CPLErr extractSample(VectorOgr& ogrWriter, app::AppFactory& app); |
| 972 |
|
| 973 |
std::shared_ptr<VectorOgr> extractSample(app::AppFactory& app); |
| 974 |
|
| 975 |
void extractImg(Jim& classReader, VectorOgr& ogrWriter, app::AppFactory& app); |
| 976 |
template<typename T> void extractImg_t(Jim& classReader, VectorOgr& ogrWriter, app::AppFactory& app); |
| 977 |
|
| 978 |
std::shared_ptr<VectorOgr> extractImg(Jim& classReader, app::AppFactory& app); |
| 979 |
|
| 980 |
void statProfile(Jim& imgWriter, app::AppFactory& app); |
| 981 |
|
| 982 |
std::shared_ptr<Jim> statProfile(app::AppFactory& app); |
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
void filter1d(Jim& imgWriter, app::AppFactory& app); |
| 987 |
|
| 988 |
void filter2d(Jim& imgWriter, const app::AppFactory& app); |
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
std::shared_ptr<Jim> filter1d(app::AppFactory& app); |
| 993 |
|
| 994 |
std::shared_ptr<Jim> filter2d(const app::AppFactory& app); |
| 995 |
|
| 996 |
std::shared_ptr<Jim> firfilter1d(app::AppFactory& app); |
| 997 |
|
| 998 |
void firfilter1d(Jim& imgWriter, app::AppFactory& app); |
| 999 |
|
| 1000 |
std::shared_ptr<Jim> savgolay(app::AppFactory& app); |
| 1001 |
|
| 1002 |
void savgolay(Jim& imgWriter, app::AppFactory& app); |
| 1003 |
|
| 1004 |
template<typename T> void firfilter1d_t(Jim& imgWriter, app::AppFactory& app); |
| 1005 |
|
| 1006 |
void d_dwt1d(app::AppFactory& app); |
| 1007 |
std::shared_ptr<Jim> dwt1d(app::AppFactory& app); |
| 1008 |
|
| 1009 |
void d_dwti1d(app::AppFactory& app); |
| 1010 |
std::shared_ptr<Jim> dwti1d(app::AppFactory& app); |
| 1011 |
|
| 1012 |
void smoothNoData1d(Jim& imgWriter, app::AppFactory& app); |
| 1013 |
template<typename T> void smoothNoData1d_t(Jim& imgWriter, app::AppFactory& app); |
| 1014 |
std::shared_ptr<Jim> smoothNoData1d(app::AppFactory& app); |
| 1015 |
|
| 1016 |
void stats1d(Jim& imgWriter, app::AppFactory& app); |
| 1017 |
template<typename T> void stats1d_t(Jim& imgWriter, app::AppFactory& app); |
| 1018 |
std::shared_ptr<Jim> stats1d(app::AppFactory& app); |
| 1019 |
|
| 1020 |
std::shared_ptr<Jim> firfilter2d(app::AppFactory& app); |
| 1021 |
|
| 1022 |
void firfilter2d(Jim& imgWriter, app::AppFactory& app); |
| 1023 |
template<typename T> void firfilter2d_t(Jim& imgWriter, app::AppFactory& app); |
| 1024 |
|
| 1025 |
void d_dwt2d(app::AppFactory& app); |
| 1026 |
std::shared_ptr<Jim> dwt2d(app::AppFactory& app); |
| 1027 |
|
| 1028 |
void d_dwti2d(app::AppFactory& app); |
| 1029 |
std::shared_ptr<Jim> dwti2d(app::AppFactory& app); |
| 1030 |
|
| 1031 |
CPLErr diff(Jim& imgReference, app::AppFactory& app); |
| 1032 |
|
| 1033 |
CPLErr validate(app::AppFactory& app); |
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
void classify(Jim& imgWriter, app::AppFactory& app); |
| 1039 |
|
| 1040 |
std::shared_ptr<Jim> classify(app::AppFactory& app); |
| 1041 |
|
| 1042 |
void classifySVM(Jim& imgWriter, app::AppFactory& app); |
| 1043 |
|
| 1044 |
std::shared_ptr<Jim> classifySVM(app::AppFactory& app); |
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
void classifyANN(Jim& imgWriter, app::AppFactory& app); |
| 1051 |
|
| 1052 |
std::shared_ptr<Jim> classifyANN(app::AppFactory& app); |
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
void classifySML(Jim& imgWriter, JimList& referenceReader, app::AppFactory& app); |
| 1059 |
void classifySML(Jim& imgWriter, app::AppFactory& app); |
| 1060 |
template<typename T> void classifySML_t(Jim& imgWriter, JimList& referenceReader, app::AppFactory& app); |
| 1061 |
std::shared_ptr<Jim> classifySML(JimList& referenceReader, app::AppFactory& app); |
| 1062 |
std::shared_ptr<Jim> classifySML(app::AppFactory& app); |
| 1063 |
|
| 1064 |
void trainSML(JimList& referenceReader, app::AppFactory& app); |
| 1065 |
void trainSML2d(JimList& referenceReader, app::AppFactory& app); |
| 1066 |
template<typename T> void trainSML_t(JimList& referenceReader, app::AppFactory& app); |
| 1067 |
template<typename T> std::string trainSML2d_t(JimList& referenceReader, app::AppFactory& app); |
| 1068 |
|
| 1069 |
std::string trainMem(JimList& referenceReader, app::AppFactory& app); |
| 1070 |
|
| 1071 |
template<typename T> void classifySML_t(Jim& imgWriter, app::AppFactory& app); |
| 1072 |
|
| 1073 |
template<typename T> std::shared_ptr<Jim> classifySML_t(app::AppFactory& app); |
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
void stretch(Jim& imgWriter, app::AppFactory& app); |
| 1078 |
|
| 1079 |
std::shared_ptr<Jim> stretch(app::AppFactory& app); |
| 1080 |
|
| 1081 |
void reclass(Jim& imgWriter, app::AppFactory& app); |
| 1082 |
|
| 1083 |
std::shared_ptr<Jim> reclass(app::AppFactory& app); |
| 1084 |
|
| 1085 |
void d_reclass(app::AppFactory& app); |
| 1086 |
|
| 1087 |
|
| 1088 |
void setMask(VectorOgr& ogrReader, Jim& imgWriter, app::AppFactory& app); |
| 1089 |
void d_setMask(VectorOgr& ogrReader, app::AppFactory& app); |
| 1090 |
|
| 1091 |
|
| 1092 |
void setMask(JimList& maskReader, Jim& imgWriter, app::AppFactory& app); |
| 1093 |
|
| 1094 |
|
| 1095 |
std::shared_ptr<Jim> setMask(VectorOgr& ogrReader, app::AppFactory& app); |
| 1096 |
|
| 1097 |
std::shared_ptr<Jim> setMask(JimList& maskReader, app::AppFactory& app); |
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
void d_setMask2D(Jim& mask, double value); |
| 1102 |
void d_setMask(Jim& mask, double value); |
| 1103 |
template<typename T> void d_setMask_t(Jim& mask, double value); |
| 1104 |
void d_setMask2D(Jim& mask, Jim& other); |
| 1105 |
void d_setMask(Jim& mask, Jim& other); |
| 1106 |
template<typename T1, typename T2> void d_setMask_t(Jim& mask, Jim& other); |
| 1107 |
|
| 1108 |
void getMask(Jim& imgWriter, app::AppFactory& app); |
| 1109 |
|
| 1110 |
std::shared_ptr<Jim> getMask(app::AppFactory& app); |
| 1111 |
|
| 1112 |
CPLErr dumpImg(app::AppFactory& app); |
| 1113 |
|
| 1114 |
std::multimap<std::string,std::string> getStats(app::AppFactory& app); |
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
void d_band2plane(); |
| 1120 |
|
| 1121 |
CPLErr readDataPlanes(std::vector<int> bands); |
| 1122 |
|
| 1123 |
CPLErr writeDataPlanes(); |
| 1124 |
|
| 1125 |
|
| 1126 |
#if MIALLIB == 1 |
| 1127 |
|
| 1128 |
IMAGE* getMIA(int band=0); |
| 1129 |
|
| 1130 |
CPLErr setMIA(int band=0); |
| 1131 |
|
| 1132 |
CPLErr setMIA(IMAGE* mia, int band=0); |
| 1133 |
|
| 1134 |
int getMIADataType(); |
| 1135 |
|
| 1136 |
int JIPLIB2MIADataType(int aJIPLIBDataType); |
| 1137 |
|
| 1138 |
int GDAL2MIADataType(GDALDataType aGDALDataType); |
| 1139 |
|
| 1140 |
int MIA2JIPLIBDataType(int aMIADataType); |
| 1141 |
#endif |
| 1142 |
|
| 1143 |
|
| 1144 |
template<typename T> void d_jlframebox_t(std::vector<int> box, T val, std::size_t band); |
| 1145 |
void d_jlframebox(std::vector<int> box, double val, std::size_t band); |
| 1146 |
template<typename T> void d_jldistanceGeodesic_t(Jim& reference, std::size_t graph, std::size_t band); |
| 1147 |
void d_jldistanceGeodesic(Jim& reference, std::size_t, std::size_t band); |
| 1148 |
std::shared_ptr<Jim> jldistanceGeodesic(Jim& reference, std::size_t graph, std::size_t band); |
| 1149 |
void testFunction(){std::cout << "Hello testFunction" << std::endl;}; |
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
protected: |
| 1168 |
|
| 1169 |
void reset(); |
| 1170 |
|
| 1171 |
|
| 1172 |
CPLErr initMem(unsigned int memory); |
| 1173 |
|
| 1174 |
std::string m_filename; |
| 1175 |
|
| 1176 |
GDALDataset *m_gds; |
| 1177 |
|
| 1178 |
int m_ncol; |
| 1179 |
|
| 1180 |
int m_nrow; |
| 1181 |
|
| 1182 |
int m_nband; |
| 1183 |
|
| 1184 |
int m_nplane; |
| 1185 |
|
| 1186 |
int m_dataType; |
| 1187 |
|
| 1188 |
|
| 1189 |
std::string m_imageType; |
| 1190 |
|
| 1191 |
std::vector<double> m_gt; |
| 1192 |
|
| 1193 |
std::string m_projection; |
| 1194 |
|
| 1195 |
std::vector<double> m_noDataValues; |
| 1196 |
|
| 1197 |
std::vector<double> m_scale; |
| 1198 |
|
| 1199 |
std::vector<double> m_offset; |
| 1200 |
|
| 1201 |
bool m_externalData; |
| 1202 |
|
| 1203 |
|
| 1204 |
unsigned int m_blockSize; |
| 1205 |
|
| 1206 |
std::vector<void*> m_data; |
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
std::vector<int> m_begin; |
| 1211 |
|
| 1212 |
std::vector<int> m_end; |
| 1213 |
|
| 1214 |
|
| 1215 |
CPLErr registerDriver(); |
| 1216 |
|
| 1217 |
std::vector<std::string> m_coptions; |
| 1218 |
|
| 1219 |
std::vector<std::string> m_ooptions; |
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
DATA_ACCESS m_access; |
| 1224 |
|
| 1225 |
GDALRIOResampleAlg m_resample; |
| 1226 |
|
| 1227 |
|
| 1228 |
CPLErr readNewBlockDS(int row, int band, int ds_band); |
| 1229 |
|
| 1230 |
CPLErr readNewBlock(int row, int band){return readNewBlockDS(row,band,band);}; |
| 1231 |
|
| 1232 |
CPLErr writeNewBlock(int row, int band); |
| 1233 |
|
| 1234 |
private: |
| 1235 |
std::shared_ptr<Jim> cloneImpl(bool copyData) { |
| 1236 |
return(std::make_shared<Jim>(*this,copyData)); |
| 1237 |
}; |
| 1238 |
#if MIALLIB == 1 |
| 1239 |
std::vector<IMAGE*> m_mia; |
| 1240 |
#endif |
| 1241 |
}; |
| 1242 |
|
| 1243 |
template<typename T> CPLErr Jim::readData(T& value, int col, int row, int band) |
| 1244 |
{ |
| 1245 |
CPLErr returnValue=CE_None; |
| 1246 |
try{ |
| 1247 |
if(nrOfBand()<=band){ |
| 1248 |
std::string errorString="Error: band number exceeds number of bands in input image"; |
| 1249 |
throw(errorString); |
| 1250 |
} |
| 1251 |
if(nrOfCol()<=col){ |
| 1252 |
std::string errorString="Error: col number exceeds number of cols in input image"; |
| 1253 |
throw(errorString); |
| 1254 |
} |
| 1255 |
if(nrOfRow()<=row){ |
| 1256 |
std::string errorString="Error: row number exceeds number of rows in input image"; |
| 1257 |
throw(errorString); |
| 1258 |
} |
| 1259 |
double dvalue=0; |
| 1260 |
double theScale=1; |
| 1261 |
double theOffset=0; |
| 1262 |
if(m_scale.size()>band||m_offset.size()>band){ |
| 1263 |
if(m_scale.size()>band) |
| 1264 |
theScale=m_scale[band]; |
| 1265 |
if(m_offset.size()>band) |
| 1266 |
theOffset=m_offset[band]; |
| 1267 |
} |
| 1268 |
if(m_data.size()){ |
| 1269 |
|
| 1270 |
if(m_blockSize!=nrOfRow()){ |
| 1271 |
std::ostringstream s; |
| 1272 |
s << "Error: increase memory to support random access reading (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 1273 |
throw(s.str()); |
| 1274 |
} |
| 1275 |
if(row<m_begin[band]||row>=m_end[band]){ |
| 1276 |
if(m_filename.size()) |
| 1277 |
returnValue = readNewBlock(row,band); |
| 1278 |
} |
| 1279 |
int index=(row-m_begin[band])*nrOfCol()+col; |
| 1280 |
switch(getDataType()){ |
| 1281 |
case(GDT_Byte): |
| 1282 |
dvalue=theScale*(static_cast<unsigned char*>(m_data[band])[index])+theOffset; |
| 1283 |
break; |
| 1284 |
case(GDT_Int16): |
| 1285 |
dvalue=theScale*(static_cast<short*>(m_data[band])[index])+theOffset; |
| 1286 |
break; |
| 1287 |
case(GDT_UInt16): |
| 1288 |
dvalue=theScale*(static_cast<unsigned short*>(m_data[band])[index])+theOffset; |
| 1289 |
break; |
| 1290 |
case(GDT_Int32): |
| 1291 |
dvalue=theScale*(static_cast<int*>(m_data[band])[index])+theOffset; |
| 1292 |
break; |
| 1293 |
case(GDT_UInt32): |
| 1294 |
dvalue=theScale*(static_cast<unsigned int*>(m_data[band])[index])+theOffset; |
| 1295 |
break; |
| 1296 |
case(GDT_Float32): |
| 1297 |
dvalue=theScale*(static_cast<float*>(m_data[band])[index])+theOffset; |
| 1298 |
break; |
| 1299 |
case(GDT_Float64): |
| 1300 |
dvalue=theScale*(static_cast<double*>(m_data[band])[index])+theOffset; |
| 1301 |
break; |
| 1302 |
default: |
| 1303 |
std::string errorString="Error: data type not supported"; |
| 1304 |
throw(errorString); |
| 1305 |
break; |
| 1306 |
} |
| 1307 |
value=static_cast<T>(dvalue); |
| 1308 |
} |
| 1309 |
else{ |
| 1310 |
|
| 1311 |
GDALRasterBand *poBand; |
| 1312 |
poBand = m_gds->GetRasterBand(band+1); |
| 1313 |
returnValue = poBand->RasterIO(GF_Read,col,row,1,1,&value,1,1,type2GDAL<T>(),0,0); |
| 1314 |
dvalue=theScale*value+theOffset; |
| 1315 |
value=static_cast<T>(dvalue); |
| 1316 |
} |
| 1317 |
} |
| 1318 |
catch(std::string errorString){ |
| 1319 |
std::cerr << errorString << std::endl; |
| 1320 |
throw; |
| 1321 |
} |
| 1322 |
catch(...){ |
| 1323 |
throw; |
| 1324 |
} |
| 1325 |
return(returnValue); |
| 1326 |
} |
| 1327 |
|
| 1328 |
template<typename T> CPLErr Jim::readData3D(T& value, std::size_t col, std::size_t row, std::size_t plane, std::size_t band) |
| 1329 |
{ |
| 1330 |
try{ |
| 1331 |
if(nrOfBand()<=band){ |
| 1332 |
std::string errorString="Error: band number exceeds number of bands in input image"; |
| 1333 |
throw(errorString); |
| 1334 |
} |
| 1335 |
if(nrOfCol()<=col){ |
| 1336 |
std::string errorString="Error: col number exceeds number of cols in input image"; |
| 1337 |
throw(errorString); |
| 1338 |
} |
| 1339 |
if(nrOfRow()<=row){ |
| 1340 |
std::string errorString="Error: row number exceeds number of rows in input image"; |
| 1341 |
throw(errorString); |
| 1342 |
} |
| 1343 |
if(nrOfPlane()<=plane){ |
| 1344 |
std::string errorString="Error: plane number exceeds number of planes in input image"; |
| 1345 |
throw(errorString); |
| 1346 |
} |
| 1347 |
double dvalue=0; |
| 1348 |
double theScale=1; |
| 1349 |
double theOffset=0; |
| 1350 |
if(m_scale.size()>band||m_offset.size()>band){ |
| 1351 |
if(m_scale.size()>band) |
| 1352 |
theScale=m_scale[band]; |
| 1353 |
if(m_offset.size()>band) |
| 1354 |
theOffset=m_offset[band]; |
| 1355 |
} |
| 1356 |
if(m_data.size()){ |
| 1357 |
|
| 1358 |
if(m_blockSize!=nrOfRow()){ |
| 1359 |
std::ostringstream s; |
| 1360 |
s << "Error: increase memory to support random access reading (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 1361 |
throw(s.str()); |
| 1362 |
} |
| 1363 |
if(row<m_begin[band]||row>=m_end[band]){ |
| 1364 |
if(m_filename.size()) |
| 1365 |
readNewBlock(row,band); |
| 1366 |
} |
| 1367 |
int index=(plane*nrOfRow()*nrOfCol())+(row-m_begin[band])*nrOfCol()+col; |
| 1368 |
switch(getDataType()){ |
| 1369 |
case(GDT_Byte): |
| 1370 |
dvalue=theScale*(static_cast<unsigned char*>(m_data[band])[index])+theOffset; |
| 1371 |
break; |
| 1372 |
case(GDT_Int16): |
| 1373 |
dvalue=theScale*(static_cast<short*>(m_data[band])[index])+theOffset; |
| 1374 |
break; |
| 1375 |
case(GDT_UInt16): |
| 1376 |
dvalue=theScale*(static_cast<unsigned short*>(m_data[band])[index])+theOffset; |
| 1377 |
break; |
| 1378 |
case(GDT_Int32): |
| 1379 |
dvalue=theScale*(static_cast<int*>(m_data[band])[index])+theOffset; |
| 1380 |
break; |
| 1381 |
case(GDT_UInt32): |
| 1382 |
dvalue=theScale*(static_cast<unsigned int*>(m_data[band])[index])+theOffset; |
| 1383 |
break; |
| 1384 |
case(GDT_Float32): |
| 1385 |
dvalue=theScale*(static_cast<float*>(m_data[band])[index])+theOffset; |
| 1386 |
break; |
| 1387 |
case(GDT_Float64): |
| 1388 |
dvalue=theScale*(static_cast<double*>(m_data[band])[index])+theOffset; |
| 1389 |
break; |
| 1390 |
default: |
| 1391 |
std::string errorString="Error: data type not supported"; |
| 1392 |
throw(errorString); |
| 1393 |
break; |
| 1394 |
} |
| 1395 |
value=static_cast<T>(dvalue); |
| 1396 |
} |
| 1397 |
else{ |
| 1398 |
std::ostringstream s; |
| 1399 |
s << "Error: read 3D image only supported for in memory images"; |
| 1400 |
throw(s.str()); |
| 1401 |
} |
| 1402 |
} |
| 1403 |
catch(std::string errorString){ |
| 1404 |
std::cerr << errorString << std::endl; |
| 1405 |
throw; |
| 1406 |
} |
| 1407 |
catch(...){ |
| 1408 |
throw; |
| 1409 |
} |
| 1410 |
return(CE_None); |
| 1411 |
} |
| 1412 |
|
| 1413 |
template<typename T> CPLErr Jim::readData3D(std::vector<T>& buffer, std::size_t minCol, std::size_t maxCol, std::size_t row, std::size_t plane, std::size_t band) |
| 1414 |
{ |
| 1415 |
try{ |
| 1416 |
if(nrOfBand()<=band){ |
| 1417 |
std::string errorString="Error: band number exceeds number of bands in input image"; |
| 1418 |
throw(errorString); |
| 1419 |
} |
| 1420 |
if(nrOfRow()<=row){ |
| 1421 |
std::string errorString="Error: row number exceeds number of rows in input image"; |
| 1422 |
throw(errorString); |
| 1423 |
} |
| 1424 |
if(nrOfPlane()<=plane){ |
| 1425 |
std::string errorString="Error: plane number exceeds number of planes in input image"; |
| 1426 |
throw(errorString); |
| 1427 |
} |
| 1428 |
double theScale=1; |
| 1429 |
double theOffset=0; |
| 1430 |
if(m_scale.size()>band||m_offset.size()>band){ |
| 1431 |
if(m_scale.size()>band) |
| 1432 |
theScale=m_scale[band]; |
| 1433 |
if(m_offset.size()>band) |
| 1434 |
theOffset=m_offset[band]; |
| 1435 |
} |
| 1436 |
if(m_data.size()){ |
| 1437 |
if(row<m_begin[band]||row>=m_end[band]){ |
| 1438 |
if(m_filename.size()) |
| 1439 |
readNewBlock(row,band); |
| 1440 |
} |
| 1441 |
if(buffer.size()!=maxCol-minCol+1) |
| 1442 |
buffer.resize(maxCol-minCol+1); |
| 1443 |
int index=plane*nrOfRow()*nrOfCol()+(row-m_begin[band])*nrOfCol(); |
| 1444 |
int minindex=(index+minCol); |
| 1445 |
int maxindex=(index+maxCol); |
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
typename std::vector<T>::iterator bufit=buffer.begin(); |
| 1456 |
for(index=minindex;index<=maxindex;++index,++bufit){ |
| 1457 |
double dvalue=0; |
| 1458 |
switch(getDataType()){ |
| 1459 |
case(GDT_Byte): |
| 1460 |
dvalue=theScale*(static_cast<unsigned char*>(m_data[band])[index])+theOffset; |
| 1461 |
break; |
| 1462 |
case(GDT_Int16): |
| 1463 |
dvalue=theScale*(static_cast<short*>(m_data[band])[index])+theOffset; |
| 1464 |
break; |
| 1465 |
case(GDT_UInt16): |
| 1466 |
dvalue=theScale*(static_cast<unsigned short*>(m_data[band])[index])+theOffset; |
| 1467 |
break; |
| 1468 |
case(GDT_Int32): |
| 1469 |
dvalue=theScale*(static_cast<int*>(m_data[band])[index])+theOffset; |
| 1470 |
break; |
| 1471 |
case(GDT_UInt32): |
| 1472 |
dvalue=theScale*(static_cast<unsigned int*>(m_data[band])[index])+theOffset; |
| 1473 |
break; |
| 1474 |
case(GDT_Float32): |
| 1475 |
dvalue=theScale*(static_cast<float*>(m_data[band])[index])+theOffset; |
| 1476 |
break; |
| 1477 |
case(GDT_Float64): |
| 1478 |
dvalue=theScale*(static_cast<double*>(m_data[band])[index])+theOffset; |
| 1479 |
break; |
| 1480 |
default: |
| 1481 |
std::string errorString="Error: data type not supported"; |
| 1482 |
throw(errorString); |
| 1483 |
break; |
| 1484 |
} |
| 1485 |
|
| 1486 |
*(bufit)=static_cast<T>(dvalue); |
| 1487 |
} |
| 1488 |
} |
| 1489 |
else{ |
| 1490 |
std::ostringstream s; |
| 1491 |
s << "Error: read 3D image only supported for in memory images"; |
| 1492 |
throw(s.str()); |
| 1493 |
} |
| 1494 |
} |
| 1495 |
catch(std::string errorString){ |
| 1496 |
std::cerr << errorString << std::endl; |
| 1497 |
throw; |
| 1498 |
} |
| 1499 |
catch(...){ |
| 1500 |
throw; |
| 1501 |
} |
| 1502 |
return(CE_None); |
| 1503 |
} |
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
template<typename T> CPLErr Jim::readData(std::vector<T>& buffer, int minCol, int maxCol, int row, int band) |
| 1513 |
{ |
| 1514 |
CPLErr returnValue=CE_None; |
| 1515 |
try{ |
| 1516 |
if(nrOfBand()<=band){ |
| 1517 |
std::string errorString="Error: band number exceeds number of bands in input image"; |
| 1518 |
throw(errorString); |
| 1519 |
} |
| 1520 |
if(maxCol<minCol){ |
| 1521 |
std::string errorString="Error: maxCol must be larger or equal to minCol"; |
| 1522 |
throw(errorString); |
| 1523 |
} |
| 1524 |
if(minCol<0){ |
| 1525 |
std::string errorString="Error: col number must be positive"; |
| 1526 |
throw(errorString); |
| 1527 |
} |
| 1528 |
if(maxCol<0){ |
| 1529 |
std::string errorString="Error: col number must be positive"; |
| 1530 |
throw(errorString); |
| 1531 |
} |
| 1532 |
if(row<0){ |
| 1533 |
std::string errorString="Error: row number must be positive"; |
| 1534 |
throw(errorString); |
| 1535 |
} |
| 1536 |
if(nrOfCol()<=minCol){ |
| 1537 |
std::string errorString="Error: col number exceeds number of cols in input image"; |
| 1538 |
throw(errorString); |
| 1539 |
} |
| 1540 |
if(nrOfCol()<=maxCol){ |
| 1541 |
std::string errorString="Error: col number exceeds number of cols in input image"; |
| 1542 |
throw(errorString); |
| 1543 |
} |
| 1544 |
if(nrOfRow()<=row){ |
| 1545 |
std::string errorString="Error: row number exceeds number of rows in input image"; |
| 1546 |
throw(errorString); |
| 1547 |
} |
| 1548 |
double theScale=1; |
| 1549 |
double theOffset=0; |
| 1550 |
if(m_scale.size()>band||m_offset.size()>band){ |
| 1551 |
if(m_scale.size()>band) |
| 1552 |
theScale=m_scale[band]; |
| 1553 |
if(m_offset.size()>band) |
| 1554 |
theOffset=m_offset[band]; |
| 1555 |
} |
| 1556 |
if(m_data.size()){ |
| 1557 |
if(row<m_begin[band]||row>=m_end[band]){ |
| 1558 |
if(m_filename.size()) |
| 1559 |
returnValue=readNewBlock(row,band); |
| 1560 |
} |
| 1561 |
if(buffer.size()!=maxCol-minCol+1) |
| 1562 |
buffer.resize(maxCol-minCol+1); |
| 1563 |
int index=(row-m_begin[band])*nrOfCol(); |
| 1564 |
int minindex=(index+minCol); |
| 1565 |
int maxindex=(index+maxCol); |
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
typename std::vector<T>::iterator bufit=buffer.begin(); |
| 1576 |
for(index=minindex;index<=maxindex;++index,++bufit){ |
| 1577 |
double dvalue=0; |
| 1578 |
switch(getDataType()){ |
| 1579 |
case(GDT_Byte): |
| 1580 |
dvalue=theScale*(static_cast<unsigned char*>(m_data[band])[index])+theOffset; |
| 1581 |
break; |
| 1582 |
case(GDT_Int16): |
| 1583 |
dvalue=theScale*(static_cast<short*>(m_data[band])[index])+theOffset; |
| 1584 |
break; |
| 1585 |
case(GDT_UInt16): |
| 1586 |
dvalue=theScale*(static_cast<unsigned short*>(m_data[band])[index])+theOffset; |
| 1587 |
break; |
| 1588 |
case(GDT_Int32): |
| 1589 |
dvalue=theScale*(static_cast<int*>(m_data[band])[index])+theOffset; |
| 1590 |
break; |
| 1591 |
case(GDT_UInt32): |
| 1592 |
dvalue=theScale*(static_cast<unsigned int*>(m_data[band])[index])+theOffset; |
| 1593 |
break; |
| 1594 |
case(GDT_Float32): |
| 1595 |
dvalue=theScale*(static_cast<float*>(m_data[band])[index])+theOffset; |
| 1596 |
break; |
| 1597 |
case(GDT_Float64): |
| 1598 |
dvalue=theScale*(static_cast<double*>(m_data[band])[index])+theOffset; |
| 1599 |
break; |
| 1600 |
default: |
| 1601 |
std::string errorString="Error: data type not supported"; |
| 1602 |
throw(errorString); |
| 1603 |
break; |
| 1604 |
} |
| 1605 |
|
| 1606 |
*(bufit)=static_cast<T>(dvalue); |
| 1607 |
} |
| 1608 |
} |
| 1609 |
else{ |
| 1610 |
|
| 1611 |
GDALRasterBand *poBand; |
| 1612 |
poBand = m_gds->GetRasterBand(band+1); |
| 1613 |
if(buffer.size()!=maxCol-minCol+1) |
| 1614 |
buffer.resize(maxCol-minCol+1); |
| 1615 |
returnValue=poBand->RasterIO(GF_Read,minCol,row,buffer.size(),1,&(buffer[0]),buffer.size(),1,type2GDAL<T>(),0,0); |
| 1616 |
if(m_scale.size()>band||m_offset.size()>band){ |
| 1617 |
for(int index=0;index<buffer.size();++index) |
| 1618 |
buffer[index]=theScale*static_cast<double>(buffer[index])+theOffset; |
| 1619 |
} |
| 1620 |
} |
| 1621 |
return(returnValue); |
| 1622 |
} |
| 1623 |
catch(std::string errorString){ |
| 1624 |
std::cerr << errorString << std::endl; |
| 1625 |
throw; |
| 1626 |
} |
| 1627 |
catch(...){ |
| 1628 |
throw; |
| 1629 |
} |
| 1630 |
} |
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
template<typename T> CPLErr Jim::readData(std::vector<T>& buffer, int minCol, int maxCol, double row, int band, RESAMPLE resample) |
| 1641 |
{ |
| 1642 |
CPLErr returnValue=CE_None; |
| 1643 |
std::vector<T> readBuffer_upper; |
| 1644 |
std::vector<T> readBuffer_lower; |
| 1645 |
if(buffer.size()!=maxCol-minCol+1) |
| 1646 |
buffer.resize(maxCol-minCol+1); |
| 1647 |
double upperRow=row-0.5; |
| 1648 |
upperRow=static_cast<int>(upperRow+FLT_EPSILON); |
| 1649 |
double lowerRow=row+0.5; |
| 1650 |
lowerRow=static_cast<int>(lowerRow+FLT_EPSILON); |
| 1651 |
switch(resample){ |
| 1652 |
case(BILINEAR): |
| 1653 |
if(lowerRow>=nrOfRow()) |
| 1654 |
lowerRow=nrOfRow()-1; |
| 1655 |
if(upperRow<0) |
| 1656 |
upperRow=0; |
| 1657 |
returnValue=readData(readBuffer_upper,minCol,maxCol,static_cast<int>(upperRow),band); |
| 1658 |
returnValue=readData(readBuffer_lower,minCol,maxCol,static_cast<int>(lowerRow),band); |
| 1659 |
|
| 1660 |
for(int icol=0;icol<maxCol-minCol+1;++icol){ |
| 1661 |
|
| 1662 |
double upperVal = readBuffer_upper[icol]; |
| 1663 |
double lowerVal = readBuffer_lower[icol]; |
| 1664 |
if (!isNoData(upperVal)) { |
| 1665 |
if (!isNoData(lowerVal)) |
| 1666 |
buffer[icol]=(lowerRow-row+0.5)*upperVal+(1-lowerRow+row-0.5)*lowerVal; |
| 1667 |
else |
| 1668 |
buffer[icol] = upperVal; |
| 1669 |
} |
| 1670 |
else |
| 1671 |
buffer[icol] = lowerVal; |
| 1672 |
} |
| 1673 |
break; |
| 1674 |
default: |
| 1675 |
|
| 1676 |
returnValue=readData(buffer,minCol,maxCol,static_cast<int>(row+FLT_EPSILON),band); |
| 1677 |
break; |
| 1678 |
} |
| 1679 |
return(returnValue); |
| 1680 |
} |
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
template<typename T> CPLErr Jim::readDataBlock(Vector2d<T>& buffer2d, int minCol, int maxCol, int minRow, int maxRow, int band) |
| 1691 |
{ |
| 1692 |
CPLErr returnValue=CE_None; |
| 1693 |
buffer2d.resize(maxRow-minRow+1,maxCol-minCol+1); |
| 1694 |
typename std::vector<T> buffer; |
| 1695 |
returnValue=readDataBlock(buffer,minCol,maxCol,minRow,maxRow,band); |
| 1696 |
typename std::vector<T>::const_iterator startit=buffer.begin(); |
| 1697 |
typename std::vector<T>::const_iterator endit=startit; |
| 1698 |
for(int irow=minRow;irow<=maxRow;++irow){ |
| 1699 |
|
| 1700 |
endit+=maxCol-minCol+1; |
| 1701 |
buffer2d[irow-minRow].assign(startit,endit); |
| 1702 |
startit+=maxCol-minCol+1; |
| 1703 |
} |
| 1704 |
return(returnValue); |
| 1705 |
} |
| 1706 |
|
| 1707 |
template<typename T> CPLErr Jim::readDataBlock3D(Vector2d<T>& buffer2d, std::size_t minCol, std::size_t maxCol, std::size_t minRow, std::size_t maxRow, std::size_t plane, std::size_t band){ |
| 1708 |
CPLErr returnValue=CE_None; |
| 1709 |
buffer2d.resize(maxRow-minRow+1,maxCol-minCol+1); |
| 1710 |
typename std::vector<T> buffer; |
| 1711 |
returnValue = readDataBlock3D(buffer,minCol,maxCol,minRow,maxRow,plane,band); |
| 1712 |
typename std::vector<T>::const_iterator startit=buffer.begin(); |
| 1713 |
typename std::vector<T>::const_iterator endit=startit; |
| 1714 |
for(int irow=minRow;irow<=maxRow;++irow){ |
| 1715 |
|
| 1716 |
endit+=maxCol-minCol+1; |
| 1717 |
buffer2d[irow-minRow].assign(startit,endit); |
| 1718 |
startit+=maxCol-minCol+1; |
| 1719 |
} |
| 1720 |
return(returnValue); |
| 1721 |
} |
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
template<typename T> CPLErr Jim::readDataBlock(std::vector<T>& buffer, int minCol, int maxCol, int minRow, int maxRow, int band) |
| 1732 |
{ |
| 1733 |
try{ |
| 1734 |
CPLErr returnValue=CE_None; |
| 1735 |
double theScale=1; |
| 1736 |
double theOffset=0; |
| 1737 |
if(m_scale.size()>band) |
| 1738 |
theScale=m_scale[band]; |
| 1739 |
if(m_offset.size()>band) |
| 1740 |
theOffset=m_offset[band]; |
| 1741 |
if(minCol>=nrOfCol() || |
| 1742 |
(minCol<0) || |
| 1743 |
(maxCol>=nrOfCol()) || |
| 1744 |
(minCol>maxCol) || |
| 1745 |
(minRow>=nrOfRow()) || |
| 1746 |
(minRow<0) || |
| 1747 |
(maxRow>=nrOfRow()) || |
| 1748 |
(minRow>maxRow)){ |
| 1749 |
std::string errorString="block not within image boundaries"; |
| 1750 |
throw(errorString); |
| 1751 |
} |
| 1752 |
if(buffer.size()!=(maxRow-minRow+1)*(maxCol-minCol+1)) |
| 1753 |
buffer.resize((maxRow-minRow+1)*(maxCol-minCol+1)); |
| 1754 |
if(m_data.size()){ |
| 1755 |
typename std::vector<T>::iterator bufit=buffer.begin(); |
| 1756 |
for(int irow=minRow;irow<=maxRow;++irow){ |
| 1757 |
if(irow<m_begin[band]||irow>=m_end[band]){ |
| 1758 |
if(m_filename.size()) |
| 1759 |
returnValue=readNewBlock(irow,band); |
| 1760 |
} |
| 1761 |
int index=(irow-m_begin[band])*nrOfCol(); |
| 1762 |
int minindex=(index+minCol); |
| 1763 |
int maxindex=(index+maxCol); |
| 1764 |
|
| 1765 |
for(index=minindex;index<=maxindex;++index,++bufit){ |
| 1766 |
double dvalue=0; |
| 1767 |
switch(getDataType()){ |
| 1768 |
case(GDT_Byte): |
| 1769 |
dvalue=theScale*(static_cast<unsigned char*>(m_data[band])[index])+theOffset; |
| 1770 |
break; |
| 1771 |
case(GDT_Int16): |
| 1772 |
dvalue=theScale*(static_cast<short*>(m_data[band])[index])+theOffset; |
| 1773 |
break; |
| 1774 |
case(GDT_UInt16): |
| 1775 |
dvalue=theScale*(static_cast<unsigned short*>(m_data[band])[index])+theOffset; |
| 1776 |
break; |
| 1777 |
case(GDT_Int32): |
| 1778 |
dvalue=theScale*(static_cast<int*>(m_data[band])[index])+theOffset; |
| 1779 |
break; |
| 1780 |
case(GDT_UInt32): |
| 1781 |
dvalue=theScale*(static_cast<unsigned int*>(m_data[band])[index])+theOffset; |
| 1782 |
break; |
| 1783 |
case(GDT_Float32): |
| 1784 |
dvalue=theScale*(static_cast<float*>(m_data[band])[index])+theOffset; |
| 1785 |
break; |
| 1786 |
case(GDT_Float64): |
| 1787 |
dvalue=theScale*(static_cast<double*>(m_data[band])[index])+theOffset; |
| 1788 |
break; |
| 1789 |
default: |
| 1790 |
std::string errorString="Error: data type not supported"; |
| 1791 |
throw(errorString); |
| 1792 |
break; |
| 1793 |
} |
| 1794 |
*(bufit)=static_cast<T>(dvalue); |
| 1795 |
} |
| 1796 |
} |
| 1797 |
} |
| 1798 |
else{ |
| 1799 |
|
| 1800 |
GDALRasterBand *poBand; |
| 1801 |
if(nrOfBand()<=band){ |
| 1802 |
std::string errorString="Error: band number exceeds number of bands in input image"; |
| 1803 |
throw(errorString); |
| 1804 |
} |
| 1805 |
poBand = m_gds->GetRasterBand(band+1); |
| 1806 |
returnValue=poBand->RasterIO(GF_Read,minCol,minRow,maxCol-minCol+1,maxRow-minRow+1,&(buffer[0]),(maxCol-minCol+1),(maxRow-minRow+1),type2GDAL<T>(),0,0); |
| 1807 |
if(m_scale.size()>band||m_offset.size()>band){ |
| 1808 |
for(int index=0;index<buffer.size();++index) |
| 1809 |
buffer[index]=theScale*buffer[index]+theOffset; |
| 1810 |
} |
| 1811 |
} |
| 1812 |
return(returnValue); |
| 1813 |
} |
| 1814 |
catch(std::string errorString){ |
| 1815 |
std::cerr << errorString << std::endl; |
| 1816 |
throw; |
| 1817 |
} |
| 1818 |
catch(...){ |
| 1819 |
throw; |
| 1820 |
} |
| 1821 |
} |
| 1822 |
|
| 1823 |
template<typename T> CPLErr Jim::readDataBlock3D(std::vector<T>& buffer, std::size_t minCol, std::size_t maxCol, std::size_t minRow, std::size_t maxRow, std::size_t plane, std::size_t band) |
| 1824 |
{ |
| 1825 |
CPLErr returnValue=CE_None; |
| 1826 |
try{ |
| 1827 |
double theScale=1; |
| 1828 |
double theOffset=0; |
| 1829 |
if(m_scale.size()>band) |
| 1830 |
theScale=m_scale[band]; |
| 1831 |
if(m_offset.size()>band) |
| 1832 |
theOffset=m_offset[band]; |
| 1833 |
if(minCol>=nrOfCol() || |
| 1834 |
(minCol<0) || |
| 1835 |
(maxCol>=nrOfCol()) || |
| 1836 |
(minCol>maxCol) || |
| 1837 |
(minRow>=nrOfRow()) || |
| 1838 |
(minRow<0) || |
| 1839 |
(maxRow>=nrOfRow()) || |
| 1840 |
(minRow>maxRow) || |
| 1841 |
(plane>=nrOfPlane()) || |
| 1842 |
(plane<0)){ |
| 1843 |
std::string errorString="block not within image boundaries"; |
| 1844 |
throw(errorString); |
| 1845 |
} |
| 1846 |
if(buffer.size()!=(maxRow-minRow+1)*(maxCol-minCol+1)) |
| 1847 |
buffer.resize((maxRow-minRow+1)*(maxCol-minCol+1)); |
| 1848 |
if(m_data.size()){ |
| 1849 |
typename std::vector<T>::iterator bufit=buffer.begin(); |
| 1850 |
for(int irow=minRow;irow<=maxRow;++irow){ |
| 1851 |
if(irow<m_begin[band]||irow>=m_end[band]){ |
| 1852 |
if(m_filename.size()) |
| 1853 |
readNewBlock(irow,band); |
| 1854 |
} |
| 1855 |
|
| 1856 |
std::size_t index=(plane*nrOfRow()*nrOfCol())+(irow-m_begin[band])*nrOfCol(); |
| 1857 |
std::size_t minindex=(index+minCol); |
| 1858 |
std::size_t maxindex=(index+maxCol); |
| 1859 |
|
| 1860 |
for(index=minindex;index<=maxindex;++index,++bufit){ |
| 1861 |
double dvalue=0; |
| 1862 |
switch(getDataType()){ |
| 1863 |
case(GDT_Byte): |
| 1864 |
dvalue=theScale*(static_cast<unsigned char*>(m_data[band])[index])+theOffset; |
| 1865 |
break; |
| 1866 |
case(GDT_Int16): |
| 1867 |
dvalue=theScale*(static_cast<short*>(m_data[band])[index])+theOffset; |
| 1868 |
break; |
| 1869 |
case(GDT_UInt16): |
| 1870 |
dvalue=theScale*(static_cast<unsigned short*>(m_data[band])[index])+theOffset; |
| 1871 |
break; |
| 1872 |
case(GDT_Int32): |
| 1873 |
dvalue=theScale*(static_cast<int*>(m_data[band])[index])+theOffset; |
| 1874 |
break; |
| 1875 |
case(GDT_UInt32): |
| 1876 |
dvalue=theScale*(static_cast<unsigned int*>(m_data[band])[index])+theOffset; |
| 1877 |
break; |
| 1878 |
case(GDT_Float32): |
| 1879 |
dvalue=theScale*(static_cast<float*>(m_data[band])[index])+theOffset; |
| 1880 |
break; |
| 1881 |
case(GDT_Float64): |
| 1882 |
dvalue=theScale*(static_cast<double*>(m_data[band])[index])+theOffset; |
| 1883 |
break; |
| 1884 |
default: |
| 1885 |
std::string errorString="Error: data type not supported"; |
| 1886 |
throw(errorString); |
| 1887 |
break; |
| 1888 |
} |
| 1889 |
*(bufit)=static_cast<T>(dvalue); |
| 1890 |
} |
| 1891 |
} |
| 1892 |
} |
| 1893 |
} |
| 1894 |
catch(std::string errorString){ |
| 1895 |
std::cerr << errorString << std::endl; |
| 1896 |
throw; |
| 1897 |
} |
| 1898 |
catch(...){ |
| 1899 |
throw; |
| 1900 |
} |
| 1901 |
return(returnValue); |
| 1902 |
} |
| 1903 |
|
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
template<typename T> CPLErr Jim::readData(std::vector<T>& buffer, int row, int band) |
| 1910 |
{ |
| 1911 |
return(readData(buffer,0,nrOfCol()-1,row,band)); |
| 1912 |
} |
| 1913 |
|
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
|
| 1918 |
|
| 1919 |
|
| 1920 |
template<typename T> CPLErr Jim::readData(std::vector<T>& buffer, double row, int band, RESAMPLE resample) |
| 1921 |
{ |
| 1922 |
return(readData(buffer,0,nrOfCol()-1,row,band,resample)); |
| 1923 |
} |
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
template<typename T> CPLErr Jim::writeData(const T& value, int col, int row, int band) |
| 1934 |
{ |
| 1935 |
CPLErr returnValue=CE_None; |
| 1936 |
if(band>=nrOfBand()+1){ |
| 1937 |
std::ostringstream s; |
| 1938 |
s << "Error: band (" << band << ") exceeds nrOfBand (" << nrOfBand() << ")"; |
| 1939 |
throw(s.str()); |
| 1940 |
} |
| 1941 |
if(col>=nrOfCol()){ |
| 1942 |
std::ostringstream s; |
| 1943 |
s << "Error: col (" << col << ") exceeds nrOfCol (" << nrOfCol() << ")"; |
| 1944 |
throw(s.str()); |
| 1945 |
} |
| 1946 |
if(col<0){ |
| 1947 |
std::ostringstream s; |
| 1948 |
s << "Error: col (" << col << ") is negative"; |
| 1949 |
throw(s.str()); |
| 1950 |
} |
| 1951 |
if(row>=nrOfRow()){ |
| 1952 |
std::ostringstream s; |
| 1953 |
s << "Error: row (" << row << ") exceeds nrOfRow (" << nrOfRow() << ")"; |
| 1954 |
throw(s.str()); |
| 1955 |
} |
| 1956 |
if(row<0){ |
| 1957 |
std::ostringstream s; |
| 1958 |
s << "Error: row (" << row << ") is negative"; |
| 1959 |
throw(s.str()); |
| 1960 |
} |
| 1961 |
double theScale=1; |
| 1962 |
double theOffset=0; |
| 1963 |
if(m_scale.size()>band||m_offset.size()>band){ |
| 1964 |
if(m_scale.size()>band) |
| 1965 |
theScale=m_scale[band]; |
| 1966 |
if(m_offset.size()>band) |
| 1967 |
theOffset=m_offset[band]; |
| 1968 |
} |
| 1969 |
if(m_data.size()){ |
| 1970 |
|
| 1971 |
if(m_blockSize!=nrOfRow()){ |
| 1972 |
std::ostringstream s; |
| 1973 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 1974 |
throw(s.str()); |
| 1975 |
} |
| 1976 |
int index=(row-m_begin[band])*nrOfCol()+col; |
| 1977 |
double dvalue=theScale*value+theOffset; |
| 1978 |
switch(getDataType()){ |
| 1979 |
case(GDT_Byte): |
| 1980 |
static_cast<unsigned char*>(m_data[band])[index]=static_cast<unsigned char>(dvalue); |
| 1981 |
break; |
| 1982 |
case(GDT_Int16): |
| 1983 |
static_cast<short*>(m_data[band])[index]=static_cast<short>(dvalue); |
| 1984 |
break; |
| 1985 |
case(GDT_UInt16): |
| 1986 |
static_cast<unsigned short*>(m_data[band])[index]=static_cast<unsigned short>(dvalue); |
| 1987 |
break; |
| 1988 |
case(GDT_Int32): |
| 1989 |
static_cast<int*>(m_data[band])[index]=static_cast<int>(dvalue); |
| 1990 |
break; |
| 1991 |
case(GDT_UInt32): |
| 1992 |
static_cast<unsigned int*>(m_data[band])[index]=static_cast<unsigned int>(dvalue); |
| 1993 |
break; |
| 1994 |
case(GDT_Float32): |
| 1995 |
static_cast<float*>(m_data[band])[index]=static_cast<float>(dvalue); |
| 1996 |
break; |
| 1997 |
case(GDT_Float64): |
| 1998 |
static_cast<double*>(m_data[band])[index]=static_cast<double>(dvalue); |
| 1999 |
break; |
| 2000 |
default: |
| 2001 |
std::string errorString="Error: data type not supported"; |
| 2002 |
throw(errorString); |
| 2003 |
break; |
| 2004 |
} |
| 2005 |
} |
| 2006 |
else{ |
| 2007 |
|
| 2008 |
GDALRasterBand *poBand; |
| 2009 |
T dvalue=theScale*value+theOffset; |
| 2010 |
returnValue=poBand->RasterIO(GF_Write,col,row,1,1,&dvalue,1,1,type2GDAL<T>(),0,0); |
| 2011 |
} |
| 2012 |
return(returnValue); |
| 2013 |
} |
| 2014 |
|
| 2015 |
template<typename T> CPLErr Jim::writeData(std::vector<T>& buffer, int minCol, int maxCol, int row, int band) |
| 2016 |
{ |
| 2017 |
CPLErr returnValue=CE_None; |
| 2018 |
if(buffer.size()!=maxCol-minCol+1){ |
| 2019 |
std::string errorstring="invalid size of buffer"; |
| 2020 |
throw(errorstring); |
| 2021 |
} |
| 2022 |
if(minCol>=nrOfCol()){ |
| 2023 |
std::ostringstream s; |
| 2024 |
s << "minCol (" << minCol << ") exceeds nrOfCol (" << nrOfCol() << ")"; |
| 2025 |
throw(s.str()); |
| 2026 |
} |
| 2027 |
if(minCol<0){ |
| 2028 |
std::ostringstream s; |
| 2029 |
s << "mincol (" << minCol << ") is negative"; |
| 2030 |
throw(s.str()); |
| 2031 |
} |
| 2032 |
if(maxCol>=nrOfCol()){ |
| 2033 |
std::ostringstream s; |
| 2034 |
s << "maxCol (" << maxCol << ") exceeds nrOfCol (" << nrOfCol() << ")"; |
| 2035 |
throw(s.str()); |
| 2036 |
} |
| 2037 |
if(maxCol<minCol){ |
| 2038 |
std::ostringstream s; |
| 2039 |
s << "maxCol (" << maxCol << ") is less than minCol (" << minCol << ")"; |
| 2040 |
throw(s.str()); |
| 2041 |
} |
| 2042 |
if(row>=nrOfRow()){ |
| 2043 |
std::ostringstream s; |
| 2044 |
s << "row (" << row << ") exceeds nrOfRow (" << nrOfRow() << ")"; |
| 2045 |
throw(s.str()); |
| 2046 |
} |
| 2047 |
if(row<0){ |
| 2048 |
std::ostringstream s; |
| 2049 |
s << "row (" << row << ") is negative"; |
| 2050 |
throw(s.str()); |
| 2051 |
} |
| 2052 |
if(m_data.size()){ |
| 2053 |
if(minCol>0){ |
| 2054 |
std::ostringstream s; |
| 2055 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2056 |
throw(s.str()); |
| 2057 |
} |
| 2058 |
if(row>=m_end[band]){ |
| 2059 |
if(row>=m_end[band]+m_blockSize){ |
| 2060 |
std::ostringstream s; |
| 2061 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2062 |
throw(s.str()); |
| 2063 |
} |
| 2064 |
else if(m_filename.size()) |
| 2065 |
returnValue=writeNewBlock(row,band); |
| 2066 |
} |
| 2067 |
int index=(row-m_begin[band])*nrOfCol(); |
| 2068 |
int minindex=(index+minCol); |
| 2069 |
int maxindex=(index+maxCol); |
| 2070 |
typename std::vector<T>::const_iterator bufit=buffer.begin(); |
| 2071 |
double theScale=1; |
| 2072 |
double theOffset=0; |
| 2073 |
if(m_scale.size()>band) |
| 2074 |
theScale=m_scale[band]; |
| 2075 |
if(m_offset.size()>band) |
| 2076 |
theOffset=m_offset[band]; |
| 2077 |
for(index=minindex;index<=maxindex;++index,++bufit){ |
| 2078 |
double dvalue=theScale*(*(bufit))+theOffset; |
| 2079 |
switch(getDataType()){ |
| 2080 |
case(GDT_Byte): |
| 2081 |
static_cast<unsigned char*>(m_data[band])[index]=static_cast<unsigned char>(dvalue); |
| 2082 |
break; |
| 2083 |
case(GDT_Int16): |
| 2084 |
static_cast<short*>(m_data[band])[index]=static_cast<short>(dvalue); |
| 2085 |
break; |
| 2086 |
case(GDT_UInt16): |
| 2087 |
static_cast<unsigned short*>(m_data[band])[index]=static_cast<unsigned short>(dvalue); |
| 2088 |
break; |
| 2089 |
case(GDT_Int32): |
| 2090 |
static_cast<int*>(m_data[band])[index]=static_cast<int>(dvalue); |
| 2091 |
break; |
| 2092 |
case(GDT_UInt32): |
| 2093 |
static_cast<unsigned int*>(m_data[band])[index]=static_cast<unsigned int>(dvalue); |
| 2094 |
break; |
| 2095 |
case(GDT_Float32): |
| 2096 |
static_cast<float*>(m_data[band])[index]=static_cast<float>(dvalue); |
| 2097 |
break; |
| 2098 |
case(GDT_Float64): |
| 2099 |
static_cast<double*>(m_data[band])[index]=static_cast<double>(dvalue); |
| 2100 |
break; |
| 2101 |
default: |
| 2102 |
std::string errorString="Error: data type not supported"; |
| 2103 |
throw(errorString); |
| 2104 |
break; |
| 2105 |
} |
| 2106 |
} |
| 2107 |
} |
| 2108 |
else{ |
| 2109 |
|
| 2110 |
|
| 2111 |
GDALRasterBand *poBand; |
| 2112 |
if(band>=nrOfBand()+1){ |
| 2113 |
std::ostringstream s; |
| 2114 |
s << "band (" << band << ") exceeds nrOfBand (" << nrOfBand() << ")"; |
| 2115 |
throw(s.str()); |
| 2116 |
} |
| 2117 |
poBand = m_gds->GetRasterBand(band+1); |
| 2118 |
returnValue=poBand->RasterIO(GF_Write,minCol,row,buffer.size(),1,&(buffer[0]),buffer.size(),1,type2GDAL<T>(),0,0); |
| 2119 |
} |
| 2120 |
return(returnValue); |
| 2121 |
} |
| 2122 |
|
| 2123 |
|
| 2124 |
|
| 2125 |
|
| 2126 |
|
| 2127 |
|
| 2128 |
|
| 2129 |
|
| 2130 |
|
| 2131 |
|
| 2132 |
|
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
|
| 2137 |
|
| 2138 |
|
| 2139 |
|
| 2140 |
|
| 2141 |
|
| 2142 |
|
| 2143 |
|
| 2144 |
|
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
|
| 2150 |
|
| 2151 |
|
| 2152 |
|
| 2153 |
|
| 2154 |
|
| 2155 |
|
| 2156 |
|
| 2157 |
|
| 2158 |
|
| 2159 |
|
| 2160 |
|
| 2161 |
|
| 2162 |
|
| 2163 |
|
| 2164 |
|
| 2165 |
|
| 2166 |
|
| 2167 |
|
| 2168 |
|
| 2169 |
|
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
|
| 2175 |
|
| 2176 |
|
| 2177 |
|
| 2178 |
|
| 2179 |
|
| 2180 |
|
| 2181 |
|
| 2182 |
|
| 2183 |
|
| 2184 |
|
| 2185 |
|
| 2186 |
|
| 2187 |
|
| 2188 |
|
| 2189 |
|
| 2190 |
|
| 2191 |
|
| 2192 |
|
| 2193 |
|
| 2194 |
|
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
|
| 2202 |
|
| 2203 |
|
| 2204 |
|
| 2205 |
|
| 2206 |
|
| 2207 |
|
| 2208 |
|
| 2209 |
|
| 2210 |
|
| 2211 |
|
| 2212 |
|
| 2213 |
|
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
|
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
|
| 2226 |
|
| 2227 |
|
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
|
| 2232 |
|
| 2233 |
|
| 2234 |
|
| 2235 |
|
| 2236 |
|
| 2237 |
|
| 2238 |
template<typename T> CPLErr Jim::writeData(std::vector<T>& buffer, int row, int band) |
| 2239 |
{ |
| 2240 |
return writeData(buffer,0,nrOfCol()-1,row,band); |
| 2241 |
} |
| 2242 |
|
| 2243 |
|
| 2244 |
|
| 2245 |
|
| 2246 |
|
| 2247 |
|
| 2248 |
|
| 2249 |
|
| 2250 |
|
| 2251 |
template<typename T> CPLErr Jim::writeDataBlock(Vector2d<T>& buffer2d, int minCol, int maxCol, int minRow, int maxRow, int band) |
| 2252 |
{ |
| 2253 |
CPLErr returnValue=CE_None; |
| 2254 |
double theScale=1; |
| 2255 |
double theOffset=0; |
| 2256 |
if(m_scale.size()>band) |
| 2257 |
theScale=m_scale[band]; |
| 2258 |
if(m_offset.size()>band) |
| 2259 |
theOffset=m_offset[band]; |
| 2260 |
if(buffer2d.size()!=maxRow-minRow+1){ |
| 2261 |
std::string errorstring="invalid buffer size"; |
| 2262 |
throw(errorstring); |
| 2263 |
} |
| 2264 |
if(band>=nrOfBand()+1){ |
| 2265 |
std::ostringstream s; |
| 2266 |
s << "band (" << band << ") exceeds nrOfBand (" << nrOfBand() << ")"; |
| 2267 |
throw(s.str()); |
| 2268 |
} |
| 2269 |
if(minCol>=nrOfCol()){ |
| 2270 |
std::ostringstream s; |
| 2271 |
s << "minCol (" << minCol << ") exceeds nrOfCol (" << nrOfCol() << ")"; |
| 2272 |
throw(s.str()); |
| 2273 |
} |
| 2274 |
if(minCol<0){ |
| 2275 |
std::ostringstream s; |
| 2276 |
s << "mincol (" << minCol << ") is negative"; |
| 2277 |
throw(s.str()); |
| 2278 |
} |
| 2279 |
if(minCol>0){ |
| 2280 |
std::ostringstream s; |
| 2281 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2282 |
throw(s.str()); |
| 2283 |
} |
| 2284 |
if(maxCol>=nrOfCol()){ |
| 2285 |
std::ostringstream s; |
| 2286 |
s << "maxCol (" << maxCol << ") exceeds nrOfCol (" << nrOfCol() << ")"; |
| 2287 |
throw(s.str()); |
| 2288 |
} |
| 2289 |
if(maxCol<minCol){ |
| 2290 |
std::ostringstream s; |
| 2291 |
s << "maxCol (" << maxCol << ") is less than minCol (" << minCol << ")"; |
| 2292 |
throw(s.str()); |
| 2293 |
} |
| 2294 |
if(m_data.size()){ |
| 2295 |
for(int irow=minRow;irow<=maxRow;++irow){ |
| 2296 |
if(irow>=nrOfRow()){ |
| 2297 |
std::ostringstream s; |
| 2298 |
s << "row (" << irow << ") exceeds nrOfRow (" << nrOfRow() << ")"; |
| 2299 |
throw(s.str()); |
| 2300 |
} |
| 2301 |
if(irow<0){ |
| 2302 |
std::ostringstream s; |
| 2303 |
s << "row (" << irow << ") is negative"; |
| 2304 |
throw(s.str()); |
| 2305 |
} |
| 2306 |
if(irow<m_begin[band]){ |
| 2307 |
std::ostringstream s; |
| 2308 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2309 |
throw(s.str()); |
| 2310 |
} |
| 2311 |
if(irow>=m_end[band]){ |
| 2312 |
if(irow>=m_end[band]+m_blockSize){ |
| 2313 |
std::ostringstream s; |
| 2314 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2315 |
throw(s.str()); |
| 2316 |
} |
| 2317 |
else if(m_filename.size()) |
| 2318 |
returnValue=writeNewBlock(irow,band); |
| 2319 |
} |
| 2320 |
int index=(irow-m_begin[band])*nrOfCol(); |
| 2321 |
int minindex=index+minCol; |
| 2322 |
int maxindex=index+maxCol; |
| 2323 |
typename std::vector<T>::iterator bufit=buffer2d[irow-minRow].begin(); |
| 2324 |
for(index=minindex;index<=maxindex;++index,++bufit){ |
| 2325 |
double dvalue=theScale*(*(bufit))+theOffset; |
| 2326 |
switch(getDataType()){ |
| 2327 |
case(GDT_Byte): |
| 2328 |
static_cast<unsigned char*>(m_data[band])[index]=static_cast<unsigned char>(dvalue); |
| 2329 |
break; |
| 2330 |
case(GDT_Int16): |
| 2331 |
static_cast<short*>(m_data[band])[index]=static_cast<short>(dvalue); |
| 2332 |
break; |
| 2333 |
case(GDT_UInt16): |
| 2334 |
static_cast<unsigned short*>(m_data[band])[index]=static_cast<unsigned short>(dvalue); |
| 2335 |
break; |
| 2336 |
case(GDT_Int32): |
| 2337 |
static_cast<int*>(m_data[band])[index]=static_cast<int>(dvalue); |
| 2338 |
break; |
| 2339 |
case(GDT_UInt32): |
| 2340 |
static_cast<unsigned int*>(m_data[band])[index]=static_cast<unsigned int>(dvalue); |
| 2341 |
break; |
| 2342 |
case(GDT_Float32): |
| 2343 |
static_cast<float*>(m_data[band])[index]=static_cast<float>(dvalue); |
| 2344 |
break; |
| 2345 |
case(GDT_Float64): |
| 2346 |
static_cast<double*>(m_data[band])[index]=static_cast<double>(dvalue); |
| 2347 |
break; |
| 2348 |
default: |
| 2349 |
std::string errorString="Error: data type not supported"; |
| 2350 |
throw(errorString); |
| 2351 |
break; |
| 2352 |
} |
| 2353 |
} |
| 2354 |
} |
| 2355 |
} |
| 2356 |
else{ |
| 2357 |
|
| 2358 |
typename std::vector<T> buffer((maxRow-minRow+1)*(maxCol-minCol+1)); |
| 2359 |
|
| 2360 |
GDALRasterBand *poBand; |
| 2361 |
|
| 2362 |
for(int irow=minRow;irow<=maxRow;++irow){ |
| 2363 |
buffer.insert(buffer.begin()+(maxCol-minCol+1)*(irow-minRow),buffer2d[irow-minRow].begin(),buffer2d[irow-minRow].end()); |
| 2364 |
} |
| 2365 |
poBand = m_gds->GetRasterBand(band+1); |
| 2366 |
returnValue=poBand->RasterIO(GF_Write,minCol,minRow,maxCol-minCol+1,maxRow-minRow+1,&(buffer[0]),(maxCol-minCol+1),(maxRow-minRow+1),type2GDAL<T>(),0,0); |
| 2367 |
} |
| 2368 |
return(returnValue); |
| 2369 |
} |
| 2370 |
|
| 2371 |
template<typename T> CPLErr Jim::writeDataBlock(T value, int minCol, int maxCol, int minRow, int maxRow, int band){ |
| 2372 |
CPLErr returnValue=CE_None; |
| 2373 |
double theScale=1; |
| 2374 |
double theOffset=0; |
| 2375 |
if(m_scale.size()>band) |
| 2376 |
theScale=m_scale[band]; |
| 2377 |
if(m_offset.size()>band) |
| 2378 |
theOffset=m_offset[band]; |
| 2379 |
if(band>=nrOfBand()+1){ |
| 2380 |
std::ostringstream s; |
| 2381 |
s << "band (" << band << ") exceeds nrOfBand (" << nrOfBand() << ")"; |
| 2382 |
throw(s.str()); |
| 2383 |
} |
| 2384 |
if(minCol>=nrOfCol()){ |
| 2385 |
std::ostringstream s; |
| 2386 |
s << "minCol (" << minCol << ") exceeds nrOfCol (" << nrOfCol() << ")"; |
| 2387 |
throw(s.str()); |
| 2388 |
} |
| 2389 |
if(minCol<0){ |
| 2390 |
std::ostringstream s; |
| 2391 |
s << "mincol (" << minCol << ") is negative"; |
| 2392 |
throw(s.str()); |
| 2393 |
} |
| 2394 |
if(minCol>0){ |
| 2395 |
std::ostringstream s; |
| 2396 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2397 |
throw(s.str()); |
| 2398 |
} |
| 2399 |
if(maxCol>=nrOfCol()){ |
| 2400 |
std::ostringstream s; |
| 2401 |
s << "maxCol (" << maxCol << ") exceeds nrOfCol (" << nrOfCol() << ")"; |
| 2402 |
throw(s.str()); |
| 2403 |
} |
| 2404 |
if(maxCol<minCol){ |
| 2405 |
std::ostringstream s; |
| 2406 |
s << "maxCol (" << maxCol << ") is less than minCol (" << minCol << ")"; |
| 2407 |
throw(s.str()); |
| 2408 |
} |
| 2409 |
if(m_data.size()){ |
| 2410 |
for(int irow=minRow;irow<=maxRow;++irow){ |
| 2411 |
if(irow>=nrOfRow()){ |
| 2412 |
std::ostringstream s; |
| 2413 |
s << "row (" << irow << ") exceeds nrOfRow (" << nrOfRow() << ")"; |
| 2414 |
throw(s.str()); |
| 2415 |
} |
| 2416 |
if(irow<0){ |
| 2417 |
std::ostringstream s; |
| 2418 |
s << "row (" << irow << ") is negative"; |
| 2419 |
throw(s.str()); |
| 2420 |
} |
| 2421 |
if(irow<m_begin[band]){ |
| 2422 |
std::ostringstream s; |
| 2423 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2424 |
throw(s.str()); |
| 2425 |
} |
| 2426 |
if(irow>=m_end[band]){ |
| 2427 |
if(irow>=m_end[band]+m_blockSize){ |
| 2428 |
std::ostringstream s; |
| 2429 |
s << "Error: increase memory to support random access writing (now at " << 100.0*m_blockSize/nrOfRow() << "%)"; |
| 2430 |
throw(s.str()); |
| 2431 |
} |
| 2432 |
else if(m_filename.size()) |
| 2433 |
returnValue=writeNewBlock(irow,band); |
| 2434 |
} |
| 2435 |
int index=(irow-m_begin[band])*nrOfCol(); |
| 2436 |
int minindex=index+minCol; |
| 2437 |
int maxindex=index+maxCol; |
| 2438 |
for(index=minindex;index<=maxindex;++index){ |
| 2439 |
double dvalue=value; |
| 2440 |
switch(getDataType()){ |
| 2441 |
case(GDT_Byte): |
| 2442 |
static_cast<unsigned char*>(m_data[band])[index]=static_cast<unsigned char>(dvalue); |
| 2443 |
break; |
| 2444 |
case(GDT_Int16): |
| 2445 |
static_cast<short*>(m_data[band])[index]=static_cast<short>(dvalue); |
| 2446 |
break; |
| 2447 |
case(GDT_UInt16): |
| 2448 |
static_cast<unsigned short*>(m_data[band])[index]=static_cast<unsigned short>(dvalue); |
| 2449 |
break; |
| 2450 |
case(GDT_Int32): |
| 2451 |
static_cast<int*>(m_data[band])[index]=static_cast<int>(dvalue); |
| 2452 |
break; |
| 2453 |
case(GDT_UInt32): |
| 2454 |
static_cast<unsigned int*>(m_data[band])[index]=static_cast<unsigned int>(dvalue); |
| 2455 |
break; |
| 2456 |
case(GDT_Float32): |
| 2457 |
static_cast<float*>(m_data[band])[index]=static_cast<float>(dvalue); |
| 2458 |
break; |
| 2459 |
case(GDT_Float64): |
| 2460 |
static_cast<double*>(m_data[band])[index]=static_cast<double>(dvalue); |
| 2461 |
break; |
| 2462 |
default: |
| 2463 |
std::string errorString="Error: data type not supported"; |
| 2464 |
throw(errorString); |
| 2465 |
break; |
| 2466 |
} |
| 2467 |
} |
| 2468 |
} |
| 2469 |
} |
| 2470 |
else{ |
| 2471 |
|
| 2472 |
typename std::vector<T> buffer((maxRow-minRow+1)*(maxCol-minCol+1),value); |
| 2473 |
|
| 2474 |
GDALRasterBand *poBand; |
| 2475 |
poBand = m_gds->GetRasterBand(band+1); |
| 2476 |
returnValue=poBand->RasterIO(GF_Write,minCol,minRow,maxCol-minCol+1,maxRow-minRow+1,&(buffer[0]),(maxCol-minCol+1),(maxRow-minRow+1),type2GDAL<T>(),0,0); |
| 2477 |
} |
| 2478 |
return(returnValue); |
| 2479 |
} |
| 2480 |
|
| 2481 |
#endif |