OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimImageGeometryFactory.cpp
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Description: Class implementation of ossimImageGeometryFactory.
8 // See .h file for class documentation.
9 //
10 //*****************************************************************************
11 // $Id$
23 
25 
27 {
28  m_instance = this;
29 }
30 
32 {
33  if(!m_instance)
34  {
36  }
37 
38  return m_instance;
39 }
40 
42  const ossimString& typeName)const
43 {
44  if(typeName == "ossimImageGeometry")
45  {
46  return new ossimImageGeometry();
47  }
48 
49  return 0;
50 }
51 
53  const ossimKeywordlist& kwl, const char* prefix)const
54 {
56  ossimString type = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
57  if(!type.empty())
58  {
59  result = createGeometry(type);
60  if(result.valid()&&!result->loadState(kwl, prefix))
61  {
62  result = 0;
63  }
64  }
65 
66  return result.release();
67 }
68 
70  const ossimFilename& /* filename */, ossim_uint32 /* entryIdx */)const
71 {
72  // currently don't support this option just yet by this factory
73  return 0;
74 }
75 
77 {
78  bool result = false;
79  if (handler)
80  {
81  bool add2D = true;
83  if(geom.valid())
84  {
85  if(!geom->getProjection())
86  {
87  geom->setProjection(createProjection(handler));
88  result = geom->hasProjection();
89  }
90  if(geom->getProjection())
91  {
92  if( !(dynamic_cast<ossimSensorModel*>(geom->getProjection())))
93  {
94  add2D = false;
95  }
96  }
97  if(!geom->getTransform()&&add2D)
98  {
99  geom->setTransform(createTransform(handler));
100  result |= geom->hasTransform();
101  }
102  }
103  }
104  return result;
105 }
106 
108  std::vector<ossimString>& typeList)const
109 {
110  typeList.push_back("ossimImageGeometry");
111 }
112 
114  ossimImageHandler* handler)const
115 {
116  // Currently nothing to do...
117 
119 
120  ossimNitfTileSource* nitf = dynamic_cast<ossimNitfTileSource*> (handler);
121 
122  if(nitf)
123  {
124  result = createTransformFromNitf(nitf);
125  }
126 
127  return result.release();
128 }
129 
131  ossimImageHandler* handler) const
132 {
135 
136  return result.release();
137 }
138 
140 {
141  ossim2dTo2dTransform* result = 0;
142 
144  if (!hdr)
145  {
146  return result;
147  }
148 
149  //---
150  // Test for the ichipb tag and set the sub image if needed.
151  //
152  // NOTE # 1:
153  //
154  // There are nitf writers that set the ichipb offsets and only have
155  // IGEOLO field present. For these it has been determined
156  // (but still in question) that we should not apply the sub image offset.
157  //
158  // See trac # 1578
159  // http://trac.osgeo.org/ossim/ticket/1578
160  //
161  // NOTE # 2:
162  //
163  // Let the ICHIPB have precedence over the STDIDC tag as we could have a
164  // chip of a segment.
165  //---
167  hdr->getTagData(ossimString("ICHIPB"));
168  if (tag.valid())
169  {
171  if (ichipb)
172  {
173 // const ossimRefPtr<ossimNitfRegisteredTag> blocka =
174 // hdr->getTagData(ossimString("BLOCKA"));
175 // const ossimRefPtr<ossimNitfRegisteredTag> rpc00a =
176 // hdr->getTagData(ossimString("RPC00A"));
177 // const ossimRefPtr<ossimNitfRegisteredTag> rpc00b =
178 // hdr->getTagData(ossimString("RPC00B"));
179 
180  //---
181  // If any of these tags are present we will use the sub image from
182  // the ichipb tag.
183  //---
184 // if ( blocka.get() || rpc00a.get() || rpc00b.get() )
185 
186  // ************************* THERE ARE PROBLEMS NOT SETTING THIS AT SITE. GO AHEAD AND ALWAYS INIT THE SHIFT
187  {
188  result = ichipb->newTransform();
189  }
190  }
191  }
192 
193  if ( !result)
194  {
195  //---
196  // Look for the STDIDC tag for a sub image (segment) offset.
197  //
198  // See: STDI-002 Table 7.3 for documentation.
199  //---
200  tag = hdr->getTagData(ossimString("STDIDC"));
201  if (tag.valid() && (hdr->getIMode() == "B") )
202  {
203  ossimDpt shift;
205  if (stdidc)
206  {
207  ossim_int32 startCol = stdidc->getStartColumn().toInt32();
208  ossim_int32 startRow = stdidc->getStartRow().toInt32();
209  if ( (startCol > 0) && (startRow > 0) )
210  {
211 
212  // field are one based; hence, the - 1.
213  shift.x = (startCol-1) * hdr->getNumberOfPixelsPerBlockHoriz();
214  shift.y = (startRow-1) * hdr->getNumberOfPixelsPerBlockVert();
215  }
216  if(shift.x > 0 ||
217  shift.y > 0)
218  {
219  result = new ossim2dTo2dShiftTransform(shift);
220  }
221  }
222  }
223  }
224 
225  return result;
226 }
227 
static ossimImageGeometryFactory * m_instance
ossimString getStartRow() const
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
virtual ossimImageGeometry * createGeometry(const ossimString &typeName) const
static ossimImageGeometryFactory * instance()
Represents serializable keyword/value map.
virtual ossimString getIMode() const =0
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.
const char * find(const char *key) const
double y
Definition: ossimDpt.h:165
static const char * TYPE_KW
virtual bool extendGeometry(ossimImageHandler *handler) const
ossim_int32 toInt32() const
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
unsigned int ossim_uint32
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
T * release()
Definition: ossimRefPtr.h:93
const ossimNitfImageHeader * getCurrentImageHeader() const
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
static ossimProjectionFactoryRegistry * instance()
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual ossim_int32 getNumberOfPixelsPerBlockVert() const =0
This class defines an abstract Handler which all image handlers(loaders) should derive from...
void setTransform(ossim2dTo2dTransform *transform)
Sets the transform to be used for local-to-full-image coordinate transformation.
virtual ossim2dTo2dTransform * createTransform(ossimImageHandler *handler) const
This is a utility method used by crateGeoemtry that takes an image handler.
double x
Definition: ossimDpt.h:164
ossimRefPtr< ossimNitfRegisteredTag > getTagData(const ossimString &tagName)
bool empty() const
Definition: ossimString.h:411
virtual ossim2dTo2dTransform * createTransformFromNitf(ossimNitfTileSource *handler) const
const ossim2dTo2dTransform * getTransform() const
Access methods for transform (may be NULL pointer).
ossim2dTo2dTransform * newTransform() const
bool hasProjection() const
Returns TRUE if valid projection defined.
ossimString getStartColumn() const
virtual ossim_int32 getNumberOfPixelsPerBlockHoriz() const =0
bool hasTransform() const
Returns TRUE if valid transform defined.
virtual ossimProjection * createProjection(ossimImageHandler *handler) const
Utility method to create a projection from an image handler.
int ossim_int32