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

#include <ossimShapeFile.h>

Inheritance diagram for ossimShapeFile:
ossimObject ossimReferenced

Public Member Functions

 ossimShapeFile ()
 
virtual ~ossimShapeFile ()
 
virtual bool open (const ossimFilename &file, const ossimString &flags=ossimString("rb"))
 
virtual void close ()
 
bool isOpen () const
 
virtual SHPHandle getHandle ()
 
virtual const SHPHandlegetHandle () const
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual ossimString getShapeTypeString () const
 
virtual long getNumberOfShapes () const
 
void getBounds (double &minX, double &minY, double &minZ, double &minM, double &maxX, double &maxY, double &maxZ, double &maxM) const
 
void getBounds (double &minX, double &minY, double &maxX, double &maxY) const
 
void getBoundingRect (ossimDrect &result, ossimCoordSysOrientMode orient=OSSIM_RIGHT_HANDED) const
 
ossimDrect getBoundingRect (ossimCoordSysOrientMode orient=OSSIM_RIGHT_HANDED) const
 
const ossimFilenamegetFilename () const
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Attributes

SHPHandle theHandle
 
ossimFilename theFilename
 

Friends

std::ostream & operator<< (std::ostream &out, const ossimShapeFile &rhs)
 

Additional Inherited Members

- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Detailed Description

Definition at line 77 of file ossimShapeFile.h.

Constructor & Destructor Documentation

◆ ossimShapeFile()

ossimShapeFile::ossimShapeFile ( )

Definition at line 314 of file ossimShapeFile.cpp.

315  :theHandle(NULL)
316 {
317 }
SHPHandle theHandle

◆ ~ossimShapeFile()

ossimShapeFile::~ossimShapeFile ( )
virtual

Definition at line 319 of file ossimShapeFile.cpp.

References close().

320 {
321  close();
322 }
virtual void close()

Member Function Documentation

◆ close()

void ossimShapeFile::close ( )
virtual

Definition at line 324 of file ossimShapeFile.cpp.

References SHPClose(), and theHandle.

Referenced by open(), and ~ossimShapeFile().

325 {
326  if(theHandle)
327  {
329  theHandle = NULL;
330  }
331 }
void SHPAPI_CALL SHPClose(SHPHandle hSHP)
SHPHandle theHandle

◆ getBoundingRect() [1/2]

void ossimShapeFile::getBoundingRect ( ossimDrect result,
ossimCoordSysOrientMode  orient = OSSIM_RIGHT_HANDED 
) const

Definition at line 454 of file ossimShapeFile.cpp.

References getBounds(), and OSSIM_RIGHT_HANDED.

Referenced by getBoundingRect().

456 {
457  double minx, miny, maxx, maxy;
458 
459  getBounds(minx, miny, maxx, maxy);
460  if(orient == OSSIM_RIGHT_HANDED)
461  {
462  result = ossimDrect(minx, maxy, maxx, miny, orient);
463  }
464  else
465  {
466  result = ossimDrect(minx, miny, maxx, maxy, orient);
467  }
468 }
void getBounds(double &minX, double &minY, double &minZ, double &minM, double &maxX, double &maxY, double &maxZ, double &maxM) const

◆ getBoundingRect() [2/2]

ossimDrect ossimShapeFile::getBoundingRect ( ossimCoordSysOrientMode  orient = OSSIM_RIGHT_HANDED) const

Definition at line 470 of file ossimShapeFile.cpp.

References getBoundingRect().

472 {
473  ossimDrect result;
474 
475  getBoundingRect(result, orient);
476 
477  return result;
478 }
void getBoundingRect(ossimDrect &result, ossimCoordSysOrientMode orient=OSSIM_RIGHT_HANDED) const

◆ getBounds() [1/2]

void ossimShapeFile::getBounds ( double &  minX,
double &  minY,
double &  minZ,
double &  minM,
double &  maxX,
double &  maxY,
double &  maxZ,
double &  maxM 
) const

Definition at line 372 of file ossimShapeFile.cpp.

References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, ossim::nan(), and theHandle.

Referenced by getBoundingRect(), and ossimEsriShapeFileFilter::loadShapeFile().

