From 7a0c16a0e6cb9af436aa1c4a810e6d974d16a9f3 Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Wed, 20 May 2009 18:22:16 +0800 Subject: [PATCH] ENH: add overlay option (change background behaviour) --- Code/Common/otbVectorDataToImageFilter.h | 12 ++++++++++++ Code/Common/otbVectorDataToImageFilter.txx | 15 +++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Code/Common/otbVectorDataToImageFilter.h b/Code/Common/otbVectorDataToImageFilter.h index 80bdeda3cb..afc5d0025d 100644 --- a/Code/Common/otbVectorDataToImageFilter.h +++ b/Code/Common/otbVectorDataToImageFilter.h @@ -129,6 +129,13 @@ template <class TVectorData, class TImage> m_StyleList.clear(); } + /** Specify if the output image is to be uses as an overlar + * (with transparent background) or not (with blue background). + */ + itkSetMacro(UseAsOverlay, bool); + itkGetMacro(UseAsOverlay, bool); + itkBooleanMacro(UseAsOverlay) + protected: /** Constructor */ VectorDataToImageFilter(); @@ -169,9 +176,14 @@ template <class TVectorData, class TImage> //style list std::vector<std::string> m_StyleList; + //Overlay option: change the backgroup (blue or transparent) + bool m_UseAsOverlay; + //Projection in the proj.4 format (for mapnik) std::string m_VectorDataProjectionProj4; + + }; // end class } // end namespace otb diff --git a/Code/Common/otbVectorDataToImageFilter.txx b/Code/Common/otbVectorDataToImageFilter.txx index 25eb26a640..eb2ea34d95 100644 --- a/Code/Common/otbVectorDataToImageFilter.txx +++ b/Code/Common/otbVectorDataToImageFilter.txx @@ -47,7 +47,8 @@ namespace otb template <class TVectorData, class TImage> VectorDataToImageFilter<TVectorData, TImage> ::VectorDataToImageFilter() : - m_StyleList() + m_StyleList(), + m_UseAsOverlay(true) { this->SetNumberOfRequiredInputs( 1 ); m_Spacing.Fill(1.0); @@ -214,9 +215,15 @@ namespace otb mapnik::freetype_engine::register_font("/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"); - //Set the default backgroup to transparent - m_Map.set_background(mapnik::color(255,255,255,0)); - + if(m_UseAsOverlay) + { + //Set the default backgroup to transparent + m_Map.set_background(mapnik::color(255,255,255,0)); + } + else + { + m_Map.set_background(mapnik::color("#b5d0d0")); + } //Load the OSM styles using helper class otb::VectorDataStyle::Pointer styleLoader = otb::VectorDataStyle::New(); styleLoader->SetScaleFactor(m_ScaleFactor); -- GitLab