OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ossimFgdcXmlDoc Class Reference

Class for FGDC XML doc parsing. More...

#include <ossimFgdcXmlDoc.h>

Public Member Functions

 ossimFgdcXmlDoc ()
 default constructor More...
 
 ~ossimFgdcXmlDoc ()
 destructor More...
 
bool open (const ossimFilename &xmlFileName)
 Open method. More...
 
bool isOpen () const
 
void close ()
 close method. More...
 
ossimRefPtr< ossimProjectiongetProjection ()
 Gets projection from document. More...
 
ossimUnitType getUnitType () const
 
bool getGeoCsn (ossimString &s) const
 
bool getProjCsn (ossimString &s) const
 
bool getAltitudeDistantUnits (ossimString &s) const
 Get the Altitude Distance Units. More...
 
bool getGridCoordinateSystem (ossimString &s) const
 Get the Grid Coordinate system. More...
 
ossimRefPtr< ossimProjectiongetGridCoordSysProjection ()
 Gets projection from Grid Coordinate system node. More...
 
bool getHorizontalDatum (ossimString &s) const
 Get the Grid Coordinate system. More...
 
bool getPlanarDistantUnits (ossimString &s) const
 Get the Planar Distant Units. More...
 
bool getUtmFalseNorthing (ossimString &s) const
 Get UTM false Northing. More...
 
bool getUtmZone (ossimString &s) const
 Get UTM zone. More...
 
ossim_uint32 getNumberOfBands ()
 Get Bands. More...
 
bool getPath (const ossimString &path, ossimString &s) const
 Gets path from doc and initializes string. More...
 
bool getImageSize (ossimIpt &size) const
 

Private Member Functions

bool getXRes (ossim_float64 &v) const
 
bool getYRes (ossim_float64 &v) const
 
void getBoundingBox (ossimDrect &rect) const
 
bool getPath (const ossimString &path, ossim_float64 &v) const
 Gets path from doc and initializes string. More...
 
const ossimDatumcreateOssimDatum (const ossimString &s) const
 Gets the ossimDatum from string. More...
 

Private Attributes

ossimFilename m_xmlFilename
 
ossimRefPtr< ossimXmlDocumentm_xmlDocument
 
ossimRefPtr< ossimProjectionm_projection
 
bool m_boundInDegree
 

Detailed Description

Class for FGDC XML doc parsing.

Definition at line 27 of file ossimFgdcXmlDoc.h.

Constructor & Destructor Documentation

◆ ossimFgdcXmlDoc()

ossimFgdcXmlDoc::ossimFgdcXmlDoc ( )

default constructor

Definition at line 30 of file ossimFgdcXmlDoc.cpp.

32  m_xmlDocument(0),
33  m_projection(0),
34  m_boundInDegree(false)
35 {
36 }
ossimRefPtr< ossimProjection > m_projection
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
ossimRefPtr< ossimXmlDocument > m_xmlDocument
ossimFilename m_xmlFilename

◆ ~ossimFgdcXmlDoc()

ossimFgdcXmlDoc::~ossimFgdcXmlDoc ( )

destructor

Definition at line 38 of file ossimFgdcXmlDoc.cpp.

39 {
40 }

Member Function Documentation

◆ close()

void ossimFgdcXmlDoc::close ( )

close method.

Definition at line 63 of file ossimFgdcXmlDoc.cpp.

References m_projection, m_xmlDocument, m_xmlFilename, and ossimFilename::NIL.

Referenced by open().

64 {
66  m_xmlDocument = 0;
67  m_projection = 0;
68 }
ossimRefPtr< ossimProjection > m_projection
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
ossimRefPtr< ossimXmlDocument > m_xmlDocument
ossimFilename m_xmlFilename

◆ createOssimDatum()

const ossimDatum * ossimFgdcXmlDoc::createOssimDatum ( const ossimString s) const
private

Gets the ossimDatum from string.

Definition at line 525 of file ossimFgdcXmlDoc.cpp.

References ossimDatumFactoryRegistry::create(), ossimString::downcase(), ossimDatumFactoryRegistry::instance(), and ossimString::string().

