OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Functions
ossimGpt.cpp File Reference
#include <ossim/base/ossimGpt.h>
#include <ossim/base/ossimEcefPoint.h>
#include <ossim/base/ossimEcefVector.h>
#include <ossim/base/ossimDms.h>
#include <ossim/base/ossimDatum.h>
#include <ossim/base/ossimDatumFactory.h>
#include <ossim/base/ossimDatumFactoryRegistry.h>
#include <ossim/base/ossimGeoidManager.h>
#include <ossim/base/ossimEllipsoid.h>
#include <ossim/base/ossimGeocent.h>
#include <iostream>
#include <sstream>

Go to the source code of this file.

Functions

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

Function Documentation

◆ operator<<()

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

Definition at line 73 of file ossimGpt.cpp.

References ossimGpt::print().

74 {
75  return pt.print(os);
76 }
std::ostream & print(std::ostream &os, ossim_uint32 precision=15) const
Definition: ossimGpt.cpp:27

◆ operator>>()

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

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

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

Expected format: ( 30.00000000000000, -90.00000000000000, 0.00000000000000, WGE ) --—latitude-— --—longitude-— ---—height-— datum

Definition at line 122 of file ossimGpt.cpp.

References ossimString::contains(), ossimDatumFactoryRegistry::create(), ossimGpt::datum(), ossimString::erase(), ossimString::find(), ossimGpt::height(), ossimDatumFactoryRegistry::instance(), ossimDatumFactory::instance(), ossimGpt::latd(), ossimGpt::lond(), ossimGpt::makeNan(), ossim::nan(), ossimString::toFloat64(), and ossimString::trim().

123 {
124  //---
125  // Expected input format:
126  // ( 30.00000000000000, -90.00000000000000, 0.00000000000000, WGE )
127  // -----latitude---- -----longitude---- ------height---- datum
128  //---
129 
130  // Start with a nan point.
131  pt.makeNan();
132 
133  // Check the stream.
134  if (!is) return is;
135 
136  const int SZ = 64; // Handle real big number...
137  ossimString os;
138  char buf[SZ];
139  char c = 0;
140 
141  //---
142  // LATITUDE SECTION:
143  //---
144 
145  // Grab data up to the first comma.
146  is.get(buf, SZ, ',');
147 
148  if (!is) return is;
149 
150  // Copy to ossim string.
151  os = buf;
152 
153  // Get rid of the '(' if there is any.
154  std::string::size_type pos = os.find('(');
155  if (pos != std::string::npos)
156  {
157  os.erase(pos, 1);
158  }
159 
160  if (os.contains("nan") == false)
161  {
162  pt.latd(os.toFloat64());
163  }
164  else
165  {
166  pt.latd(ossim::nan());
167  }
168 
169  // Eat the comma that we stopped at.
170  while (c != ',')
171  {
172  is.get(c);
173  if (!is) break;
174  }
175 
176  //---
177  // LONGITUDE SECTION:
178  //---
179 
180  // Grab the data up to the next ','
181  is.get(buf, SZ, ',');
182 
183  if (!is) return is;
184 
185  // Copy to ossim string.
186  os = buf;
187 
188  if (os.contains("nan") == false)
189  {
190  pt.lond(os.toFloat64());
191  }
192  else
193  {
194  pt.lond(ossim::nan());
195  }
196 
197  // Eat the comma that we stopped at.
198  c = 0;
199  while (c != ',')
200  {
201  is.get(c);
202  if (!is) break;
203  }
204 
205  //---
206  // HEIGHT SECTION:
207  //---
208 
209  // Grab the data up to the ','
210  is.get(buf, SZ, ',');
211 
212  if (!is) return is;
213 
214  // Copy to ossim string.
215  os = buf;
216 
217  if (os.contains("nan") == false)
218  {
219  pt.height(os.toFloat64());
220  }
221  else
222  {
223  pt.height(ossim::nan());
224  }
225 
226  // Eat the comma that we stopped at.
227  c = 0;
228  while (c != ',')
229  {
230  is.get(c);
231  if (!is) break;
232  }
233 
234  //---
235  // DATUM SECTION:
236  //---
237 
238  // Grab the data up to the ')'
239  is.get(buf, SZ, ')');
240 
241  if (!is) return is;
242 
243  // Copy to ossim string.
244  os = buf;
245  os.trim(); // Just in case datum factory doesn't handle spaces.
246 
248  if (datum)
249  {
250  pt.datum(datum);
251  }
252  else
253  {
254  pt.datum(ossimDatumFactory::instance()->wgs84());
255  }
256 
257  // Gobble the trailing ")".
258  c = 0;
259  while (c != ')')
260  {
261  is.get(c);
262  if (!is) break;
263  }
264 
265  // Finished
266  return is;
267 }
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
static ossimDatumFactoryRegistry * instance()
instance method
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
bool contains(char aChar) const
Definition: ossimString.h:58
void makeNan()
Definition: ossimGpt.h:130
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
std::string::iterator erase(std::string::iterator p)
Erases the character at position p.
Definition: ossimString.h:736
virtual const ossimDatum * create(const ossimString &code) const
create method
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
double height() const
Definition: ossimGpt.h:107
ossim_float64 toFloat64() const
static ossimDatumFactory * instance()
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