OTB  6.7.0
Orfeo Toolbox
otbVectorImage.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbVectorImage_hxx
22 #define otbVectorImage_hxx
23 
24 
25 #include "otbVectorImage.h"
27 #include "otbImageKeywordlist.h"
28 #include "itkMetaDataObject.h"
29 
30 namespace otb
31 {
32 
33 template <class TPixel, unsigned int VImageDimension>
35 {
36 }
37 
38 template <class TPixel, unsigned int VImageDimension>
40 {
41  return (this->GetMetaDataInterface()->GetProjectionRef());
42 }
43 
44 template <class TPixel, unsigned int VImageDimension>
46 {
47  itk::EncapsulateMetaData<std::string>(this->GetMetaDataDictionary(), MetaDataKey::ProjectionRefKey, kwl);
48 }
49 
50 
51 template <class TPixel, unsigned int VImageDimension>
53 {
54  return (this->GetMetaDataInterface()->GetGCPProjection());
55 }
56 
57 template <class TPixel, unsigned int VImageDimension>
59 {
60  return (this->GetMetaDataInterface()->GetGCPCount());
61 }
62 
63 template <class TPixel, unsigned int VImageDimension>
65 {
66  return (this->GetMetaDataInterface()->GetGCPs(GCPnum));
67 }
68 
69 template <class TPixel, unsigned int VImageDimension>
70 const OTB_GCP& VectorImage<TPixel, VImageDimension>::GetGCPs(unsigned int GCPnum) const
71 {
72  return (this->GetMetaDataInterface()->GetGCPs(GCPnum));
73 }
74 
75 template <class TPixel, unsigned int VImageDimension>
76 std::string VectorImage<TPixel, VImageDimension>::GetGCPId(unsigned int GCPnum) const
77 {
78  return (this->GetMetaDataInterface()->GetGCPId(GCPnum));
79 }
80 
81 template <class TPixel, unsigned int VImageDimension>
82 std::string VectorImage<TPixel, VImageDimension>::GetGCPInfo(unsigned int GCPnum) const
83 {
84  return (this->GetMetaDataInterface()->GetGCPInfo(GCPnum));
85 }
86 
87 template <class TPixel, unsigned int VImageDimension>
88 double VectorImage<TPixel, VImageDimension>::GetGCPRow(unsigned int GCPnum) const
89 {
90  return (this->GetMetaDataInterface()->GetGCPRow(GCPnum));
91 }
92 
93 template <class TPixel, unsigned int VImageDimension>
94 double VectorImage<TPixel, VImageDimension>::GetGCPCol(unsigned int GCPnum) const
95 {
96  return (this->GetMetaDataInterface()->GetGCPCol(GCPnum));
97 }
98 
99 template <class TPixel, unsigned int VImageDimension>
100 double VectorImage<TPixel, VImageDimension>::GetGCPX(unsigned int GCPnum) const
101 {
102  return (this->GetMetaDataInterface()->GetGCPX(GCPnum));
103 }
104 
105 template <class TPixel, unsigned int VImageDimension>
106 double VectorImage<TPixel, VImageDimension>::GetGCPY(unsigned int GCPnum) const
107 {
108  return (this->GetMetaDataInterface()->GetGCPY(GCPnum));
109 }
110 
111 template <class TPixel, unsigned int VImageDimension>
112 double VectorImage<TPixel, VImageDimension>::GetGCPZ(unsigned int GCPnum) const
113 {
114  return (this->GetMetaDataInterface()->GetGCPZ(GCPnum));
115 }
116 
117 template <class TPixel, unsigned int VImageDimension>
119 {
120  return (this->GetMetaDataInterface()->GetGeoTransform());
121 }
122 
123 template <class TPixel, unsigned int VImageDimension>
125 {
126  return (this->GetMetaDataInterface()->GetUpperLeftCorner());
127 }
128 
129 template <class TPixel, unsigned int VImageDimension>
131 {
132  return (this->GetMetaDataInterface()->GetUpperRightCorner());
133 }
134 
135 template <class TPixel, unsigned int VImageDimension>
137 {
138  return (this->GetMetaDataInterface()->GetLowerLeftCorner());
139 }
140 
141 template <class TPixel, unsigned int VImageDimension>
143 {
144  return (this->GetMetaDataInterface()->GetLowerRightCorner());
145 }
146 
147 template <class TPixel, unsigned int VImageDimension>
149 {
150  auto spacing = this->GetSpacing();
151  for (unsigned int i = 0; i < VImageDimension; ++i)
152  {
153  if (this->m_Direction[i][i] < 0)
154  spacing[i] = -spacing[i];
155  }
156  return spacing;
157 }
158 
159 template <class TPixel, unsigned int VImageDimension>
161 {
162 
163  for (unsigned int i = 0; i < VImageDimension; i++)
164  {
165  if (spacing[i] < 0.0)
166  {
167  if (this->m_Direction[i][i] > 0)
168  {
169  for (unsigned j = 0; j < VImageDimension; ++j)
170  {
171  this->m_Direction[j][i] = -this->m_Direction[j][i];
172  }
173  }
174  spacing[i] = -spacing[i];
175  }
176  }
177  this->SetSpacing(spacing);
178  this->ComputeIndexToPhysicalPointMatrices();
179  this->Modified();
180 }
181 
182 template <class TPixel, unsigned int VImageDimension>
183 void VectorImage<TPixel, VImageDimension>::SetSignedSpacing(double spacing[VImageDimension])
184 {
185  SpacingType s(spacing);
186  this->SetSignedSpacing(s);
187 }
188 
189 template <class TPixel, unsigned int VImageDimension>
191 {
192  ImageKeywordlist kwl;
193 
194  itk::ExposeMetaData<ImageKeywordlist>(this->GetMetaDataDictionary(), MetaDataKey::OSSIMKeywordlistKey, kwl);
195  return kwl;
196 }
197 
198 template <class TPixel, unsigned int VImageDimension>
200 {
201  ImageKeywordlist kwl;
202 
203  itk::ExposeMetaData<ImageKeywordlist>(this->GetMetaDataDictionary(), MetaDataKey::OSSIMKeywordlistKey, kwl);
204  return kwl;
205 }
206 
207 template <class TPixel, unsigned int VImageDimension>
209 {
210  itk::EncapsulateMetaData<ImageKeywordlistType>(this->GetMetaDataDictionary(), MetaDataKey::OSSIMKeywordlistKey, kwl);
211 }
212 
213 
214 template <class TPixel, unsigned int VImageDimension>
216 {
217  Superclass::CopyInformation(data);
219 }
220 
221 template <class TPixel, unsigned int VImageDimension>
223 {
224  if (m_ImageMetadataInterface.IsNull())
225  m_ImageMetadataInterface = ImageMetadataInterfaceFactory::CreateIMI(this->GetMetaDataDictionary());
226  return m_ImageMetadataInterface;
227 }
228 
229 template <class TPixel, unsigned int VImageDimension>
231 {
232  Superclass::PrintSelf(os, indent);
233  this->GetMetaDataInterface()->PrintMetadata(os, indent, this->GetMetaDataDictionary());
234 }
235 
236 } // end namespace otb
237 #endif
virtual double GetGCPCol(unsigned int GCPnum) const
Creation of an "otb" vector image which contains metadata.
void SetMetaDataDictionary(const MetaDataDictionary &rhs)
virtual VectorType GetLowerRightCorner(void) const
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Storage and conversion for OSSIM metadata.
static ImageMetadataInterfaceBasePointerType CreateIMI(const MetaDataDictionaryType &dict)
virtual void SetImageKeywordList(const ImageKeywordlistType &kwl)
This OTB_GCP class is used to manage the GCP parameters in OTB.
void SetSignedSpacing(InputImage *input, SpacingType spacing)
Definition: otbImage.h:53
OTBOSSIMAdapters_EXPORT char const * ProjectionRefKey
virtual unsigned int GetGCPCount(void) const
virtual void SetSignedSpacing(SpacingType spacing)
virtual VectorType GetUpperLeftCorner(void) const
MetaDataDictionary & GetMetaDataDictionary()
virtual VectorType GetGeoTransform(void) const
virtual std::string GetGCPId(unsigned int GCPnum) const
virtual double GetGCPZ(unsigned int GCPnum) const
virtual std::string GetGCPProjection(void) const
void CopyInformation(const itk::DataObject *) override
Copy metadata from a DataObject.
virtual VectorType GetLowerLeftCorner(void) const
virtual double GetGCPY(unsigned int GCPnum) const
virtual ImageKeywordlistType GetImageKeywordlist(void)
virtual double GetGCPRow(unsigned int GCPnum) const
virtual void SetProjectionRef(const std::string &wkt)
virtual VectorType GetUpperRightCorner(void) const
virtual OTB_GCP & GetGCPs(unsigned int GCPnum)
virtual std::string GetProjectionRef(void) const
virtual std::string GetGCPInfo(unsigned int GCPnum) const
SpacingType GetSignedSpacing() const
OTBOSSIMAdapters_EXPORT char const * OSSIMKeywordlistKey
virtual double GetGCPX(unsigned int GCPnum) const
ImageMetadataInterfacePointerType GetMetaDataInterface() const