526 {
527  ossimString horizdn = s.downcase();
528  ossimString datumCode;
529  if ( horizdn == "north american datum of 1983" )
530  {
531  datumCode = "NAR-C";
532  }
533  else if ( horizdn == "north american datum of 1927" )
534  {
535  datumCode = "NAS-C";
536  }
537  else if ( horizdn == "wgs84")
538  {
539  datumCode = "WGE";
540  }
541  else
542  {
543  std::string errMsg = "ossimFgdcXmlDoc::createOssimDatum ERROR: Unhandled datum: ";
544  errMsg += horizdn.string();
545  throw ossimException(errMsg);
546  }
547  return ossimDatumFactoryRegistry::instance()->create(datumCode);
548 }
static ossimDatumFactoryRegistry * instance()
instance method
virtual const ossimDatum * create(const ossimString &code) const
create method
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
const std::string & string() const
Definition: ossimString.h:414

◆ getAltitudeDistantUnits()

bool ossimFgdcXmlDoc::getAltitudeDistantUnits ( ossimString s) const

Get the Altitude Distance Units.

Path: "/metadata/spref/vertdef/altsys/altunits"

Domain: "meters" "feet"

Returns
Text for path.

Definition at line 170 of file ossimFgdcXmlDoc.cpp.

References getPath().

