OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimProjectionFactoryBase.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Garrett Potts
9 //*******************************************************************
10 // $Id: ossimProjectionFactoryBase.cpp 22626 2014-02-11 22:18:06Z dburken $
11 
17 //---
18 // Define Trace flags for use within this file:
19 //---
20 #include <ossim/base/ossimTrace.h>
21 static ossimTrace traceDebug = ossimTrace("ossimProjectionFactoryBase:debug");
22 
23 RTTI_DEF1(ossimProjectionFactoryBase, "ossimProjectionFactoryBase", ossimObjectFactory);
24 
26 {
27  if (traceDebug())
28  {
30  << "ossimProjectionFactoryBase::createProjectionFromGeometryFile "
31  << "DEBUG:"
32  << "\nimageFile: " << imageFile
33  << "\nentryIdx: " << entryIdx
34  << std::endl;
35  }
36 
37  // Try to find a geometry file for imageFile.
38 
39  ossimFilename geomFile = imageFile;
40  if (entryIdx == 0)
41  {
42  geomFile.setExtension("geom");
43  if(geomFile.exists())
44  {
45  if (traceDebug())
46  {
48  << "Found geometry file: " << geomFile
49  << std::endl;
50  }
51 
52  ossimKeywordlist kwl;
53  if(kwl.addFile(geomFile))
54  {
55  //---
56  // Add the geometry file to the keyword list.
57  // This was added for ossimCoarseGridModel so it can pick up the
58  // file.ocg with a relative path.
59  //
60  // NOTE: The can't be called "geometry_file" as it causes an infinite loop in the factory
61  // code. (drb - 20140211)
62  //---
63  kwl.addPair( std::string("kwl_source"),
64  geomFile.expand().string(),
65  false); // Don't overwrite if in there already.
66 
68  createProjection(kwl);
69  }
70  }
71  }
72 
73  // Look for an indexed geometry file.
74  geomFile = imageFile.fileNoExtension();
75  geomFile += "_e";
76  geomFile += ossimString::toString(entryIdx);
77  geomFile.setExtension("geom");
78  if(geomFile.exists())
79  {
80  if (traceDebug())
81  {
83  << "Found geometry file: " << geomFile
84  << std::endl;
85  }
86 
87  ossimKeywordlist kwl;
88  if(kwl.addFile(geomFile))
89  {
91  createProjection(kwl);
92  }
93  }
94 
95  if (traceDebug())
96  {
98  << "DEBUG: No geometry file found. Returning NULL..."
99  << std::endl;
100  }
101 
102  return NULL;
103 }
104 
106 {
107  if(!handler) return 0;
108  return createProjection(handler->getFilename(), handler->getCurrentEntry());
109 }
110 
ossimProjection * createProjectionFromGeometryFile(const ossimFilename &imageFile, ossim_uint32 entryIdx) const
This method takes the filename and tries to find an external ".geom" file.
Represents serializable keyword/value map.
bool addFile(const char *file)
ossimFilename expand() const
Method to do file name expansion.
static ossimString toString(bool aValue)
Numeric to string methods.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const =0
takes a filename.
RTTI_DEF1(ossimProjectionFactoryBase, "ossimProjectionFactoryBase", ossimObjectFactory)
bool exists() const
virtual const ossimFilename & getFilename() const
Returns the filename.
unsigned int ossim_uint32
virtual ossim_uint32 getCurrentEntry() const
static ossimProjectionFactoryRegistry * instance()
This class defines an abstract Handler which all image handlers(loaders) should derive from...
ossimFilename fileNoExtension() const
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414