diff --git a/Examples/IO/TileMapImageIOExample.cxx b/Examples/IO/TileMapImageIOExample.cxx index bfb0be2c4b11c6c0de081b997f0e08740c14f75e..a1981c1d12b8962e7e2256e0dcc7517fa977c783 100644 --- a/Examples/IO/TileMapImageIOExample.cxx +++ b/Examples/IO/TileMapImageIOExample.cxx @@ -25,6 +25,15 @@ // ${GeneratedFolder} 1.4835345 43.55968261 12 // Software Guide : EndCommandLineArgs + +// Software Guide : BeginLatex +// +// First, we need to include several headers. There will be a bit of +// manual work going on here. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet #include "itkRGBPixel.h" #include "otbImage.h" #include "otbImageFileReader.h" @@ -33,6 +42,7 @@ #include "otbExtractROI.h" #include "otbImageFileWriter.h" #include "ossim/projection/ossimTileMapModel.h" +// Software Guide : EndCodeSnippet int main( int argc, char* argv[] ) { @@ -47,14 +57,40 @@ int main( int argc, char* argv[] ) } - + // Software Guide : BeginLatex + // + // We retrieve the input parameters: + // \begin{itemize} + // \item the input filename is a simple text file specifying the access + // modality to open street map data; + // \item the output file is the image where you want to save the result; + // \item the cache directory is necessary to keep the data retrieved from + // the internet. It can also be reused to minimize network access; + // \item longitude of the center of the scene; + // \item latitude of the center of the scene; + // \item depth which is inversely related to the resolution: when you increase + // the depth by one, you divide the resolution by two. + // \end{itemize} + // + // Software Guide : EndLatex + + // Software Guide : BeginCodeSnippet char * inputFilename = argv[1]; char * outputFilename = argv[2]; char * cacheDirectory = argv[3]; double lon = atof(argv[4]); double lat = atof(argv[5]); int depth = atoi(argv[6]); + // Software Guide : EndCodeSnippet + + // Software Guide : BeginLatex + // + // We now instanciate the reader. As some parameters need to be given to the + // IO which is an \doxygen{otb}{TileMapImageIO}, we need to manually create it also: + // + // Software Guide : EndLatex + // Software Guide : BeginCodeSnippet typedef itk::RGBPixel<unsigned char> RGBPixelType; typedef otb::Image<RGBPixelType, 2> ImageType; typedef otb::ImageFileReader<ImageType> ReaderType; @@ -67,7 +103,22 @@ int main( int argc, char* argv[] ) readerTile->SetImageIO(tileIO); readerTile->SetFileName(inputFilename); readerTile->UpdateOutputInformation(); - + // Software Guide : EndCodeSnippet + + // Software Guide : BeginLatex + // + // Now, we potentially have an image of several Peta-bytes covering the whole world + // in the reader + // that's why we don't want to do an update before extracting a specific + // area. + // + // The coordinates are refered with an origin at the north pole and the + // change date meridian in Mercator projection. So we need to translate the latitude + // and the longitude in this funny coordinate system: + // + // Software Guide : EndLatex + + // Software Guide : BeginCodeSnippet typedef otb::InverseSensorModel<double> ModelType; ModelType::Pointer model= ModelType::New(); @@ -79,6 +130,7 @@ int main( int argc, char* argv[] ) return 1; } + typedef itk::Point <double, 2> PointType; PointType lonLatPoint; lonLatPoint[0]=lon; @@ -86,7 +138,16 @@ int main( int argc, char* argv[] ) PointType tilePoint; tilePoint=model->TransformPoint(lonLatPoint); + // Software Guide : EndCodeSnippet + // Software Guide : BeginLatex + // + // This enable us to use the \doxygen{otb}{ExtractROI} to retrieve only + // the area of interest and to avoid crashing our memory-limited computer. + // + // Software Guide : EndLatex + + // Software Guide : BeginCodeSnippet long int startX=static_cast<long int>(tilePoint[0]); long int startY=static_cast<long int>(tilePoint[1]); long int sizeX = 500; @@ -103,14 +164,40 @@ int main( int argc, char* argv[] ) extractROIOsmFilter->SetSizeY( sizeY ); extractROIOsmFilter->SetInput(readerTile->GetOutput()); + // Software Guide : EndCodeSnippet + // Software Guide : BeginLatex + // + // Finally, we just plug this to the writer to save our nice map of + // the area: + // + // Software Guide : EndLatex - + // Software Guide : BeginCodeSnippet typedef otb::ImageFileWriter<ImageType> WriterType; WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outputFilename); writer->SetInput(extractROIOsmFilter->GetOutput()); writer->Update(); + // Software Guide : EndCodeSnippet + + + // Software Guide : BeginLatex + // + // Figure~\ref{fig:TILEMAPIMAGEIOEXAMPLE} shows the output images created from + // open street map data. + // + // + // \begin{figure} + // \center + // \includegraphics[width=0.70\textwidth]{openStreetMap.eps} + // \itkcaption[Open street map]{Map created from open street map at depth 12 near Toulouse} + // \label{fig:TILEMAPIMAGEIOEXAMPLE} + // \end{figure} + // + // If your street is missing, go and improve the map. + // + // Software Guide : EndLatex return EXIT_SUCCESS;