OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Functions
ossimDpt.cpp File Reference
#include <iostream>
#include <iomanip>
#include <sstream>
#include <ossim/base/ossimDpt.h>
#include <ossim/base/ossimDpt3d.h>
#include <ossim/base/ossimIpt.h>
#include <ossim/base/ossimFpt.h>
#include <ossim/base/ossimGpt.h>

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const ossimDpt &pt)
 
std::istream & operator>> (std::istream &is, ossimDpt &pt)
 

Function Documentation

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const ossimDpt pt 
)

Definition at line 148 of file ossimDpt.cpp.

References ossimDpt::print().

149 {
150  return pt.print(os);
151 }
std::ostream & print(std::ostream &os, ossim_uint32 precision=15) const
Definition: ossimDpt.cpp:118

◆ operator>>()

std::istream& operator>> ( std::istream &  is,
ossimDpt pt 
)

Expected format: ( 30.00000000000000, -90.00000000000000 ) -----—x-----— ------—y-----—

This method starts by doing a "makeNan" on pt. So if anything goes wrong with the stream or parsing pt could be all or partially nan.

Parameters
isInput stream istream to formatted text.
ptosimDpt to be initialized from stream.
Returns
istream pass in.

Definition at line 198 of file ossimDpt.cpp.

References ossimString::contains(), ossimString::erase(), ossimString::find(), ossimDpt::makeNan(), ossim::nan(), ossimString::toFloat64(), ossimDpt::x, and ossimDpt::y.

199 {
200  //---
201  // Expected input format:
202  // ( 30.00000000000000, -90.00000000000000 )
203  // --------x-------- ---------y--------
204  //---
205 
206  // Start with a nan point.
207  pt.makeNan();
208 
209  // Check the stream.
210  if (!is) return is;
211 
212  const int SZ = 64; // Handle real big number...
213  ossimString os;
214  char buf[SZ];
215 
216  //---
217  // X SECTION:
218  //---
219 
220  // Grab data up to the first comma.
221  is.get(buf, SZ, ',');
222 
223  if (!is) return is;
224 
225  // Copy to ossim string.
226  os = buf;
227 
228  // Get rid of the '(' if there is any.
229  std::string::size_type pos = os.find('(');
230  if (pos != std::string::npos)
231  {
232  os.erase(pos, 1);
233  }
234 
235  if (os.contains("nan") == false)
236  {
237  pt.x = os.toFloat64();
238  }
239  else
240  {
241  pt.x = ossim::nan();
242  }
243 
244  //---
245  // Y SECTION:
246  //---
247 
248  // Grab the data up to the ')'
249  is.get(buf, SZ, ')');
250 
251  if (!is) return is;
252 
253  // Copy to ossim string.
254  os = buf;
255 
256  // Get rid of the ',' if there is any.
257  pos = os.find(',');
258  if (pos != std::string::npos)
259  {
260  os.erase(pos, 1);
261  }
262 
263  if (os.contains("nan") == false)
264  {
265  pt.y = os.toFloat64();
266  }
267  else
268  {
269  pt.y = ossim::nan();
270  }
271 
272  // Gobble the trailing ")".
273  char c = '\0';
274  while (c != ')')
275  {
276  is.get(c);
277  if (!is) break;
278  }
279 
280  // Finished
281  return is;
282 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double y
Definition: ossimDpt.h:165
bool contains(char aChar) const
Definition: ossimString.h:58
std::string::iterator erase(std::string::iterator p)
Erases the character at position p.
Definition: ossimString.h:736
ossim_float64 toFloat64() const
double x
Definition: ossimDpt.h:164
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
Definition: ossimString.h:753
void makeNan()
Definition: ossimDpt.h:65