OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTiffProjectionFactory.cpp
Go to the documentation of this file.
1 //*****************************************************************************
2 // FILE: ossimTiffProjectionFactory.cc
3 //
4 // License: See top level LICENSE.txt file.
5 //
6 // DESCRIPTION:
7 // Contains implementation of class ossimTiffProjectionFactory
8 //
9 //*****************************************************************************
10 // $Id: ossimTiffProjectionFactory.cpp 17108 2010-04-15 21:08:06Z dburken $
11 
21 #include <fstream>
22 
24 
25 //*****************************************************************************
26 // STATIC METHOD: ossimTiffProjectionFactory::instance()
27 //
28 //*****************************************************************************
30 {
31  if(!theInstance)
32  {
34  }
35 
37 }
38 
41  ossim_uint32 entryIdx)const
42 {
43  std::shared_ptr<ossim::TiffHandlerState> state = std::make_shared<ossim::TiffHandlerState>();
44  if(state->loadDefaults(filename))
45  {
46  ossimGeoTiff geotiff;
47  ossimKeywordlist kwl;
48  if(geotiff.readTags(state, entryIdx))
49  {
50  if(geotiff.addImageGeometry(kwl))
51  {
53  }
54  }
55  }
56  return 0;
57 }
58 
59 //*****************************************************************************
60 // METHOD: ossimSensorModelFactory::create(kwl, prefix)
61 //
62 //*****************************************************************************
65  const char* /* prefix */) const
66 {
67  return 0;
68 }
69 
70 //*****************************************************************************
71 // METHOD: ossimSensorModelFactory::create(projection_name)
72 //
73 //*****************************************************************************
75 {
76  return 0;
77 }
78 
80 {
81  ossimTiffTileSource* tiff = dynamic_cast<ossimTiffTileSource*> (handler);
82 
83  if(tiff)
84  {
85  ossimGeoTiff geotiff;
86  ossimKeywordlist kwl;
87  std::shared_ptr<ossim::TiffHandlerState> state = std::dynamic_pointer_cast<ossim::TiffHandlerState>(tiff->getState());
88  bool addGeometry = false;
89  if(state)
90  {
91  addGeometry = geotiff.readTags(state,
92  tiff->getCurrentEntry());
93  }
94  else
95  {
96  addGeometry = geotiff.readTags(tiff->tiffPtr(),
97  tiff->getCurrentEntry(), false);
98  }
99  if(addGeometry&&geotiff.addImageGeometry(kwl))
100  {
102  }
103  }
104 
105  return 0;
106 }
107 
109 {
110  return (ossimObject*)createProjection(typeName);
111 }
112 
114  const char* prefix)const
115 {
116  return createProjection(kwl, prefix);
117 }
118 
119 void ossimTiffProjectionFactory::getTypeNameList(std::vector<ossimString>& /* typeList */)const
120 {
121 }
122 
124 {
125  std::ifstream in;
126  unsigned char header[2];
127 
128  in.open( filename.c_str(), ios::in|ios::binary);
129  if( !in)
130  return false;
131 
132  in.read( (char*)header, 2);
133 
134  if( (header[0] != 'M' || header[1] != 'M')
135  && (header[0] != 'I' || header[1] != 'I') )
136  {
137  return false;
138  }
139 
140  return true;
141 }
bool isTiff(const ossimFilename &filename) const
static ossimTiffProjectionFactory * instance()
static ossimTiffProjectionFactory * theInstance
bool addImageGeometry(ossimKeywordlist &kwl, const char *prefix=0) const
Add geometry info from tags to keword list.
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
std::shared_ptr< ossim::ImageHandlerState > getState()
virtual ossimObject * createObject(const ossimString &typeName) const
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
takes a 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...
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 readTags(const ossimFilename &file, ossim_uint32 entryIdx=0)
Reads tags.
virtual void getTypeNameList(std::vector< ossimString > &typeList) const