Commit 404d2b1d authored by Victor Poughon's avatar Victor Poughon

Merge branch '1792-remove-use-deprecated' into 'develop'

Remove OTB_USE_DEPRECATED, TileMapImageIO and VectorDataRendering

Closes #1792 and #877

See merge request !320
parents bab627ff 88e09483
#
# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# - Find Mapnik
# Find the native Mapnik includes and library
#
# MAPNIK_FOUND - True if MAPNIK found.
# MAPNIK_INCLUDE_DIRS - where to find mapnik/map.hpp, etc.
# MAPNIK_LIBRARIES - List of libraries when using MAPNIK
#
find_path( MAPNIK_INCLUDE_DIR mapnik/map.hpp )
find_library( MAPNIK_LIBRARY
NAMES mapnik2 mapnik )
# handle the QUIETLY and REQUIRED arguments and set MAPNIK_FOUND to TRUE if
# all listed variables are TRUE
include( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( Mapnik DEFAULT_MSG MAPNIK_LIBRARY MAPNIK_INCLUDE_DIR )
mark_as_advanced( MAPNIK_INCLUDE_DIR MAPNIK_LIBRARY )
if(MAPNIK_FOUND)
set(MAPNIK_INCLUDE_DIRS ${MAPNIK_INCLUDE_DIR})
set(MAPNIK_LIBRARIES ${MAPNIK_LIBRARY})
else()
set(MAPNIK_INCLUDE_DIRS)
set(MAPNIK_LIBRARIES)
endif()
......@@ -196,8 +196,6 @@ foreach(otb-module ${OTB_MODULES_ALL})
if(OTB_MODULE_${otb-module}_ACTIVATION_OPTION
AND NOT ${OTB_MODULE_${otb-module}_ACTIVATION_OPTION})
otb_module_disable("${otb-module}" "${OTB_MODULE_${otb-module}_ACTIVATION_OPTION}")
elseif(OTB_MODULE_${otb-module}_IS_DEPRECATED AND NOT OTB_USE_DEPRECATED)
otb_module_disable("${otb-module}" "OTB_USE_DEPRECATED")
endif()
endforeach()
......
......@@ -219,11 +219,6 @@ else()
set(OTB_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
endif()
#-----------------------------------------------------------------------------
# Option to activate deprecated classes
option(OTB_USE_DEPRECATED "Turn on the use and test of deprecated classes" OFF)
mark_as_advanced(OTB_USE_DEPRECATED)
# Although the OpenMP option looks like a 3rd party module, it is NOT. This option
# is handled with other compilation flags in file OTBSetStandardCompilerFlags.cmake
# before any module is parsed or enabled (see OTBModuleEnablement.cmake later on
......
......@@ -249,7 +249,6 @@ SET( OTB_EXAMPLES_SRCS
${OTB_SOURCE_DIR}/Examples/IO/OGRWrappersExample.cxx
${OTB_SOURCE_DIR}/Examples/IO/DEMToImageGenerator.cxx
${OTB_SOURCE_DIR}/Examples/IO/DEMHandlerExample.cxx
${OTB_SOURCE_DIR}/Examples/IO/TileMapImageIOExample.cxx
${OTB_SOURCE_DIR}/Examples/Filtering/BinaryThresholdImageFilter.cxx
${OTB_SOURCE_DIR}/Examples/Filtering/ThresholdImageFilter.cxx
${OTB_SOURCE_DIR}/Examples/Filtering/CannyEdgeDetectionImageFilter.cxx
......@@ -302,8 +301,8 @@ SET( OTB_EXAMPLES_SRCS
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/CorrelationLineDetectorExample.cxx
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/AsymmetricFusionOfLineDetectorExample.cxx
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/LocalHoughExample.cxx
#${OTB_SOURCE_DIR}/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
#${OTB_SOURCE_DIR}/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ExtractSegmentsByStepsExample.cxx
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ExtractSegmentsExample.cxx
${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ParallelLineDetectionExample.cxx
......
......@@ -105,12 +105,13 @@ More features are available in \doxygen{otb}{ScalarImageToAdvancedTexturesFilter
\input{LocalHoughExample}
%\input{ExtractSegmentsByStepsExample}
%\input{ExtractSegmentsExample}
%\subsubsection{Line Segment Detector}
%\label{sec:LSD}
%\input{LineSegmentDetectorExample}
%\subsection{Right Angle Detector}
%\label{sec:RightAngleDetector}
%\input{RightAngleDetectionExample}
\subsubsection{Line Segment Detector}
\label{sec:LSD}
\input{LineSegmentDetectorExample}
\subsection{Right Angle Detector}
\label{sec:RightAngleDetector}
\input{RightAngleDetectionExample}
\section{Density Features}
......
......@@ -468,18 +468,6 @@ The Markov Random Field framework for OTB is more detailed in \ref{sec:MarkovRan
\fi
%\section{Rasterization}
%Rasterization is the process of rendering vectorial data on a raster
%grid. This rasterization can be either binary or more complete,
%including different styles and labels for the vectorial features.For
%rasterization purposes, OTB uses the Mapnik library through the
%\doxygen{otb}{VectorDataToImageFilter}. Hence, rasterization will be
%only available to users compiling OTB with the Mapnik CMake option
%set to ON, or using a binary package with Mapnik activated.
%\input{RasterizationExample.tex}
%% \ifitkFullVersion
%% %\input{SignedDanielssonDistanceMapImageFilter.tex}
......
......@@ -114,8 +114,6 @@ See table \ref{tab:otb-dependencies} for the full list of dependencies.
\hline
\textbf{libSVM} & \url{http://www.csie.ntu.edu.tw/~cjlin/libsvm} & no & 2.0 \\
\hline
\textbf{Mapnik} & \url{http://www.mapnik.org} & no & 2.x \\
\hline
\textbf{MPI} & \url{https://www.open-mpi.org/} & no & - \\
\hline
\textbf{MuParser} & \url{http://www.muparser.sourceforge.net} & no & - \\
......@@ -431,8 +429,6 @@ $ make install
\hline
\textbf{OTB\_USE\_SHARK} & OTBShark & optional for OTBSupervised OTBAppClassification \\
\hline
\textbf{OTB\_USE\_MAPNIK} & OTBMapnik & OTBVectorDataRendering \\
\hline
\textbf{OTB\_USE\_6S} & OTB6S & OTBOpticalCalibration OTBAppOpticalCalibration OTBSimulation \\
\hline
\textbf{OTB\_USE\_SIFTFAST} & OTBSiftFast & \\
......
\chapter{Online data}\label{sec:Online}
With almost every computer connected to the Internet, the amount of
online information is steadily growing. It is quite easy to retrieve
valuable information. OTB has a few experimental classes for this
purpose.
For these examples to work, you need to have OTB compiled with the
\texttt{OTB\_USE\_CURL} option to \texttt{ON} (and the curl library
installed somewhere).
Let's see what we can do.
\section{Name to Coordinates}
\label{sec:NamesToCoordinates}
\input{PlaceNameToLonLatExample.tex}
\section{Open Street Map}
\label{sec:OpenStreetMap}
The power of sharing which is a driving force in open source software such
as OTB can also be demonstrated for data collection. One good example is
Open Street Map (\url{http://www.openstreetmap.org/}).
In this project, hundreds of thousands of users upload GPS data and draw maps of their
surroundings. The coverage is impressive and this data is freely available.
It is even possible to get the vector data (not covered yet by OTB), but
here we will focus on retrieving some nice maps for any place in the world. The following
example describes the method. This part is pretty experimental and the code is
not as polished as the rest of the library. You've been warned!
\input{TileMapImageIOExample.tex}
......@@ -246,7 +246,6 @@ colorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue},
\input{ChangeDetection.tex}
\input{Hyperspectral.tex}
\input{Visualization.tex}
\input{Online.tex}
%%% \input{Applications.tex}
......
......@@ -68,13 +68,11 @@ target_link_libraries(HarrisExample ${OTB_LIBRARIES})
add_executable(HuMomentsImageFunctionExample HuMomentsImageFunctionExample.cxx)
target_link_libraries(HuMomentsImageFunctionExample ${OTB_LIBRARIES})
if (Module_OTBVectorDataRendering AND OTB_USE_MAPNIK)
add_executable(LineSegmentDetectorExample LineSegmentDetectorExample.cxx)
target_link_libraries(LineSegmentDetectorExample ${OTB_LIBRARIES})
add_executable(LineSegmentDetectorExample LineSegmentDetectorExample.cxx)
target_link_libraries(LineSegmentDetectorExample ${OTB_LIBRARIES})
add_executable(RightAngleDetectionExample RightAngleDetectionExample.cxx)
target_link_libraries(RightAngleDetectionExample ${OTB_LIBRARIES})
endif()
add_executable(RightAngleDetectionExample RightAngleDetectionExample.cxx)
target_link_libraries(RightAngleDetectionExample ${OTB_LIBRARIES})
add_executable(LocalHoughExample LocalHoughExample.cxx)
target_link_libraries(LocalHoughExample ${OTB_LIBRARIES})
......
......@@ -19,16 +19,14 @@
*/
#include "otbImageFileReader.h"
#include "otbVectorDataToMapFilter.h"
#include "otbAlphaBlendingFunctor.h"
#include "itkBinaryFunctorImageFilter.h"
#include "otbImageFileWriter.h"
#include "otbVectorDataFileWriter.h"
// Software Guide : BeginCommandLineArgs
// INPUTS: {Scene.png}
// OUTPUTS: {LSDOutput.png}
// OUTPUTS: {LSDOutput.shp}
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
......@@ -48,8 +46,14 @@
int main(int argc, char * argv[])
{
const char * infname = argv[1];
const char * outfname = argv[2];
if (argc != 3)
{
std::cerr << "Usage: ./LineSegmentDetectorExample input output\n";
return EXIT_FAILURE;
}
const char* infname = argv[1];
const char* outfname = argv[2];
typedef unsigned char InputPixelType;
typedef double PrecisionType;
......@@ -89,45 +93,21 @@ int main(int argc, char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::LineSegmentDetector<ImageType,
PrecisionType> LsdFilterType;
typedef otb::LineSegmentDetector<ImageType, PrecisionType> LsdFilterType;
LsdFilterType::Pointer lsdFilter = LsdFilterType::New();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// In order to be able to display the results, we will draw the
// detected segments on top of the input image. For this matter, we
// will use a \doxygen{otb}{VectorDataToMapFilter} which
// is templated over the input vector data type and the output image
// type, and a combination of a \doxygen{itk}{binaryFunctorImageFilter}
// and the \doxygen{otb}{Functor}{AlphaBlendingFunctor}.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::VectorData<PrecisionType> VectorDataType;
typedef otb::VectorDataToMapFilter<VectorDataType,
ImageType> VectorDataRendererType;
VectorDataRendererType::Pointer vectorDataRenderer = VectorDataRendererType::New();
typedef otb::Functor::AlphaBlendingFunctor<InputPixelType,
InputPixelType, InputPixelType> FunctorType;
typedef itk::BinaryFunctorImageFilter<ImageType, ImageType,
ImageType, FunctorType> BlendingFilterType;
BlendingFilterType::Pointer blendingFilter = BlendingFilterType::New();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We can now define the type for the writer, instantiate it and set
// the file name for the output image.
// the file name for the output vector data.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef otb::VectorDataFileWriter<LsdFilterType::VectorDataType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outfname);
// Software Guide : EndCodeSnippet
......@@ -140,16 +120,7 @@ int main(int argc, char * argv[])
// Software Guide : BeginCodeSnippet
lsdFilter->SetInput(reader->GetOutput());
vectorDataRenderer->SetInput(lsdFilter->GetOutput());
vectorDataRenderer->SetSize(reader->GetOutput()->GetLargestPossibleRegion().GetSize());
vectorDataRenderer->SetRenderingStyleType(VectorDataRendererType::Binary);
blendingFilter->SetInput1(reader->GetOutput());
blendingFilter->SetInput2(vectorDataRenderer->GetOutput());
blendingFilter->GetFunctor().SetAlpha(0.25);
writer->SetInput(blendingFilter->GetOutput());
writer->SetInput(lsdFilter->GetOutput());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -166,19 +137,5 @@ int main(int argc, char * argv[])
writer->Update();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
// Figure~\ref{fig:LSD} shows the result of applying the line segment
// detection to an image.
// \begin{figure}
// \center
// \includegraphics[width=0.35\textwidth]{Scene.eps}
// \includegraphics[width=0.35\textwidth]{LSDOutput.eps}
// \itkcaption[LSD Application]{Result of applying the
// \doxygen{otb}{LineSegmentDetector} to an image.}
// \label{fig:LSD}
// \end{figure}
//
// Software Guide : EndLatex
return EXIT_SUCCESS;
}
......@@ -22,18 +22,11 @@
#include "otbImageFileReader.h"
#include "otbLineSegmentDetector.h"
#include "otbVectorDataToMapFilter.h"
#include "otbAlphaBlendingFunctor.h"
#include "itkBinaryFunctorImageFilter.h"
#include "otbImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "otbVectorDataFileWriter.h"
// Software Guide : BeginCommandLineArgs
// INPUTS: {Scene.png}
// OUTPUTS: {RighAngleOutput.tif}, {PrettyRighAngleInput.png}, {PrettyRighAngleOutput.png}
// OUTPUTS: {rightAngleOutput.shp}
// 0.1 20
// Software Guide : EndCommandLineArgs
......@@ -57,25 +50,27 @@
int main(int argc, char * argv[])
{
const char * infname = argv[1];
const char * outfname = argv[2];
const char * inprettyfname = argv[3];
const char * outprettyfname = argv[4];
double angleThreshold = atof(argv[5]);
double distanceThreshold = atof(argv[6]);
const unsigned int Dimension = 2;
if (argc != 5)
{
std::cerr << "Usage: ./RightAngleDetectionExample input rightAngleOutput angleThreshold distanceThreshold\n";
return EXIT_FAILURE;
}
const char* infname = argv[1];
const char* rightAngleOutputFilename = argv[2];
double angleThreshold = atof(argv[3]);
double distanceThreshold = atof(argv[4]);
const unsigned int Dimension = 2;
typedef unsigned char PixelType;
typedef double PrecisionType;
typedef otb::Image<PixelType, Dimension> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
reader->SetFileName(infname);
reader->GenerateOutputInformation();
WriterType::Pointer writer = WriterType::New();
// Software Guide : BeginLatex
//
......@@ -124,8 +119,8 @@ int main(int argc, char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
LsdFilterType::Pointer lsdFilter = LsdFilterType::New();
RightAngleFilterType::Pointer rightAngleFilter = RightAngleFilterType::New();
auto lsdFilter = LsdFilterType::New();
auto rightAngleFilter = RightAngleFilterType::New();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -151,48 +146,16 @@ int main(int argc, char * argv[])
rightAngleFilter->SetDistanceThreshold(distanceThreshold);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We will now draw the right angles on top of the input image. For
// this, we will draw the detected points on top of the input
// image. For this matter, we will use a
// \doxygen{otb}{VectorDataToMapFilter} which is templated over
// the input vector data type and the output image type, and a
// combination of a \doxygen{itk}{binaryFunctorImageFilter}
// and the \doxygen{otb}{Functor}{UnaryFunctorImageFilter}.
//
// Software Guide : EndLatex
typedef otb::VectorDataFileWriter<LsdFilterType::VectorDataType> WriterType;
// Software Guide : BeginCodeSnippet
typedef otb::VectorDataToMapFilter<VectorDataType,
ImageType> VectorDataRendererType;
VectorDataRendererType::Pointer vectorDataRenderer = VectorDataRendererType::New();
typedef otb::Functor::AlphaBlendingFunctor<PixelType,
PixelType, PixelType> FunctorType;
typedef itk::BinaryFunctorImageFilter<ImageType, ImageType,
ImageType, FunctorType> BlendingFilterType;
BlendingFilterType::Pointer blendingFilter = BlendingFilterType::New();
vectorDataRenderer->SetInput(1, lsdFilter->GetOutput());
vectorDataRenderer->SetInput(rightAngleFilter->GetOutput());
vectorDataRenderer->SetSize(reader->GetOutput()->GetLargestPossibleRegion().GetSize());
vectorDataRenderer->SetOrigin(reader->GetOutput()->GetOrigin());
vectorDataRenderer->SetSpacing(reader->GetOutput()->GetSignedSpacing());
vectorDataRenderer->SetRenderingStyleType(VectorDataRendererType::Binary);
blendingFilter->SetInput1(reader->GetOutput());
blendingFilter->SetInput2(vectorDataRenderer->GetOutput());
blendingFilter->GetFunctor().SetAlpha(0.25);
writer->SetInput(blendingFilter->GetOutput());
writer->SetFileName(outfname);
// Software Guide : EndCodeSnippet
auto rightAngleWriter = WriterType::New();
rightAngleWriter->SetInput(rightAngleFilter->GetOutput());
rightAngleWriter->SetFileName(rightAngleOutputFilename);
// Software Guide : BeginLatex
//
// Before calling the \code{Update()} method of the writer in order to
// Before calling the \code{Update()} method of the writers in order to
// trigger the pipeline execution, we call the
// \code{GenerateOutputInformation()} of the reader, so the
// filter gets the information about image size and spacing.
......@@ -201,50 +164,8 @@ int main(int argc, char * argv[])
// Software Guide : BeginCodeSnippet
reader->GenerateOutputInformation();
writer->Update();
rightAngleWriter->Update();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
// Figure~\ref{fig:RIGHTANGLE_FILTER} shows the result of applying
// the right angle detection filter to an image.
// \begin{figure}
// \center
// \includegraphics[width=0.25\textwidth]{PrettyRighAngleInput.eps}
// \includegraphics[width=0.25\textwidth]{PrettyRighAngleOutput.eps}
// \itkcaption[Right Angle Detection Filter]{Result of applying the
// \doxygen{otb}{LineSegmentDetector} and the
// \doxygen{otb}{VectorDataToRightAngleVectorDataFilter} to an image. From left to right :
// original image, detected right angles.}
// \label{fig:RIGHTANGLE_FILTER}
// \end{figure}
//
// Software Guide : EndLatex
/************** images for printing *********/
typedef unsigned char OutputPixelType;
typedef otb::Image<OutputPixelType,
Dimension> OutputImageType;
typedef otb::ImageFileWriter<OutputImageType>
OutputWriterType;
typedef itk::RescaleIntensityImageFilter<ImageType,
OutputImageType> RescalerType;
RescalerType::Pointer rescaler = RescalerType::New();
OutputWriterType::Pointer outwriter = OutputWriterType::New();
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
rescaler->SetInput(reader->GetOutput());
outwriter->SetInput(rescaler->GetOutput());
outwriter->SetFileName(inprettyfname);
outwriter->Update();
rescaler->SetInput(blendingFilter->GetOutput());
outwriter->SetInput(rescaler->GetOutput());
outwriter->SetFileName(outprettyfname);
outwriter->Update();
return EXIT_SUCCESS;
}
......@@ -214,30 +214,25 @@ otb_add_test(NAME feTeCloudDetectionExampleTest COMMAND ${OTB_TEST_DRIVER}
553 467 734 581 0.4 0.6 1.0
)
if (Module_OTBVectorDataRendering AND OTB_USE_MAPNIK)
# ------- Line Segment Detector test----------
otb_add_test(NAME feTeLineSegmentDetectorExampleTest COMMAND ${OTB_TEST_DRIVER}
--compare-image ${NOTOL}
${BASELINE}/feTeLineSegmentDetectorExampleOutput.png
${TEMP}/feTeLineSegmentDetectorExampleOutput.png
Execute $<TARGET_FILE:LineSegmentDetectorExample>
${INPUTDATA}/Scene.png
${TEMP}/feTeLineSegmentDetectorExampleOutput.png
)
# ------- Right Angle Detection test----------
otb_add_test(NAME feTeRightAngleDetectionExample COMMAND ${OTB_TEST_DRIVER}
--compare-image ${NOTOL}
${BASELINE}/feTeRightAngleDetectionExampleOutput.png
${TEMP}/feTeRightAngleDetectionExampleOutput.png
Execute $<TARGET_FILE:RightAngleDetectionExample>
${INPUTDATA}/Scene.png
${TEMP}/feTeRightAngleDetectionExampleOutput.png
${TEMP}/PrettyRightAngleInput.png
${TEMP}/PrettyRightAngleOutput.png
0.1
10.
)
endif()
# ------- Line Segment Detector test----------
otb_add_test(NAME feTeLineSegmentDetectorExampleTest COMMAND ${OTB_TEST_DRIVER}
--compare-ogr ${NOTOL}
${BASELINE}/feTeLineSegmentDetectorExampleOutput.shp
${TEMP}/feTeLineSegmentDetectorExampleOutput.shp
Execute $<TARGET_FILE:LineSegmentDetectorExample>
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/feTeLineSegmentDetectorExampleOutput.shp
)
# ------- Right Angle Detection test----------
otb_add_test(NAME feTeRightAngleDetectionExample COMMAND ${OTB_TEST_DRIVER}
--compare-ogr ${NOTOL}
${BASELINE}/feTeRightAngleDetectionExampleOutput.shp
${TEMP}/feTeRightAngleDetectionExampleOutput.shp
Execute $<TARGET_FILE:RightAngleDetectionExample>
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/feTeRightAngleDetectionExampleOutput.shp
0.1
10.
)
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Software Guide : BeginCommandLineArgs
// INPUTS: {w002n44e.shp}
// OUTPUTS: {ArcachonRasterizedCoastline.png}
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
//
// The \doxygen{otb}{VectorDataToMapFilter} allows performing
// rasterization of a given vector data as a binary mask. This example
// will demonstrate how to use this filter to perform rasterization of
// the SRTM water body masks available here:
// \url{http://dds.cr.usgs.gov/srtm/version2_1/SWBD/}.
//
// First step to use this filter is to include the appropriate headers:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include "otbVectorData.h"
#include "otbImage.h"
#include "otbVectorDataToMapFilter.h"
// Software Guide : EndCodeSnippet
#include "otbImageFileWriter.h"
#include "otbVectorDataProjectionFilter.h"
#include "itkRGBAPixel.h"
#include "itkChangeLabelImageFilter.h"
#include "otbVectorDataFileReader.h"
int main(int argc, char * argv[])
{
// Software Guide : BeginLatex
//
// Then, we need to define the appropriate VectorData and Image
// type.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef unsigned char PixelType;
typedef otb::Image<PixelType, 2> ImageType;
typedef otb::VectorData<> VectorDataType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Using these typedefs, we can define and instantiate the
// \doxygen{otb}{VectorDataToMapFilter}.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::VectorDataToMapFilter<VectorDataType,
ImageType> VectorDataToMapFilterType;
VectorDataToMapFilterType::Pointer vectorDataRendering
= VectorDataToMapFilterType::New();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We will also define a \doxygen{otb}{VectorDataFileReader} to read
// the VectorData, as well as a
// \doxygen{otb}{VectorDataProjectionFilter} to reproject our data
// in a given map projection.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType;
VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New();
reader->SetFileName(argv[1]);
typedef otb::VectorDataProjectionFilter<VectorDataType,
VectorDataType> ProjectionFilterType;
ProjectionFilterType::Pointer projection = ProjectionFilterType::New();
projection->SetInput(reader->GetOutput());
// Software Guide : EndCodeSnippet
std::string projectionRefWkt = "PROJCS[\"WGS 84 / UTM zone 30N\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]], AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.01745329251994328, AUTHORITY[\"EPSG\",\"9122\"]], AUTHORITY[\"EPSG\",\"4326\"]], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\",\"9001\"]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", -3], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000], PARAMETER[\"false_northing\", 0], AUTHORITY[\"EPSG\",\"32630\"], AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH]]";
// Software Guide : BeginLatex
//
// Next step is to specify the map projection in which to reproject
// our vector.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
projection->SetOutputProjectionRef(projectionRefWkt);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Since the input vector can be pretty big, we will perform an
// extract of the region of interest using the
// \doxygen{otb}{VectorDataExtractROI}.
//
// The first step is to define the region of interest.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::RemoteSensingRegion<double> RegionType;
ImageType::SizeType size;
size[0] = 500;
size[1] = 500;