Commit 193ff00e529e668da441ea0380c3e89f03c2c152

Authored by David Mayerich
1 parent ebe94c9d

dealth with precision issues (use unsigned long long int for file reading)

Showing 2 changed files with 10 additions and 2 deletions   Show diff stats
envi/binary.h
... ... @@ -18,7 +18,7 @@ protected:
18 18 std::fstream file; //file stream used for reading and writing
19 19 std::string name; //file name
20 20  
21   - unsigned int R[D]; //resolution
  21 + unsigned long long int R[D]; //resolution
22 22 unsigned int header; //header size (in bytes)
23 23 unsigned char* mask; //pointer to a character array: 0 = background, 1 = foreground (or valid data)
24 24  
... ... @@ -35,9 +35,15 @@ protected:
35 35 //returns the file size
36 36 // reads the file size from disk and returns it (in bytes)
37 37 long long int get_file_size(){
  38 +#ifdef _WIN32
38 39 struct _stat64 results;
39 40 if(_stat64(name.c_str(), &results) == 0)
40 41 return results.st_size;
  42 +#else
  43 + struct stat results;
  44 + if(stat(name.c_str(), &results) == 0)
  45 + return results.st_size;
  46 +#endif
41 47 else return 0;
42 48 }
43 49  
... ...
envi/bsq.h
... ... @@ -48,7 +48,7 @@ public:
48 48 return false;
49 49 }
50 50  
51   - file.seekg(R[0] * R[1] * page * sizeof(T), std::ios::beg);
  51 + file.seekg(R[0] * R[1] * page * sizeof(T));
52 52  
53 53 file.read((char *)p, sizeof(T) * R[0] * R[1]);
54 54  
... ... @@ -86,6 +86,7 @@ public:
86 86 }
87 87 //when the page counter points to the first band above 'wavelength'
88 88 if ( wavelength < w[page] ){
  89 +
89 90 //do the interpolation
90 91 T * p1;
91 92 T * p2;
... ... @@ -103,6 +104,7 @@ public:
103 104 //if the wavelength is equal to a wavelength in header file
104 105 else{
105 106 band_index(p, page); //return the band
  107 + std::cout<<"wavelength: "<<wavelength<<" w[page]: "<<w[page]<<std::endl;
106 108 }
107 109  
108 110 return true;
... ...