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

ENH: separating style from the main code (done)

parent 5d310795
No related branches found
No related tags found
No related merge requests found
...@@ -24,5 +24,5 @@ TARGET_LINK_LIBRARIES(myOwnMapnik mapnik) ...@@ -24,5 +24,5 @@ TARGET_LINK_LIBRARIES(myOwnMapnik mapnik)
ADD_EXECUTABLE(mapnikFromVectorData mapnikFromVectorData.cxx) ADD_EXECUTABLE(mapnikFromVectorData mapnikFromVectorData.cxx)
TARGET_LINK_LIBRARIES(mapnikFromVectorData OTBCommon OTBIO mapnik) TARGET_LINK_LIBRARIES(mapnikFromVectorData OTBCommon OTBIO mapnik)
ADD_EXECUTABLE(mapnikOTBClasses mapnikOTBClasses.cxx) ADD_EXECUTABLE(mapnikOTBClasses mapnikOTBClasses.cxx otbVectorDataStyle.cxx)
TARGET_LINK_LIBRARIES(mapnikOTBClasses OTBCommon OTBIO mapnik) TARGET_LINK_LIBRARIES(mapnikOTBClasses OTBCommon OTBIO mapnik)
...@@ -18,3 +18,78 @@ ...@@ -18,3 +18,78 @@
#include "otbVectorDataStyle.h" #include "otbVectorDataStyle.h"
namespace otb
{
/**
* PrintSelf Method
*/
void
VectorDataStyle
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
void
VectorDataStyle
::LoadOSMStyle(mapnik::Map& mapnikMap) const
{
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(250000000000LLU);
rule.set_min_scale(600000);
rule.append(mapnik::line_symbolizer(mapnik::color("#f2efe9")));
// rule.append(mapnik::polygon_symbolizer(mapnik::Color(242,239,233)));
style.add_rule(rule);
mapnikMap.insert_style("world",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(600000);
rule.append(mapnik::line_symbolizer(mapnik::color("#f2efe9")));
// rule.append(mapnik::polygon_symbolizer(mapnik::Color(242,239,233)));
style.add_rule(rule);
mapnikMap.insert_style("coast-poly",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(600000);
rule.append(mapnik::line_symbolizer(mapnik::color("#e46d71")));
// rule.append(mapnik::polygon_symbolizer(mapnik::Color(242,239,233)));
style.add_rule(rule);
mapnikMap.insert_style("coast-poly",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(100000000);
// rule.set_max_scale(1000000);
// rule.set_min_scale(500000);
// rule.append(mapnik::line_symbolizer(mapnik::color("#809bc0"),8.0));
rule.append(mapnik::line_symbolizer(mapnik::color("#80c09b"),8.0));
mapnik::text_symbolizer textSymb("name", "DejaVu Sans Book", 9, mapnik::color("#000"));
textSymb.set_label_placement(mapnik::LINE_PLACEMENT);
rule.append(textSymb);
style.add_rule(rule);
mapnikMap.insert_style("roads",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(100000000);
// rule.set_max_scale(1000000);
// rule.set_min_scale(500000);
rule.append(mapnik::line_symbolizer(mapnik::color("#b5d0d0"),10));
mapnik::text_symbolizer textSymb("name", "DejaVu Sans Book", 10, mapnik::color("#6699cc"));
textSymb.set_label_placement(mapnik::LINE_PLACEMENT);
rule.append(textSymb);
style.add_rule(rule);
mapnikMap.insert_style("river",style);
}
}
}
...@@ -20,11 +20,13 @@ ...@@ -20,11 +20,13 @@
#define __otbVectorDataStyle_h #define __otbVectorDataStyle_h
#include "itkLightObject.h" #include "itkLightObject.h"
#include "itkObjectFactory.h"
#include <mapnik/map.hpp>
namespace otb namespace otb
{ {
/** \class VectorDataStyle /** \class VectorDataStyle
* \brief Render a vector data into an image * \brief Load style into a mapnik::Map
* *
*/ */
...@@ -32,7 +34,31 @@ namespace otb ...@@ -32,7 +34,31 @@ namespace otb
class ITK_EXPORT VectorDataStyle : public itk::LightObject class ITK_EXPORT VectorDataStyle : public itk::LightObject
{ {
public: public:
/** Standard class typedefs. */
typedef VectorDataStyle Self;
typedef itk::LightObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(VectorDataStyle, LightObject);
void LoadOSMStyle(mapnik::Map& mapnikMap) const;
protected:
/** Constructor */
VectorDataStyle() {};
/** Destructor */
virtual ~VectorDataStyle() {};
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
VectorDataStyle(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
}; // end class }; // end class
} // end namespace otb } // end namespace otb
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "otbVectorDataToImageFilter.h" #include "otbVectorDataToImageFilter.h"
#include "itkImageRegionIterator.h" #include "itkImageRegionIterator.h"
#include "otbVectorDataStyle.h"
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
...@@ -250,62 +251,10 @@ namespace otb ...@@ -250,62 +251,10 @@ namespace otb
m_Map.set_background(mapnik::color("#f2efe9"));//TODO set to transparent later m_Map.set_background(mapnik::color("#f2efe9"));//TODO set to transparent later
//TODO the code bellow will be in another class later on otb::VectorDataStyle::Pointer styleLoader = otb::VectorDataStyle::New();
{ styleLoader->LoadOSMStyle(m_Map);
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(250000000000LLU);
rule.set_min_scale(600000);
rule.append(mapnik::line_symbolizer(mapnik::color("#f2efe9")));
// rule.append(mapnik::polygon_symbolizer(mapnik::Color(242,239,233)));
style.add_rule(rule);
m_Map.insert_style("world",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(600000);
rule.append(mapnik::line_symbolizer(mapnik::color("#f2efe9")));
// rule.append(mapnik::polygon_symbolizer(mapnik::Color(242,239,233)));
style.add_rule(rule);
m_Map.insert_style("coast-poly",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(600000);
rule.append(mapnik::line_symbolizer(mapnik::color("#e46d71")));
// rule.append(mapnik::polygon_symbolizer(mapnik::Color(242,239,233)));
style.add_rule(rule);
m_Map.insert_style("coast-poly",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(100000000);
// rule.set_max_scale(1000000);
// rule.set_min_scale(500000);
// rule.append(mapnik::line_symbolizer(mapnik::color("#809bc0"),8.0));
rule.append(mapnik::line_symbolizer(mapnik::color("#80c09b"),8.0));
mapnik::text_symbolizer textSymb("name", "DejaVu Sans Book", 9, mapnik::color("#000"));
textSymb.set_label_placement(mapnik::LINE_PLACEMENT);
rule.append(textSymb);
style.add_rule(rule);
m_Map.insert_style("roads",style);
}
{
mapnik::feature_type_style style;
mapnik::rule_type rule;
rule.set_max_scale(100000000);
// rule.set_max_scale(1000000);
// rule.set_min_scale(500000);
rule.append(mapnik::line_symbolizer(mapnik::color("#b5d0d0"),10));
mapnik::text_symbolizer textSymb("name", "DejaVu Sans Book", 10, mapnik::color("#6699cc"));
textSymb.set_label_placement(mapnik::LINE_PLACEMENT);
rule.append(textSymb);
style.add_rule(rule);
m_Map.insert_style("river",style);
}
} }
template <class TVectorData, class TImage> template <class TVectorData, class TImage>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment