Added template parameter and data member to svg_renderer for holding the output stream.
This commit is contained in:
parent
3e06e21189
commit
30e85c4d58
17 changed files with 164 additions and 24 deletions
|
@ -1266,6 +1266,7 @@ if not HELP_REQUESTED:
|
||||||
|
|
||||||
# build C++ tests
|
# build C++ tests
|
||||||
SConscript('tests/cpp_tests/SConscript')
|
SConscript('tests/cpp_tests/SConscript')
|
||||||
|
SConscript('tests/cpp_tests/svg_renderer_tests/SConscript')
|
||||||
|
|
||||||
# install pkg-config script and mapnik-config script
|
# install pkg-config script and mapnik-config script
|
||||||
SConscript('utils/mapnik-config/SConscript')
|
SConscript('utils/mapnik-config/SConscript')
|
||||||
|
|
|
@ -28,17 +28,20 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/feature_style_processor.hpp>
|
#include <mapnik/feature_style_processor.hpp>
|
||||||
|
|
||||||
|
// stl
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
// svg_renderer isn't a template class for now, because
|
// parameterized with the type of ostream it will use for output.
|
||||||
// I haven't devised an equivalent of image_32 for svg.
|
template <typename T>
|
||||||
class MAPNIK_DECL svg_renderer : public feature_style_processor<svg_renderer>,
|
class MAPNIK_DECL svg_renderer : public feature_style_processor<svg_renderer<T> >,
|
||||||
private boost::noncopyable
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// the only parameter I'm sure of is the map.
|
// the only parameter I'm sure of is the map.
|
||||||
svg_renderer(Map const& m);
|
svg_renderer(Map const& m, T & output_stream);
|
||||||
~svg_renderer();
|
~svg_renderer();
|
||||||
|
|
||||||
void start_map_processing(Map const& map);
|
void start_map_processing(Map const& map);
|
||||||
|
@ -78,6 +81,14 @@ namespace mapnik
|
||||||
void process(glyph_symbolizer const& sym,
|
void process(glyph_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans);
|
proj_transform const& prj_trans);
|
||||||
|
|
||||||
|
// constant variable that stores the xml declaration.
|
||||||
|
static const std::string XML_DECLARATION;
|
||||||
|
// constant variable that stores the dtd urls.
|
||||||
|
static const std::string SVG_DTD;
|
||||||
|
|
||||||
|
private:
|
||||||
|
T & output_stream_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(building_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(building_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(building_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(glyph_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(glyph_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(glyph_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(line_pattern_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(line_pattern_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(line_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(line_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(line_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(markers_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(markers_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(markers_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(point_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(point_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(point_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(polygon_pattern_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(polygon_pattern_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(polygon_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(polygon_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(polygon_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(raster_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(raster_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(raster_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
void svg_renderer::process(shield_symbolizer const& sym,
|
template <typename T>
|
||||||
|
void svg_renderer<T>::process(shield_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(shield_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,15 @@
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
template <typename T>
|
||||||
void svg_renderer::process(text_symbolizer const& sym,
|
void svg_renderer<T>::process(text_symbolizer const& sym,
|
||||||
Feature const& feature,
|
Feature const& feature,
|
||||||
proj_transform const& prj_trans)
|
proj_transform const& prj_trans)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template void svg_renderer<std::stringstream>::process(text_symbolizer const& sym,
|
||||||
|
Feature const& feature,
|
||||||
|
proj_transform const& prj_trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,20 +28,35 @@
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
svg_renderer::svg_renderer(Map const& m) :
|
/*
|
||||||
feature_style_processor<svg_renderer>(m)
|
* XML_DECLARATION and SVG_DTD comprise the XML header of the SVG document.
|
||||||
|
* They are required for producing standard compliant XML documents.
|
||||||
|
* They are stored in svg_renderer, but they might move to somewhere else.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
const std::string svg_renderer<T>::XML_DECLARATION = "<?xml version=\"1.0\" standalone=\"no\"?>";
|
||||||
|
template <typename T>
|
||||||
|
const std::string svg_renderer<T>::SVG_DTD = "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">";
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
svg_renderer<T>::svg_renderer(Map const& m, T & output_stream) :
|
||||||
|
feature_style_processor<svg_renderer>(m),
|
||||||
|
output_stream_(output_stream)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
svg_renderer::~svg_renderer() {}
|
template <typename T>
|
||||||
|
svg_renderer<T>::~svg_renderer() {}
|
||||||
|
|
||||||
// only empty methods for now.
|
// only empty methods for now.
|
||||||
|
|
||||||
void svg_renderer::start_map_processing(Map const& map)
|
template <typename T>
|
||||||
|
void svg_renderer<T>::start_map_processing(Map const& map)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
|
|
||||||
|
@ -50,7 +65,8 @@ namespace mapnik
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg_renderer::end_map_processing(Map const& map)
|
template <typename T>
|
||||||
|
void svg_renderer<T>::end_map_processing(Map const& map)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
|
|
||||||
|
@ -59,7 +75,8 @@ namespace mapnik
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg_renderer::start_layer_processing(layer const& lay)
|
template <typename T>
|
||||||
|
void svg_renderer<T>::start_layer_processing(layer const& lay)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
|
|
||||||
|
@ -68,7 +85,8 @@ namespace mapnik
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg_renderer::end_layer_processing(layer const& lay)
|
template <typename T>
|
||||||
|
void svg_renderer<T>::end_layer_processing(layer const& lay)
|
||||||
{
|
{
|
||||||
// nothing yet.
|
// nothing yet.
|
||||||
|
|
||||||
|
@ -76,4 +94,6 @@ namespace mapnik
|
||||||
std::clog << "end layer processing: " << lay.name() << std::endl;
|
std::clog << "end layer processing: " << lay.name() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template class svg_renderer<std::stringstream>;
|
||||||
}
|
}
|
||||||
|
|
20
tests/cpp_tests/svg_renderer_tests/SConscript
Normal file
20
tests/cpp_tests/svg_renderer_tests/SConscript
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
|
|
||||||
|
Import ('env')
|
||||||
|
|
||||||
|
headers = env['CPPPATH']
|
||||||
|
|
||||||
|
boost_filesystem = 'boost_filesystem%s' % env['BOOST_APPEND']
|
||||||
|
boost_system = 'boost_system%s' % env['BOOST_APPEND']
|
||||||
|
|
||||||
|
libraries = [boost_system, boost_filesystem, 'mapnik2']
|
||||||
|
|
||||||
|
if env['PLATFORM'] == 'Darwin':
|
||||||
|
libraries.append(env['ICU_LIB_NAME'])
|
||||||
|
|
||||||
|
if env['HAS_BOOST_SYSTEM']:
|
||||||
|
libraries.append(boost_system)
|
||||||
|
|
||||||
|
for cpp_test in glob.glob('*_test.cpp'):
|
||||||
|
env.Program(cpp_test.replace('.cpp',''), [cpp_test], CPPPATH=headers, LIBS=libraries)
|
34
tests/cpp_tests/svg_renderer_tests/compilation_test.cpp
Normal file
34
tests/cpp_tests/svg_renderer_tests/compilation_test.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#define BOOST_TEST_MODULE compile_tests
|
||||||
|
|
||||||
|
// boost.test
|
||||||
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
|
// mapnik
|
||||||
|
#include <mapnik/map.hpp>
|
||||||
|
#include <mapnik/svg_renderer.hpp>
|
||||||
|
|
||||||
|
// std
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test is meant to see if the empty
|
||||||
|
* implementation of SVG renderer compiles
|
||||||
|
* and runs when using the inherited methods.
|
||||||
|
*/
|
||||||
|
BOOST_AUTO_TEST_CASE(compile_test_case)
|
||||||
|
{
|
||||||
|
using namespace mapnik;
|
||||||
|
|
||||||
|
Map map(800, 600);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::stringstream output_stream;
|
||||||
|
svg_renderer<std::stringstream> renderer(map, output_stream);
|
||||||
|
renderer.apply();
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
BOOST_FAIL("Empty implementation throws exception.");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue