1 //*******************************************************************
2 //
3 // License:  See top level LICENSE.txt file.
4 //
5 // Author:  Garrett Potts  (gpotts@imagelinks.com)
6 //
7 //*******************************************************************
8 // $Id: ossimAigStatistics.cpp 9963 2006-11-28 21:11:01Z gpotts $
9 
10 #include <ostream>
11 #include <ossim/base/ossimEndian.h>
12 #include <ossim/support_data/ossimAigStatistics.h>
13 
ossimAigStatistics()14 ossimAigStatistics::ossimAigStatistics()
15    :theMin(0.0),
16     theMax(0.0),
17     theMean(0.0),
18     theStandardDev(0.0)
19 {
20 }
21 
reset()22 void ossimAigStatistics::reset()
23 {
24    theMin         = 0.0;
25    theMax         = 0.0;
26    theMean        = 0.0;
27    theStandardDev = 0.0;
28 }
29 
writeStream(std::ostream & out)30 bool ossimAigStatistics::writeStream(std::ostream& out)
31 {
32    ossimEndian endian;
33    double tempDouble;
34 
35    if(endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN)
36    {
37       tempDouble = theMin;
38       endian.swap(tempDouble);
39       out.write((char*)(&tempDouble), 8);
40 
41       tempDouble = theMax;
42       endian.swap(tempDouble);
43       out.write((char*)(&tempDouble), 8);
44 
45       tempDouble = theMean;
46       endian.swap(tempDouble);
47       out.write((char*)(&tempDouble), 8);
48 
49       tempDouble = theStandardDev;
50       endian.swap(tempDouble);
51       out.write((char*)(&tempDouble), 8);
52    }
53    else
54    {
55       out.write((char*)(&theMin), 8);
56       out.write((char*)(&theMax), 8);
57       out.write((char*)(&theMean), 8);
58       out.write((char*)(&theStandardDev), 8);
59    }
60 
61    return true;
62 }
63