make it possible to disable compilation of grid_renderer - closes #1962

This commit is contained in:
Dane Springmeyer 2013-07-23 19:37:25 -04:00
parent 5ad2ebb30e
commit ef4dfeb747
14 changed files with 507 additions and 395 deletions

View file

@ -8,6 +8,10 @@ For a complete change history, see the git log.
## Future
- Added to python bindings: `has_tiff`, `has_png`, `has_webp`, `has_proj4`, `has_svg_renderer`, and `has_grid_renderer`
- Made it possible to disable compilation of `grid_renderer` with `./configure GRID_RENDERER=False` (#1962)
- Added `webp` image encoding and decoding support (#1955)
- Added `premultiplied` property on mapnik::image_32 / mapnik.Image to enable knowledge of premultiplied status of image buffer.

View file

@ -336,6 +336,7 @@ opts.AddVariables(
# Variables affecting rendering back-ends
BoolVariable('GRID_RENDERER', 'build support for native grid renderer', 'True'),
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
BoolVariable('CPP_TESTS', 'Compile the C++ tests', 'True'),
BoolVariable('BENCHMARK', 'Compile the C++ benchmark scripts', 'False'),
@ -447,6 +448,7 @@ pickle_store = [# Scons internal variables
'CAIRO_LIBPATHS',
'CAIRO_ALL_LIBS',
'CAIRO_CPPPATHS',
'GRID_RENDERER',
'SVG_RENDERER',
'SQLITE_LINKFLAGS',
'BOOST_LIB_VERSION_FROM_HEADER',

View file

@ -20,6 +20,8 @@
*
*****************************************************************************/
#if defined(GRID_RENDERER)
// boost
#include <boost/python.hpp>
#include <boost/python/module.hpp>
@ -80,3 +82,5 @@ void export_grid()
;
}
#endif

View file

@ -20,6 +20,8 @@
*
*****************************************************************************/
#if defined(GRID_RENDERER)
// boost
#include <boost/python.hpp>
#include <boost/python/module.hpp>
@ -49,3 +51,5 @@ void export_grid_view()
)
;
}
#endif

View file

@ -41,8 +41,10 @@ void export_image();
void export_image_view();
void export_gamma_method();
void export_scaling_method();
#if defined(GRID_RENDERER)
void export_grid();
void export_grid_view();
#endif
void export_map();
void export_python();
void export_expression();
@ -92,7 +94,9 @@ void export_logger();
#include <mapnik/value_error.hpp>
#include <mapnik/save_map.hpp>
#include <mapnik/scale_denominator.hpp>
#if defined(GRID_RENDERER)
#include "python_grid_utils.hpp"
#endif
#include "mapnik_value_converter.hpp"
#include "mapnik_threads.hpp"
#include "python_optional.hpp"
@ -366,7 +370,33 @@ std::string mapnik_version_string()
return MAPNIK_VERSION_STRING;
}
// indicator for jpeg read/write support within libmapnik
bool has_proj4()
{
#if defined(MAPNIK_USE_PROJ4)
return true;
#else
return false;
#endif
}
bool has_svg_renderer()
{
#if defined(SVG_RENDERER)
return true;
#else
return false;
#endif
}
bool has_grid_renderer()
{
#if defined(GRID_RENDERER)
return true;
#else
return false;
#endif
}
bool has_jpeg()
{
#if defined(HAVE_JPEG)
@ -376,6 +406,33 @@ bool has_jpeg()
#endif
}
bool has_png()
{
#if defined(HAVE_PNG)
return true;
#else
return false;
#endif
}
bool has_tiff()
{
#if defined(HAVE_TIFF)
return true;
#else
return false;
#endif
}
bool has_webp()
{
#if defined(HAVE_WEBP)
return true;
#else
return false;
#endif
}
// indicator for cairo rendering support inside libmapnik
bool has_cairo()
{
@ -427,7 +484,6 @@ BOOST_PYTHON_MODULE(_mapnik)
using mapnik::load_map_string;
using mapnik::save_map;
using mapnik::save_map_to_string;
using mapnik::render_grid;
register_exception_translator<std::exception>(&standard_error_translator);
register_exception_translator<std::out_of_range>(&out_of_range_error_translator);
@ -448,8 +504,10 @@ BOOST_PYTHON_MODULE(_mapnik)
export_image_view();
export_gamma_method();
export_scaling_method();
#if defined(GRID_RENDERER)
export_grid();
export_grid_view();
#endif
export_expression();
export_rule();
export_style();
@ -487,7 +545,8 @@ BOOST_PYTHON_MODULE(_mapnik)
">>> clear_cache()\n"
);
def("render_grid",&render_grid,
#if defined(GRID_RENDERER)
def("render_grid",&mapnik::render_grid,
( arg("map"),
arg("layer"),
args("key")="__id__",
@ -495,6 +554,7 @@ BOOST_PYTHON_MODULE(_mapnik)
arg("fields")=boost::python::list()
)
);
#endif
def("render_to_file",&render_to_file1,
"\n"
@ -579,9 +639,11 @@ BOOST_PYTHON_MODULE(_mapnik)
(arg("map"),arg("image"),args("layer"))
);
#if defined(GRID_RENDERER)
def("render_layer", &mapnik::render_layer_for_grid,
(arg("map"),arg("grid"),args("layer"),arg("fields")=boost::python::list())
);
#endif
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
def("render",&render3,
@ -739,7 +801,12 @@ BOOST_PYTHON_MODULE(_mapnik)
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
def("mapnik_version_string", &mapnik_version_string,"Get the Mapnik version string");
def("has_proj4", &has_proj4, "Get proj4 status");
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
def("has_png", &has_png, "Get png read/write support status");
def("has_tiff", &has_jpeg, "Get tiff read/write support status");
def("has_webp", &has_jpeg, "Get webp read/write support status");
def("has_grid_renderer", &has_grid_renderer, "Get grid_renderer status");
def("has_cairo", &has_cairo, "Get cairo library status");
def("has_pycairo", &has_pycairo, "Get pycairo module status");

View file

@ -20,6 +20,8 @@
*
*****************************************************************************/
#if defined(GRID_RENDERER)
// boost
#include <boost/python.hpp>
#include <boost/scoped_array.hpp>
@ -472,3 +474,5 @@ boost::python::dict render_grid(mapnik::Map const& map,
}
}
#endif

View file

@ -9,6 +9,9 @@ subdirs = ['','svg','wkt','grid','json','util','text_placements','formatting']
if env['SVG_RENDERER']:
subdirs.append('svg/output')
if env['GRID_RENDERER']:
subdirs.append('grid')
if 'install' in COMMAND_LINE_TARGETS:
for subdir in subdirs:
pathdir = os.path.join(base,subdir,'*.hpp')

View file

@ -27,7 +27,11 @@
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/gradient.hpp>
#include <mapnik/box2d.hpp>
#if defined(GRID_RENDERER)
#include <mapnik/grid/grid_pixel.hpp>
#endif
#include <mapnik/noncopyable.hpp>
// boost
@ -334,6 +338,7 @@ public:
}
}
#if defined(GRID_RENDERER)
template <typename Rasterizer, typename Scanline, typename Renderer>
void render_id(Rasterizer& ras,
Scanline& sl,
@ -416,6 +421,7 @@ public:
}
}
}
#endif
private:

