Skip to content
Snippets Groups Projects
Commit de4fe543 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

DOC: finishing up example for VectorDataExtractROI

parent 1e4c92d2
Branches
Tags
No related merge requests found
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
// Most of the time, you won't be interested in the whole area and would like // Most of the time, you won't be interested in the whole area and would like
// to focuss only on the area corresponding to your satellite image. // to focuss only on the area corresponding to your satellite image.
// //
// The \doxygen{otb}{VectorDataExtractROI} is able to extract the area corresponding
// to your satellite image, even if the image is still in sensor geometry (provided
// the sensor model is supported by OTB). Let's see how we can do that.
// //
// This example demonstrates the use of the // This example demonstrates the use of the
// \doxygen{otb}{VectorDataExtractROI}. // \doxygen{otb}{VectorDataExtractROI}.
...@@ -60,7 +63,7 @@ int main( int argc, char* argv[] ) ...@@ -60,7 +63,7 @@ int main( int argc, char* argv[] )
typedef double Type; typedef double Type;
typedef otb::VectorData<> VectorDataType; typedef otb::VectorData<> VectorDataType;
typedef otb::VectorDataExtractROI< VectorDataType > FilterType;
typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType; typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType;
typedef otb::VectorDataFileWriter<VectorDataType> VectorDataWriterType; typedef otb::VectorDataFileWriter<VectorDataType> VectorDataWriterType;
...@@ -72,11 +75,28 @@ int main( int argc, char* argv[] ) ...@@ -72,11 +75,28 @@ int main( int argc, char* argv[] )
imageReader->SetFileName(inImageName); imageReader->SetFileName(inImageName);
imageReader->UpdateOutputInformation(); imageReader->UpdateOutputInformation();
// Software Guide : BeginLatex
//
// After the usual declaration (you can check the source file for the details),
// we can declare the \doxygen{otb}{VectorDataExtractROI}:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::VectorDataExtractROI< VectorDataType > FilterType;
FilterType::Pointer filter = FilterType::New(); FilterType::Pointer filter = FilterType::New();
VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); // Software Guide : EndCodeSnippet
VectorDataWriterType::Pointer writer = VectorDataWriterType::New();
// Software Guide : BeginLatex
//
// Then, we need to specify the region to extract. This region is a bit special as
// it contains also information related to its reference system (cartographic projection
// or sensor model projection). We retrieve all these information from the image
// we gave as an input.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
TypedRegion region; TypedRegion region;
TypedRegion::SizeType size; TypedRegion::SizeType size;
TypedRegion::IndexType index; TypedRegion::IndexType index;
...@@ -92,18 +112,34 @@ int main( int argc, char* argv[] ) ...@@ -92,18 +112,34 @@ int main( int argc, char* argv[] )
region.SetSize(size); region.SetSize(size);
region.SetOrigin(index); region.SetOrigin(index);
otb::ImageMetadataInterface::Pointer imageMetadataInterface = otb::ImageMetadataInterface::New(); otb::ImageMetadataInterface::Pointer imageMetadataInterface
region.SetRegionProjection(imageMetadataInterface->GetProjectionRef(imageReader->GetOutput()->GetMetaDataDictionary())); = otb::ImageMetadataInterface::New();
region.SetRegionProjection(
imageMetadataInterface->GetProjectionRef(
imageReader->GetOutput()->GetMetaDataDictionary()));
region.SetKeywordList(imageReader->GetOutput()->GetImageKeywordlist()); region.SetKeywordList(imageReader->GetOutput()->GetImageKeywordlist());
reader->SetFileName(inVectorName);
filter->SetInput(reader->GetOutput());
filter->SetRegion(region); filter->SetRegion(region);
// Software Guide : EndCodeSnippet
VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New();
VectorDataWriterType::Pointer writer = VectorDataWriterType::New();
reader->SetFileName(inVectorName);
writer->SetFileName(outVectorName); writer->SetFileName(outVectorName);
// Software Guide : BeginLatex
//
// And finally, we can plug the filter in the pipeline:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->SetInput(reader->GetOutput());
writer->SetInput(filter->GetOutput()); writer->SetInput(filter->GetOutput());
// Software Guide : EndCodeSnippet
writer->Update(); writer->Update();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment