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

#include <ossimGeoAnnotationPolyObject.h>

Inheritance diagram for ossimGeoAnnotationPolyObject:
ossimGeoAnnotationObject ossimAnnotationObject ossimObject ossimReferenced

Public Types

enum  ossimPolyType { OSSIM_POLY_EXTERIOR_RING = 0, OSSIM_POLY_INTERIOR_RING = 1 }
 

Public Member Functions

 ossimGeoAnnotationPolyObject (bool enableFill=false, ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)
 
 ossimGeoAnnotationPolyObject (const std::vector< ossimGpt > &groundPts, bool enableFill=false, ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)
 
 ossimGeoAnnotationPolyObject (const ossimGeoAnnotationPolyObject &rhs)
 
virtual ossimObjectdup () const
 
virtual void applyScale (double x, double y)
 
virtual void transform (ossimImageGeometry *projection)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual void draw (ossimRgbImage &anImage) const
 
virtual ossimAnnotationObjectgetNewClippedObject (const ossimDrect &rect) const
 
virtual bool intersects (const ossimDrect &rect) const
 
virtual void getBoundingRect (ossimDrect &rect) const
 
virtual void computeBoundingRect ()
 
virtual const std::vector< ossimGpt > & getPolygon () const
 
virtual void setPolygon (const std::vector< ossimGpt > &poly)
 
virtual void setFillFlag (bool flag)
 
virtual void setColor (ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
 
virtual void setThickness (ossim_uint8 thickness)
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Saves the current state of this object. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of an object from a keyword list. More...
 
virtual std::vector< ossimGptgetPoints ()
 
virtual ossimPolyType getPolyType ()
 
virtual void setPolyType (ossimPolyType polyType)
 
- Public Member Functions inherited from ossimGeoAnnotationObject
 ossimGeoAnnotationObject (unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)
 
 ossimGeoAnnotationObject (const ossimGeoAnnotationObject &rhs)
 
- Public Member Functions inherited from ossimAnnotationObject
virtual ~ossimAnnotationObject ()
 
 ossimAnnotationObject (ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)
 
virtual void applyScale (const ossimDpt &scale)
 
virtual ossimDrect getBoundingRect () const
 
void getColor (ossim_uint8 &r, ossim_uint8 &g, ossim_uint8 &b) const
 
ossim_uint8 getThickness () const
 
virtual bool isPointWithin (const ossimDpt &imagePoint) const
 
virtual ossimString getName () const
 
virtual void setName (const ossimString &name)
 
ossim_uint32 getId () const
 
virtual ossim_uint32 setId ()
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
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 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 Member Functions

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

Protected Attributes

std::vector< ossimGptthePolygon
 
ossimRefPtr< ossimAnnotationPolyObjecttheProjectedPolyObject
 
ossimPolyType m_PolyType
 
- Protected Attributes inherited from ossimAnnotationObject
ossim_uint8 theRed
 
ossim_uint8 theGreen
 
ossim_uint8 theBlue
 
ossim_uint8 theThickness
 
ossimString theName
 
ossim_uint32 theId
 

Additional Inherited Members

- Static Public Member Functions inherited from ossimAnnotationObject
static ossim_uint32 getNextId ()
 
static void restIdCounter ()
 
- Static Protected Attributes inherited from ossimAnnotationObject
static ossim_uint32 theIdCounter = 0
 

Detailed Description

Definition at line 18 of file ossimGeoAnnotationPolyObject.h.

Member Enumeration Documentation

◆ ossimPolyType

Constructor & Destructor Documentation

◆ ossimGeoAnnotationPolyObject() [1/3]

ossimGeoAnnotationPolyObject::ossimGeoAnnotationPolyObject ( bool  enableFill = false,
ossim_uint8  r = 255,
ossim_uint8  g = 255,
ossim_uint8  b = 255,
ossim_uint8  thickness = 1 
)

Referenced by dup().

◆ ossimGeoAnnotationPolyObject() [2/3]

ossimGeoAnnotationPolyObject::ossimGeoAnnotationPolyObject ( const std::vector< ossimGpt > &  groundPts,
bool  enableFill = false,
ossim_uint8  r = 255,
ossim_uint8  g = 255,
ossim_uint8  b = 255,
ossim_uint8  thickness = 1 
)

Definition at line 43 of file ossimGeoAnnotationPolyObject.cpp.

References thePolygon, and theProjectedPolyObject.

50  :ossimGeoAnnotationObject(r, g, b, thickness),
51  thePolygon(),
54 {
55 
56  thePolygon = groundPts;
57 
58  // we will initialize the projected polygon's size
59  // so we don't have to reset it every time we do a
60  // projection
61  //
62  std::vector<ossimDpt> projectedPoints(thePolygon.size());
63 
65  enableFill,
66  r,
67  g,
68  b,
69  thickness);
70 }
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
ossimGeoAnnotationObject(unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)

◆ ossimGeoAnnotationPolyObject() [3/3]

ossimGeoAnnotationPolyObject::ossimGeoAnnotationPolyObject ( const ossimGeoAnnotationPolyObject rhs)

Definition at line 72 of file ossimGeoAnnotationPolyObject.cpp.

78 {
79 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
ossimGeoAnnotationObject(unsigned char r=255, unsigned char g=255, unsigned char b=255, long thickness=1)

◆ ~ossimGeoAnnotationPolyObject()

ossimGeoAnnotationPolyObject::~ossimGeoAnnotationPolyObject ( )
protectedvirtual

Definition at line 81 of file ossimGeoAnnotationPolyObject.cpp.

References theProjectedPolyObject.

82 {
84 }
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject

Member Function Documentation

◆ applyScale()

void ossimGeoAnnotationPolyObject::applyScale ( double  x,
double  y 
)
virtual

Implements ossimAnnotationObject.

Definition at line 91 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::applyScale(), thePolygon, theProjectedPolyObject, ossimRefPtr< T >::valid(), x, and y.

93 {
94  for(int i = 0; i < (int)thePolygon.size(); ++i)
95  {
96  thePolygon[i].lond(thePolygon[i].lond()*x);
97  thePolygon[i].latd(thePolygon[i].latd()*y);
98  }
100  {
102  }
103 
104 }
ossim_uint32 x
ossim_uint32 y
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
virtual void applyScale(double x, double y)

◆ computeBoundingRect()

void ossimGeoAnnotationPolyObject::computeBoundingRect ( )
virtual

◆ draw()

void ossimGeoAnnotationPolyObject::draw ( ossimRgbImage anImage) const
virtual

Implements ossimAnnotationObject.

Definition at line 142 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::draw(), theProjectedPolyObject, and ossimRefPtr< T >::valid().

Referenced by ossimGdalOgrVectorAnnotation::drawAnnotations().

143 {
145  {
146  theProjectedPolyObject->draw(anImage);
147  }
148 }
virtual void draw(ossimRgbImage &anImage) const
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject

◆ dup()

ossimObject * ossimGeoAnnotationPolyObject::dup ( ) const
virtual

Reimplemented from ossimObject.

Definition at line 86 of file ossimGeoAnnotationPolyObject.cpp.

References ossimGeoAnnotationPolyObject().

87 {
88  return new ossimGeoAnnotationPolyObject(*this);
89 }
ossimGeoAnnotationPolyObject(bool enableFill=false, ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

◆ getBoundingRect()

void ossimGeoAnnotationPolyObject::getBoundingRect ( ossimDrect rect) const
virtual

Implements ossimAnnotationObject.

Definition at line 171 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::getBoundingRect(), ossimDrect::makeNan(), theProjectedPolyObject, and ossimRefPtr< T >::valid().

172 {
173  rect.makeNan();
175  {
177  }
178 }
void makeNan()
Definition: ossimDrect.h:388
virtual void getBoundingRect(ossimDrect &rect) const
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject

◆ getNewClippedObject()

ossimAnnotationObject * ossimGeoAnnotationPolyObject::getNewClippedObject ( const ossimDrect rect) const
virtual

Will allocate a new object that is clipped to the passed. in rect. Look at derived classes to see if the object is actually clipped or not. A new object is returned if it clips to the rect else NULL should be returned it doesn't clip.

Implements ossimAnnotationObject.

Definition at line 150 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::getNewClippedObject(), theProjectedPolyObject, and ossimRefPtr< T >::valid().

152 {
154  {
156  }
157 
158  return (ossimAnnotationObject*)0;
159 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimAnnotationObject * getNewClippedObject(const ossimDrect &rect) const
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject

◆ getPoints()

virtual std::vector<ossimGpt> ossimGeoAnnotationPolyObject::getPoints ( )
inlinevirtual

Definition at line 86 of file ossimGeoAnnotationPolyObject.h.

Referenced by ossimTilingPoly::parseShpFile().

86 { return thePolygon; }

◆ getPolygon()

const std::vector< ossimGpt > & ossimGeoAnnotationPolyObject::getPolygon ( ) const
virtual

Definition at line 188 of file ossimGeoAnnotationPolyObject.cpp.

References thePolygon.

189 {
190  return thePolygon;
191 }

◆ getPolyType()

virtual ossimPolyType ossimGeoAnnotationPolyObject::getPolyType ( )
inlinevirtual

Definition at line 88 of file ossimGeoAnnotationPolyObject.h.

Referenced by ossimTilingPoly::parseShpFile().

◆ intersects()

bool ossimGeoAnnotationPolyObject::intersects ( const ossimDrect rect) const
virtual

Implements ossimAnnotationObject.

Definition at line 161 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::intersects(), theProjectedPolyObject, and ossimRefPtr< T >::valid().

162 {
164  {
165  return theProjectedPolyObject->intersects(rect);
166  }
167 
168  return false;
169 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
virtual bool intersects(const ossimDrect &rect) const

◆ loadState()

bool ossimGeoAnnotationPolyObject::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of an object from a keyword list.

Return true if ok or false on error.

Reimplemented from ossimGeoAnnotationObject.

Definition at line 251 of file ossimGeoAnnotationPolyObject.cpp.

References ossimString::c_str(), ossimKeywordlist::find(), ossimKeywordlist::getNumberOfSubstringKeys(), ossimGeoAnnotationObject::loadState(), ossimAnnotationObject::setColor(), ossimAnnotationPolyObject::setPolygon(), ossimAnnotationObject::setThickness(), status, ossimAnnotationObject::theBlue, ossimAnnotationObject::theGreen, thePolygon, theProjectedPolyObject, ossimAnnotationObject::theRed, ossimAnnotationObject::theThickness, and ossimString::toString().

253 {
255  {
256  return false;
257  }
258 
259  //---
260  // Base class state must be called first to pick up colors...
261  //---
262  bool status = ossimGeoAnnotationObject::loadState(kwl, prefix);
263 
264  ossim_uint32 index = 0;
265  ossimString copyPrefix = prefix;
266  ossim_uint32 count = kwl.getNumberOfSubstringKeys(copyPrefix+"v[0-9]*");
267 
268  ossim_uint32 numberOfMatches = 0;
269  const ossim_uint32 MAX_INDEX = count + 100;
270 
271  while(numberOfMatches < count)
272  {
273  ossimString key = "v";
274  key += ossimString::toString(index);
275 
276  const char* lookup = kwl.find(prefix, key.c_str());
277  if (lookup)
278  {
279  ++numberOfMatches;
280  ossimGpt gpt;
281 
282  std::istringstream is(lookup);
283  is >> gpt;
284  thePolygon.push_back(gpt);
285  }
286 
287  ++index;
288 
289  if (index > MAX_INDEX) // Avoid infinite loop...
290  {
291  break;
292  }
293  }
294 
295  // Set up the annotator.
298 
299  std::vector<ossimDpt> projectedPoints(thePolygon.size());
300  theProjectedPolyObject->setPolygon(projectedPoints);
301 
302  if (traceDebug())
303  {
305  << "ossimGeoAnnotationPolyObject::loadState DEBUG:" << std::endl;
306  for (ossim_uint32 i=0; i<thePolygon.size(); ++i)
307  {
309  << "thePolygon[" << i << "]: " << thePolygon[i] << std::endl;
310  }
311  }
312 
313  return status;
314 }
ossim_uint32 getNumberOfSubstringKeys(const ossimString &regularExpression) const
virtual void setThickness(ossim_uint8 thickness)
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
unsigned int ossim_uint32
virtual void setColor(ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
return status
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
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
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
virtual void setPolygon(const vector< ossimDpt > &imagePoints)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ print()

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

Generic print method.

Derived classes should re-implement as they see fit.

Returns
std::ostream&

Reimplemented from ossimAnnotationObject.

Definition at line 126 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::print(), thePolygon, and theProjectedPolyObject.

127 {
128  out << "number_of_points: " << thePolygon.size() << std::endl;
129  if(thePolygon.size() > 0)
130  {
131  for(long index =0; index < (long)(thePolygon.size()-1); ++index)
132  {
133  out << thePolygon[index] << std::endl;
134  }
135  out << thePolygon[thePolygon.size()-1] << std::endl;
136  }
137  out << "Projected Polygon" << std::endl;
139  return out;
140 }
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
virtual std::ostream & print(std::ostream &out) const
Generic print method.

◆ saveState()

bool ossimGeoAnnotationPolyObject::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Saves the current state of this object.

Reimplemented from ossimGeoAnnotationObject.

Definition at line 233 of file ossimGeoAnnotationPolyObject.cpp.

References ossimKeywordlist::add(), ossimString::c_str(), ossimGeoAnnotationObject::saveState(), thePolygon, and ossimString::toString().

235 {
236  ossim_uint32 vIdx = 0;
237 
238  for(ossim_uint32 i = 0; i < thePolygon.size(); ++i)
239  {
240  ossimString key = "v";
241  key += ossimString::toString(vIdx);
242 
243  kwl.add(prefix, key.c_str(), thePolygon[i].toString().c_str());
244 
245  ++vIdx;
246  }
247 
248  return ossimGeoAnnotationObject::saveState(kwl, prefix);
249 }
static ossimString toString(bool aValue)
Numeric to string methods.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the current state of this object.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
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

◆ setColor()

void ossimGeoAnnotationPolyObject::setColor ( ossim_uint8  r,
ossim_uint8  g,
ossim_uint8  b 
)
virtual

Reimplemented from ossimAnnotationObject.

Definition at line 213 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationObject::setColor(), theProjectedPolyObject, and ossimRefPtr< T >::valid().

Referenced by ossimGdalOgrVectorAnnotation::drawAnnotations().

216 {
219  {
221  }
222 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
virtual void setColor(ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)

◆ setFillFlag()

void ossimGeoAnnotationPolyObject::setFillFlag ( bool  flag)
virtual

◆ setPolygon()

void ossimGeoAnnotationPolyObject::setPolygon ( const std::vector< ossimGpt > &  poly)
virtual

Definition at line 193 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::setPolygon(), thePolygon, theProjectedPolyObject, and ossimRefPtr< T >::valid().

194 {
195  thePolygon = poly;
196  std::vector<ossimDpt> projectedPoints(thePolygon.size());
198  {
199  theProjectedPolyObject->setPolygon(projectedPoints);
200  }
201 
202 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
virtual void setPolygon(const vector< ossimDpt > &imagePoints)

◆ setPolyType()

virtual void ossimGeoAnnotationPolyObject::setPolyType ( ossimPolyType  polyType)
inlinevirtual

◆ setThickness()

void ossimGeoAnnotationPolyObject::setThickness ( ossim_uint8  thickness)
virtual

Reimplemented from ossimAnnotationObject.

Definition at line 224 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationObject::setThickness(), theProjectedPolyObject, and ossimRefPtr< T >::valid().

Referenced by ossimGdalOgrVectorAnnotation::drawAnnotations().

225 {
228  {
230  }
231 }
virtual void setThickness(ossim_uint8 thickness)
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject

◆ transform()

void ossimGeoAnnotationPolyObject::transform ( ossimImageGeometry projection)
virtual

Add the projection interface to all geographically defined objects.

Implements ossimGeoAnnotationObject.

Definition at line 106 of file ossimGeoAnnotationPolyObject.cpp.

References ossimAnnotationPolyObject::computeBoundingRect(), ossimAnnotationPolyObject::getPolygon(), thePolygon, theProjectedPolyObject, and ossimImageGeometry::worldToLocal().

Referenced by ossimGdalOgrVectorAnnotation::loadPolygon().

107 {
108  // make sure it's not null
109  if(!projection)
110  {
111  return;
112  }
114  const std::vector<ossimGpt>::size_type BOUNDS = thePolygon.size();
115 
116  for(std::vector<ossimGpt>::size_type index=0; index < BOUNDS; ++index)
117  {
118  projection->worldToLocal(thePolygon[(int)index], poly[(int)index]);
119  }
120 
121  // update the bounding rect
122  //
124 }
ossimRefPtr< ossimAnnotationPolyObject > theProjectedPolyObject
const ossimPolygon & getPolygon() const
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.

Member Data Documentation

◆ m_PolyType

ossimPolyType ossimGeoAnnotationPolyObject::m_PolyType
protected

Definition at line 97 of file ossimGeoAnnotationPolyObject.h.

◆ thePolygon

std::vector<ossimGpt> ossimGeoAnnotationPolyObject::thePolygon
protected

◆ theProjectedPolyObject

ossimRefPtr<ossimAnnotationPolyObject> ossimGeoAnnotationPolyObject::theProjectedPolyObject
protected

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