View file

@ -292,6 +292,7 @@ if env['RUNTIME_LINK'] == "static":
source += glob.glob('../deps/agg/src/' + '*.cpp')
# grid backend
if env['GRID_RENDERER']: # svg backend
source += Split(
"""
grid/grid.cpp
@ -307,6 +308,8 @@ source += Split(
grid/process_shield_symbolizer.cpp
grid/process_text_symbolizer.cpp
""")
lib_env.Append(CPPDEFINES = '-DGRID_RENDERER')
libmapnik_defines.append('-DGRID_RENDERER')
# https://github.com/mapnik/mapnik/issues/1438
if env['SVG_RENDERER']: # svg backend

View file

@ -24,8 +24,11 @@
#include <mapnik/feature_style_processor_impl.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/graphics.hpp>
#if defined(GRID_RENDERER)
#include <mapnik/grid/grid_renderer.hpp>
#include <mapnik/grid/grid.hpp>
#endif
#if defined(HAVE_CAIRO)
#include <cairo.h>
@ -48,7 +51,10 @@ template class feature_style_processor<cairo_renderer<cairo_surface_ptr> >;
template class feature_style_processor<svg_renderer<std::ostream_iterator<char> > >;
#endif
#if defined(GRID_RENDERER)
template class feature_style_processor<grid_renderer<grid> >;
#endif
template class feature_style_processor<agg_renderer<image_32> >;
}

View file

@ -25,7 +25,11 @@
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/text_properties.hpp>
#include <mapnik/graphics.hpp>
#if defined(GRID_RENDERER)
#include <mapnik/grid/grid.hpp>
#endif
#include <mapnik/text_path.hpp>
#include <mapnik/pixel_position.hpp>
#include <mapnik/font_util.hpp>
@ -686,6 +690,7 @@ void text_renderer<T>::render(pixel_position const& pos)
}
}
#if defined(GRID_RENDERER)
template <typename T>
void text_renderer<T>::render_id(mapnik::value_integer feature_id,
pixel_position const& pos)
@ -715,6 +720,7 @@ void text_renderer<T>::render_id(mapnik::value_integer feature_id,
}
}
}
#endif
#ifdef MAPNIK_THREADSAFE
boost::mutex freetype_engine::mutex_;
@ -729,6 +735,7 @@ template text_renderer<image_32>::text_renderer(image_32&,
double);
template box2d<double>text_renderer<image_32>::prepare_glyphs(text_path const&);
template void text_renderer<image_32>::render(pixel_position const&);
#if defined(GRID_RENDERER)
template void text_renderer<grid>::render_id(mapnik::value_integer,
pixel_position const&);
template text_renderer<grid>::text_renderer(grid&,
@ -736,4 +743,5 @@ template text_renderer<grid>::text_renderer(grid&,
halo_rasterizer_e,
composite_mode_e, double);
template box2d<double>text_renderer<grid>::prepare_glyphs(text_path const& );
#endif
}

View file

@ -45,6 +45,7 @@ def make_map():
m.zoom_all()
return m
if mapnik.has_grid_renderer():
def test_clearing_grid_data():
g = mapnik.Grid(256,256)
utf = g.encode()
@ -57,7 +58,6 @@ def test_clearing_grid_data():
g.clear()
eq_(g.encode(),utf)
if __name__ == "__main__":
setup()
run_all(eval(x) for x in dir() if x.startswith("test_"))

View file

@ -15,6 +15,7 @@ def setup():
# from another directory we need to chdir()
os.chdir(execution_path('.'))
if mapnik.has_grid_renderer():
def show_grids(name,g1,g2):
g1_file = '/tmp/mapnik-%s-actual.json' % name
open(g1_file,'w').write(json.dumps(g1,sort_keys=True))

View file

@ -21,7 +21,7 @@ defaults = {
'scales':[1.0,2.0],
'agg': True,
'cairo': mapnik.has_cairo(),
'grid': True
'grid': mapnik.has_grid_renderer()
}
cairo_threshold = 10