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

#include <ossimShapeFile.h>

Public Member Functions

 ossimShapeObject ()
 
 ~ossimShapeObject ()
 
void setShape (SHPObject *obj)
 
bool isLoaded () const
 
long getIndex () const
 
long getId () const
 
bool loadShape (const ossimShapeFile &shapeFile, long shapeRecord)
 
ossim_uint32 getNumberOfParts () const
 
ossim_uint32 getNumberOfVertices () 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
 
int getType () const
 
ossimString getTypeByName () const
 
int getPartType (ossim_uint32 partIndex) const
 
ossimString getPartByName (ossim_uint32 partIndex) const
 
SHPObjectgetShapeObject ()
 
const SHPObjectgetShapeObject () const
 

Protected Attributes

SHPObjecttheShape
 
long theIndex
 

Friends

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

Detailed Description

Definition at line 28 of file ossimShapeFile.h.

Constructor & Destructor Documentation

◆ ossimShapeObject()

ossimShapeObject::ossimShapeObject ( )

Definition at line 69 of file ossimShapeFile.cpp.

70  :theShape((SHPObject*)NULL),
71  theIndex(-1)
72 {
73 }
SHPObject * theShape

◆ ~ossimShapeObject()

ossimShapeObject::~ossimShapeObject ( )

Definition at line 75 of file ossimShapeFile.cpp.

References SHPDestroyObject(), and theShape.

76 {
77  if(theShape)
78  {
80  theShape = NULL;
81  }
82 }
SHPObject * theShape
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)

Member Function Documentation

◆ getBoundingRect() [1/2]

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

Definition at line 84 of file ossimShapeFile.cpp.

References getBounds(), ossimDrect::makeNan(), OSSIM_RIGHT_HANDED, and theShape.

Referenced by getBoundingRect().

86 {
87  double minx, miny, maxx, maxy;
88 
89  if(theShape)
90  {
91  getBounds(minx, miny, maxx, maxy);
92 
93  if(orient == OSSIM_RIGHT_HANDED)
94  {
95  result = ossimDrect(minx, maxy, maxx, miny, orient);
96  }
97  else
98  {
99  result = ossimDrect(minx, miny, maxx, maxy, orient);
100  }
101  }
102  else
103  {
104  result = ossimDrect(0,0,0,0,orient);
105  result.makeNan();
106  }
107 }
void makeNan()
Definition: ossimDrect.h:388
SHPObject * theShape
void getBounds(double &minX, double &minY, double &minZ, double &minM, double &maxX, double &maxY, double &maxZ, double &maxM) const

◆ getBoundingRect() [2/2]

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

Definition at line 220 of file ossimShapeFile.cpp.

References getBoundingRect().

222 {
223  ossimDrect result;
224 
225  getBoundingRect(result, orient);
226 
227  return result;
228 }
void getBoundingRect(ossimDrect &result, ossimCoordSysOrientMode orient=OSSIM_RIGHT_HANDED) const

◆ getBounds() [1/2]

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

Definition at line 181 of file ossimShapeFile.cpp.

References SHPObject::dfMMax, SHPObject::dfMMin, SHPObject::dfXMax, SHPObject::dfXMin, SHPObject::dfYMax, SHPObject::dfYMin, SHPObject::dfZMax, SHPObject::dfZMin, ossim::nan(), and theShape.

Referenced by getBoundingRect(), and operator<<().

184 {
185  if(theShape)
186  {
187  minX = theShape->dfXMin;
188  minY = theShape->dfYMin;
189  minZ = theShape->dfZMin;
190  minM = theShape->dfMMin;
191  maxX = theShape->dfXMax;
192  maxY = theShape->dfYMax;
193  maxZ = theShape->dfZMax;
194  maxM = theShape->dfMMax;
195  }
196  else
197  {
198  minX = minY = minZ = minM =
199  maxX = maxY = maxZ = maxM = ossim::nan();
200  }
201 }
double dfZMin
Definition: shapefil.h:295
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double dfYMax
Definition: shapefil.h:299
double dfZMax
Definition: shapefil.h:300
double dfXMax
Definition: shapefil.h:298
SHPObject * theShape
double dfMMax
Definition: shapefil.h:301
double dfXMin
Definition: shapefil.h:293
double dfMMin
Definition: shapefil.h:296
double dfYMin
Definition: shapefil.h:294