375 {
376  if(theHandle)
377  {
378  minX = theHandle->adBoundsMin[0];
379  minY = theHandle->adBoundsMin[1];
380  minZ = theHandle->adBoundsMin[2];
381  minM = theHandle->adBoundsMin[3];
382  maxX = theHandle->adBoundsMax[0];
383  maxY = theHandle->adBoundsMax[1];
384  maxZ = theHandle->adBoundsMax[2];
385  maxM = theHandle->adBoundsMax[3];
386  }
387  else
388  {
389  minX = minY = minZ = minM =
390  maxX = maxY = maxZ = maxM = ossim::nan();
391  }
392 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double adBoundsMax[4]
Definition: shapefil.h:232
SHPHandle theHandle
double adBoundsMin[4]
Definition: shapefil.h:231

◆ getBounds() [2/2]

void ossimShapeFile::getBounds ( double &  minX,
double &  minY,
double &  maxX,
double &  maxY 
) const

Definition at line 394 of file ossimShapeFile.cpp.

References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, ossim::nan(), and theHandle.

396 {
397  if(theHandle)
398  {
399  minX = theHandle->adBoundsMin[0];
400  minY = theHandle->adBoundsMin[1];
401  maxX = theHandle->adBoundsMax[0];
402  maxY = theHandle->adBoundsMax[1];
403  }
404  else
405  {
406  minX = minY = maxX = maxY = ossim::nan();
407  }
408 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double adBoundsMax[4]
Definition: shapefil.h:232
SHPHandle theHandle
double adBoundsMin[4]
Definition: shapefil.h:231

◆ getFilename()

const ossimFilename & ossimShapeFile::getFilename ( ) const

Definition at line 480 of file ossimShapeFile.cpp.

References theFilename.

Referenced by ossimEsriShapeFileFilter::saveState().

481 {
482  return theFilename;
483 }
ossimFilename theFilename

◆ getHandle() [1/2]

SHPHandle ossimShapeFile::getHandle ( )
virtual

Definition at line 353 of file ossimShapeFile.cpp.

References theHandle.

Referenced by ossimShapeObject::loadShape(), and ossimEsriShapeFileFilter::loadShapeFile().

354 {
355  return theHandle;
356 }
SHPHandle theHandle

◆ getHandle() [2/2]

const SHPHandle & ossimShapeFile::getHandle ( ) const
virtual

Definition at line 358 of file ossimShapeFile.cpp.

References theHandle.

359 {
360  return theHandle;
361 }
SHPHandle theHandle

◆ getNumberOfShapes()

long ossimShapeFile::getNumberOfShapes ( ) const
virtual

Definition at line 363 of file ossimShapeFile.cpp.

References SHPInfo::nRecords, and theHandle.

Referenced by ossimEsriShapeFileFilter::loadShapeFile().

364 {
365  if(theHandle)
366  {
367  return theHandle->nRecords;
368  }
369  return 0;
370 }
SHPHandle theHandle
int nRecords
Definition: shapefil.h:226

◆ getShapeTypeString()

ossimString ossimShapeFile::getShapeTypeString ( ) const
virtual

Definition at line 445 of file ossimShapeFile.cpp.

References SHPInfo::nShapeType, SHPTypeName(), and theHandle.

Referenced by print().

446 {
447  if(theHandle)
448  {
450  }
451  return "";
452 }
int nShapeType
Definition: shapefil.h:222
SHPHandle theHandle
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType);const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType

◆ isOpen()

bool ossimShapeFile::isOpen ( ) const

Definition at line 348 of file ossimShapeFile.cpp.

References theHandle.

Referenced by ossimEsriShapeFileFilter::drawAnnotations(), ossimShapeObject::loadShape(), ossimEsriShapeFileFilter::loadShapeFile(), open(), and print().

349 {
350  return (theHandle!=NULL);
351 }
SHPHandle theHandle

◆ open()

bool ossimShapeFile::open ( const ossimFilename file,
const ossimString flags = ossimString("rb") 
)
virtual

Definition at line 333 of file ossimShapeFile.cpp.

References ossimString::c_str(), close(), isOpen(), SHPOpen(), theFilename, and theHandle.

Referenced by ossimEsriShapeFileFilter::loadShapeFile().

335 {
336  if(isOpen()) close();
337 
338  theHandle = SHPOpen( file.c_str(),
339  flags.c_str());
340  if(isOpen())
341  {
342  theFilename = file;
343  }
344 
345  return (theHandle != NULL);
346 }
ossimFilename theFilename
SHPHandle theHandle
virtual void close()
SHPHandle SHPAPI_CALL SHPOpen(const char *pszShapeFile, const char *pszAccess)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool isOpen() const

◆ print()

std::ostream & ossimShapeFile::print ( std::ostream &  out) const
virtual

Generic print method.

Derived classes should re-implement as they see fit.

Returns
std::ostream&

Reimplemented from ossimObject.

Definition at line 410 of file ossimShapeFile.cpp.

References SHPInfo::adBoundsMax, SHPInfo::adBoundsMin, ossimString::c_str(), getShapeTypeString(), isOpen(), ossimShapeObject::loadShape(), SHPInfo::nRecords, theFilename, and theHandle.

Referenced by operator<<().

411 {
412  if(isOpen())
413  {
414  out << std::setw(15) << setiosflags(std::ios::left)<<"Shp filename:" << theFilename << std::endl;
415  out << std::setw(15) << setiosflags(std::ios::left)<<"Record count:" << theHandle->nRecords << std::endl;
416  out << std::setw(15) << setiosflags(std::ios::left)<<"File type:" << getShapeTypeString().c_str() << std::endl;
417  out << std::setw(15) << setiosflags(std::ios::left)<<"minx:" << theHandle->adBoundsMin[0] << std::endl;
418  out << std::setw(15) << setiosflags(std::ios::left)<<"miny:" << theHandle->adBoundsMin[1] << std::endl;
419  out << std::setw(15) << setiosflags(std::ios::left)<<"minz:" << theHandle->adBoundsMin[2] << std::endl;
420  out << std::setw(15) << setiosflags(std::ios::left)<<"minm:" << theHandle->adBoundsMin[3] << std::endl;
421  out << std::setw(15) << setiosflags(std::ios::left)<<"maxx:" << theHandle->adBoundsMax[0] << std::endl;
422  out << std::setw(15) << setiosflags(std::ios::left)<<"maxy:" << theHandle->adBoundsMax[1] << std::endl;
423  out << std::setw(15) << setiosflags(std::ios::left)<<"maxz:" << theHandle->adBoundsMax[2] << std::endl;
424  out << std::setw(15) << setiosflags(std::ios::left)<<"maxm:" << theHandle->adBoundsMax[3] << std::endl;
425 
426  ossimShapeObject shape;
427 
428  if(theHandle->nRecords)
429  {
430  out << std::setw(30) << std::setfill('_') << "" << std::setfill(' ')<<std::endl;
431  }
432  for(int i=0; i < theHandle->nRecords; ++i)
433  {
434  if(shape.loadShape(*this, i))
435  {
436  out << shape << std::endl;
437  out << std::setw(30) << std::setfill('_') << ""<<std::setfill(' ')<<std::endl;
438  }
439  }
440  }
441  return out;
442 }
ossimFilename theFilename
bool loadShape(const ossimShapeFile &shapeFile, long shapeRecord)
double adBoundsMax[4]
Definition: shapefil.h:232
SHPHandle theHandle
virtual ossimString getShapeTypeString() const
double adBoundsMin[4]
Definition: shapefil.h:231
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
int nRecords
Definition: shapefil.h:226
bool isOpen() const

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const ossimShapeFile rhs 
)
friend

Definition at line 306 of file ossimShapeFile.cpp.

307 {
308  rhs.print(out);
309 
310  return out;
311 }
virtual std::ostream & print(std::ostream &out) const
Generic print method.

Member Data Documentation

◆ theFilename

ossimFilename ossimShapeFile::theFilename
protected

Definition at line 119 of file ossimShapeFile.h.

Referenced by getFilename(), open(), and print().

◆ theHandle

SHPHandle ossimShapeFile::theHandle
protected

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