21 #ifndef otbImageToOSMVectorDataGenerator_hxx
22 #define otbImageToOSMVectorDataGenerator_hxx
32 template <
class TImage>
35 this->SetNumberOfRequiredInputs(1);
36 this->SetNumberOfRequiredOutputs(1);
38 m_ImageExtent.minX = 0;
39 m_ImageExtent.maxX = 0;
40 m_ImageExtent.minY = 0;
41 m_ImageExtent.maxY = 0;
44 template <
class TImage>
48 this->itk::ProcessObject::SetNthInput(0,
const_cast<ImageType*
>(input));
52 template <
class TImage>
55 if (this->GetNumberOfInputs() < 1)
60 return static_cast<const ImageType*
>(this->itk::ProcessObject::GetInput(0));
64 template <
class TImage>
68 this->EstimateImageExtent();
70 this->SetWest(m_ImageExtent.minX);
71 this->SetSouth(m_ImageExtent.minY);
72 this->SetEast(m_ImageExtent.maxX);
73 this->SetNorth(m_ImageExtent.maxY);
75 Superclass::GenerateData();
78 template <
class TImage>
82 typename ImageType::ConstPointer input = this->GetInput();
86 typename TransformType::Pointer transform = TransformType::New();
87 transform->SetInputImageMetadata(&(input->GetImageMetadata()));
88 transform->SetInputProjectionRef(input->GetProjectionRef());
90 transform->InstantiateTransform();
93 std::vector<IndexType> vindex;
94 std::vector<PointType> voutput;
100 size = input->GetLargestPossibleRegion().GetSize();
103 index1 = input->GetLargestPossibleRegion().GetIndex();
104 index2 = input->GetLargestPossibleRegion().GetIndex();
105 index3 = input->GetLargestPossibleRegion().GetIndex();
106 index4 = input->GetLargestPossibleRegion().GetIndex();
108 index2[0] += size[0] - 1;
109 index3[0] += size[0] - 1;
110 index3[1] += size[1] - 1;
111 index4[1] += size[1] - 1;
113 vindex.push_back(index1);
114 vindex.push_back(index2);
115 vindex.push_back(index3);
116 vindex.push_back(index4);
118 for (
unsigned int i = 0; i < vindex.size(); ++i)
121 input->TransformIndexToPhysicalPoint(vindex[i], physicalPoint);
122 otbMsgDevMacro(<<
" physical point " << physicalPoint <<
" --> Transform " << transform->TransformPoint(physicalPoint));
123 voutput.push_back(transform->TransformPoint(physicalPoint));
127 double minX = voutput[0][0];
128 double maxX = voutput[0][0];
129 double minY = voutput[0][1];
130 double maxY = voutput[0][1];
132 for (
unsigned int i = 0; i < voutput.size(); ++i)
135 if (minX > voutput[i][0])
136 minX = voutput[i][0];
137 if (minY > voutput[i][1])
138 minY = voutput[i][1];
141 if (maxX < voutput[i][0])
142 maxX = voutput[i][0];
144 if (maxY < voutput[i][1])
145 maxY = voutput[i][1];
149 m_ImageExtent.maxX = maxX;
150 m_ImageExtent.minX = minX;
151 m_ImageExtent.maxY = maxY;
152 m_ImageExtent.minY = minY;