OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimMetadataFileWriter.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2003 Stroage Area Networks, Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Kenneth Melero (kmelero@sanz.com)
9 //
10 //*******************************************************************
11 // $Id: ossimMetadataFileWriter.cpp 17195 2010-04-23 17:32:18Z dburken $
12 
14 #include <ossim/base/ossimTrace.h>
23 
25  "ossimMetadataFileWriter",
29 
30 static ossimTrace traceDebug("ossimMetadataFileWriter:debug");
31 
36  theInputConnection(NULL),
37  theFilename(),
38  thePixelType(OSSIM_PIXEL_IS_POINT),
39  theAreaOfInterest()
40 {
43 }
44 
46 {
48 }
49 
51 {
52  theInputConnection = dynamic_cast<ossimImageSource*> (getInput(0));
53 }
54 
56  const char* prefix)
57 {
58  bool result = ossimConnectableObject::loadState(kwl, prefix);
59 
60  // Get the filename...
61  const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
62  if(lookup)
63  {
64  ossimString filename = lookup;
65 
66  setFilename(filename);
67  }
68 
69  // Note: Defaulted to point in constructor.
70  lookup = kwl.find(prefix, ossimKeywordNames::PIXEL_TYPE_KW);
71  if (lookup)
72  {
73  ossimString s = lookup;
74  s.downcase();
75  if (s.contains("area"))
76  {
78  }
79  else if (s.contains("point"))
80  {
82  }
83  }
84 
85  if(theInputObjectList.size() != 1)
86  {
87  theInputObjectList.resize(1);
89  }
90 
92 
93  return result;
94 }
95 
97 {
98  initialize();
99 }
100 
102 {
103  initialize();
104 }
105 
107 {
108  initialize();
109 }
110 
112 {
113  thePixelType = pixelType;
114 }
115 
117 {
118  return thePixelType;
119 }
120 
122 {
123  return this;
124 }
125 
127 {
128  return this;
129 }
130 
132 {
133  bool result = false;
134  if (!theInputConnection)
135  {
136  initialize();
137  if (!theInputConnection)
138  {
139  if (traceDebug())
140  {
142  << "ossimMetadataFileWriter::execute DEBUG:\n"
143  << "theInputConnection is null!"
144  << endl;
145  }
146  return result;
147  }
148  }
149 
151  {
152  if (traceDebug())
153  {
155  << "ossimMetadataFileWriter::execute DEBUG:\n"
156  << "theFilename is not set!"
157  << endl;
158  }
159  return result;
160  }
161 
162  //---
163  // If theAreaOfInterest hasNans then it was probably not set so use
164  // the bounding rectangle of the input source.
165  //---
167  {
170  {
171  if (traceDebug())
172  {
174  << "ossimMetadataFileWriter::execute DEBUG:\n"
175  << "theAreaOfInterest is not set!"
176  << endl;
177  }
178  return result;
179  }
180  }
181 
183 
184  setPercentComplete(0.0);
185 
186  result = writeFile();
187 
189 
190  if (traceDebug())
191  {
193  << "ossimMetadataFileWriter::execute DEBUG:\n"
194  << (result?"successful":"unsuccessful") << " write of file: "
195  << theFilename
196  << endl;
197  }
198 
199  return result;
200 }
201 
203 {
205  ossimProcessProgressEvent event(this,
206  percentComplete);
207  fireEvent(event);
208 }
209 
211 {
212  theFilename = file;
213 }
214 
216 {
217  return theFilename;
218 }
219 
221  const ossimConnectableObject* object) const
222 {
223  return (object &&
224  ((PTR_CAST(ossimImageSource, object) &&
225  inputIndex == 0)||
226  (PTR_CAST(ossimViewController, object) &&
227  inputIndex == 1)));
228 }
229 
231  const ossimIrect& areaOfInterest)
232 {
233  theAreaOfInterest = areaOfInterest;
234 }
235 
237 {
238  return theAreaOfInterest;
239 }
240 
242 {
243  if(!property.valid())return;
244 
245  ossimString name = property->getName();
246 
248  {
249  setFilename(property->valueToString());
250  }
251  else
252  {
254  }
255 }
256 
258 {
260  {
261  ossimFilenameProperty* filenameProp =
263 
265 
266  return filenameProp;
267 
268  }
269 
271 }
272 
273 void ossimMetadataFileWriter::getPropertyNames(std::vector<ossimString>& propertyNames)const
274 {
276  propertyNames.push_back(ossimKeywordNames::FILENAME_KW);
277 }
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual void valueToString(ossimString &valueResult) const =0
virtual bool addListener(ossimListener *listener)
virtual bool writeFile()=0
Write out the file.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual void setAreaOfInterest(const ossimIrect &areaOfInterest)
Sets the area of interest to write the meta data for.
const ossimFilename & getFilename() const
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
Represents serializable keyword/value map.
virtual void disconnectInputEvent(ossimConnectionEvent &event)
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
bool contains(char aChar) const
Definition: ossimString.h:58
virtual void propertyEvent(ossimPropertyEvent &event)
virtual void setPercentComplete(double percentComplete)
virtual ossimIrect getAreaOfInterest() const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Load state method:
virtual void setProcessStatus(ossimProcessStatus processStatus)
virtual void fireEvent(ossimEvent &event)
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
virtual void setPercentComplete(double percentComplete)
virtual void connectInputEvent(ossimConnectionEvent &event)
ossimMetadataFileWriter
virtual ossimPixelType getPixelType() const
virtual void setProperty(ossimRefPtr< ossimProperty > property)
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual ossimObject * getObject()
ossimPixelType
ConnectableObjectList theInputObjectList
Holds a list of input objects.
virtual void setPixelType(ossimPixelType pixelType)
Ossim uses a concept of "pixel is point" internally.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
void setIoType(ossimFilenamePropertyIoType ioType)
void makeNan()
Definition: ossimIrect.h:329
static const char * PIXEL_TYPE_KW
bool theInputListIsFixedFlag
Indicates whether the theInputObjectList is fixed.
bool canConnectMyInputTo(ossim_int32 inputIndex, const ossimConnectableObject *object) const
required to be overriden by derived classes
virtual void setFilename(const ossimFilename &file)
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
bool hasNans() const
Definition: ossimIrect.h:337
ossimImageSource * theInputConnection
bool theOutputListIsFixedFlag
Indicates whether the theOutputObjectList is fixed.
static const char * FILENAME_KW
RTTI_DEF3(ossimMetadataFileWriter, "ossimMetadataFileWriter", ossimConnectableObject, ossimProcessInterface, ossimConnectableObjectListener)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32
virtual bool removeListener(ossimListener *listener)