171 {
172  ossimString xpath = "/metadata/spref/vertdef/altsys/altunits";
173  return getPath(xpath, s);
174 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getBoundingBox()

void ossimFgdcXmlDoc::getBoundingBox ( ossimDrect rect) const
private

Definition at line 375 of file ossimFgdcXmlDoc.cpp.

References getPath(), isOpen(), m_boundInDegree, ossimDrect::makeNan(), and OSSIM_RIGHT_HANDED.

Referenced by getProjection().

376 {
377  rect.makeNan();
378 
379  if (isOpen())
380  {
381  double ll_lat = 0.0;
382  double ll_lon = 0.0;
383  double lr_lat = 0.0;
384  double lr_lon = 0.0;
385  double ul_lat = 0.0;
386  double ul_lon = 0.0;
387  double ur_lat = 0.0;
388  double ur_lon = 0.0;
389 
390  ossimString xpath = "/metadata/idinfo/spdom/lboundng/leftbc";
391  bool result = getPath(xpath, ul_lon);
392  if (!result)
393  {
394  xpath = "/metadata/idinfo/spdom/bounding/westbc";
395  result = getPath(xpath, ul_lon);
396  m_boundInDegree = true;
397  }
398  if (result)
399  {
400  ll_lon = ul_lon;
401  }
402 
403  xpath = "/metadata/idinfo/spdom/lboundng/rightbc";
404  result = getPath(xpath, ur_lon);
405  if (!result)
406  {
407  xpath = "/metadata/idinfo/spdom/bounding/eastbc";
408  result = getPath(xpath, ur_lon);
409  m_boundInDegree = true;
410  }
411  if (result)
412  {
413  lr_lon = ur_lon;
414  }
415 
416  xpath = "/metadata/idinfo/spdom/lboundng/bottombc";
417  result = getPath(xpath, ll_lat);
418  if (!result)
419  {
420  xpath = "/metadata/idinfo/spdom/bounding/southbc";
421  result = getPath(xpath, ll_lat);
422  m_boundInDegree = true;
423  }
424  if (result)
425  {
426  lr_lat = ll_lat;
427  }
428 
429  xpath = "/metadata/idinfo/spdom/lboundng/topbc";
430  result = getPath(xpath, ul_lat);
431  if (!result)
432  {
433  xpath = "/metadata/idinfo/spdom/bounding/northbc";
434  result = getPath(xpath, ul_lat);
435  m_boundInDegree = true;
436  }
437  if (result)
438  {
439  ur_lat = ul_lat;
440  }
441 
442  rect = ossimDrect(ossimDpt(ul_lon, ul_lat),
443  ossimDpt(ur_lon, ur_lat),
444  ossimDpt(lr_lon, lr_lat),
445  ossimDpt(ll_lon, ll_lat), OSSIM_RIGHT_HANDED);
446  }
447 }
void makeNan()
Definition: ossimDrect.h:388
bool isOpen() const
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getGeoCsn()

bool ossimFgdcXmlDoc::getGeoCsn ( ossimString s) const
Returns
text for path "/metadata/spref/horizsys/cordsysn/geogcsn"

Definition at line 158 of file ossimFgdcXmlDoc.cpp.

References getPath().

159 {
160  ossimString xpath = "/metadata/spref/horizsys/cordsysn/geogcsn";
161  return getPath(xpath, s);
162 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getGridCoordinateSystem()

bool ossimFgdcXmlDoc::getGridCoordinateSystem ( ossimString s) const

Get the Grid Coordinate system.

Path: "/metadata/spref/horizsys/planar/gridsys/gridsysn"

Returns
Text for path.

Definition at line 176 of file ossimFgdcXmlDoc.cpp.

References getPath().

177 {
178  ossimString xpath = "/metadata/spref/horizsys/planar/gridsys/gridsysn";
179  return getPath(xpath, s);
180 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getGridCoordSysProjection()

ossimRefPtr< ossimProjection > ossimFgdcXmlDoc::getGridCoordSysProjection ( )

Gets projection from Grid Coordinate system node.

Throws ossimException on error.

Returns
Refptr with projection pointer. Underlying pointer may be null.

Definition at line 182 of file ossimFgdcXmlDoc.cpp.

Referenced by ossimGeneralRasterTileSource::getImageGeometry().

183 {
184  static const char M[] = "ossimFgdcXmlDoc::getGridCoordSysProjection";
185  if ( traceDebug() )
186  {
187  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
188  }
189 
190  if ( m_projection.valid() == false )
191  {
192  ossimString s;
193  if ( getGridCoordinateSystem(s) )
194  {
195  ossimString gridsysn = s.downcase();
196  if ( getHorizontalDatum(s) )
197  {
198  ossimString horizdn = s.downcase();
199  const ossimDatum* datum = createOssimDatum(s); // throws exception
200 
201  if ( gridsysn == "universal transverse mercator" )
202  {
203  // Get the zone:
204  if ( getUtmZone(s) )
205  {
206  ossim_int32 zone = s.toInt32();
207 
208  //---
209  // Note: Contruct with an origin with our datum.
210  // "proj->setDatum" does not change the origin's datum.
211  // This ensures theossimEpsgProjectionDatabase::findProjectionCode
212  // sets the psc code correctly down the line.
213  //---
215  new ossimUtmProjection( *(datum->ellipsoid()), ossimGpt(0.0,0.0,0.0,datum) );
216  utmProj->setDatum(datum);
217  utmProj->setZone(zone);
218 
219  // Hemisphere( North false easting = 0.0, South = 10000000):
220  bool tmpResult = getUtmFalseNorthing(s);
221  if ( tmpResult && ( s != "0.0" ) )
222  {
223  utmProj->setHemisphere('S');
224  }
225  else
226  {
227  utmProj->setHemisphere('N');
228  }
229  utmProj->setPcsCode(0);
230 
231  ossim_float64 xRes = 0.0;
232  ossim_float64 yRes = 0.0;
233  if (getXRes(xRes) && getYRes(yRes))
234  {
235  ossimDrect rect;
236  getBoundingBox(rect);
237 
238  ossimDpt gsd(std::fabs(xRes), std::fabs(yRes));
239  ossimUnitType unitType = getUnitType();
240 
241  if (m_boundInDegree)
242  {
243  ossimGpt tieg(rect.ul().lat, rect.ul().lon);
244  utmProj->setUlTiePoints(tieg);
245  }
246  else
247  {
248  ossimDpt tie(rect.ul().x, rect.ul().y);
249  if ( unitType == OSSIM_US_SURVEY_FEET)
250  {
251  tie = tie * US_METERS_PER_FT;
252  }
253  else if ( unitType == OSSIM_FEET )
254  {
255  tie = tie * MTRS_PER_FT;
256  }
257  utmProj->setUlTiePoints(tie);
258  }
259 
260  if ( unitType == OSSIM_US_SURVEY_FEET)
261  {
262  gsd = gsd * US_METERS_PER_FT;
263  }
264  else if ( unitType == OSSIM_FEET )
265  {
266  gsd = gsd * MTRS_PER_FT;
267  }
268  utmProj->setMetersPerPixel(gsd);
269  }
270  m_projection = utmProj.get(); // Capture projection.
271  }
272  else
273  {
274  std::string errMsg = M;
275  errMsg += " ERROR: Could not determine utm zone!";
276  throw ossimException(errMsg);
277  }
278  }
279  }
280  }
281  }
282 
283  if ( traceDebug() )
284  {
285  if ( m_projection.valid() )
286  {
288  }
289  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exiting...\n";
290  }
291  return m_projection;
292 }
ossimRefPtr< ossimProjection > m_projection
const ossimDatum * createOssimDatum(const ossimString &s) const
Gets the ossimDatum from string.
ossimUnitType
bool valid() const
Definition: ossimRefPtr.h:75
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
const ossimDpt & ul() const
Definition: ossimDrect.h:339
bool getYRes(ossim_float64 &v) const
double y
Definition: ossimDpt.h:165
virtual void setMetersPerPixel(const ossimDpt &gsd)
ossim_int32 toInt32() const
double ossim_float64
#define US_METERS_PER_FT
bool getUtmFalseNorthing(ossimString &s) const
Get UTM false Northing.
double lat
Definition: ossimDpt.h:165
virtual void setPcsCode(ossim_uint32 pcsCode)
virtual const ossimEllipsoid * ellipsoid() const
Definition: ossimDatum.h:60
bool getXRes(ossim_float64 &v) const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
double lon
Definition: ossimDpt.h:164
void getBoundingBox(ossimDrect &rect) const
void setZone(const ossimGpt &ground)
#define MTRS_PER_FT
bool getHorizontalDatum(ossimString &s) const
Get the Grid Coordinate system.
double x
Definition: ossimDpt.h:164
bool getUtmZone(ossimString &s) const
Get UTM zone.
virtual void setUlTiePoints(const ossimGpt &gpt)
virtual void setDatum(const ossimDatum *datum)
Sets theDatum to datum.
ossimUnitType getUnitType() const
bool getGridCoordinateSystem(ossimString &s) const
Get the Grid Coordinate system.
void setHemisphere(const ossimGpt &ground)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ getHorizontalDatum()

bool ossimFgdcXmlDoc::getHorizontalDatum ( ossimString s) const

Get the Grid Coordinate system.

Path: "/metadata/spref/horizsys/planar/gridsys/gridsysn"

Returns
Text for path.

Definition at line 295 of file ossimFgdcXmlDoc.cpp.

References getPath().

296 {
297  ossimString xpath = "/metadata/spref/horizsys/geodetic/horizdn";
298  return getPath(xpath, s);
299 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getImageSize()

bool ossimFgdcXmlDoc::getImageSize ( ossimIpt size) const

Definition at line 339 of file ossimFgdcXmlDoc.cpp.

References ossimXmlDocument::findNodes(), getPath(), m_xmlDocument, size, ossimRefPtr< T >::valid(), x, and y.

Referenced by ossimGeneralRasterTileSource::getXmlInfo(), and ossimGeneralRasterInfo::initializeFromXml().

340 {
341  bool result = false;
342  if ( m_xmlDocument.valid() )
343  {
344  ossimString xpath = "/metadata/spatRepInfo/GridSpatRep/axDimProps/Dimen/dimSize";
345  vector<ossimRefPtr<ossimXmlNode> > xml_nodes;
346  m_xmlDocument->findNodes(xpath, xml_nodes);
347  if (xml_nodes.size() > 1)
348  {
349  size.x = xml_nodes[0]->getText().toInt32();
350  size.y = xml_nodes[1]->getText().toInt32();
351  result = true;
352  }
353 
354  if (result == false)
355  {
356  xpath = "/metadata/spdoinfo/rastinfo/colcount";
357  ossim_float64 x = 0.0;
358  result = getPath(xpath, x);
359  if (result)
360  {
361  size.x = (ossim_int32)x;
362  }
363  xpath = "/metadata/spdoinfo/rastinfo/rowcount";
364  ossim_float64 y = 0.0;
365  result = getPath(xpath, y);
366  if (result)
367  {
368  size.y = (ossim_int32)y;
369  }
370  }
371  }
372  return result;
373 }
ossim_uint32 x
ossim_uint32 y
bool valid() const
Definition: ossimRefPtr.h:75
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.
ossimRefPtr< ossimXmlDocument > m_xmlDocument
double ossim_float64
yy_size_t size
void findNodes(const ossimString &xpath, std::vector< ossimRefPtr< ossimXmlNode > > &nodelist) const
Appends any matching nodes to the list supplied (should be empty):
int ossim_int32

◆ getNumberOfBands()

ossim_uint32 ossimFgdcXmlDoc::getNumberOfBands ( )

Get Bands.

Path: "/metadata/spdoinfo/rastinfo/vrtcount"

the maximum number of raster objects along the vertical (z) axis. For use with rectangular volumetric raster objects (voxels).

Returns
int for path.

Definition at line 449 of file ossimFgdcXmlDoc.cpp.

References getPath(), and ossimString::toInt().

Referenced by ossimGeneralRasterTileSource::getXmlInfo(), and ossimGeneralRasterInfo::initializeFromXml().

450 {
451  ossim_uint32 numOfBands = 0;
452  ossimString s;
453  ossimString xpath = "/metadata/spdoinfo/rastinfo/vrtcount";
454  if (getPath(xpath, s))
455  {
456  numOfBands = s.toInt();
457  }
458  return numOfBands;
459 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.
unsigned int ossim_uint32
int toInt() const

◆ getPath() [1/2]

bool ossimFgdcXmlDoc::getPath ( const ossimString path,
ossimString s 
) const

Gets path from doc and initializes string.

This method errors if multiple nodes are found for path.

Parameters
pathXml path to look for.
sString to initialize.
Returns
true on success and false if path is not found or if there are more than one of path.

Definition at line 461 of file ossimFgdcXmlDoc.cpp.

References ossimXmlDocument::findNodes(), m_xmlDocument, and ossimRefPtr< T >::valid().

Referenced by getAltitudeDistantUnits(), getBoundingBox(), getGeoCsn(), getGridCoordinateSystem(), getHorizontalDatum(), getImageSize(), getNumberOfBands(), getPath(), getPlanarDistantUnits(), getProjCsn(), getUtmFalseNorthing(), getUtmZone(), ossimGeneralRasterTileSource::getXmlInfo(), getXRes(), getYRes(), and ossimGeneralRasterInfo::initializeFromXml().

462 {
463  static const char M[] = "ossimFgdcXmlDoc::getPath";
464 
465  bool result = false;
466  if ( m_xmlDocument.valid() )
467  {
468  std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
469  m_xmlDocument->findNodes(path, xnodes);
470  if ( xnodes.size() == 1 ) // Error if more than one.
471  {
472  if ( xnodes[0].valid() )
473  {
474  s = xnodes[0]->getText();
475  result = true;
476  }
477  else
478  {
479  if(traceDebug())
480  {
481 
483  << M << " ERROR:\n"
484  << "Node not found: " << path
485  << std::endl;
486  }
487  }
488  }
489  else if ( xnodes.size() == 0 )
490  {
491  if(traceDebug())
492  {
493  ossimNotify(ossimNotifyLevel_WARN) << M << " ERROR:\nNode not found: " << path
494  << std::endl;
495  }
496  }
497  else
498  {
499  if(traceDebug())
500  {
501 
503  << M << " ERROR:\nMultiple nodes found: " << path << std::endl;
504  }
505  }
506  }
507  if (!result)
508  {
509  s.clear();
510  }
511  return result;
512 }
void clear()
Erases the entire container.
Definition: ossimString.h:432
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimXmlDocument > m_xmlDocument
void findNodes(const ossimString &xpath, std::vector< ossimRefPtr< ossimXmlNode > > &nodelist) const
Appends any matching nodes to the list supplied (should be empty):
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getPath() [2/2]

bool ossimFgdcXmlDoc::getPath ( const ossimString path,
ossim_float64 v 
) const
private

Gets path from doc and initializes string.

Parameters
pathXml path to look for.
vValue to initialize.
Returns
true on success and false if path is not found or if there are more than one of path.

Definition at line 514 of file ossimFgdcXmlDoc.cpp.

References getPath(), and ossimString::toFloat64().

515 {
516  ossimString s;
517  bool result = getPath(path, s);
518  if ( result )
519  {
520  v = s.toFloat64();
521  }
522  return result;
523 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.
ossim_float64 toFloat64() const

◆ getPlanarDistantUnits()

bool ossimFgdcXmlDoc::getPlanarDistantUnits ( ossimString s) const

Get the Planar Distant Units.

Path: "/metadata/spref/horizsys/planar/planci/plandu"

Domain: "meters" "international feet" "survey feet"

Returns
Text for path.

Definition at line 301 of file ossimFgdcXmlDoc.cpp.

References getPath().

Referenced by getUnitType().

302 {
303  ossimString xpath = "/metadata/spref/horizsys/planar/planci/plandu";
304  return getPath(xpath, s);
305 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getProjCsn()

bool ossimFgdcXmlDoc::getProjCsn ( ossimString s) const
Returns
text for path "/metadata/spref/horizsys/cordsysn/projcsn"

Definition at line 164 of file ossimFgdcXmlDoc.cpp.

References getPath().

Referenced by getProjection().

165 {
166  ossimString xpath = "/metadata/spref/horizsys/cordsysn/projcsn";
167  return getPath(xpath, s);
168 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getProjection()

ossimRefPtr< ossimProjection > ossimFgdcXmlDoc::getProjection ( )

Gets projection from document.

Definition at line 70 of file ossimFgdcXmlDoc.cpp.

References ossimEpsgProjectionFactory::createProjection(), ossimString::empty(), ossimRefPtr< T >::get(), getBoundingBox(), getProjCsn(), getUnitType(), getXRes(), getYRes(), ossimEpsgProjectionFactory::instance(), ossimMapProjection::isGeographic(), isOpen(), ossimDpt::lat, ossimDpt::lon, m_projection, ossimDpt::makeNan(), MTRS_PER_FT, OSSIM_FEET, OSSIM_US_SURVEY_FEET, ossimMapProjection::setDecimalDegreesPerPixel(), ossimMapProjection::setMetersPerPixel(), ossimMapProjection::setUlTiePoints(), ossimDrect::ul(), US_METERS_PER_FT, ossimRefPtr< T >::valid(), ossimDpt::x, and ossimDpt::y.

Referenced by ossimGdalTileSource::getExternalImageGeometryFromXml(), ossimGeneralRasterTileSource::getImageGeometry(), and ossimGdalOgrVectorAnnotation::loadExternalImageGeometryFromXml().

71 {
72  if ( (m_projection.valid() == false) && isOpen() )
73  {
74  ossimString projName;
75  if ( getProjCsn(projName) )
76  {
77  if (!projName.empty())
78  {
80 
81  if ( m_projection.valid() )
82  {
83  ossimDpt gsd;
84  gsd.makeNan();
85  ossim_float64 d;
86  if ( getXRes(d) )
87  {
88  gsd.x = std::fabs(d);
89  }
90  if ( getYRes(d) )
91  {
92  gsd.y = std::fabs(d);
93  }
94  ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(m_projection.get());
95  if (mapProj)
96  {
97  ossimDrect rect;
98  getBoundingBox(rect);
99  if (mapProj->isGeographic())
100  {
101  ossimGpt tie(rect.ul().lat, rect.ul().lon);
102  mapProj->setUlTiePoints(tie);
103  mapProj->setDecimalDegreesPerPixel(gsd);
104  }
105  else
106  {
107  ossimDpt tie(rect.ul().x, rect.ul().y);
108  ossimUnitType unitType = getUnitType();
109  if ( unitType == OSSIM_US_SURVEY_FEET)
110  {
111  gsd = gsd * US_METERS_PER_FT;
112  tie = tie * US_METERS_PER_FT;
113  }
114  else if ( unitType == OSSIM_FEET )
115  {
116  gsd = gsd * MTRS_PER_FT;
117  tie = tie * MTRS_PER_FT;
118  }
119 
120  mapProj->setUlTiePoints(tie);
121  mapProj->setMetersPerPixel(gsd);
122  }
123  }
124  }
125  }
126  }
127  }
128  return m_projection;
129 }
ossimRefPtr< ossimProjection > m_projection
bool isOpen() const
ossimUnitType
bool valid() const
Definition: ossimRefPtr.h:75
const ossimDpt & ul() const
Definition: ossimDrect.h:339
bool getYRes(ossim_float64 &v) const
double y
Definition: ossimDpt.h:165
virtual bool isGeographic() const
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
bool getProjCsn(ossimString &s) const
virtual void setMetersPerPixel(const ossimDpt &gsd)
double ossim_float64
#define US_METERS_PER_FT
double lat
Definition: ossimDpt.h:165
bool getXRes(ossim_float64 &v) const
double lon
Definition: ossimDpt.h:164
void getBoundingBox(ossimDrect &rect) const
#define MTRS_PER_FT
double x
Definition: ossimDpt.h:164
bool empty() const
Definition: ossimString.h:411
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
STUB. Not implemented.
virtual void setUlTiePoints(const ossimGpt &gpt)
ossimUnitType getUnitType() const
static ossimEpsgProjectionFactory * instance()
Implements singleton pattern.
void makeNan()
Definition: ossimDpt.h:65

◆ getUnitType()

ossimUnitType ossimFgdcXmlDoc::getUnitType ( ) const
Returns
Unit type. Note meters is the default if not found in doc.

Definition at line 131 of file ossimFgdcXmlDoc.cpp.

References ossimString::contains(), ossimString::downcase(), getPlanarDistantUnits(), OSSIM_FEET, OSSIM_METERS, and OSSIM_US_SURVEY_FEET.

Referenced by getProjection().

132 {
133  ossimUnitType result = OSSIM_METERS; // default
134  ossimString units;
135  if ( getPlanarDistantUnits(units) )
136  {
137  units.downcase();
138  if ( units.contains("feet") )
139  {
140  if ( units.contains("international") )
141  {
142  result = OSSIM_FEET;
143  }
144  else
145  {
146  result = OSSIM_US_SURVEY_FEET; // Default for feet.
147  }
148  }
149  }
150  return result;
151 }
ossimUnitType
bool contains(char aChar) const
Definition: ossimString.h:58
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
bool getPlanarDistantUnits(ossimString &s) const
Get the Planar Distant Units.

◆ getUtmFalseNorthing()

bool ossimFgdcXmlDoc::getUtmFalseNorthing ( ossimString s) const

Get UTM false Northing.

Path: "/metadata/spref/horizsys/planar/gridsys/utm/transmer/fnorth"

Returns
Text for path.

Definition at line 307 of file ossimFgdcXmlDoc.cpp.

References getPath().

308 {
309  ossimString xpath = "/metadata/spref/horizsys/planar/gridsys/utm/transmer/fnorth";
310  return getPath(xpath, s);
311 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getUtmZone()

bool ossimFgdcXmlDoc::getUtmZone ( ossimString s) const

Get UTM zone.

Path: "/metadata/spref/horizsys/planar/gridsys/utm/utmzone"

Domain: 1 <= UTM Zone Number <= 60 for the northern hemisphere; -60 <= UTM Zone Number <= -1 for the southern hemisphere

Returns
Text for path.

Definition at line 313 of file ossimFgdcXmlDoc.cpp.

References getPath().

314 {
315  ossimString xpath = "/metadata/spref/horizsys/planar/gridsys/utm/utmzone";
316  return getPath(xpath, s);
317 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getXRes()

bool ossimFgdcXmlDoc::getXRes ( ossim_float64 v) const
private

Definition at line 319 of file ossimFgdcXmlDoc.cpp.

References getPath().

Referenced by getProjection().

320 {
321  ossimString xpath = "/metadata/spdoinfo/rastinfo/rastxsz";
322  if (getPath(xpath, v) == false)
323  {
324  xpath = "/metadata/spref/horizsys/planar/planci/coordrep/absres";
325  }
326  return getPath(xpath, v);
327 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ getYRes()

bool ossimFgdcXmlDoc::getYRes ( ossim_float64 v) const
private

Definition at line 329 of file ossimFgdcXmlDoc.cpp.

References getPath().

Referenced by getProjection().

330 {
331  ossimString xpath = "/metadata/spdoinfo/rastinfo/rastysz";
332  if (getPath(xpath, v) == false)
333  {
334  xpath = "/metadata/spref/horizsys/planar/planci/coordrep/ordres";
335  }
336  return getPath(xpath, v);
337 }
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.

◆ isOpen()

bool ossimFgdcXmlDoc::isOpen ( ) const
Returns
true if m_xmlDocument is open; false if not.

Definition at line 153 of file ossimFgdcXmlDoc.cpp.

References m_xmlDocument, and ossimRefPtr< T >::valid().

Referenced by getBoundingBox(), getProjection(), and open().

154 {
155  return m_xmlDocument.valid();
156 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimXmlDocument > m_xmlDocument

◆ open()

bool ossimFgdcXmlDoc::open ( const ossimFilename xmlFileName)

Open method.

Returns
true on success, false on error.

Definition at line 42 of file ossimFgdcXmlDoc.cpp.

References close(), isOpen(), m_xmlDocument, m_xmlFilename, ossimString::size(), and ossimRefPtr< T >::valid().

Referenced by ossimGdalTileSource::getExternalImageGeometryFromXml(), ossimGeneralRasterTileSource::getImageGeometry(), ossimGeneralRasterTileSource::getXmlInfo(), ossimGeneralRasterInfo::initializeFromXml(), and ossimGdalOgrVectorAnnotation::loadExternalImageGeometryFromXml().

43 {
44  bool result = false;
45  if ( isOpen() )
46  {
47  close();
48  }
49 
50  if (xmlFileName.size())
51  {
52  m_xmlDocument = new ossimXmlDocument(xmlFileName);
53  if ( m_xmlDocument.valid() )
54  {
55  // May want to add a test for valid FGDC here??? (drb)
56  m_xmlFilename = xmlFileName;
57  result = true;
58  }
59  }
60  return result;
61 }
bool isOpen() const
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimXmlDocument > m_xmlDocument
std::string::size_type size() const
Definition: ossimString.h:405
ossimFilename m_xmlFilename
void close()
close method.

Member Data Documentation

◆ m_boundInDegree

bool ossimFgdcXmlDoc::m_boundInDegree
mutableprivate

Definition at line 185 of file ossimFgdcXmlDoc.h.

Referenced by getBoundingBox().

◆ m_projection

ossimRefPtr<ossimProjection> ossimFgdcXmlDoc::m_projection
private

Definition at line 184 of file ossimFgdcXmlDoc.h.

Referenced by close(), and getProjection().

◆ m_xmlDocument

ossimRefPtr<ossimXmlDocument> ossimFgdcXmlDoc::m_xmlDocument
private

Definition at line 183 of file ossimFgdcXmlDoc.h.

Referenced by close(), getImageSize(), getPath(), isOpen(), and open().

◆ m_xmlFilename

ossimFilename ossimFgdcXmlDoc::m_xmlFilename
private

Definition at line 182 of file ossimFgdcXmlDoc.h.

Referenced by close(), and open().


The documentation for this class was generated from the following files: