OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeoAnnotationSource.cpp
Go to the documentation of this file.
1 //************************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: See LICENSE.txt file in the top level directory.
5 //
6 // Author: Garrett Potts
7 //
8 //*************************************************************************
9 // $Id: ossimGeoAnnotationSource.cpp 19900 2011-08-04 14:19:57Z dburken $
10 
15 
17  "ossimGeoAnnotationSource",
20 
21 
23 {
25  for(ossim_uint32 index = 0; index < tempList.size(); ++index)
26  {
27  out << "output " << index << endl;
28  tempList[index]->print(out);
29  }
30 
31  return out;
32 }
33 
35  bool /* ownsProjectionFlag */ )
38  m_geometry(geom)
39 {
41 }
42 
44  ossimImageGeometry* geom,
45  bool /* ownsProjectionFlag */)
46  :ossimAnnotationSource(inputSource),
48  m_geometry(geom)
49 {
51 }
52 
54 {
55 }
56 
58 {
60 
61  if(objectToAdd)
62  {
64  if(m_geometry.valid())
65  {
66  objectToAdd->transform(m_geometry.get());
68  }
69  return true;
70  }
71 
72  return false;
73 }
74 
76 {
77  m_geometry = geom;
79 }
80 
82 {
83  bool result = false;
84  ossimProjection* proj = PTR_CAST(ossimProjection, baseObject);
85  if(proj)
86  {
87  if(m_geometry.valid())
88  {
90  }
91  else
92  {
93  m_geometry = new ossimImageGeometry(0, proj);
94  }
96  result = true;
97  }
98  else
99  {
100  m_geometry = dynamic_cast<ossimImageGeometry*>(baseObject);
101  if ( m_geometry.valid() )
102  {
103  result = true;
104  }
105  }
106  return result;
107 }
108 
110 {
111  return m_geometry.get();
112 }
113 
115 {
116  return m_geometry.get();
117 }
118 
120 {
121 // static const char *MODULE = "ossimAnnotationSource::computeBoundingRect";
122 
124 
125  if(theAnnotationObjectList.size()>0)
126  {
127  ossimDrect rect;
128  theAnnotationObjectList[0]->getBoundingRect(theRectangle);
129 
130  AnnotationObjectListType::iterator object = (theAnnotationObjectList.begin()+1);
131  while(object != theAnnotationObjectList.end())
132  {
133  (*object)->getBoundingRect(rect);
135  ++object;
136  }
137  }
138 }
139 
141 {
142  ossimRefPtr<ossimImageGeometry> tempGeom = geom;
143  if(!tempGeom)
144  {
145  tempGeom = m_geometry.get();
146  }
147 
148  if(!tempGeom) return;
149  AnnotationObjectListType::iterator currentObject;
150 
151  currentObject = theAnnotationObjectList.begin();
152 
153  while(currentObject != theAnnotationObjectList.end())
154  {
155  // this is safe since we trapped all adds to make
156  // sure that each object added to the list is
157  // geographic.
158  ossimGeoAnnotationObject* object = static_cast<ossimGeoAnnotationObject*>((*currentObject).get());
159 
160  // transform the object to image space.
161  object->transform(m_geometry.get());
162 
163  ++currentObject;
164  }
166 }
167 
169 {
170  if(!m_geometry.valid())
171  {
173  }
174  return m_geometry;
175 }
176 
178  const char* prefix)const
179 {
180  return ossimAnnotationSource::saveState(kwl, prefix);
181 }
182 
183 
185  const char* prefix)
186 {
188 
189  ossimString newPrefix = ossimString(prefix)+"view_proj.";
190  if(!m_geometry->loadState(kwl, newPrefix.c_str()))
191  {
192  m_geometry = 0;
193  }
194  else
195  {
196  if(!m_geometry->hasProjection())
197  {
198  m_geometry = 0;
199  }
200  }
201 
202  return ossimAnnotationSource::loadState(kwl, prefix);
203 }
void makeNan()
Definition: ossimDrect.h:388
ossimObject * theObject
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Attempts to initialize a transform and a projection given the KWL.
ostream & operator<<(ostream &out, const ossimGeoAnnotationSource &rhs)
RTTI_DEF2(ossimGeoAnnotationSource, "ossimGeoAnnotationSource", ossimAnnotationSource, ossimViewInterface)
virtual void transform(ossimImageGeometry *projection)=0
ossimRefPtr< ossimImageGeometry > m_geometry
ossimDrect combine(const ossimDrect &rect) const
Definition: ossimDrect.h:826
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
std::vector< ossimRefPtr< ossimAnnotationObject > > AnnotationObjectListType
virtual void setGeometry(ossimImageGeometry *projection)
const AnnotationObjectListType & getObjectList() const
virtual bool addObject(ossimAnnotationObject *anObject)
virtual bool setView(ossimObject *baseObject)
unsigned int ossim_uint32
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
virtual bool addObject(ossimAnnotationObject *anObject)
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the current state of this object.
ossimGeoAnnotationSource(ossimImageGeometry *geom=NULL, bool ownsProjectionFlag=false)
AnnotationObjectListType theAnnotationObjectList
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
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
bool hasProjection() const
Returns TRUE if valid projection defined.
virtual void transformObjects(ossimImageGeometry *geom=0)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23