◆ getBounds() [2/2]

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

Definition at line 203 of file ossimShapeFile.cpp.

References SHPObject::dfXMax, SHPObject::dfXMin, SHPObject::dfYMax, SHPObject::dfYMin, ossim::nan(), and theShape.

205 {
206  if(theShape)
207  {
208  minX = theShape->dfXMin;
209  minY = theShape->dfYMin;
210  maxX = theShape->dfXMax;
211  maxY = theShape->dfYMax;
212  }
213  else
214  {
215  minX = minY =
216  maxX = maxY = ossim::nan();
217  }
218 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double dfYMax
Definition: shapefil.h:299
double dfXMax
Definition: shapefil.h:298
SHPObject * theShape
double dfXMin
Definition: shapefil.h:293
double dfYMin
Definition: shapefil.h:294

◆ getId()

long ossimShapeObject::getId ( ) const

Definition at line 130 of file ossimShapeFile.cpp.

References SHPObject::nShapeId, and theShape.

Referenced by ossimEsriShapeFileFilter::loadArc(), ossimEsriShapeFileFilter::loadPoint(), ossimEsriShapeFileFilter::loadPolygon(), and operator<<().

131 {
132  if(theShape)
133  {
134  return theShape->nShapeId;
135  }
136 
137  return -1;
138 }
SHPObject * theShape
int nShapeId
Definition: shapefil.h:281

◆ getIndex()

long ossimShapeObject::getIndex ( ) const

Definition at line 125 of file ossimShapeFile.cpp.

References theIndex.

126 {
127  return theIndex;
128 }

◆ getNumberOfParts()

ossim_uint32 ossimShapeObject::getNumberOfParts ( ) const

Definition at line 161 of file ossimShapeFile.cpp.

References SHPObject::nParts, and theShape.

Referenced by getPartByName(), getPartType(), ossimEsriShapeFileFilter::loadArc(), ossimEsriShapeFileFilter::loadPolygon(), and operator<<().

162 {
163  if(theShape)
164  {
165  return theShape->nParts;
166  }
167 
168  return 0;
169 }
int nParts
Definition: shapefil.h:283
SHPObject * theShape

◆ getNumberOfVertices()

ossim_uint32 ossimShapeObject::getNumberOfVertices ( ) const

Definition at line 171 of file ossimShapeFile.cpp.

References SHPObject::nVertices, and theShape.

Referenced by ossimEsriShapeFileFilter::loadPoint(), and operator<<().

172 {
173  if(theShape)
174  {
175  return theShape->nVertices;
176  }
177 
178  return 0;
179 }
SHPObject * theShape
int nVertices
Definition: shapefil.h:287

◆ getPartByName()

ossimString ossimShapeObject::getPartByName ( ossim_uint32  partIndex) const

Definition at line 259 of file ossimShapeFile.cpp.

References getNumberOfParts(), SHPObject::panPartType, SHPP_INNERRING, SHPP_OUTERRING, SHPP_RING, SHPP_TRIFAN, SHPP_TRISTRIP, and theShape.

Referenced by ossimEsriShapeFileFilter::loadArc(), and ossimEsriShapeFileFilter::loadPolygon().

260 {
261  if((partIndex > getNumberOfParts())||
262  (!theShape))
263  {
264  }
265  switch(theShape->panPartType[partIndex])
266  {
267  case SHPP_TRISTRIP:
268  {
269  ossimString("tristrip");
270  break;
271  }
272  case SHPP_TRIFAN:
273  {
274  ossimString("trifan");
275  break;
276  }
277  case SHPP_OUTERRING:
278  {
279  ossimString("outerring");
280  break;
281  }
282  case SHPP_INNERRING:
283  {
284  ossimString("innerring");
285  break;
286  }
287  case SHPP_RING:
288  {
289  ossimString("ring");
290  break;
291  }
292  }
293  return ossimString("unknown");
294 }
ossim_uint32 getNumberOfParts() const
int * panPartType
Definition: shapefil.h:285
SHPObject * theShape
#define SHPP_TRIFAN
Definition: shapefil.h:267
#define SHPP_RING
Definition: shapefil.h:271
#define SHPP_TRISTRIP
Definition: shapefil.h:266
#define SHPP_INNERRING
Definition: shapefil.h:269
#define SHPP_OUTERRING
Definition: shapefil.h:268

◆ getPartType()

int ossimShapeObject::getPartType ( ossim_uint32  partIndex) const

Definition at line 248 of file ossimShapeFile.cpp.

References getNumberOfParts(), SHPObject::panPartType, and theShape.

Referenced by ossimEsriShapeFileFilter::loadArc(), and ossimEsriShapeFileFilter::loadPolygon().

249 {
250  if((partIndex > getNumberOfParts())||
251  (!theShape))
252  {
253  return -1;
254  }
255 
256  return theShape->panPartType[partIndex];
257 }
ossim_uint32 getNumberOfParts() const
int * panPartType
Definition: shapefil.h:285
SHPObject * theShape

◆ getShapeObject() [1/2]

SHPObject * ossimShapeObject::getShapeObject ( )

Definition at line 296 of file ossimShapeFile.cpp.

References theShape.

Referenced by ossimEsriShapeFileFilter::loadArc(), ossimEsriShapeFileFilter::loadPoint(), and ossimEsriShapeFileFilter::loadPolygon().

297 {
298  return theShape;
299 }
SHPObject * theShape

◆ getShapeObject() [2/2]

const SHPObject * ossimShapeObject::getShapeObject ( ) const

Definition at line 301 of file ossimShapeFile.cpp.

References theShape.

302 {
303  return theShape;
304 }
SHPObject * theShape

◆ getType()

int ossimShapeObject::getType ( ) const

Definition at line 230 of file ossimShapeFile.cpp.

References SHPObject::nSHPType, SHPT_NULL, and theShape.

231 {
232  if(theShape)
233  {
234  return theShape->nSHPType;
235  }
236  return SHPT_NULL;
237 }
int nSHPType
Definition: shapefil.h:279
SHPObject * theShape
#define SHPT_NULL
Definition: shapefil.h:245

◆ getTypeByName()

ossimString ossimShapeObject::getTypeByName ( ) const

Definition at line 239 of file ossimShapeFile.cpp.

References SHPObject::nSHPType, SHPTypeName(), and theShape.

Referenced by ossimEsriShapeFileFilter::loadArc(), ossimEsriShapeFileFilter::loadPolygon(), and operator<<().

240 {
241  if(theShape)
242  {
244  }
245  return "unknown";
246 }
int nSHPType
Definition: shapefil.h:279
SHPObject * theShape
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType);const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType

◆ isLoaded()

bool ossimShapeObject::isLoaded ( ) const

Definition at line 120 of file ossimShapeFile.cpp.

References theShape.

Referenced by operator<<().

121 {
122  return (theShape!=NULL);
123 }
SHPObject * theShape

◆ loadShape()

bool ossimShapeObject::loadShape ( const ossimShapeFile shapeFile,
long  shapeRecord 
)

Definition at line 140 of file ossimShapeFile.cpp.

References ossimShapeFile::getHandle(), ossimShapeFile::isOpen(), SHPDestroyObject(), SHPReadObject(), theIndex, and theShape.

Referenced by ossimEsriShapeFileFilter::loadShapeFile(), and ossimShapeFile::print().

142 {
143  if(theShape)
144  {
146  theShape = NULL;
147  }
148  if(shapeFile.isOpen())
149  {
150  theShape = SHPReadObject(shapeFile.getHandle(),
151  shapeRecord);
152  theIndex = shapeRecord;
153  }
154  else
155  {
156  theIndex = -1;
157  }
158  return (theShape != (SHPObject*)NULL);
159 }
virtual SHPHandle getHandle()
SHPObject * theShape
SHPObject SHPAPI_CALL1 * SHPReadObject(SHPHandle hSHP, int iShape);int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape, SHPObject *psObject
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)
bool isOpen() const

◆ setShape()

void ossimShapeObject::setShape ( SHPObject obj)

Definition at line 109 of file ossimShapeFile.cpp.

References SHPDestroyObject(), and theShape.

110 {
111  if(theShape)
112  {
114  theShape = NULL;
115  }
116 
117  theShape = obj;
118 }
SHPObject * theShape
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 18 of file ossimShapeFile.cpp.

19 {
20  if(rhs.isLoaded())
21  {
22  double minx, miny, minz, minm;
23  double maxx, maxy, maxz, maxm;
24  ossim_uint32 i = 0;
25 
26  rhs.getBounds(minx, miny, minz, minm,
27  maxx, maxy, maxz, maxm);
28 
29  out << std::setw(15) << setiosflags(std::ios::left)<<"type:"<<rhs.getTypeByName() << std::endl
30  << std::setw(15) << setiosflags(std::ios::left)<<"id:"<<rhs.getId()<<std::endl
31  << std::setw(15) << setiosflags(std::ios::left)<<"minx:"<<minx <<std::endl
32  << std::setw(15) << setiosflags(std::ios::left)<<"miny:"<<miny <<std::endl
33  << std::setw(15) << setiosflags(std::ios::left)<<"minz:"<<minz <<std::endl
34  << std::setw(15) << setiosflags(std::ios::left)<<"minm:"<<minm <<std::endl
35  << std::setw(15) << setiosflags(std::ios::left)<<"maxx:"<<maxx <<std::endl
36  << std::setw(15) << setiosflags(std::ios::left)<<"maxy:"<<maxy <<std::endl
37  << std::setw(15) << setiosflags(std::ios::left)<<"maxz:"<<maxz <<std::endl
38  << std::setw(15) << setiosflags(std::ios::left)<<"maxm:"<<maxm <<std::endl
39  << std::setw(15) << setiosflags(std::ios::left)<<"parts:"<<rhs.getNumberOfParts()<<std::endl
40  << std::setw(15) << setiosflags(std::ios::left)<<"vertices:"<<rhs.getNumberOfVertices();
41 
42  if(rhs.getNumberOfParts())
43  {
44  out << std::endl;
45  for(i = 0; i < rhs.getNumberOfParts()-1; ++i)
46  {
47  ossimString s1 = "part start ";
48  ossimString s2 = "part type ";
49  s1 += (ossimString::toString(i+1)+":");
50  s2 += (ossimString::toString(i+1)+":");
51 
52  out << std::setw(15) << setiosflags(std::ios::left) << s1.c_str() << rhs.theShape->panPartStart[i]<<std::endl;
53  out << std::setw(15) << setiosflags(std::ios::left) << s2.c_str() << SHPPartTypeName(rhs.theShape->panPartType[i])<<std::endl;
54  }
55  ossimString s1 = "part start ";
56  ossimString s2 = "part type ";
57 
58  s1 += (ossimString::toString(rhs.getNumberOfParts())+":");
59  out << std::setw(15) << setiosflags(std::ios::left) << s1.c_str() << rhs.theShape->panPartStart[i]<<std::endl;
60  out << std::setw(15) << setiosflags(std::ios::left) << s2.c_str() << SHPPartTypeName(rhs.theShape->panPartType[i]);
61  }
62 
63  out << std::setw(0);
64 
65  }
66  return out;
67 }
ossimString getTypeByName() const
ossim_uint32 getNumberOfParts() const
long getId() const
static ossimString toString(bool aValue)
Numeric to string methods.
int * panPartType
Definition: shapefil.h:285
SHPObject * theShape
ossim_uint32 getNumberOfVertices() const
unsigned int ossim_uint32
int * panPartStart
Definition: shapefil.h:284
void getBounds(double &minX, double &minY, double &minZ, double &minM, double &maxX, double &maxY, double &maxZ, double &maxM) const
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 isLoaded() const

Member Data Documentation

◆ theIndex

long ossimShapeObject::theIndex
protected

Definition at line 74 of file ossimShapeFile.h.

Referenced by getIndex(), and loadShape().

◆ theShape

SHPObject* ossimShapeObject::theShape
protected

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