OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTDpt.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include <ossim/base/ossimTDpt.h>
6 
7 //*******************************************************************
8 
10 {
11  os << "( ";
12  os << dynamic_cast<const ossimDpt&>(*this);
13  os << ", ";
14  os << tie;
15  os << ", ";
16  if (ossim::isnan(score) == false)
17  {
18  os << std::setiosflags(std::ios::fixed) << std::setprecision(15);
19  os << score;
20  }
21  else
22  {
23  os << "nan";
24  }
25  os << " )";
26 
27  return os;
28 }
29 
31 {
32  os << std::setiosflags(std::ios::fixed) << std::setprecision(15);
33  os<< x ;
34  os<<"\t"<< y;
35  os<<"\t"<< tie.x;
36  os<<"\t"<< tie.y;
37  os<<"\t"<< score;
38 
39  return os;
40 }
41 
43 {
44  return pt.print(os);
45 }
46 
48 {
49  //---
50  // Expected input format:
51  // ( (ossimDPt), (ossimDpt), score )
52  // score is real or nan
53  //---
54 
55  // Start with a nan point.
56  pt.makeNan();
57  // Check the stream.
58  if (!is) return is;
59 
60  ossimString tempString;
61 
62  // Gobble the "(".
63  is >> tempString;
64 
65  //get the first point
66  is>>dynamic_cast<ossimDpt&>(pt);
67 
68  // Eat the ",".
69  char c;
70  is.get(c);
71 
72  //get the second point
73  is>>pt.tie;
74 
75  // Eat the second ",".
76  is.get(c);
77 
78  // Get the score
79  const int SZ = 64; // real number buffer size
80  char tempChars[SZ];
81  is.get(tempChars, SZ, ',');
82  if (!is) return is;
83  tempChars[SZ-1] = '\0';
84  tempString = tempChars;
85  tempString.trim();
86  if (tempString == "nan")
87  {
88  pt.score = ossim::nan();
89  }
90  else
91  {
92  pt.score = tempString.toDouble();
93  }
94 
95  // Gobble the trailing ")".
96  is >> tempString;
97 
98  // Finished
99  return is;
100 }
ossimDpt tie
Definition: ossimTDpt.h:74
ossim_float64 score
Definition: ossimTDpt.h:75
std::ostream & operator<<(std::ostream &os, const ossimTDpt &pt)
Definition: ossimTDpt.cpp:42
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double y
Definition: ossimDpt.h:165
void makeNan()
Definition: ossimTDpt.h:38
std::ostream & print(std::ostream &os) const
Definition: ossimTDpt.cpp:9
std::istream & operator>>(std::istream &is, ossimTDpt &pt)
Definition: ossimTDpt.cpp:47
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
double x
Definition: ossimDpt.h:164
std::ostream & printTab(std::ostream &os) const
Definition: ossimTDpt.cpp:30
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91