OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimQuickbirdTiffTileSource.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 // Copyright (c) 2005, David Burken, all rights reserved.
3 //
4 // License: See top level LICENSE.txt file.
5 //
6 // Author: David Burken
7 //
8 // Copied from ossimQuickbirdTiffTileSource written by Garrett Potts.
9 //
10 // Description:
11 //
12 // Class definition for specialized image handler to pick up offsets from
13 // Quick Bird ".TIL" files.
14 //
15 //----------------------------------------------------------------------------
16 // $Id: ossimQuickbirdTiffTileSource.cpp 21631 2012-09-06 18:10:55Z dburken $
17 
23 #include <ossim/base/ossimTrace.h>
24 
26  "ossimQuickbirdTiffTileSource",
28 
29 static const ossimTrace traceDebug("ossimQuickbirdTiffTileSource:debug");
30 
31 //*************************************************************************************************
32 // Checks for presence of required info before flagging successful open
33 //*************************************************************************************************
35 {
36  static const char M[] = "ossimQuickbirdTiffTileSource::open()";
37 
38  bool result = false;
39 
40  if(traceDebug())
41  {
42  ossimNotify(ossimNotifyLevel_DEBUG) << M << " ENTERED ..." << std::endl;
43  }
44 
46 
47  // QB is recognized by the presence of a tile info file. Fail if not present:
49 
50  if ( !m_tileInfoFilename.exists() )
51  {
53  }
54 
55  if ( m_tileInfoFilename.exists() )
56  {
57  // Call the base class open...
58  result = ossimTiffTileSource::open();
59  }
60 
61 
62  if(traceDebug())
63  {
64  ossimNotify(ossimNotifyLevel_DEBUG) << M << " result=" << (result?"true\n":"false\n");
65  }
66 
67  return result;
68 }
69 
70 //*************************************************************************************************
71 // I know what I am. I am a Quickbird TIFF image. I may be standalone or tiled with row-column
72 // designation in the file name. My projection information is available (possibly) in an
73 // accompanying RPC file and/or internal TIF tag, and my transform info (sub-image offset) is
74 // available in a TILE info file (*.til) or internal TIF tag. Therefore, I (and not some outside
75 // factory) am best qualified for establishing my image geometry.
76 //*************************************************************************************************
78 {
79  if ( !theGeometry )
80  {
81  //---
82  // Check factory for external geom:
83  //---
85 
86  if ( !theGeometry )
87  {
89 
90  // Fetch the tile info for this particular image:
91  if ( m_tileInfoFilename.size() )
92  {
93  ossimQuickbirdTile tileFile;
94  if ( tileFile.open(m_tileInfoFilename) )
95  {
97  bool infoStatus = tileFile.getInfo(info, theImageFile.file().upcase());
98  if ( !infoStatus )
99  {
100  infoStatus = tileFile.getInfo(info, theImageFile.file().downcase());
101  }
102 
103  if ( infoStatus )
104  {
105  // Next is the projection part of the image geometry. This should be available
106  // as an external RPC file or internal RPC's in the tiff file. Otherwise use
107  // the map projection specified in the
108  // tiff file:
110 
112  if (model->parseFile(theImageFile))
113  {
114  //---
115  // If RPC projection set the sub-image offset:
116  // Establish sub-image offset (shift) for this tile:
117  //---
118  ossimDpt shift(0,0);
119  if ((info.theUlXOffset != OSSIM_INT_NAN) &&
120  (info.theUlYOffset != OSSIM_INT_NAN))
121  shift = ossimIpt(info.theUlXOffset, info.theUlYOffset);
122 
123  if(traceDebug())
124  {
126  << "ossimQuickbirdTiffTileSource::open() DEBUG:"
127  << "\nSub image offset = " << shift << std::endl;
128  }
129 
130  // Create the transform and set it in the geometry object:
132  new ossim2dTo2dShiftTransform(shift);
133 
134  theGeometry->setTransform(transform.get());
135  theGeometry->setProjection(model.get());
136  }
137  else
138  {
139  // Last resort to a projection factory:
142  if (proj.valid()) theGeometry->setProjection(proj.get());
143  }
144  }
145 
146  // Set image things the geometry object should know about.
148  }
149  }
150  }
151  }
152 
153  return theGeometry;
154 }
155 
156 
ossimRefPtr< ossimImageGeometry > theGeometry
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossimFilename noExtension() const
bool open()
Returns true if no errors initializing object.
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
ossimFilename theImageFile
bool open(const ossimFilename tileFile)
bool valid() const
Definition: ossimRefPtr.h:75
#define OSSIM_INT_NAN
RTTI_DEF1(ossimQuickbirdTiffTileSource, "ossimQuickbirdTiffTileSource", ossimTiffTileSource)
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual bool open()
Pure virtual open.
ossimString replaceAllThatMatch(const char *regularExpressionPattern, const char *value="") const
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
bool getInfo(ossimQuickbirdTileInfo &result, const ossimFilename &filename) const
bool exists() const
std::string::size_type size() const
Definition: ossimString.h:405
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
static ossimProjectionFactoryRegistry * instance()
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
void setTransform(ossim2dTo2dTransform *transform)
Sets the transform to be used for local-to-full-image coordinate transformation.
ossimFilename file() const
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool parseFile(const ossimFilename &file)
Public method for parsing generic image file.