diff --git a/Code/Projections/otbVectorDataTransformFilter.h b/Code/Projections/otbVectorDataTransformFilter.h index 969bd63da5103312644c2a59be79e95666ab2a47..9c47ebd8a44aee27a9c44a3d6801e793718ff43a 100644 --- a/Code/Projections/otbVectorDataTransformFilter.h +++ b/Code/Projections/otbVectorDataTransformFilter.h @@ -45,15 +45,16 @@ class ITK_EXPORT VectorDataTransformFilter : public: /** Standard class typedefs. */ - typedef VectorDataTransformFilter Self; - typedef otb::VectorDataToVectorDataFilter<TInputVectorData,TOutputVectorData> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef TInputVectorData InputVectorDataType; - typedef TOutputVectorData OutputVectorDataType; + typedef VectorDataTransformFilter Self; + typedef otb::VectorDataToVectorDataFilter + <TInputVectorData,TOutputVectorData> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef TInputVectorData InputVectorDataType; + typedef TOutputVectorData OutputVectorDataType; typedef typename TInputVectorData::ConstPointer InputVectorDataPointer; - typedef typename TOutputVectorData::Pointer OutputVectorDataPointer; + typedef typename TOutputVectorData::Pointer OutputVectorDataPointer; /** Some typedefs. */ typedef itk::Transform<double, 2, 2> GenericTransformType; @@ -62,8 +63,8 @@ public: typedef itk::Vector<double, 2> SpacingType; typedef itk::Point<double, 2> OriginType; - typedef typename InputVectorDataType::DataNodePointerType InputDataNodePointerType; - typedef typename OutputVectorDataType::DataNodeType OutputDataNodeType; + typedef typename InputVectorDataType::DataNodePointerType InputDataNodePointerType; + typedef typename OutputVectorDataType::DataNodeType OutputDataNodeType; typedef typename OutputVectorDataType::DataNodePointerType OutputDataNodePointerType; typedef typename OutputVectorDataType::DataTreePointerType OutputDataTreePointerType; @@ -72,19 +73,18 @@ public: typedef typename InputInternalTreeNodeType::ChildrenListType InputChildrenListType; - typedef typename OutputDataNodeType::PointType PointType; - - typedef typename OutputDataNodeType::LineType LineType; + typedef typename OutputDataNodeType::PointType PointType; + typedef typename OutputDataNodeType::LineType LineType; typedef typename OutputDataNodeType::LineConstPointerType LineConstPointerType; - typedef typename OutputDataNodeType::LinePointerType LinePointerType; + typedef typename OutputDataNodeType::LinePointerType LinePointerType; - typedef typename OutputDataNodeType::PolygonType PolygonType; + typedef typename OutputDataNodeType::PolygonType PolygonType; typedef typename OutputDataNodeType::PolygonConstPointerType PolygonConstPointerType; - typedef typename OutputDataNodeType::PolygonPointerType PolygonPointerType; + typedef typename OutputDataNodeType::PolygonPointerType PolygonPointerType; - typedef typename OutputDataNodeType::PolygonListType PolygonListType; + typedef typename OutputDataNodeType::PolygonListType PolygonListType; typedef typename OutputDataNodeType::PolygonListConstPointerType PolygonListConstPointerType; - typedef typename OutputDataNodeType::PolygonListPointerType PolygonListPointerType; + typedef typename OutputDataNodeType::PolygonListPointerType PolygonListPointerType; /** Method for creation through the object factory. */ @@ -97,7 +97,6 @@ public: itkSetObjectMacro(Transform,GenericTransformType); itkGetObjectMacro(Transform,GenericTransformType); - protected: VectorDataTransformFilter(); virtual ~VectorDataTransformFilter() {}; @@ -113,7 +112,6 @@ protected: private: VectorDataTransformFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented - GenericTransformPointerType m_Transform; }; diff --git a/Code/Projections/otbVectorDataTransformFilter.txx b/Code/Projections/otbVectorDataTransformFilter.txx index 3bf5103b9a34ea68d7605efa8a61f765166e6f04..f8306cda407ba3f94f9daf824ccba2632c7081d6 100644 --- a/Code/Projections/otbVectorDataTransformFilter.txx +++ b/Code/Projections/otbVectorDataTransformFilter.txx @@ -73,17 +73,17 @@ VectorDataTransformFilter<TInputVectorData,TOutputVectorData> VertexListConstIteratorType it = vertexList->Begin(); typename LineType::Pointer newLine = LineType::New(); while ( it != vertexList->End()) - { + { itk::Point<double,2> point; itk::ContinuousIndex<double,2> index; typename LineType::VertexType pointCoord = it.Value(); point = m_Transform->TransformPoint(pointCoord); index[0]=point[0]; index[1]=point[1]; - if( !LocalIsNaN(index[0]) && !LocalIsNaN(index[1]) ) - newLine->AddVertex(index); + if (!LocalIsNaN(index[0]) && !LocalIsNaN(index[1])) + newLine->AddVertex(index); it++; - } + } return newLine; } @@ -102,7 +102,7 @@ VectorDataTransformFilter<TInputVectorData,TOutputVectorData> VertexListConstIteratorType it = vertexList->Begin(); typename PolygonType::Pointer newPolygon = PolygonType::New(); while ( it != vertexList->End()) - { + { itk::Point<double,2> point; itk::ContinuousIndex<double,2> index; typename PolygonType::VertexType pointCoord = it.Value(); @@ -110,9 +110,9 @@ VectorDataTransformFilter<TInputVectorData,TOutputVectorData> index[0]=point[0]; index[1]=point[1]; if( !LocalIsNaN(index[0]) && !LocalIsNaN(index[1]) ) - newPolygon->AddVertex(index); + newPolygon->AddVertex(index); it++; - } + } return newPolygon; } @@ -128,9 +128,9 @@ VectorDataTransformFilter<TInputVectorData,TOutputVectorData> PolygonListPointerType newPolygonList = PolygonListType::New(); for (typename PolygonListType::ConstIterator it = polygonList->Begin(); it != polygonList->End(); ++it) - { + { newPolygonList->PushBack(this->ReprojectPolygon(it.Get())); - } + } return newPolygonList; } @@ -181,7 +181,7 @@ VectorDataTransformFilter<TInputVectorData,TOutputVectorData> // For each child for(typename InputChildrenListType::iterator it = children.begin(); it!=children.end();++it) - { + { typename OutputInternalTreeNodeType::Pointer newContainer; // Copy input DataNode info @@ -191,110 +191,110 @@ VectorDataTransformFilter<TInputVectorData,TOutputVectorData> newDataNode->SetNodeId(dataNode->GetNodeId()); switch(dataNode->GetNodeType()) - { - case ROOT: { - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - ProcessNode((*it),newContainer); - break; + case ROOT: + { + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + ProcessNode((*it),newContainer); + break; } case DOCUMENT: { - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - ProcessNode((*it),newContainer); - break; + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + ProcessNode((*it),newContainer); + break; } case FOLDER: { - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - ProcessNode((*it),newContainer); - break; + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + ProcessNode((*it),newContainer); + break; } case FEATURE_POINT: { - PointType point = this->ReprojectPoint(dataNode->GetPoint()); - if(!LocalIsNaN(point[0]) && !LocalIsNaN(point[1]) ) - { - newDataNode->SetPoint(this->ReprojectPoint(dataNode->GetPoint())); - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - } - break; + PointType point = this->ReprojectPoint(dataNode->GetPoint()); + if (!LocalIsNaN(point[0]) && !LocalIsNaN(point[1]) ) + { + newDataNode->SetPoint(this->ReprojectPoint(dataNode->GetPoint())); + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + } + break; } case FEATURE_LINE: { - LinePointerType line = this->ReprojectLine(dataNode->GetLine()); - if( line->GetVertexList()->Size()!=0 ) - { - newDataNode->SetLine(this->ReprojectLine(dataNode->GetLine())); - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - } - break; + LinePointerType line = this->ReprojectLine(dataNode->GetLine()); + if( line->GetVertexList()->Size()!= 0 ) + { + newDataNode->SetLine(this->ReprojectLine(dataNode->GetLine())); + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + } + break; } case FEATURE_POLYGON: { - PolygonPointerType polyExt = this->ReprojectPolygon(dataNode->GetPolygonExteriorRing()); - PolygonListPointerType polyInt = this->ReprojectPolygonList(dataNode->GetPolygonInteriorRings()); - bool ok=true; - for (typename PolygonListType::ConstIterator it = polyInt->Begin(); - it != polyInt->End(); ++it) - { - if( it.Get()->GetVertexList()->Size()==0 ) - ok = false; - } - if(polyExt->GetVertexList()->Size()!=0 && ok==true) - { - newDataNode->SetPolygonExteriorRing(this->ReprojectPolygon(dataNode->GetPolygonExteriorRing())); - newDataNode->SetPolygonInteriorRings(this->ReprojectPolygonList(dataNode->GetPolygonInteriorRings())); - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - } - break; - } - case FEATURE_MULTIPOINT: - { + PolygonPointerType polyExt = this->ReprojectPolygon(dataNode->GetPolygonExteriorRing()); + PolygonListPointerType polyInt = this->ReprojectPolygonList(dataNode->GetPolygonInteriorRings()); + bool ok=true; + for (typename PolygonListType::ConstIterator it = polyInt->Begin(); + it != polyInt->End(); ++it) + { + if( it.Get()->GetVertexList()->Size() == 0 ) + ok = false; + } + if(polyExt->GetVertexList()->Size()!= 0 && ok == true) + { + newDataNode->SetPolygonExteriorRing(this->ReprojectPolygon(dataNode->GetPolygonExteriorRing())); + newDataNode->SetPolygonInteriorRings(this->ReprojectPolygonList(dataNode->GetPolygonInteriorRings())); newContainer = OutputInternalTreeNodeType::New(); newContainer->Set(newDataNode); destination->AddChild(newContainer); - ProcessNode((*it),newContainer); - break; + } + break; + } + case FEATURE_MULTIPOINT: + { + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + ProcessNode((*it),newContainer); + break; } case FEATURE_MULTILINE: { - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - ProcessNode((*it),newContainer); - break; + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + ProcessNode((*it),newContainer); + break; } case FEATURE_MULTIPOLYGON: { - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - ProcessNode((*it),newContainer); - break; + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + ProcessNode((*it),newContainer); + break; } case FEATURE_COLLECTION: { - newContainer = OutputInternalTreeNodeType::New(); - newContainer->Set(newDataNode); - destination->AddChild(newContainer); - ProcessNode((*it),newContainer); - break; + newContainer = OutputInternalTreeNodeType::New(); + newContainer->Set(newDataNode); + destination->AddChild(newContainer); + ProcessNode((*it),newContainer); + break; + } } } - } } diff --git a/Testing/Code/Projections/otbVectorDataTransformFilter.cxx b/Testing/Code/Projections/otbVectorDataTransformFilter.cxx index 742954126f353c4b8018904cae75a562a735e574..e40502d64fa43bf1b011ef2a0ba0adffb1540547 100644 --- a/Testing/Code/Projections/otbVectorDataTransformFilter.cxx +++ b/Testing/Code/Projections/otbVectorDataTransformFilter.cxx @@ -101,4 +101,3 @@ int otbVectorDataTransformFilter (int argc, char * argv[]) return EXIT_SUCCESS; } -