diff --git a/CHANGELOG.md b/CHANGELOG.md index 162d4901b..30e0d1210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ For a complete change history, see the git log. ## Future +- Added the ability to create a mapnik Feature from a geojson feature with `mapnik.Feature.from_geojson` in python. + +- 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. diff --git a/SConstruct b/SConstruct index cf8904425..19336030e 100644 --- a/SConstruct +++ b/SConstruct @@ -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', @@ -613,6 +615,10 @@ def get_pkg_lib(context, config, lib): if ret: try: value = call(cmd,silent=True) + if ' ' in value: + parts = value.split(' ') + if len(parts) > 1: + value = parts[1] libnames = re.findall(libpattern,value) if libnames: libname = libnames[0] @@ -1325,19 +1331,19 @@ if not preconfigured: else: env['SKIPPED_DEPS'].append('boost_regex_icu') - if not env['HOST']: for libname, headers, required, lang, define in OPTIONAL_LIBSHEADERS: - if not conf.CheckLibWithHeader(libname, headers, lang): - if required: - color_print(1, 'Could not find required header or shared library for %s' % libname) - env['MISSING_DEPS'].append(libname) + if not env['HOST']: + if not conf.CheckLibWithHeader(libname, headers, lang): + if required: + color_print(1, 'Could not find required header or shared library for %s' % libname) + env['MISSING_DEPS'].append(libname) + else: + color_print(4, 'Could not find optional header or shared library for %s' % libname) + env['SKIPPED_DEPS'].append(libname) else: - color_print(4, 'Could not find optional header or shared library for %s' % libname) - env['SKIPPED_DEPS'].append(libname) + env.Append(CPPDEFINES = define) else: env.Append(CPPDEFINES = define) - else: - env.Append(CPPDEFINES = define) env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] @@ -1362,7 +1368,12 @@ if not preconfigured: conf.parse_config('GDAL_CONFIG',checks='--cflags') libname = conf.get_pkg_lib('GDAL_CONFIG','gdal') if libname: - details['lib'] = libname + if not conf.CheckLibWithHeader(libname, details['inc'], details['lang']): + env['SKIPPED_DEPS'].append('gdal') + if libname in env['LIBS']: + env['LIBS'].remove(libname) + else: + details['lib'] = libname elif plugin == 'postgis': conf.parse_pg_config('PG_CONFIG') elif plugin == 'ogr': @@ -1372,7 +1383,13 @@ if not preconfigured: conf.parse_config('GDAL_CONFIG',checks='--cflags') libname = conf.get_pkg_lib('GDAL_CONFIG','ogr') if libname: - details['lib'] = libname + if not conf.CheckLibWithHeader(libname, details['inc'], details['lang']): + if 'gdal' not in env['SKIPPED_DEPS']: + env['SKIPPED_DEPS'].append('gdal') + if libname in env['LIBS']: + env['LIBS'].remove(libname) + else: + details['lib'] = libname elif details['path'] and details['lib'] and details['inc']: backup = env.Clone().Dictionary() # Note, the 'delete_existing' keyword makes sure that these paths are prepended @@ -1385,7 +1402,6 @@ if not preconfigured: env.Replace(**backup) env['SKIPPED_DEPS'].append(details['lib']) if plugin == 'sqlite': - SQLITE_HAS_RTREE = conf.sqlite_has_rtree() sqlite_backup = env.Clone().Dictionary() # if statically linking, on linux we likely # need to link sqlite to pthreads and dl @@ -1400,8 +1416,7 @@ if not preconfigured: env.Append(LIBS=lib) except OSError,e: pass - if SQLITE_HAS_RTREE is None: - SQLITE_HAS_RTREE = conf.sqlite_has_rtree() + SQLITE_HAS_RTREE = conf.sqlite_has_rtree() if not SQLITE_HAS_RTREE: env.Replace(**sqlite_backup) if details['lib'] in env['LIBS']: @@ -1654,6 +1669,16 @@ if not preconfigured: debug_defines = ['-DDEBUG', '-DMAPNIK_DEBUG'] ndebug_defines = ['-DNDEBUG'] + # c++11 support / https://github.com/mapnik/mapnik/issues/1683 + # - upgrade to PHOENIX_V3 since that is needed for c++11 compile + if 'c++11' in env['CUSTOM_CXXFLAGS']: + env.Append(CPPDEFINES = '-DBOOST_SPIRIT_USE_PHOENIX_V3=1') + # - workaround boost gil channel_algorithm.hpp narrowing error + # TODO - remove when building against >= 1.55 + # https://github.com/mapnik/mapnik/issues/1970 + if 'clang++' in env['CXX']: + env.Append(CXXFLAGS = '-Wno-c++11-narrowing') + # Enable logging in debug mode (always) and release mode (when specified) if env['DEFAULT_LOG_SEVERITY']: if env['DEFAULT_LOG_SEVERITY'] not in severities: @@ -1694,7 +1719,7 @@ if not preconfigured: if not env['SUNCC']: # Common flags for CXX compiler. - common_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread) + common_cxx_flags = '-Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread) # https://github.com/mapnik/mapnik/issues/1835 if sys.platform == 'darwin' and env['CXX'] == 'g++': diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 8668ab5d4..6173f6758 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -266,7 +266,7 @@ struct test5 s.resize(s.capacity()); while (true) { - size_t n2 = static_cast(snprintf(&s[0], s.size()+1, "%g", val_)); + size_t n2 = static_cast(snprintf(&s[0], s.size()+1, "%g", val)); if (n2 <= s.size()) { s.resize(n2); diff --git a/bindings/python/build.py b/bindings/python/build.py index bf9b1b2f1..7526ea48d 100644 --- a/bindings/python/build.py +++ b/bindings/python/build.py @@ -46,6 +46,8 @@ target_path_deprecated = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.pa py_env = env.Clone() py_env.Append(CPPPATH = env['PYTHON_INCLUDES']) +py_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES']) + py_env['LIBS'] = ['mapnik',env['BOOST_PYTHON_LIB']] link_all_libs = env['LINKING'] == 'static' or env['RUNTIME_LINK'] == 'static' or (env['PLATFORM'] == 'Darwin' and not env['PYTHON_DYNAMIC_LOOKUP']) diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index 19b3b4aa2..f2271da1a 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -30,12 +30,15 @@ #include #include + // mapnik #include +#include #include #include #include #include +#include #include // stl @@ -49,7 +52,7 @@ using mapnik::context_type; using mapnik::context_ptr; using mapnik::feature_kv_iterator; -mapnik::geometry_type const& (mapnik::feature_impl::*get_geometry_by_const_ref)(unsigned) const = &mapnik::feature_impl::get_geometry; +mapnik::geometry_type const& (mapnik::feature_impl::*get_geometry_by_const_ref)(std::size_t) const = &mapnik::feature_impl::get_geometry; boost::ptr_vector const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths; void feature_add_geometries_from_wkb(mapnik::feature_impl &feature, std::string wkb) @@ -64,6 +67,18 @@ void feature_add_geometries_from_wkt(mapnik::feature_impl &feature, std::string if (!result) throw std::runtime_error("Failed to parse WKT"); } +mapnik::feature_ptr from_geojson_impl(std::string const& json, mapnik::context_ptr const& ctx) +{ + mapnik::transcoder tr("utf8"); + mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1)); + mapnik::json::feature_parser parser(tr); + if (!parser.parse(json.begin(), json.end(), *feature)) + { + throw std::runtime_error("Failed to parse geojson feature"); + } + return feature; +} + std::string feature_to_geojson(mapnik::feature_impl const& feature) { std::string json; @@ -232,5 +247,7 @@ void export_feature() .def("__len__", &mapnik::feature_impl::size) .def("context",&mapnik::feature_impl::context) .def("to_geojson",&feature_to_geojson) + .def("from_geojson",from_geojson_impl) + .staticmethod("from_geojson") ; } diff --git a/bindings/python/mapnik_grid.cpp b/bindings/python/mapnik_grid.cpp index 1118d3b4b..09b21ee3d 100644 --- a/bindings/python/mapnik_grid.cpp +++ b/bindings/python/mapnik_grid.cpp @@ -20,6 +20,8 @@ * *****************************************************************************/ +#if defined(GRID_RENDERER) + // boost #include #include @@ -80,3 +82,5 @@ void export_grid() ; } + +#endif diff --git a/bindings/python/mapnik_grid_view.cpp b/bindings/python/mapnik_grid_view.cpp index aa29dda78..5e9d2745f 100644 --- a/bindings/python/mapnik_grid_view.cpp +++ b/bindings/python/mapnik_grid_view.cpp @@ -20,6 +20,8 @@ * *****************************************************************************/ +#if defined(GRID_RENDERER) + // boost #include #include @@ -49,3 +51,5 @@ void export_grid_view() ) ; } + +#endif diff --git a/bindings/python/mapnik_map.cpp b/bindings/python/mapnik_map.cpp index ba9012652..4fabd5177 100644 --- a/bindings/python/mapnik_map.cpp +++ b/bindings/python/mapnik_map.cpp @@ -106,17 +106,6 @@ double get_scale_denominator(mapnik::Map const& map) return mapnik::scale_denominator( map.scale(), map_proj.is_geographic()); } -// deepcopy -/* -mapnik::Map map_deepcopy(mapnik::Map & m, boost::python::dict memo) -{ - // FIXME: ignore memo for now - mapnik::Map result; - mapnik::util::deepcopy(m, result); - return result; -} -*/ - void set_maximum_extent(mapnik::Map & m, boost::optional > const& box) { if (box) diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 9d9deb45f..1be3f5b5a 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -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 #include #include +#if defined(GRID_RENDERER) #include "python_grid_utils.hpp" +#endif #include "mapnik_value_converter.hpp" #include "mapnik_threads.hpp" #include "python_optional.hpp" @@ -365,7 +369,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) @@ -375,6 +405,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() { @@ -426,7 +483,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(&standard_error_translator); register_exception_translator(&out_of_range_error_translator); @@ -447,8 +503,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(); @@ -486,7 +544,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__", @@ -494,6 +553,7 @@ BOOST_PYTHON_MODULE(_mapnik) arg("fields")=boost::python::list() ) ); +#endif def("render_to_file",&render_to_file1, "\n" @@ -578,9 +638,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, @@ -738,7 +800,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"); diff --git a/bindings/python/mapnik_text_placement.cpp b/bindings/python/mapnik_text_placement.cpp index 05201326a..c2b08eb50 100644 --- a/bindings/python/mapnik_text_placement.cpp +++ b/bindings/python/mapnik_text_placement.cpp @@ -194,13 +194,16 @@ struct ListNodeWrap: formatting::list_node, wrapper ListNodeWrap(object l) : formatting::list_node(), wrapper() { stl_input_iterator begin(l), end; - children_.insert(children_.end(), begin, end); + while (begin != end) + { + children_.push_back(*begin); + ++begin; + } } /* TODO: Add constructor taking variable number of arguments. http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_function */ - virtual void apply(char_properties const& p, feature_impl const& feature, processed_text &output) const { if(override o = this->get_override("apply")) diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index 96af0218c..3d8408225 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -20,6 +20,8 @@ * *****************************************************************************/ +#if defined(GRID_RENDERER) + // boost #include #include @@ -472,3 +474,5 @@ boost::python::dict render_grid(mapnik::Map const& map, } } + +#endif diff --git a/bindings/python/python_optional.hpp b/bindings/python/python_optional.hpp index 9bc38d119..3b41ff757 100644 --- a/bindings/python/python_optional.hpp +++ b/bindings/python/python_optional.hpp @@ -228,7 +228,7 @@ public: : boost::python::class_(name, doc, i) { } template - self& def_readwrite_convert(char const* name, D const& d, char const* doc=0) + self& def_readwrite_convert(char const* name, D const& d, char const* /*doc*/=0) { this->add_property(name, boost::python::make_getter(d, boost::python::return_value_policy()), diff --git a/demo/c++/build.py b/demo/c++/build.py index 63f1db762..4e8945d33 100644 --- a/demo/c++/build.py +++ b/demo/c++/build.py @@ -34,6 +34,7 @@ demo_env = env.Clone() demo_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS']) +demo_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES']) if env['HAS_CAIRO']: demo_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) @@ -41,9 +42,6 @@ if env['HAS_CAIRO']: libraries = ['mapnik'] libraries.extend(copy(env['LIBMAPNIK_LIBS'])) -if env['RUNTIME_LINK'] == 'static' and env['PLATFORM'] == 'Linux': - libraries.append('dl') - rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"]) Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) diff --git a/deps/agg/include/agg_pixfmt_rgba.h b/deps/agg/include/agg_pixfmt_rgba.h index a859982dd..5ad41f817 100644 --- a/deps/agg/include/agg_pixfmt_rgba.h +++ b/deps/agg/include/agg_pixfmt_rgba.h @@ -134,7 +134,7 @@ namespace agg static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, - unsigned cover=0) + unsigned /*cover*/=0) { calc_type r = p[Order::R]; calc_type g = p[Order::G]; diff --git a/include/build.py b/include/build.py index 02d3d0032..6fed90d9b 100644 --- a/include/build.py +++ b/include/build.py @@ -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') diff --git a/include/mapnik/agg_helpers.hpp b/include/mapnik/agg_helpers.hpp index c96c75a02..100847e7f 100644 --- a/include/mapnik/agg_helpers.hpp +++ b/include/mapnik/agg_helpers.hpp @@ -25,17 +25,12 @@ // mapnik #include -#include +#include // for line_cap_e, line_join_e, etc + // agg -#include "agg_basics.h" -#include "agg_gamma_functions.h" -#include "agg_math_stroke.h" -#include "agg_pixfmt_rgba.h" -#include "agg_scanline_u.h" -#include "agg_scanline_p.h" -#include "agg_renderer_outline_aa.h" -#include "agg_renderer_scanline.h" +#include "agg_gamma_functions.h" // for gamma_power, gamma_linear, etc +#include "agg_math_stroke.h" // for line_join_e::miter_join, etc #include "agg_rasterizer_outline_aa.h" namespace mapnik { diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index 5dc9d1328..bc70dd459 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -47,7 +47,6 @@ #include // for text_placements // boost -#include #include #include @@ -62,12 +61,11 @@ struct expression_attributes : boost::static_visitor explicit expression_attributes(Container& names) : names_(names) {} - void operator() (value_type const& x) const + void operator() (value_type const& /*x*/) const { - boost::ignore_unused_variable_warning(x); } - void operator() (geometry_type_attribute const& type) const + void operator() (geometry_type_attribute const& /*type*/) const { // do nothing } diff --git a/include/mapnik/cairo_context.hpp b/include/mapnik/cairo_context.hpp index 16a55e617..369edaf94 100644 --- a/include/mapnik/cairo_context.hpp +++ b/include/mapnik/cairo_context.hpp @@ -59,7 +59,7 @@ typedef cairo_status_t ErrorStatus; /// Throws the appropriate exception, if exceptions are enabled. inline void throw_exception(ErrorStatus status) { - throw std::runtime_error("cairo: fixme"); + throw std::runtime_error(std::string("cairo: ") + cairo_status_to_string(status)); } //We inline this because it is called so often. @@ -70,7 +70,7 @@ inline void check_status_and_throw_exception(ErrorStatus status) } template -void check_object_status_and_throw_exception(const T& object) +void check_object_status_and_throw_exception(T const& object) { check_status_and_throw_exception(object.get_status()); } diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index 1a4bade72..c2278231d 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -43,10 +43,6 @@ // boost #include -// FIXME -// forward declare so that -// apps using mapnik do not -// need agg headers namespace agg { struct trans_affine; } diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index a15f0fa87..e5dd849b1 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include // spirit2 #include @@ -39,24 +40,6 @@ // stl #include -namespace mapnik { - -// http://www.w3.org/TR/css3-color/#hsl-color -inline double hue_to_rgb( double m1, double m2, double h) -{ - if (h < 0.0) h = h + 1.0; - else if (h > 1) h = h - 1.0; - - if (h * 6 < 1.0) - return m1 + (m2 - m1) * h * 6.0; - if (h * 2 < 1.0) - return m2; - if (h * 3 < 2.0) - return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0; - return m1; -} - -} // namespace mapnik // boost #include @@ -125,7 +108,11 @@ struct alpha_conv_impl struct hsl_conv_impl { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp index caf5777fc..c190eef96 100644 --- a/include/mapnik/debug.hpp +++ b/include/mapnik/debug.hpp @@ -164,7 +164,7 @@ namespace mapnik { public: typedef std::basic_ostringstream stream_buffer; - void operator()(const logger::severity_type& severity, const stream_buffer &s) + void operator()(const logger::severity_type& /*severity*/, const stream_buffer &s) { #ifdef MAPNIK_THREADSAFE static boost::mutex mutex; @@ -193,15 +193,19 @@ namespace mapnik { base_log() {} +#ifdef MAPNIK_LOG base_log(const char* object_name) { -#ifdef MAPNIK_LOG if (object_name != NULL) { object_name_ = object_name; } -#endif } +#else + base_log(const char* /*object_name*/) + { + } +#endif ~base_log() { @@ -214,13 +218,20 @@ namespace mapnik { } template +#ifdef MAPNIK_LOG base_log &operator<<(const T &x) { -#ifdef MAPNIK_LOG + streambuf_ << x; -#endif return *this; } +#else + base_log &operator<<(const T& /*x*/) + { + + return *this; + } +#endif private: #ifdef MAPNIK_LOG diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index ed4a43008..d8c3732e4 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -65,7 +65,11 @@ struct unicode_impl struct regex_match_impl { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef expr_node type; @@ -82,7 +86,12 @@ struct regex_match_impl struct regex_replace_impl { + +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef expr_node type; diff --git a/include/mapnik/expression_grammar_impl.hpp b/include/mapnik/expression_grammar_impl.hpp index 5ca2c5eeb..2255d4856 100644 --- a/include/mapnik/expression_grammar_impl.hpp +++ b/include/mapnik/expression_grammar_impl.hpp @@ -145,7 +145,7 @@ expression_grammar::expression_grammar(mapnik::transcoder const& tr) multiplicative_expr = unary_expr [_val = _1] >> *( '*' >> unary_expr [_val *= _1] | '/' >> unary_expr [_val /= _1] - | '%' >> unary_expr [_val %= _1] + | '%' >> unary_expr [_val %= construct(_1)] //needed by clang++ with -std=c++11 | regex_match_expr[_val = regex_match_(_val, _1)] | regex_replace_expr(_val) [_val = _1] ) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index ce9a3dc79..83400a67d 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -211,17 +211,17 @@ public: geom_cont_.push_back(geom); } - unsigned num_geometries() const + std::size_t num_geometries() const { return geom_cont_.size(); } - geometry_type const& get_geometry(unsigned index) const + geometry_type const& get_geometry(std::size_t index) const { return geom_cont_[index]; } - geometry_type& get_geometry(unsigned index) + geometry_type& get_geometry(std::size_t index) { return geom_cont_[index]; } diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index 7d245d736..65312e286 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -49,7 +49,6 @@ #include #include #include -#include // stl #include @@ -74,11 +73,8 @@ template <> // No-op specialization struct process_impl { template - static void process(T0 & ren, T1 const& sym, T2 & f, T3 const& tr) + static void process(T0 & /*ren*/, T1 const& /*sym*/, T2 & /*f*/, T3 const& /*tr*/) { - boost::ignore_unused_variable_warning(ren); - boost::ignore_unused_variable_warning(f); - boost::ignore_unused_variable_warning(tr); #ifdef MAPNIK_DEBUG std::clog << "NO-OP ...\n"; #endif diff --git a/include/mapnik/graphics.hpp b/include/mapnik/graphics.hpp index ae7681304..b9a3c8f31 100644 --- a/include/mapnik/graphics.hpp +++ b/include/mapnik/graphics.hpp @@ -137,59 +137,6 @@ public: data_(x,y)=rgba; } } - inline void blendPixel(int x,int y,unsigned int rgba1,int t) - { - blendPixel2(x,y,rgba1,t,1.0); // do not change opacity - } - - inline void blendPixel2(int x,int y,unsigned int rgba1,int t,double opacity) - { - if (checkBounds(x,y)) - { - unsigned rgba0 = data_(x,y); -#ifdef MAPNIK_BIG_ENDIAN - unsigned a1 = (unsigned)((rgba1 & 0xff) * opacity) & 0xff; // adjust for desired opacity - a1 = (t*a1) / 255; - if (a1 == 0) return; - unsigned r1 = (rgba1 >> 24) & 0xff; - unsigned g1 = (rgba1 >> 16 ) & 0xff; - unsigned b1 = (rgba1 >> 8) & 0xff; - - unsigned a0 = (rgba0 & 0xff); - unsigned r0 = ((rgba0 >> 24 ) & 0xff) * a0; - unsigned g0 = ((rgba0 >> 16 ) & 0xff) * a0; - unsigned b0 = ((rgba0 >> 8) & 0xff) * a0; - - a0 = ((a1 + a0) << 8) - a0*a1; - - r0 = ((((r1 << 8) - r0) * a1 + (r0 << 8)) / a0); - g0 = ((((g1 << 8) - g0) * a1 + (g0 << 8)) / a0); - b0 = ((((b1 << 8) - b0) * a1 + (b0 << 8)) / a0); - a0 = a0 >> 8; - data_(x,y)= (a0)| (b0 << 8) | (g0 << 16) | (r0 << 24) ; -#else - unsigned a1 = (unsigned)(((rgba1 >> 24) & 0xff) * opacity) & 0xff; // adjust for desired opacity - a1 = (t*a1) / 255; - if (a1 == 0) return; - unsigned r1 = rgba1 & 0xff; - unsigned g1 = (rgba1 >> 8 ) & 0xff; - unsigned b1 = (rgba1 >> 16) & 0xff; - - unsigned a0 = (rgba0 >> 24) & 0xff; - unsigned r0 = (rgba0 & 0xff) * a0; - unsigned g0 = ((rgba0 >> 8 ) & 0xff) * a0; - unsigned b0 = ((rgba0 >> 16) & 0xff) * a0; - - a0 = ((a1 + a0) << 8) - a0*a1; - - r0 = ((((r1 << 8) - r0) * a1 + (r0 << 8)) / a0); - g0 = ((((g1 << 8) - g0) * a1 + (g0 << 8)) / a0); - b0 = ((((b1 << 8) - b0) * a1 + (b0 << 8)) / a0); - a0 = a0 >> 8; - data_(x,y)= (a0 << 24)| (b0 << 16) | (g0 << 8) | (r0) ; -#endif - } - } void composite_pixel(unsigned op, int x,int y,unsigned c, unsigned cover, double opacity); diff --git a/include/mapnik/grid/grid.hpp b/include/mapnik/grid/grid.hpp index bdbceae78..e9d7e85c1 100644 --- a/include/mapnik/grid/grid.hpp +++ b/include/mapnik/grid/grid.hpp @@ -198,30 +198,6 @@ public: return height_; } - inline void blendPixel(value_type feature_id,int x,int y,unsigned int rgba1,int t) - { - blendPixel2(feature_id ,x,y,rgba1,t,1.0); // do not change opacity - } - - inline void blendPixel2(value_type feature_id,int x,int y,unsigned int rgba1,int t,double opacity) - { - if (checkBounds(x,y)) - { - -#ifdef MAPNIK_BIG_ENDIAN - unsigned a = (int)((rgba1 & 0xff) * opacity) & 0xff; // adjust for desired opacity -#else - unsigned a = (int)(((rgba1 >> 24) & 0xff) * opacity) & 0xff; // adjust for desired opacity -#endif - // if the pixel is more than a tenth - // opaque then burn in the feature id - if (a >= 25) - { - data_(x,y) = feature_id; - } - } - } - inline void set_rectangle(value_type id,image_data_32 const& data,int x0,int y0) { box2d ext0(0,0,width_,height_); diff --git a/include/mapnik/grid/grid_pixfmt.hpp b/include/mapnik/grid/grid_pixfmt.hpp index 30c43fcd2..5ad790b9b 100644 --- a/include/mapnik/grid/grid_pixfmt.hpp +++ b/include/mapnik/grid/grid_pixfmt.hpp @@ -40,7 +40,7 @@ template struct blender_gray enum base_scale_e { base_shift = color_type::base_shift }; static AGG_INLINE void blend_pix(value_type* p, unsigned cv, - unsigned alpha, unsigned cover=0) + unsigned alpha, unsigned /*cover*/=0) { *p = (value_type)((((cv - calc_type(*p)) * alpha) + (calc_type(*p) << base_shift)) >> base_shift); } @@ -256,7 +256,7 @@ public: void blend_hline(int x, int y, unsigned len, const color_type& c, - agg::int8u cover) + agg::int8u /*cover*/) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x * Step + Offset; @@ -588,7 +588,7 @@ public: void blend_from_color(const SrcPixelFormatRenderer& from, const color_type& color, int xdst, int ydst, - int xsrc, int ysrc, + int /*xsrc*/, int ysrc, unsigned len, agg::int8u cover) { @@ -615,7 +615,7 @@ public: void blend_from_lut(const SrcPixelFormatRenderer& from, const color_type* color_lut, int xdst, int ydst, - int xsrc, int ysrc, + int /*xsrc*/, int ysrc, unsigned len, agg::int8u cover) { diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index f2b8e83b5..8abf326be 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -73,8 +73,8 @@ public: void end_map_processing(Map const& map); void start_layer_processing(layer const& lay, box2d const& query_extent); void end_layer_processing(layer const& lay); - void start_style_processing(feature_type_style const& st) {} - void end_style_processing(feature_type_style const& st) {} + void start_style_processing(feature_type_style const& /*st*/) {} + void end_style_processing(feature_type_style const& /*st*/) {} void render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, const agg::trans_affine & tr, double opacity, composite_mode_e comp_op); void process(point_symbolizer const& sym, diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index 3946cb8ad..4d41ea4a6 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -37,6 +37,7 @@ // agg #include "agg_basics.h" #include "agg_rendering_buffer.h" +#include "agg_color_rgba.h" #include "agg_pixfmt_rgba.h" #include "agg_scanline_u.h" #include "agg_blur.h" @@ -401,7 +402,7 @@ template void apply_filter(Src & src, agg_stack_blur const& op) { agg::rendering_buffer buf(src.raw_data(),src.width(),src.height(), src.width() * 4); - agg::pixfmt_rgba32 pixf(buf); + agg::pixfmt_rgba32_pre pixf(buf); agg::stack_blur_rgba32(pixf,op.rx,op.ry); } @@ -503,41 +504,46 @@ void apply_filter(Src & src, scale_hsla const& transform) uint8_t & g = get_color(src_it[x], green_t()); uint8_t & b = get_color(src_it[x], blue_t()); uint8_t & a = get_color(src_it[x], alpha_t()); + double r2 = static_cast(r)/255.0; + double g2 = static_cast(g)/255.0; + double b2 = static_cast(b)/255.0; double a2 = static_cast(a)/255.0; - double a1 = a2; - bool alpha_modified = false; - if (set_alpha && a2 > 0.01) + // demultiply + if (a2 <= 0.0) + { + r = g = b = 0; + continue; + } + else + { + r2 /= a2; + g2 /= a2; + b2 /= a2; + } + if (set_alpha) { a2 = transform.a0 + (a2 * (transform.a1 - transform.a0)); if (a2 <= 0) { - a = 0; + r = g = b = a = 0; + continue; + } + else if (a2 > 1) + { + a2 = 1; + a = 255; } else { - a = static_cast(std::floor((a2 * 255.0) +.5)); - if (a > 255) a = 255; + a = static_cast(std::floor((a2 * 255.0) +.5)); } - alpha_modified = true; } - if (tinting && a > 1) + if (tinting) { double h; double s; double l; - // demultiply - if (a1 <= 0.0) - { - r = g = b = 0; - continue; - } - else if (a1 < 1) - { - r /= a1; - g /= a1; - b /= a1; - } - rgb2hsl(r,g,b,h,s,l); + rgb2hsl(r2,g2,b2,h,s,l); double h2 = transform.h0 + (h * (transform.h1 - transform.h0)); double s2 = transform.s0 + (s * (transform.s1 - transform.s0)); double l2 = transform.l0 + (l * (transform.l1 - transform.l0)); @@ -547,42 +553,26 @@ void apply_filter(Src & src, scale_hsla const& transform) else if (s2 < 0) { s2 = 0; } if (l2 > 1) { l2 = 1; } else if (l2 < 0) { l2 = 0; } - hsl2rgb(h2,s2,l2,r,g,b); - // premultiply - // we only work with premultiplied source, - // thus all color values must be <= alpha - r *= a2; - g *= a2; - b *= a2; - } - else if (alpha_modified) - { - // demultiply - if (a1 <= 0.0) - { - r = g = b = 0; - continue; - } - else if (a1 < 1) - { - r /= a1; - g /= a1; - b /= a1; - } - // premultiply - // we only work with premultiplied source, - // thus all color values must be <= alpha - r *= a2; - g *= a2; - b *= a2; + hsl2rgb(h2,s2,l2,r2,g2,b2); } + // premultiply + r2 *= a2; + g2 *= a2; + b2 *= a2; + r = static_cast(std::floor((r2*255.0)+.5)); + g = static_cast(std::floor((g2*255.0)+.5)); + b = static_cast(std::floor((b2*255.0)+.5)); + // all color values must be <= alpha + if (r>a) r=a; + if (g>a) g=a; + if (b>a) b=a; } } } } template -void apply_filter(Src & src, gray const& op) +void apply_filter(Src & src, gray const& /*op*/) { using namespace boost::gil; @@ -632,14 +622,14 @@ void x_gradient_impl(Src const& src_view, Dst const& dst_view) } template -void apply_filter(Src & src, x_gradient const& op) +void apply_filter(Src & src, x_gradient const& /*op*/) { double_buffer tb(src); x_gradient_impl(tb.src_view, tb.dst_view); } template -void apply_filter(Src & src, y_gradient const& op) +void apply_filter(Src & src, y_gradient const& /*op*/) { double_buffer tb(src); x_gradient_impl(rotated90ccw_view(tb.src_view), @@ -647,7 +637,7 @@ void apply_filter(Src & src, y_gradient const& op) } template -void apply_filter(Src & src, invert const& op) +void apply_filter(Src & src, invert const& /*op*/) { using namespace boost::gil; diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index e5f0b5db6..8457880c7 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -26,13 +26,17 @@ // mapnik #include #include +#include + // boost #include + // stl #include #include #include // for std::back_insert_iterator + namespace mapnik { namespace filter { struct blur {}; @@ -66,7 +70,19 @@ struct scale_hsla l0(_l0), l1(_l1), a0(_a0), - a1(_a1) {} + a1(_a1) { + if (h0 < 0 || h0 > 1 || + h1 < 0 || h1 > 1 || + s0 < 0 || s0 > 1 || + s1 < 0 || s1 > 1 || + l0 < 0 || l0 > 1 || + l1 < 0 || l1 > 1 || + a0 < 0 || a0 > 1 || + a1 < 0 || a1 > 1) + { + throw config_error("scale-hsla values must be between 0 and 1"); + } + } inline bool is_identity() const { return (h0 == 0 && h1 == 1 && diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp index 43b8db635..ef8b8aadd 100644 --- a/include/mapnik/json/feature_collection_grammar.hpp +++ b/include/mapnik/json/feature_collection_grammar.hpp @@ -42,14 +42,14 @@ using standard_wide::space_type; struct generate_id { typedef int result_type; - + generate_id(int start) : id_(start) {} - + int operator() () const { return id_++; - } + } mutable int id_; }; @@ -76,7 +76,7 @@ struct feature_collection_grammar : feature_collection = lit('{') >> (type | features) % lit(",") >> lit('}') ; - + type = lit("\"type\"") > lit(":") > lit("\"FeatureCollection\"") ; @@ -86,29 +86,29 @@ struct feature_collection_grammar : > -(feature(_val) % lit(',')) > lit(']') ; - + feature = eps[_a = phoenix::construct(new_(ctx_,generate_id_()))] >> feature_g(*_a)[push_back(_r1,_a)] ; - + type.name("type"); features.name("features"); feature.name("feature"); feature_g.name("feature-grammar"); - + qi::on_error ( feature_collection , std::clog << phoenix::val("Error parsing GeoJSON ") - << qi::_4 + << qi::_4 << phoenix::val(" here: \"") - << construct(qi::_3, qi::_2) + << construct(qi::_3, qi::_2) << phoenix::val("\"") << std::endl ); } - + context_ptr ctx_; qi::rule(), space_type> feature_collection; // START qi::rule type; diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index a117b53dc..38bba2453 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -66,6 +66,31 @@ public: mapnik::transcoder const& tr_; }; +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 +struct put_property +{ + typedef void result_type; + explicit put_property(mapnik::transcoder const& tr) + : tr_(tr) {} + template + result_type operator() (T0 & feature, T1 const& key, T2 const& val) const + { + mapnik::value v = boost::apply_visitor(attribute_value_visitor(tr_),val); // TODO: optimize + feature.put_new(key, v); + } + mapnik::transcoder const& tr_; +}; + +struct extract_geometry +{ + typedef boost::ptr_vector& result_type; + template + result_type operator() (T & feature) const + { + return feature.paths(); + } +}; +#else struct put_property { template @@ -100,11 +125,12 @@ struct extract_geometry return feature.paths(); } }; +#endif template struct feature_grammar : - qi::grammar + qi::grammar { feature_grammar(mapnik::transcoder const& tr); diff --git a/include/mapnik/json/feature_parser.hpp b/include/mapnik/json/feature_parser.hpp new file mode 100644 index 000000000..e3c3ed8d6 --- /dev/null +++ b/include/mapnik/json/feature_parser.hpp @@ -0,0 +1,57 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_FEATURE_PARSER_HPP +#define MAPNIK_FEATURE_PARSER_HPP + +// mapnik +#include +#include +#include +#include + +// boost +#include + +// stl +#include + +namespace mapnik { namespace json { + +template struct feature_grammar; + +template +class MAPNIK_DECL feature_parser : private mapnik::noncopyable +{ + typedef Iterator iterator_type; + typedef mapnik::feature_impl feature_type; +public: + feature_parser(mapnik::transcoder const& tr); + ~feature_parser(); + bool parse(iterator_type first, iterator_type last, mapnik::feature_impl & f); +private: + boost::scoped_ptr > grammar_; +}; + +}} + +#endif //MAPNIK_FEATURE_PARSER_HPP diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 47974c201..3a57b1a78 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -39,10 +39,7 @@ #include #include #include -#include // trunc to avoid needing C++11 - - -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 +#include // for vc++ namespace boost { namespace spirit { namespace traits { @@ -61,6 +58,52 @@ namespace phoenix = boost::phoenix; namespace { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 +struct get_type +{ + typedef int result_type; + result_type operator() (geometry_type const& geom) const + { + return static_cast(geom.type()); + } +}; + +struct get_first +{ + typedef geometry_type::value_type const result_type; + result_type operator() (geometry_type const& geom) const + { + geometry_type::value_type coord; + boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord)); + return coord; + } +}; + +struct multi_geometry_type +{ + typedef boost::tuple result_type; + result_type operator() (geometry_container const& geom) const + { + unsigned type = 0u; + bool collection = false; + + geometry_container::const_iterator itr = geom.begin(); + geometry_container::const_iterator end = geom.end(); + + for ( ; itr != end; ++itr) + { + if (type != 0u && itr->type() != type) + { + collection = true; + break; + } + type = itr->type(); + } + if (geom.size() > 1) type +=3; + return boost::tuple(type, collection); + } +}; +#else struct get_type { template @@ -111,6 +154,7 @@ struct multi_geometry_type return boost::tuple(type, collection); } }; +#endif template @@ -123,7 +167,7 @@ struct json_coordinate_policy : karma::real_policies { if (n == 0.0) return 0; using namespace boost::spirit; - return static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); + return static_cast(14 - boost::math::trunc(log10(traits::get_absolute_value(n)))); } template @@ -135,7 +179,7 @@ struct json_coordinate_policy : karma::real_policies template static bool fraction_part(OutputIterator& sink, T n - , unsigned adjprec, unsigned precision) + , unsigned adjprec, unsigned precision) { if (n == 0) return true; return base_type::fraction_part(sink, n, adjprec, precision); @@ -187,7 +231,10 @@ struct geometry_generator_grammar : polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1] << karma::string[ if_ (_r1 > 1) [_1 = "],["] - .else_[_1 = '[' ]] | &uint_ << lit(',')) + .else_[_1 = '[' ]] + | + &uint_(mapnik::SEG_LINETO)) + << lit(',') << lit('[') << coord_type << lit(',') << coord_type << lit(']') @@ -258,9 +305,9 @@ struct multi_geometry_generator_grammar : geometry = (lit("{\"type\":") << geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)] << lit(",\"coordinates\":") - << karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']] + << karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = '['].else_[_1 = ""]] << coordinates - << karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']] + << karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']'].else_[_1 = ""]] << lit('}')) | lit("null") ; diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 9600b4179..821ab9646 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -37,6 +37,55 @@ namespace qi = boost::spirit::qi; namespace standard_wide = boost::spirit::standard_wide; using standard_wide::space_type; +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 +struct push_vertex +{ + typedef void result_type; + + template + result_type operator() (T0 c, T1 path, T2 x, T3 y) const + { + BOOST_ASSERT( path!=0 ); + path->push_vertex(x,y,c); + } +}; + +struct close_path +{ + typedef void result_type; + + template + result_type operator() (T path) const + { + BOOST_ASSERT( path!=0 ); + path->close_path(); + } +}; + +struct cleanup +{ + typedef void result_type; + template + void operator() (T0 & path) const + { + if (path) delete path, path=0; + } +}; + +struct where_message +{ + typedef std::string result_type; + + template + std::string operator() (Iterator first, Iterator last, std::size_t size) const + { + std::string str(first, last); + if (str.length() > size) + return str.substr(0, size) + "..." ; + return str; + } +}; +#else struct push_vertex { template @@ -101,12 +150,13 @@ struct where_message return str; } }; +#endif template struct geometry_grammar : qi::grammar, void(boost::ptr_vector& ) - , space_type> + , space_type> { geometry_grammar(); qi::rule, void(boost::ptr_vector& ),space_type> geometry; diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 04645ef16..f5bcce8fe 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -38,6 +38,7 @@ // agg #include "agg_ellipse.h" #include "agg_basics.h" +#include "agg_color_rgba.h" #include "agg_renderer_base.h" #include "agg_renderer_scanline.h" #include "agg_rendering_buffer.h" diff --git a/include/mapnik/memory_featureset.hpp b/include/mapnik/memory_featureset.hpp index f334b1d5e..51ff72155 100644 --- a/include/mapnik/memory_featureset.hpp +++ b/include/mapnik/memory_featureset.hpp @@ -76,7 +76,7 @@ public: } else { - for (unsigned i=0; i<(*pos_)->num_geometries();++i) + for (std::size_t i=0; i<(*pos_)->num_geometries();++i) { geometry_type & geom = (*pos_)->get_geometry(i); if (bbox_.intersects(geom.envelope())) diff --git a/include/mapnik/miniz_png.hpp b/include/mapnik/miniz_png.hpp index a371daa41..db116c3b4 100644 --- a/include/mapnik/miniz_png.hpp +++ b/include/mapnik/miniz_png.hpp @@ -37,6 +37,7 @@ - avoiding including miniz.c here requires fwd declaring the two structs below - being able to fwd declare requires removing typedef from struct declarations in miniz.c - being able to fwd declare also requires using pointers to structs + - if updated, need to apply c++11 fix: https://github.com/mapnik/mapnik/issues/1967 */ // TODO: try using #define MINIZ_HEADER_FILE_ONLY diff --git a/include/mapnik/params_impl.hpp b/include/mapnik/params_impl.hpp index 258275ff5..a39e55cfc 100644 --- a/include/mapnik/params_impl.hpp +++ b/include/mapnik/params_impl.hpp @@ -47,7 +47,7 @@ namespace mapnik { namespace detail { template struct extract_value { - static inline boost::optional do_extract_from_string(std::string const& source) + static inline boost::optional do_extract_from_string(std::string const& /*source*/) { std::string err_msg = (boost::format("No conversion from std::string to %s") % typeid(T).name()).str(); throw std::runtime_error(err_msg); diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index 0af9e1479..ad14c6936 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -57,8 +57,7 @@ template class placement_finder : mapnik::noncopyable { public: - placement_finder(feature_impl const& feature, - text_placement_info const& placement_info, + placement_finder(text_placement_info const& placement_info, string_info const& info, DetectorT & detector, box2d const& extent); diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index f76e19072..1e98fee09 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -79,8 +79,8 @@ public: void end_map_processing(Map const& map); void start_layer_processing(layer const& lay, box2d const& query_extent); void end_layer_processing(layer const& lay); - void start_style_processing(feature_type_style const& st) {} - void end_style_processing(feature_type_style const& st) {} + void start_style_processing(feature_type_style const& /*st*/) {} + void end_style_processing(feature_type_style const& /*st*/) {} /*! * @brief Overloads that process each kind of symbolizer individually. @@ -115,9 +115,9 @@ public: void process(markers_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans); - void process(debug_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans) {} + void process(debug_symbolizer const& /*sym*/, + mapnik::feature_impl & /*feature*/, + proj_transform const& /*prj_trans*/) {} /*! * @brief Overload that process the whole set of symbolizers of a rule. @@ -127,7 +127,7 @@ public: mapnik::feature_impl & feature, proj_transform const& prj_trans); - void painted(bool painted) + void painted(bool /*painted*/) { // nothing to do } diff --git a/include/mapnik/svg/svg_path_attributes.hpp b/include/mapnik/svg/svg_path_attributes.hpp index 3a09e8e6b..831fd1f5a 100644 --- a/include/mapnik/svg/svg_path_attributes.hpp +++ b/include/mapnik/svg/svg_path_attributes.hpp @@ -26,7 +26,6 @@ // agg #include "agg_math_stroke.h" #include "agg_color_rgba.h" -#include "agg_pixfmt_rgba.h" #include "agg_trans_affine.h" // mapnik diff --git a/include/mapnik/svg/svg_path_commands.hpp b/include/mapnik/svg/svg_path_commands.hpp index e45b5b1c0..ba631ed76 100644 --- a/include/mapnik/svg/svg_path_commands.hpp +++ b/include/mapnik/svg/svg_path_commands.hpp @@ -45,7 +45,12 @@ inline double deg2rad(double deg) template struct move_to { + +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -66,7 +71,11 @@ struct move_to template struct hline_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -88,7 +97,11 @@ struct hline_to template struct vline_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -109,7 +122,11 @@ struct vline_to template struct line_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -131,7 +148,11 @@ struct line_to template struct curve4 { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -156,7 +177,11 @@ struct curve4 template struct curve4_smooth { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -178,7 +203,11 @@ struct curve4_smooth template struct curve3 { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -201,7 +230,11 @@ struct curve3 template struct curve3_smooth { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -223,7 +256,11 @@ struct curve3_smooth template struct arc_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index d3586873a..cf76e0a99 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -27,7 +27,11 @@ #include #include #include + +#if defined(GRID_RENDERER) #include +#endif + #include // boost @@ -52,7 +56,6 @@ #include "agg_gradient_lut.h" #include "agg_gamma_lut.h" #include "agg_span_interpolator_linear.h" -#include "agg_pixfmt_rgba.h" namespace mapnik { namespace svg { @@ -335,14 +338,15 @@ public: } } +#if defined(GRID_RENDERER) template void render_id(Rasterizer& ras, Scanline& sl, Renderer& ren, int feature_id, agg::trans_affine const& mtx, - double opacity, - box2d const& symbol_bbox) + double /*opacity*/, + box2d const& /*symbol_bbox*/) { using namespace agg; @@ -417,6 +421,7 @@ public: } } } +#endif private: diff --git a/include/mapnik/svg/svg_transform_grammar.hpp b/include/mapnik/svg/svg_transform_grammar.hpp index 087bab311..a63884bfb 100644 --- a/include/mapnik/svg/svg_transform_grammar.hpp +++ b/include/mapnik/svg/svg_transform_grammar.hpp @@ -50,7 +50,11 @@ namespace mapnik { namespace svg { template struct process_matrix { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -70,7 +74,11 @@ namespace mapnik { namespace svg { template struct process_rotate { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -101,7 +109,11 @@ namespace mapnik { namespace svg { template struct process_translate { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -123,7 +135,11 @@ namespace mapnik { namespace svg { template struct process_scale { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -146,7 +162,11 @@ namespace mapnik { namespace svg { template struct process_skew { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/include/mapnik/symbolizer_hash.hpp b/include/mapnik/symbolizer_hash.hpp index 795743402..db89ff8a9 100644 --- a/include/mapnik/symbolizer_hash.hpp +++ b/include/mapnik/symbolizer_hash.hpp @@ -34,10 +34,9 @@ namespace mapnik { struct symbolizer_hash { template - static std::size_t value(T const& sym) + static std::size_t value(T const& /*sym*/) { - std::size_t seed = 0; - return seed; + return 0; } // specialisation for polygon_symbolizer static std::size_t value(polygon_symbolizer const& sym) diff --git a/include/mapnik/tiff_io.hpp b/include/mapnik/tiff_io.hpp index 18b666180..d3c52a5c4 100644 --- a/include/mapnik/tiff_io.hpp +++ b/include/mapnik/tiff_io.hpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2011 Artem Pavlenko + * Copyright (C) 2013 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -86,7 +86,7 @@ static toff_t tiff_seek_proc(thandle_t fd, toff_t off, int whence) // grow std::stringstream buffer (re: libtiff/tif_stream.cxx) std::ios::pos_type pos = out->tellp(); // second check needed for clang (libcxx doesn't set failbit when seeking beyond the current buffer size - if( out->fail() || off != pos) + if( out->fail() || static_cast(off) != pos) { std::ios::iostate old_state; std::ios::pos_type origin; @@ -146,16 +146,16 @@ static toff_t tiff_size_proc(thandle_t fd) return (toff_t)len; } -static tsize_t tiff_dummy_read_proc(thandle_t fd, tdata_t buf, tsize_t size) +static tsize_t tiff_dummy_read_proc(thandle_t , tdata_t , tsize_t) { return 0; } -static void tiff_dummy_unmap_proc(thandle_t fd, tdata_t base, toff_t size) +static void tiff_dummy_unmap_proc(thandle_t , tdata_t , toff_t) { } -static int tiff_dummy_map_proc(thandle_t fd, tdata_t* pbase, toff_t* psize) +static int tiff_dummy_map_proc(thandle_t , tdata_t*, toff_t* ) { return 0; } @@ -193,17 +193,16 @@ void save_as_tiff(T1 & file, T2 const& image) // TODO - handle palette images // std::vector const& palette - /* - unsigned short r[256], g[256], b[256]; - for (int i = 0; i < (1 << 24); ++i) - { - r[i] = (unsigned short)palette[i * 3 + 0] << 8; - g[i] = (unsigned short)palette[i * 3 + 1] << 8; - b[i] = (unsigned short)palette[i * 3 + 2] << 8; - } - TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); - TIFFSetField(output, TIFFTAG_COLORMAP, r, g, b); - */ + + // unsigned short r[256], g[256], b[256]; + // for (int i = 0; i < (1 << 24); ++i) + // { + // r[i] = (unsigned short)palette[i * 3 + 0] << 8; + // g[i] = (unsigned short)palette[i * 3 + 1] << 8; + // b[i] = (unsigned short)palette[i * 3 + 2] << 8; + // } + // TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); + // TIFFSetField(output, TIFFTAG_COLORMAP, r, g, b); #ifdef HAVE_GEOTIFF GTIF* geotiff = GTIFNew(output); diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp index 5f98e995e..d6c1bbc26 100644 --- a/include/mapnik/util/container_adapter.hpp +++ b/include/mapnik/util/container_adapter.hpp @@ -55,7 +55,7 @@ template <> struct end_container { static mapnik::util::path_iterator - call (mapnik::geometry_type const& g) + call (mapnik::geometry_type const& /*g*/) { return mapnik::util::path_iterator(); } diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index aec04fd8d..acb4ca8e5 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP #define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP + // mapnik #include #include // for container stuff @@ -41,8 +42,6 @@ #include #include -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - /*! * adapted to conform to the concepts * required by Karma to be recognized as a container of @@ -76,7 +75,7 @@ template <> struct end_container { static mapnik::util::path_iterator - call (path_type const& g) + call (path_type const& /*g*/) { return mapnik::util::path_iterator(); } @@ -92,6 +91,31 @@ namespace mapnik { namespace util { namespace svg_detail { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template + struct get_type + { + typedef int result_type; + result_type operator() (Geometry const& geom) const + { + return static_cast(geom.type()); + } + }; + + template + struct get_first + { + typedef T geometry_type; + typedef typename geometry_type::value_type const result_type; + result_type operator() (geometry_type const& geom) const + { + typename geometry_type::value_type coord; + geom.rewind(0); + boost::get<0>(coord) = geom.vertex(&boost::get<1>(coord),&boost::get<2>(coord)); + return coord; + } + }; +#else template struct get_type { @@ -112,7 +136,7 @@ namespace mapnik { namespace util { template struct result { typedef typename geometry_type::value_type const type; }; - typename geometry_type::value_type const operator() (geometry_type const& geom) const + typename geometry_type::value_type operator() (geometry_type const& geom) const { typename geometry_type::value_type coord; geom.rewind(0); @@ -121,6 +145,7 @@ namespace mapnik { namespace util { } }; +#endif template struct coordinate_policy : karma::real_policies { @@ -169,7 +194,7 @@ namespace mapnik { namespace util { ; svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M') - | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ]) + | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ].else_[_1 =""]]) << lit(' ') << coordinate << lit(' ') << coordinate) % lit(' ') ; diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 79f9fe1fd..d1ee75902 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -40,7 +40,6 @@ #include #include // trunc to avoid needing C++11 -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 namespace boost { namespace spirit { namespace traits { diff --git a/include/mapnik/util/hsl.hpp b/include/mapnik/util/hsl.hpp index ff3fa3466..2c6bada5f 100644 --- a/include/mapnik/util/hsl.hpp +++ b/include/mapnik/util/hsl.hpp @@ -27,11 +27,8 @@ namespace mapnik { -static inline void rgb2hsl(unsigned char red, unsigned char green, unsigned char blue, - double & h, double & s, double & l) { - double r = red/255.0; - double g = green/255.0; - double b = blue/255.0; +inline void rgb2hsl(double r, double g, double b, + double & h, double & s, double & l) { double max = std::max(r,std::max(g,b)); double min = std::min(r,std::min(g,b)); double delta = max - min; @@ -46,25 +43,30 @@ static inline void rgb2hsl(unsigned char red, unsigned char green, unsigned char } } -static inline double hueToRGB(double m1, double m2, double h) { - if(h < 0) h += 1; - if(h > 1) h -= 1; - if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; - if (h * 2 < 1) return m2; - if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; +// http://www.w3.org/TR/css3-color/#hsl-color +inline double hue_to_rgb(double m1, double m2, double h) +{ + if (h < 0.0) h = h + 1.0; + else if (h > 1.0) h = h - 1.0; + if (h * 6 < 1.0) + return m1 + (m2 - m1) * h * 6.0; + if (h * 2 < 1.0) + return m2; + if (h * 3 < 2.0) + return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0; return m1; } -static inline void hsl2rgb(double h, double s, double l, - unsigned char & r, unsigned char & g, unsigned char & b) { +inline void hsl2rgb(double h, double s, double l, + double & r, double & g, double & b) { if (!s) { - r = g = b = static_cast(std::floor((l * 255.0)+.5)); + r = g = b = l; } - double m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s; - double m1 = l * 2 - m2; - r = static_cast(std::floor((hueToRGB(m1, m2, h + 0.33333) * 255.0)+.5)); - g = static_cast(std::floor((hueToRGB(m1, m2, h) * 255.0)+.5)); - b = static_cast(std::floor((hueToRGB(m1, m2, h - 0.33333) * 255.0)+.5)); + double m2 = (l <= 0.5) ? l * (s + 1.0) : l + s - l * s; + double m1 = l * 2.0 - m2; + r = hue_to_rgb(m1, m2, h + 1.0/3.0); + g = hue_to_rgb(m1, m2, h); + b = hue_to_rgb(m1, m2, h - 1.0/3.0); } } diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index a9a15725f..9ca954a6f 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -122,7 +122,7 @@ struct equals } template - bool operator() (T const& lhs, U const& rhs) const + bool operator() (T const& /*lhs*/, U const& /*rhs*/) const { return false; } @@ -182,7 +182,7 @@ struct not_equals // back compatibility shim to equate empty string with null for != test // https://github.com/mapnik/mapnik/issues/1859 // TODO - consider removing entire specialization at Mapnik 3.x - bool operator() (value_null lhs,value_unicode_string const& rhs) const + bool operator() (value_null /*lhs*/, value_unicode_string const& rhs) const { if (rhs.isEmpty()) return false; return true; diff --git a/include/mapnik/value_types.hpp b/include/mapnik/value_types.hpp index 41672eb53..c188d40b9 100644 --- a/include/mapnik/value_types.hpp +++ b/include/mapnik/value_types.hpp @@ -47,12 +47,12 @@ typedef bool value_bool; struct value_null { - bool operator==(value_null const& other) const + bool operator==(value_null const& /*other*/) const { return true; } - bool operator!=(value_null const& other) const + bool operator!=(value_null const& /*other*/) const { return false; } @@ -88,11 +88,11 @@ struct value_null } }; -inline std::size_t hash_value(const value_null& val) { +inline std::size_t hash_value(const value_null& /*val*/) { return 0; } -inline std::ostream& operator<< (std::ostream & out,value_null const& v) +inline std::ostream& operator<< (std::ostream & out,value_null const& /*v*/) { return out; } diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index 616741561..9cb0d6e49 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -64,6 +64,9 @@ #include "agg_conv_clipper.h" #include "agg_path_storage.h" +// stl +#include + namespace mapnik { struct transform_tag {}; @@ -86,9 +89,9 @@ struct converter_traits typedef T0 geometry_type; typedef geometry_type conv_type; template - static void setup(geometry_type & geom, Args const& args) + static void setup(geometry_type & /*geom*/, Args const& /*args*/) { - throw "BOOM!"; + throw std::runtime_error("invalid call to setup"); } }; @@ -216,7 +219,7 @@ struct converter_traits typedef T geometry_type; typedef typename agg::conv_close_polygon conv_type; template - static void setup(geometry_type & geom, Args const& args) + static void setup(geometry_type & /*geom*/, Args const& /*args*/) { // no-op } @@ -291,7 +294,7 @@ template <> struct converter_fwd { template - static void forward(Base& base, T0 & geom,T1 const& args) + static void forward(Base& base, T0 & geom,T1 const& /*args*/) { base.template dispatch(geom, typename boost::is_same::type()); } diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index e7e986f59..ff233d65d 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -40,12 +40,15 @@ namespace mapnik { namespace wkt { using namespace boost::spirit; - using namespace boost::fusion; using namespace boost::phoenix; struct push_vertex { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/include/mapnik/xml_attribute_cast.hpp b/include/mapnik/xml_attribute_cast.hpp index 20a411c47..76562f0c2 100644 --- a/include/mapnik/xml_attribute_cast.hpp +++ b/include/mapnik/xml_attribute_cast.hpp @@ -44,7 +44,7 @@ namespace mapnik { namespace detail { template struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& /*source*/) { std::string err_msg = (boost::format("No conversion from std::string to %s") % typeid(T).name()).str(); throw std::runtime_error(err_msg); @@ -55,7 +55,7 @@ struct do_xml_attribute_cast template <> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { bool result; if (mapnik::util::string2bool(source, result)) @@ -68,7 +68,7 @@ struct do_xml_attribute_cast template <> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { int result; if (mapnik::util::string2int(source, result)) @@ -82,7 +82,7 @@ struct do_xml_attribute_cast template <> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { int result; if (mapnik::util::string2int(source, result)) @@ -98,7 +98,7 @@ struct do_xml_attribute_cast template <> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { int result; if (mapnik::util::string2int(source, result)) @@ -111,7 +111,7 @@ struct do_xml_attribute_cast template <> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { float result; if (mapnik::util::string2float(source, result)) @@ -124,7 +124,7 @@ struct do_xml_attribute_cast template <> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { double result; if (mapnik::util::string2double(source, result)) @@ -137,7 +137,7 @@ struct do_xml_attribute_cast template struct do_xml_attribute_cast > { - static inline boost::optional > xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional > xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { typedef typename boost::optional > result_type; try @@ -168,7 +168,7 @@ struct do_xml_attribute_cast template <> struct do_xml_attribute_cast { - static inline boost::optional xml_attribute_cast_impl(xml_tree const& tree, std::string const& source) + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) { return boost::optional(source); } diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 78836a030..20d4bd181 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -144,7 +144,7 @@ feature_ptr shape_index_featureset::next() return feature_ptr(); } - // FIXME + // FIXME: https://github.com/mapnik/mapnik/issues/1020 feature->set_id(shape_.id_); if (attr_ids_.size()) { diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index f3e6cea3a..9f2b2e272 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -45,10 +45,9 @@ #include #include #include -// agg -#define AGG_RENDERING_BUFFER row_ptr_cache #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" +#include "agg_color_rgba.h" #include "agg_scanline_u.h" #include "agg_image_filters.h" #include "agg_trans_bilinear.h" @@ -193,7 +192,7 @@ void agg_renderer::end_map_processing(Map const& ) { agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4); - agg::pixfmt_rgba32 pixf(buf); + agg::pixfmt_rgba32_pre pixf(buf); pixf.demultiply(); MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: End map processing"; } @@ -298,7 +297,6 @@ void agg_renderer::render_marker(pixel_position const& pos, { typedef agg::rgba8 color_type; typedef agg::order_rgba order_type; - typedef agg::pixel32_type pixel_type; typedef agg::comp_op_adaptor_rgba blender_type; // comp blender typedef agg::pixfmt_custom_blend_rgba pixfmt_comp_type; typedef agg::renderer_base renderer_base; @@ -427,7 +425,7 @@ template template void agg_renderer::debug_draw_box(R& buf, box2d const& box, double x, double y, double angle) { - typedef agg::pixfmt_rgba32 pixfmt; + typedef agg::pixfmt_rgba32_pre pixfmt; typedef agg::renderer_base renderer_base; typedef agg::renderer_scanline_aa_solid renderer_type; diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index bd9fb6921..d4d7dae05 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -39,6 +39,7 @@ // agg #include "agg_basics.h" #include "agg_rendering_buffer.h" +#include "agg_color_rgba.h" #include "agg_pixfmt_rgba.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_scanline_u.h" @@ -54,11 +55,11 @@ void agg_renderer::process(building_symbolizer const& sym, proj_transform const& prj_trans) { typedef coord_transform path_type; - typedef agg::renderer_base ren_base; + typedef agg::renderer_base ren_base; typedef agg::renderer_scanline_aa_solid renderer; agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); - agg::pixfmt_rgba32 pixf(buf); + agg::pixfmt_rgba32_pre pixf(buf); ren_base renb(pixf); color const& fill_ = sym.get_fill(); @@ -85,7 +86,7 @@ void agg_renderer::process(building_symbolizer const& sym, height = result.to_double() * scale_factor_; } - for (unsigned i=0;i 2) diff --git a/src/agg/process_debug_symbolizer.cpp b/src/agg/process_debug_symbolizer.cpp index 277f7fea6..e85b9ce2d 100644 --- a/src/agg/process_debug_symbolizer.cpp +++ b/src/agg/process_debug_symbolizer.cpp @@ -63,7 +63,7 @@ void agg_renderer::process(debug_symbolizer const& sym, } else if (mode == DEBUG_SYM_MODE_VERTEX) { - for (unsigned i=0; i::process(line_pattern_symbolizer const& sym, { typedef agg::rgba8 color; typedef agg::order_rgba order; - typedef agg::pixel32_type pixel_type; typedef agg::comp_op_adaptor_rgba_pre blender_type; typedef agg::pattern_filter_bilinear_rgba8 pattern_filter_type; typedef agg::line_image_pattern pattern_type; diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index a0338aaf6..bf7dcd2fb 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -34,6 +34,7 @@ #include "agg_basics.h" #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" +#include "agg_color_rgba.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_scanline_u.h" #include "agg_renderer_scanline.h" @@ -77,7 +78,6 @@ void agg_renderer::process(line_symbolizer const& sym, typedef agg::rgba8 color_type; typedef agg::order_rgba order_type; - typedef agg::pixel32_type pixel_type; typedef agg::comp_op_adaptor_rgba_pre blender_type; // comp blender typedef agg::pixfmt_custom_blend_rgba pixfmt_comp_type; typedef agg::renderer_base renderer_base; diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index 2bf71bfa2..2e8b5469d 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -45,6 +45,7 @@ #include "agg_renderer_scanline.h" #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" +#include "agg_color_rgba.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_scanline_u.h" #include "agg_path_storage.h" @@ -64,7 +65,6 @@ void agg_renderer::process(markers_symbolizer const& sym, { typedef agg::rgba8 color_type; typedef agg::order_rgba order_type; - typedef agg::pixel32_type pixel_type; typedef agg::comp_op_adaptor_rgba_pre blender_type; // comp blender typedef agg::rendering_buffer buf_type; typedef agg::pixfmt_custom_blend_rgba pixfmt_comp_type; diff --git a/src/agg/process_point_symbolizer.cpp b/src/agg/process_point_symbolizer.cpp index 9db818a43..9046455b5 100644 --- a/src/agg/process_point_symbolizer.cpp +++ b/src/agg/process_point_symbolizer.cpp @@ -74,7 +74,7 @@ void agg_renderer::process(point_symbolizer const& sym, agg::trans_affine recenter_tr = recenter * tr; box2d label_ext = bbox * recenter_tr * agg::trans_affine_scaling(scale_factor_); - for (unsigned i=0; i::process(polygon_pattern_symbolizer const& sym, typedef agg::rgba8 color; typedef agg::order_rgba order; - typedef agg::pixel32_type pixel_type; typedef agg::comp_op_adaptor_rgba_pre blender_type; typedef agg::pixfmt_custom_blend_rgba pixfmt_type; typedef agg::wrap_mode_repeat wrap_x_type; typedef agg::wrap_mode_repeat wrap_y_type; - typedef agg::image_accessor_wrap img_source_type; @@ -117,7 +117,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, unsigned w=(*pat)->width(); unsigned h=(*pat)->height(); agg::rendering_buffer pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4); - agg::pixfmt_rgba32 pixf_pattern(pattern_rbuf); + agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf); img_source_type img_src(pixf_pattern); pattern_alignment_e align = sym.get_alignment(); diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 7e7e15d4c..25e2f09a2 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -36,6 +36,8 @@ #include "agg_basics.h" #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" +#include "agg_color_rgba.h" +#include "agg_renderer_scanline.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_scanline_u.h" @@ -86,7 +88,6 @@ void agg_renderer::process(polygon_symbolizer const& sym, typedef agg::rgba8 color_type; typedef agg::order_rgba order_type; - typedef agg::pixel32_type pixel_type; typedef agg::comp_op_adaptor_rgba_pre blender_type; // comp blender typedef agg::pixfmt_custom_blend_rgba pixfmt_comp_type; typedef agg::renderer_base renderer_base; diff --git a/src/build.py b/src/build.py index 7ffa2df54..cfb68d7f8 100644 --- a/src/build.py +++ b/src/build.py @@ -95,6 +95,8 @@ if '-DBOOST_REGEX_HAS_ICU' in env['CPPDEFINES']: if env['RUNTIME_LINK'] == 'static': if 'icuuc' in env['ICU_LIB_NAME']: lib_env['LIBS'].append('icudata') + if env['PLATFORM'] == 'Linux': + lib_env['LIBS'].append('dl') else: lib_env['LIBS'].insert(0, 'agg') @@ -199,6 +201,7 @@ source = Split( json/geometry_grammar.cpp json/geometry_parser.cpp json/feature_grammar.cpp + json/feature_parser.cpp json/feature_collection_parser.cpp json/geojson_generator.cpp processed_text.cpp @@ -292,21 +295,24 @@ if env['RUNTIME_LINK'] == "static": source += glob.glob('../deps/agg/src/' + '*.cpp') # grid backend -source += Split( - """ - grid/grid.cpp - grid/grid_renderer.cpp - grid/process_building_symbolizer.cpp - grid/process_line_pattern_symbolizer.cpp - grid/process_line_symbolizer.cpp - grid/process_markers_symbolizer.cpp - grid/process_point_symbolizer.cpp - grid/process_polygon_pattern_symbolizer.cpp - grid/process_polygon_symbolizer.cpp - grid/process_raster_symbolizer.cpp - grid/process_shield_symbolizer.cpp - grid/process_text_symbolizer.cpp - """) +if env['GRID_RENDERER']: + source += Split( + """ + grid/grid.cpp + grid/grid_renderer.cpp + grid/process_building_symbolizer.cpp + grid/process_line_pattern_symbolizer.cpp + grid/process_line_symbolizer.cpp + grid/process_markers_symbolizer.cpp + grid/process_point_symbolizer.cpp + grid/process_polygon_pattern_symbolizer.cpp + grid/process_polygon_symbolizer.cpp + grid/process_raster_symbolizer.cpp + 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 diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index beaaef0c9..9d58202e0 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -354,7 +354,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym, height = result.to_double() * scale_factor_; } - for (unsigned i = 0; i < feature.num_geometries(); ++i) + for (std::size_t i = 0; i < feature.num_geometries(); ++i) { geometry_type const& geom = feature.get_geometry(i); @@ -673,7 +673,7 @@ void cairo_renderer_base::process(point_symbolizer const& sym, agg::trans_affine recenter_tr = recenter * tr; box2d label_ext = bbox * recenter_tr * agg::trans_affine_scaling(scale_factor_); - for (unsigned i = 0; i < feature.num_geometries(); ++i) + for (std::size_t i = 0; i < feature.num_geometries(); ++i) { geometry_type const& geom = feature.get_geometry(i); double x; @@ -760,7 +760,7 @@ void cairo_renderer_base::process(line_pattern_symbolizer const& sym, pattern.set_filter(CAIRO_FILTER_BILINEAR); context_.set_line_width(height * scale_factor_); - for (unsigned i = 0; i < feature.num_geometries(); ++i) + for (std::size_t i = 0; i < feature.num_geometries(); ++i) { geometry_type & geom = feature.get_geometry(i); @@ -816,8 +816,8 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - typedef agg::conv_clip_polygon clipped_geometry_type; - typedef coord_transform path_type; + //typedef agg::conv_clip_polygon clipped_geometry_type; + //typedef coord_transform path_type; cairo_save_restore guard(context_); context_.set_operator(sym.comp_op()); diff --git a/src/config_error.cpp b/src/config_error.cpp index c8889b149..8de797072 100644 --- a/src/config_error.cpp +++ b/src/config_error.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include namespace mapnik diff --git a/src/datasource_cache_static.cpp b/src/datasource_cache_static.cpp index 3d7e4b58d..07e178ca4 100644 --- a/src/datasource_cache_static.cpp +++ b/src/datasource_cache_static.cpp @@ -133,23 +133,24 @@ static datasource_map ds_map = boost::assign::map_list_of ; #endif +#ifdef MAPNIK_STATIC_PLUGINS datasource_ptr create_static_datasource(parameters const& params) { datasource_ptr ds; - -#ifdef MAPNIK_STATIC_PLUGINS boost::optional type = params.get("type"); - datasource_map::iterator it = ds_map.find(*type); - if (it != ds_map.end()) { ds = it->second(params); } -#endif - return ds; } +#else +datasource_ptr create_static_datasource(parameters const& /*params*/) +{ + return datasource_ptr(); +} +#endif std::vector get_static_datasource_names() { diff --git a/src/debug.cpp b/src/debug.cpp index f9a04fbc5..a9c4d7d9e 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -137,7 +137,7 @@ void logger::use_file(std::string const& filepath) else { std::stringstream s; - s << "cannot redirect log to file " << file_output_; + s << "cannot redirect log to file " << file_name_; throw std::runtime_error(s.str()); } } diff --git a/src/expression_string.cpp b/src/expression_string.cpp index f42d5f6cc..484d3c273 100644 --- a/src/expression_string.cpp +++ b/src/expression_string.cpp @@ -59,7 +59,7 @@ struct expression_string : boost::static_visitor str_ += "]"; } - void operator() (geometry_type_attribute const& attr) const + void operator() (geometry_type_attribute const& /*attr*/) const { str_ += "[mapnik::geometry_type]"; } diff --git a/src/feature_style_processor.cpp b/src/feature_style_processor.cpp index 9deb275ab..fd79e13a7 100644 --- a/src/feature_style_processor.cpp +++ b/src/feature_style_processor.cpp @@ -24,8 +24,11 @@ #include #include #include + +#if defined(GRID_RENDERER) #include #include +#endif #if defined(HAVE_CAIRO) #include @@ -48,7 +51,10 @@ template class feature_style_processor >; template class feature_style_processor > >; #endif +#if defined(GRID_RENDERER) template class feature_style_processor >; +#endif + template class feature_style_processor >; } diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 78db9f24a..f9b2f84e0 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -25,7 +25,11 @@ #include #include #include + +#if defined(GRID_RENDERER) #include +#endif + #include #include #include @@ -686,6 +690,7 @@ void text_renderer::render(pixel_position const& pos) } } +#if defined(GRID_RENDERER) template void text_renderer::render_id(mapnik::value_integer feature_id, pixel_position const& pos) @@ -715,6 +720,7 @@ void text_renderer::render_id(mapnik::value_integer feature_id, } } } +#endif #ifdef MAPNIK_THREADSAFE boost::mutex freetype_engine::mutex_; @@ -729,6 +735,7 @@ template text_renderer::text_renderer(image_32&, double); template box2dtext_renderer::prepare_glyphs(text_path const&); template void text_renderer::render(pixel_position const&); +#if defined(GRID_RENDERER) template void text_renderer::render_id(mapnik::value_integer, pixel_position const&); template text_renderer::text_renderer(grid&, @@ -736,4 +743,5 @@ template text_renderer::text_renderer(grid&, halo_rasterizer_e, composite_mode_e, double); template box2dtext_renderer::prepare_glyphs(text_path const& ); +#endif } diff --git a/src/formatting/base.cpp b/src/formatting/base.cpp index bc3be41f8..849c8f13e 100644 --- a/src/formatting/base.cpp +++ b/src/formatting/base.cpp @@ -30,13 +30,15 @@ // boost #include +// stl +#include + namespace mapnik { namespace formatting { -void node::to_xml(boost::property_tree::ptree &xml) const +void node::to_xml(boost::property_tree::ptree & /*xml*/) const { - //TODO: Should this throw a config_error? - MAPNIK_LOG_ERROR(base) << "Trying to write unsupported node type to XML."; + throw std::runtime_error("Trying to write unsupported node type to XML"); } node_ptr node::from_xml(xml_node const& xml) @@ -62,7 +64,7 @@ node_ptr node::from_xml(xml_node const& xml) } } -void node::add_expressions(expression_set &output) const +void node::add_expressions(expression_set & /*output*/) const { //Do nothing by default } diff --git a/src/graphics.cpp b/src/graphics.cpp index 5119cf397..cf55b37c3 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -30,6 +30,7 @@ // agg #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" +#include "agg_color_rgba.h" // boost #include @@ -202,7 +203,7 @@ void image_32::premultiply() void image_32::demultiply() { agg::rendering_buffer buffer(data_.getBytes(),width_,height_,width_ * 4); - agg::pixfmt_rgba32 pixf(buffer); + agg::pixfmt_rgba32_pre pixf(buffer); pixf.demultiply(); premultiplied_ = false; } diff --git a/src/grid/grid_renderer.cpp b/src/grid/grid_renderer.cpp index 285e0c6b9..5a9e58868 100644 --- a/src/grid/grid_renderer.cpp +++ b/src/grid/grid_renderer.cpp @@ -109,7 +109,7 @@ void grid_renderer::start_map_processing(Map const& m) } template -void grid_renderer::end_map_processing(Map const& m) +void grid_renderer::end_map_processing(Map const& /*m*/) { MAPNIK_LOG_DEBUG(grid_renderer) << "grid_renderer: End map processing"; } @@ -140,7 +140,7 @@ void grid_renderer::end_layer_processing(layer const&) } template -void grid_renderer::render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity, composite_mode_e comp_op) +void grid_renderer::render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity, composite_mode_e /*comp_op*/) { if (marker.is_vector()) { diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp index dc967f0c1..5e089d272 100644 --- a/src/grid/process_building_symbolizer.cpp +++ b/src/grid/process_building_symbolizer.cpp @@ -73,7 +73,7 @@ void grid_renderer::process(building_symbolizer const& sym, height = result.to_double() * scale_factor_; } - for (unsigned i=0;i 2) diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index 542dbcab2..b79e39dd0 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -62,7 +62,7 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, // TODO - actually handle image dimensions int stroke_width = 2; - for (unsigned i=0;i 1) diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 94cd4cc1f..e04b3d53c 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -65,7 +65,6 @@ porting notes --> // agg #include "agg_basics.h" #include "agg_rendering_buffer.h" -#include "agg_pixfmt_rgba.h" #include "agg_rasterizer_scanline_aa.h" // boost diff --git a/src/grid/process_point_symbolizer.cpp b/src/grid/process_point_symbolizer.cpp index f0230825f..3d0d68f40 100644 --- a/src/grid/process_point_symbolizer.cpp +++ b/src/grid/process_point_symbolizer.cpp @@ -76,7 +76,7 @@ void grid_renderer::process(point_symbolizer const& sym, agg::trans_affine recenter_tr = recenter * tr; box2d label_ext = bbox * recenter_tr * agg::trans_affine_scaling(scale_factor_) ; - for (unsigned i=0; i::skip(j_decompress_ptr cinfo, long count) } template -void jpeg_reader::term (j_decompress_ptr cinfo) +void jpeg_reader::term (j_decompress_ptr /*cinfo*/) { // no-op } @@ -203,15 +203,16 @@ void jpeg_reader::attach_stream (j_decompress_ptr cinfo, input_stream* in) } template -void jpeg_reader::on_error(j_common_ptr cinfo) +void jpeg_reader::on_error(j_common_ptr /*cinfo*/) { - throw image_reader_exception("JPEG Reader: libjpeg could not read image"); } template void jpeg_reader::on_error_message(j_common_ptr cinfo) { - // used to supress jpeg from printing to stderr + char buffer[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo, buffer); + throw image_reader_exception(std::string("JPEG Reader: libjpeg could not read image: ") + buffer); } template diff --git a/src/json/feature_collection_parser.cpp b/src/json/feature_collection_parser.cpp index 0e1ce124e..9eb317879 100644 --- a/src/json/feature_collection_parser.cpp +++ b/src/json/feature_collection_parser.cpp @@ -23,8 +23,10 @@ // TODO https://github.com/mapnik/mapnik/issues/1658 #include #if BOOST_VERSION >= 105200 +#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 #define BOOST_SPIRIT_USE_PHOENIX_V3 #endif +#endif // mapnik #include @@ -68,4 +70,3 @@ namespace mapnik { namespace json { template class feature_collection_parser > >; }} - diff --git a/src/json/feature_parser.cpp b/src/json/feature_parser.cpp new file mode 100644 index 000000000..cc06e8050 --- /dev/null +++ b/src/json/feature_parser.cpp @@ -0,0 +1,61 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2013 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#include + +// mapnik +#include +#include + +// boost +#include +#include + +namespace mapnik { namespace json { + +#if BOOST_VERSION >= 104700 + + template + feature_parser::feature_parser(mapnik::transcoder const& tr) + : grammar_(new feature_grammar(tr)) {} + + template + feature_parser::~feature_parser() {} +#endif + + template + bool feature_parser::parse(iterator_type first, iterator_type last, mapnik::feature_impl & f) + { +#if BOOST_VERSION >= 104700 + using namespace boost::spirit; + return qi::phrase_parse(first, last, (*grammar_)(boost::phoenix::ref(f)), standard_wide::space); +#else + std::ostringstream s; + s << BOOST_VERSION/100000 << "." << BOOST_VERSION/100 % 1000 << "." << BOOST_VERSION % 100; + throw std::runtime_error("mapnik::feature_parser::parse() requires at least boost 1.47 while your build was compiled against boost " + s.str()); + return false; +#endif + } + +template class feature_parser; + +}} diff --git a/src/json/geojson_generator.cpp b/src/json/geojson_generator.cpp index f35ba7265..6e98a4d6f 100644 --- a/src/json/geojson_generator.cpp +++ b/src/json/geojson_generator.cpp @@ -44,7 +44,6 @@ bool feature_generator::generate(std::string & geojson, mapnik::feature_impl con return karma::generate(sink, *grammar_,f); } - geometry_generator::geometry_generator() : grammar_(new multi_geometry_generator_grammar()) {} diff --git a/src/load_map.cpp b/src/load_map.cpp index 88fc64d32..c7643e1ef 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -269,8 +269,6 @@ void map_parser::parse_map(Map & map, xml_node const& pt, std::string const& bas { throw config_error(std::string("Invalid version string encountered: '") + *beg + "' in '" + *min_version_string + "'"); - - break; } if (i==2) { diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp index 46dbb151b..3ea949545 100644 --- a/src/memory_datasource.cpp +++ b/src/memory_datasource.cpp @@ -42,7 +42,7 @@ struct accumulate_extent void operator() (feature_ptr feat) { - for (unsigned i=0;inum_geometries();++i) + for (std::size_t i=0;inum_geometries();++i) { geometry_type & geom = feat->get_geometry(i); if ( first_ ) diff --git a/src/miniz.c b/src/miniz.c index 03be47f2f..02aa52c8b 100644 --- a/src/miniz.c +++ b/src/miniz.c @@ -798,7 +798,7 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); // Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. -typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); +typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, size_t len, void *pUser); // tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); @@ -2704,7 +2704,7 @@ struct tdefl_output_buffer mz_bool m_expandable; }; -static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) +static mz_bool tdefl_output_buffer_putter(const void *pBuf, size_t len, void *pUser) { tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; size_t new_size = p->m_size + len; @@ -2778,7 +2778,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, *pLen_out = out_buf.m_size-41; { mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, - 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0, + 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8, (mz_uint8)"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0, (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); memcpy(out_buf.m_pBuf, pnghdr, 41); @@ -4831,4 +4831,4 @@ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to -*/ \ No newline at end of file +*/ diff --git a/src/miniz_png.cpp b/src/miniz_png.cpp index ec445d0ba..991d98da8 100644 --- a/src/miniz_png.cpp +++ b/src/miniz_png.cpp @@ -28,10 +28,11 @@ // miniz #define MINIZ_NO_ARCHIVE_APIS -#define MINIZ_NO_STDIO #define MINIZ_NO_ZLIB_COMPATIBLE_NAMES -#include "miniz.c" +extern "C" { +#include "miniz.c" +} // zlib #include @@ -137,12 +138,14 @@ void PNGWriter::finishChunk(size_t start) { // Write chunk length at the beginning of the chunk. size_t payloadLength = buffer->m_size - start - 4 - 4; - writeUInt32BE(buffer->m_pBuf + start, payloadLength); - + writeUInt32BE(buffer->m_pBuf + start, static_cast(payloadLength)); // Write CRC32 checksum. Don't include the 4-byte length, but /do/ include // the 4-byte chunk name. mz_uint32 crc = mz_crc32(MZ_CRC32_INIT, buffer->m_pBuf + start + 4, payloadLength + 4); - mz_uint8 checksum[] = { crc >> 24, crc >> 16, crc >> 8, crc }; + mz_uint8 checksum[] = { static_cast(crc >> 24), + static_cast(crc >> 16), + static_cast(crc >> 8), + static_cast(crc) }; mz_bool status = tdefl_output_buffer_putter(checksum, 4, buffer); if (status != MZ_TRUE) { @@ -362,4 +365,3 @@ template void PNGWriter::writeIDATStripAlpha(image_data_32 const& template void PNGWriter::writeIDATStripAlpha >(image_view const& image); }} - diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 0f7a3906e..63db19727 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -97,8 +97,7 @@ double get_total_distance(T & shape_path) } template -placement_finder::placement_finder(feature_impl const& feature, - text_placement_info const& placement_info, +placement_finder::placement_finder(text_placement_info const& placement_info, string_info const& info, DetectorT & detector, box2d const& extent) diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 2ef46f65b..100ce2ea6 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -96,12 +96,12 @@ const bool registered2 = register_image_reader("png", create_png_reader2); } -void user_error_fn(png_structp png_ptr, png_const_charp error_msg) +void user_error_fn(png_structp /*png_ptr*/, png_const_charp error_msg) { throw image_reader_exception(std::string("failed to read invalid png: '") + error_msg + "'"); } -void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) +void user_warning_fn(png_structp /*png_ptr*/, png_const_charp warning_msg) { MAPNIK_LOG_DEBUG(png_reader) << "libpng warning: '" << warning_msg << "'"; } diff --git a/src/save_map.cpp b/src/save_map.cpp index edfa029a3..be74aa681 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -190,8 +190,7 @@ public: if (sym.get_colorizer()) { - serialize_raster_colorizer(sym_node, sym.get_colorizer(), - explicit_defaults_); + serialize_raster_colorizer(sym_node, sym.get_colorizer()); } boost::optional premultiplied = sym.premultiplied(); @@ -352,13 +351,16 @@ public: } template +#ifdef MAPNIK_DEBUG void operator () ( Symbolizer const& sym) { - // not-supported -#ifdef MAPNIK_DEBUG MAPNIK_LOG_WARN(save_map) << typeid(sym).name() << " is not supported"; -#endif } +#else + void operator () ( Symbolizer const& /*sym*/) + { + } +#endif private: serialize_symbolizer(); @@ -394,16 +396,23 @@ private: } void serialize_raster_colorizer(ptree & sym_node, - raster_colorizer_ptr const& colorizer, - bool explicit_defaults) + raster_colorizer_ptr const& colorizer) { ptree & col_node = sym_node.push_back( ptree::value_type("RasterColorizer", ptree() ))->second; - - set_attr(col_node, "default-mode", colorizer->get_default_mode()); - set_attr(col_node, "default-color", colorizer->get_default_color()); - set_attr(col_node, "epsilon", colorizer->get_epsilon()); - + raster_colorizer dfl; + if (colorizer->get_default_mode() != dfl.get_default_mode() || explicit_defaults_) + { + set_attr(col_node, "default-mode", colorizer->get_default_mode()); + } + if (colorizer->get_default_color() != dfl.get_default_color() || explicit_defaults_) + { + set_attr(col_node, "default-color", colorizer->get_default_color()); + } + if (colorizer->get_epsilon() != dfl.get_epsilon() || explicit_defaults_) + { + set_attr(col_node, "epsilon", colorizer->get_epsilon()); + } unsigned i; colorizer_stops const &stops = colorizer->get_stops(); for (i=0; i.type", "int" ); } - void operator () ( mapnik::value_double val ) const + void operator () ( mapnik::value_double /*val*/ ) const { node_.put(".type", "float" ); } - void operator () ( std::string const& val ) const + void operator () ( std::string const& /*val*/ ) const { node_.put(".type", "string" ); } - void operator () ( mapnik::value_null val ) const + void operator () ( mapnik::value_null /*val*/ ) const { node_.put(".type", "string" ); } diff --git a/src/svg/output/process_line_symbolizer.cpp b/src/svg/output/process_line_symbolizer.cpp index a93346326..6f2008408 100644 --- a/src/svg/output/process_line_symbolizer.cpp +++ b/src/svg/output/process_line_symbolizer.cpp @@ -30,8 +30,8 @@ namespace mapnik */ template void svg_renderer::process(line_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans) + mapnik::feature_impl & /*feature*/, + proj_transform const& /*prj_trans*/) { path_attributes_.set_stroke_color(sym.get_stroke().get_color()); path_attributes_.set_stroke_opacity(sym.get_stroke().get_opacity()); diff --git a/src/svg/output/process_symbolizers.cpp b/src/svg/output/process_symbolizers.cpp index e4065159f..ca38a082f 100644 --- a/src/svg/output/process_symbolizers.cpp +++ b/src/svg/output/process_symbolizers.cpp @@ -71,7 +71,7 @@ bool svg_renderer::process(rule::symbolizers const& syms, if (process_path) { // generate path output for each geometry of the current feature. - for(unsigned i=0; i 0) diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index 99738c04d..1a322ac2c 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -29,6 +29,7 @@ #include "agg_ellipse.h" #include "agg_rounded_rect.h" #include "agg_span_gradient.h" +#include "agg_color_rgba.h" #include #include @@ -64,7 +65,6 @@ void parse_linear_gradient(svg_parser & parser,xmlTextReaderPtr reader); void parse_radial_gradient(svg_parser & parser,xmlTextReaderPtr reader); bool parse_common_gradient(svg_parser & parser,xmlTextReaderPtr reader); void parse_gradient_stop(svg_parser & parser,xmlTextReaderPtr reader); -void parse_pattern(svg_parser & parser,xmlTextReaderPtr reader); void parse_attr(svg_parser & parser,xmlTextReaderPtr reader); void parse_attr(svg_parser & parser,const xmlChar * name, const xmlChar * value ); @@ -1046,11 +1046,6 @@ void parse_linear_gradient(svg_parser & parser, xmlTextReaderPtr reader) //MAPNIK_LOG_DEBUG(svg_parser) << "Found Linear Gradient: " << "(" << x1 << " " << y1 << "),(" << x2 << " " << y2 << ")"; } -void parse_pattern(svg_parser & parser, xmlTextReaderPtr reader) -{ - //const xmlChar *value; -} - svg_parser::svg_parser(svg_converter > & path) : path_(path), diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index 4d89b039c..5286de55e 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -211,8 +211,8 @@ template void text_symbolizer_helper::initialize_geometries() { bool largest_box_only = false; - unsigned num_geom = feature_.num_geometries(); - for (unsigned i=0; i::next_placement() angle_ = 0.0; } - finder_.reset(new placement_finder(feature_, *placement_, + finder_.reset(new placement_finder(*placement_, text_.get_string_info(), detector_, dims_)); placement_valid_ = true; diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index 4540800d6..a92e99c34 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -61,7 +61,7 @@ static toff_t tiff_seek_proc(thandle_t fd, toff_t off, int whence) return static_cast(in->tellg()); } -static int tiff_close_proc(thandle_t fd) +static int tiff_close_proc(thandle_t /*fd*/) { return 0; } @@ -86,16 +86,16 @@ static tsize_t tiff_read_proc(thandle_t fd, tdata_t buf, tsize_t size) return static_cast(in->gcount()); } -static tsize_t tiff_write_proc(thandle_t fd, tdata_t buf, tsize_t size) +static tsize_t tiff_write_proc(thandle_t /*fd*/, tdata_t /*buf*/, tsize_t /*size*/) { return 0; } -static void tiff_unmap_proc(thandle_t fd, tdata_t base, toff_t size) +static void tiff_unmap_proc(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/) { } -static int tiff_map_proc(thandle_t fd, tdata_t* pbase, toff_t* psize) +static int tiff_map_proc(thandle_t /*fd*/, tdata_t* /*pbase*/, toff_t* /*psize*/) { return 0; } diff --git a/src/warp.cpp b/src/warp.cpp index c40953053..7a88005f7 100644 --- a/src/warp.cpp +++ b/src/warp.cpp @@ -78,11 +78,9 @@ void reproject_and_scale_raster(raster & target, raster const& source, prj_trans.backward(xs.getData(), ys.getData(), NULL, mesh_nx*mesh_ny); // Initialize AGG objects - typedef agg::pixfmt_rgba32 pixfmt; + typedef agg::pixfmt_rgba32_pre pixfmt; typedef pixfmt::color_type color_type; typedef agg::renderer_base renderer_base; - typedef agg::pixfmt_rgba32_pre pixfmt_pre; - typedef agg::renderer_base renderer_base_pre; agg::rasterizer_scanline_aa<> rasterizer; agg::scanline_u8 scanline; @@ -90,8 +88,8 @@ void reproject_and_scale_raster(raster & target, raster const& source, target.data_.width(), target.data_.height(), target.data_.width()*4); - pixfmt_pre pixf_pre(buf); - renderer_base_pre rb_pre(pixf_pre); + pixfmt pixf(buf); + renderer_base rb(pixf); rasterizer.clip_box(0, 0, target.data_.width(), target.data_.height()); agg::rendering_buffer buf_tile( (unsigned char*)source.data_.getData(), @@ -184,13 +182,13 @@ void reproject_and_scale_raster(raster & target, raster const& source, span_gen_type; span_gen_type sg(ia, interpolator); - agg::render_scanlines_aa(rasterizer, scanline, rb_pre, + agg::render_scanlines_aa(rasterizer, scanline, rb, sa, sg); } else { typedef agg::span_image_resample_rgba_affine span_gen_type; span_gen_type sg(ia, interpolator, filter); - agg::render_scanlines_aa(rasterizer, scanline, rb_pre, + agg::render_scanlines_aa(rasterizer, scanline, rb, sa, sg); } } diff --git a/tests/cpp_tests/build.py b/tests/cpp_tests/build.py index f967b7a70..9e1315136 100644 --- a/tests/cpp_tests/build.py +++ b/tests/cpp_tests/build.py @@ -16,6 +16,7 @@ else: test_env.AppendUnique(LIBS='dl') test_env.AppendUnique(CXXFLAGS='-g') test_env['CXXFLAGS'] = copy(test_env['LIBMAPNIK_CXXFLAGS']) + test_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES']) if test_env['HAS_CAIRO']: test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS']) test_env.Append(CPPDEFINES = '-DHAVE_CAIRO') diff --git a/tests/data/broken_maps/invalid-scale-hsla-filter.xml b/tests/data/broken_maps/invalid-scale-hsla-filter.xml new file mode 100644 index 000000000..fec9d9eb0 --- /dev/null +++ b/tests/data/broken_maps/invalid-scale-hsla-filter.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/tests/python_tests/buffer_clear_test.py b/tests/python_tests/buffer_clear_test.py index 2119d6d63..7a828f8ca 100644 --- a/tests/python_tests/buffer_clear_test.py +++ b/tests/python_tests/buffer_clear_test.py @@ -45,18 +45,18 @@ def make_map(): m.zoom_all() return m -def test_clearing_grid_data(): - g = mapnik.Grid(256,256) - utf = g.encode() - # make sure it equals itself - eq_(g.encode(),utf) - m = make_map() - mapnik.render_layer(m,g,layer=0,fields=['__id__','Name']) - eq_(g.encode()!=utf,True) - # clear grid, should now match original - g.clear() - eq_(g.encode(),utf) - +if mapnik.has_grid_renderer(): + def test_clearing_grid_data(): + g = mapnik.Grid(256,256) + utf = g.encode() + # make sure it equals itself + eq_(g.encode(),utf) + m = make_map() + mapnik.render_layer(m,g,layer=0,fields=['__id__','Name']) + eq_(g.encode()!=utf,True) + # clear grid, should now match original + g.clear() + eq_(g.encode(),utf) if __name__ == "__main__": setup() diff --git a/tests/python_tests/geometry_io_test.py b/tests/python_tests/geometry_io_test.py index c5440a449..7d6f78224 100644 --- a/tests/python_tests/geometry_io_test.py +++ b/tests/python_tests/geometry_io_test.py @@ -6,6 +6,11 @@ from utilities import execution_path, run_all import mapnik from binascii import unhexlify +try: + import json +except ImportError: + import simplejson as json + def setup(): # All of the paths used are relative, if we run the tests # from another directory we need to chdir() @@ -222,6 +227,17 @@ def test_wkt_collection_flattening(): # except RuntimeError, e: # raise RuntimeError('%s %s' % (e, wkt)) +def test_creating_feature_from_geojson(): + json_feat = { + "type": "Feature", + "geometry": {"type": "Point", "coordinates": [-122,48]}, + "properties": {"name": "value"} + } + ctx = mapnik.Context() + feat = mapnik.Feature.from_geojson(json.dumps(json_feat),ctx) + eq_(feat.id(),1) + eq_(feat['name'],u'value') + if __name__ == "__main__": setup() run_all(eval(x) for x in dir() if x.startswith("test_")) diff --git a/tests/python_tests/image_test.py b/tests/python_tests/image_test.py index fa75b32eb..f67dc49b2 100644 --- a/tests/python_tests/image_test.py +++ b/tests/python_tests/image_test.py @@ -20,9 +20,11 @@ def test_image_premultiply(): im.demultiply() eq_(im.premultiplied(),False) -@raises(RuntimeError) -def test_negative_image_dimensions(): - im = mapnik.Image(-40,40) +# Disabled for now since this breaks hard if run against +# a mapnik version that does not have the fix +#@raises(RuntimeError) +#def test_negative_image_dimensions(): + #im = mapnik.Image(-40,40) def test_tiff_round_trip(): filepath = '/tmp/mapnik-tiff-io.tiff' diff --git a/tests/python_tests/render_grid_test.py b/tests/python_tests/render_grid_test.py index f998735c0..ca0996707 100644 --- a/tests/python_tests/render_grid_test.py +++ b/tests/python_tests/render_grid_test.py @@ -15,370 +15,371 @@ def setup(): # from another directory we need to chdir() os.chdir(execution_path('.')) -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)) - g2_file = '/tmp/mapnik-%s-expected.json' % name - open(g2_file,'w').write(json.dumps(g2,sort_keys=True)) - val = 'JSON does not match ->\n' - if g1['grid'] != g2['grid']: - val += ' X grid does not match\n' - else: - val += ' ✓ grid matches\n' - if g1['data'].keys() != g2['data'].keys(): - val += ' X data does not match\n' - else: - val += ' ✓ data matches\n' - if g1['keys'] != g2['keys']: - val += ' X keys do not\n' - else: - val += ' ✓ keys match\n' - val += '\n\t%s\n\t%s' % (g1_file,g2_file) - return val - -def show_grids2(name,g1,g2): - g2_expected = '../data/grids/mapnik-%s-actual.json' % name - if not os.path.exists(g2_expected): - # create test fixture based on actual results - open(g2_expected,'a+').write(json.dumps(g1,sort_keys=True)) - return - g1_file = '/tmp/mapnik-%s-actual.json' % name - open(g1_file,'w').write(json.dumps(g1,sort_keys=True)) - val = 'JSON does not match ->\n' - if g1['grid'] != g2['grid']: - val += ' X grid does not match\n' - else: - val += ' ✓ grid matches\n' - if g1['data'].keys() != g2['data'].keys(): - val += ' X data does not match\n' - else: - val += ' ✓ data matches\n' - if g1['keys'] != g2['keys']: - val += ' X keys do not\n' - else: - val += ' ✓ keys match\n' - val += '\n\t%s\n\t%s' % (g1_file,g2_expected) - return val - -# first pass impl where resolution is passed as render -# time rather than encoding time, likely will be deprecated soon -grid_correct_old = {"keys": ["", "North West", "North East", "South West", "South East"], "data": {"South East": {"Name": "South East"}, "North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!!!! ##### ", " !!!!! ##### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$$ %%%%% ", " $$$$$ %%%%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "]} - -# now using svg rendering -grid_correct_old2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} - -grid_correct_old3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} - -# previous rendering using agg ellipse directly -grid_correct_new = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} - -# newer rendering using svg -grid_correct_new2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} - -grid_correct_new3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} - -def resolve(grid,row,col): - """ Resolve the attributes for a given pixel in a grid. - """ - row = grid['grid'][row] - utf_val = row[col] - #http://docs.python.org/library/functions.html#ord - codepoint = ord(utf_val) - if (codepoint >= 93): - codepoint-=1 - if (codepoint >= 35): - codepoint-=1 - codepoint -= 32 - key = grid['keys'][codepoint] - return grid['data'].get(key) - - -def create_grid_map(width,height,sym): - ds = mapnik.MemoryDatasource() - context = mapnik.Context() - context.push('Name') - f = mapnik.Feature(context,1) - f['Name'] = 'South East' - f.add_geometries_from_wkt('POINT (143.10 -38.60)') - ds.add_feature(f) - - f = mapnik.Feature(context,2) - f['Name'] = 'South West' - f.add_geometries_from_wkt('POINT (142.48 -38.60)') - ds.add_feature(f) - - f = mapnik.Feature(context,3) - f['Name'] = 'North West' - f.add_geometries_from_wkt('POINT (142.48 -38.38)') - ds.add_feature(f) - - f = mapnik.Feature(context,4) - f['Name'] = 'North East' - f.add_geometries_from_wkt('POINT (143.10 -38.38)') - ds.add_feature(f) - s = mapnik.Style() - r = mapnik.Rule() - sym.allow_overlap = True - r.symbols.append(sym) - s.rules.append(r) - lyr = mapnik.Layer('Places') - lyr.datasource = ds - lyr.styles.append('places_labels') - m = mapnik.Map(width,height) - m.append_style('places_labels',s) - m.layers.append(lyr) - return m - -def test_render_grid_old(): - """ test old method """ - width,height = 256,256 - symb = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png')) - sym = mapnik.MarkersSymbolizer() - sym.width = mapnik.Expression('10') - sym.height = mapnik.Expression('10') - m = create_grid_map(width,height,sym) - #print mapnik.save_map_to_string(m) - ul_lonlat = mapnik.Coord(142.30,-38.20) - lr_lonlat = mapnik.Coord(143.40,-38.80) - m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) - grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name']) - eq_(grid,grid_correct_old3,show_grids('old-markers',grid,grid_correct_old3)) - eq_(resolve(grid,0,0),None) - - # check every pixel of the nw symbol - expected = {"Name": "North West"} - - # top row - eq_(resolve(grid,23,9),expected) - eq_(resolve(grid,23,10),expected) - eq_(resolve(grid,23,11),expected) - -def test_render_grid_new(): - """ test old against new""" - width,height = 256,256 - sym = mapnik.MarkersSymbolizer() - sym.width = mapnik.Expression('10') - sym.height = mapnik.Expression('10') - m = create_grid_map(width,height,sym) - ul_lonlat = mapnik.Coord(142.30,-38.20) - lr_lonlat = mapnik.Coord(143.40,-38.80) - m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) - - # new method - grid = mapnik.Grid(m.width,m.height,key='Name') - mapnik.render_layer(m,grid,layer=0,fields=['Name']) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1,grid_correct_new3,show_grids('new-markers',utf1,grid_correct_new3)) - - # check a full view is the same as a full image - grid_view = grid.view(0,0,width,height) - # for kicks check at full res too - utf3 = grid.encode('utf',resolution=1) - utf4 = grid_view.encode('utf',resolution=1) - eq_(utf3['grid'],utf4['grid']) - eq_(utf3['keys'],utf4['keys']) - eq_(utf3['data'],utf4['data']) - - eq_(resolve(utf4,0,0),None) - - # resolve some center points in the - # resampled view - utf5 = grid_view.encode('utf',resolution=4) - eq_(resolve(utf5,25,10),{"Name": "North West"}) - eq_(resolve(utf5,25,46),{"Name": "North East"}) - eq_(resolve(utf5,38,10),{"Name": "South West"}) - eq_(resolve(utf5,38,46),{"Name": "South East"}) - - -grid_feat_id = {'keys': ['', '3', '4', '2', '1'], 'data': {'1': {'Name': 'South East'}, '3': {'Name': u'North West'}, '2': {'Name': 'South West'}, '4': {'Name': 'North East'}}, 'grid': [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' !! ## ', ' !!! ### ', ' !! ## ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $$$ %% ', ' $$$ %%% ', ' $$ %% ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']} - -grid_feat_id2 = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]} - -grid_feat_id3 = {"data": {"1": {"Name": "South East", "__id__": 1}, "2": {"Name": "South West", "__id__": 2}, "3": {"Name": "North West", "__id__": 3}, "4": {"Name": "North East", "__id__": 4}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]} - -def test_render_grid3(): - """ test using feature id""" - width,height = 256,256 - sym = mapnik.MarkersSymbolizer() - sym.width = mapnik.Expression('10') - sym.height = mapnik.Expression('10') - m = create_grid_map(width,height,sym) - ul_lonlat = mapnik.Coord(142.30,-38.20) - lr_lonlat = mapnik.Coord(143.40,-38.80) - m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) - - grid = mapnik.Grid(m.width,m.height,key='__id__') - mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name']) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1,grid_feat_id3,show_grids('id-markers',utf1,grid_feat_id3)) - # check a full view is the same as a full image - grid_view = grid.view(0,0,width,height) - # for kicks check at full res too - utf3 = grid.encode('utf',resolution=1) - utf4 = grid_view.encode('utf',resolution=1) - eq_(utf3['grid'],utf4['grid']) - eq_(utf3['keys'],utf4['keys']) - eq_(utf3['data'],utf4['data']) - - eq_(resolve(utf4,0,0),None) - - # resolve some center points in the - # resampled view - utf5 = grid_view.encode('utf',resolution=4) - eq_(resolve(utf5,25,10),{"Name": "North West","__id__": 3}) - eq_(resolve(utf5,25,46),{"Name": "North East","__id__": 4}) - eq_(resolve(utf5,38,10),{"Name": "South West","__id__": 2}) - eq_(resolve(utf5,38,46),{"Name": "South East","__id__": 1}) - - -def gen_grid_for_id(pixel_key): - ds = mapnik.MemoryDatasource() - context = mapnik.Context() - context.push('Name') - f = mapnik.Feature(context,pixel_key) - f['Name'] = str(pixel_key) - f.add_geometries_from_wkt('POLYGON ((0 0, 0 256, 256 256, 256 0, 0 0))') - ds.add_feature(f) - s = mapnik.Style() - r = mapnik.Rule() - symb = mapnik.PolygonSymbolizer() - r.symbols.append(symb) - s.rules.append(r) - lyr = mapnik.Layer('Places') - lyr.datasource = ds - lyr.styles.append('places_labels') - width,height = 256,256 - m = mapnik.Map(width,height) - m.append_style('places_labels',s) - m.layers.append(lyr) - m.zoom_all() - grid = mapnik.Grid(m.width,m.height,key='__id__') - mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name']) - return grid - -def test_negative_id(): - grid = gen_grid_for_id(-1) - eq_(grid.get_pixel(128,128),-1) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1['keys'],['-1']) - -def test_32bit_int_id(): - int32 = 2147483647 - grid = gen_grid_for_id(int32) - eq_(grid.get_pixel(128,128),int32) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1['keys'],[str(int32)]) - max_neg = -(int32) - grid = gen_grid_for_id(max_neg) - eq_(grid.get_pixel(128,128),max_neg) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1['keys'],[str(max_neg)]) - -def test_64bit_int_id(): - int64 = 0x7FFFFFFFFFFFFFFF - grid = gen_grid_for_id(int64) - eq_(grid.get_pixel(128,128),int64) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1['keys'],[str(int64)]) - max_neg = -(int64) - grid = gen_grid_for_id(max_neg) - eq_(grid.get_pixel(128,128),max_neg) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1['keys'],[str(max_neg)]) - -def test_id_zero(): - grid = gen_grid_for_id(0) - eq_(grid.get_pixel(128,128),0) - utf1 = grid.encode('utf',resolution=4) - eq_(utf1['keys'],['0']) - -line_expected = {"keys": ["", "1"], "data": {"1": {"Name": "1"}}, "grid": [" !", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", "!! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! "]} - -def test_line_rendering(): - ds = mapnik.MemoryDatasource() - context = mapnik.Context() - context.push('Name') - pixel_key = 1 - f = mapnik.Feature(context,pixel_key) - f['Name'] = str(pixel_key) - f.add_geometries_from_wkt('LINESTRING (30 10, 10 30, 40 40)') - ds.add_feature(f) - s = mapnik.Style() - r = mapnik.Rule() - symb = mapnik.LineSymbolizer() - r.symbols.append(symb) - s.rules.append(r) - lyr = mapnik.Layer('Places') - lyr.datasource = ds - lyr.styles.append('places_labels') - width,height = 256,256 - m = mapnik.Map(width,height) - m.append_style('places_labels',s) - m.layers.append(lyr) - m.zoom_all() - #mapnik.render_to_file(m,'test.png') - grid = mapnik.Grid(m.width,m.height,key='__id__') - mapnik.render_layer(m,grid,layer=0,fields=['Name']) - utf1 = grid.encode() - eq_(utf1,line_expected,show_grids('line',utf1,line_expected)) - -point_expected = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]} - -def test_point_symbolizer_grid(): - width,height = 256,256 - sym = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png')) - m = create_grid_map(width,height,sym) - ul_lonlat = mapnik.Coord(142.30,-38.20) - lr_lonlat = mapnik.Coord(143.40,-38.80) - m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) - grid = mapnik.Grid(m.width,m.height) - mapnik.render_layer(m,grid,layer=0,fields=['Name']) - utf1 = grid.encode() - eq_(utf1,point_expected,show_grids('point-sym',utf1,point_expected)) - - -# should throw because this is a mis-usage -# https://github.com/mapnik/mapnik/issues/1325 -@raises(RuntimeError) -def test_render_to_grid_multiple_times(): - # create map with two layers - m = mapnik.Map(256,256) - s = mapnik.Style() - r = mapnik.Rule() - sym = mapnik.MarkersSymbolizer() - sym.allow_overlap = True - r.symbols.append(sym) - s.rules.append(r) - m.append_style('points',s) - - # NOTE: we use a csv datasource here - # because the memorydatasource fails silently for - # queries requesting fields that do not exist in the datasource - ds1 = mapnik.Datasource(**{"type":"csv","inline":''' - wkt,Name - "POINT (143.10 -38.60)",South East'''}) - lyr1 = mapnik.Layer('One') - lyr1.datasource = ds1 - lyr1.styles.append('points') - m.layers.append(lyr1) - - ds2 = mapnik.Datasource(**{"type":"csv","inline":''' - wkt,Value - "POINT (142.48 -38.60)",South West'''}) - lyr2 = mapnik.Layer('Two') - lyr2.datasource = ds2 - lyr2.styles.append('points') - m.layers.append(lyr2) - - ul_lonlat = mapnik.Coord(142.30,-38.20) - lr_lonlat = mapnik.Coord(143.40,-38.80) - m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) - grid = mapnik.Grid(m.width,m.height) - mapnik.render_layer(m,grid,layer=0,fields=['Name']) - # should throw right here since Name will be a property now on the `grid` object - # and it is not found on the second layer - mapnik.render_layer(m,grid,layer=1,fields=['Value']) - utf1 = grid.encode() +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)) + g2_file = '/tmp/mapnik-%s-expected.json' % name + open(g2_file,'w').write(json.dumps(g2,sort_keys=True)) + val = 'JSON does not match ->\n' + if g1['grid'] != g2['grid']: + val += ' X grid does not match\n' + else: + val += ' ✓ grid matches\n' + if g1['data'].keys() != g2['data'].keys(): + val += ' X data does not match\n' + else: + val += ' ✓ data matches\n' + if g1['keys'] != g2['keys']: + val += ' X keys do not\n' + else: + val += ' ✓ keys match\n' + val += '\n\t%s\n\t%s' % (g1_file,g2_file) + return val + + def show_grids2(name,g1,g2): + g2_expected = '../data/grids/mapnik-%s-actual.json' % name + if not os.path.exists(g2_expected): + # create test fixture based on actual results + open(g2_expected,'a+').write(json.dumps(g1,sort_keys=True)) + return + g1_file = '/tmp/mapnik-%s-actual.json' % name + open(g1_file,'w').write(json.dumps(g1,sort_keys=True)) + val = 'JSON does not match ->\n' + if g1['grid'] != g2['grid']: + val += ' X grid does not match\n' + else: + val += ' ✓ grid matches\n' + if g1['data'].keys() != g2['data'].keys(): + val += ' X data does not match\n' + else: + val += ' ✓ data matches\n' + if g1['keys'] != g2['keys']: + val += ' X keys do not\n' + else: + val += ' ✓ keys match\n' + val += '\n\t%s\n\t%s' % (g1_file,g2_expected) + return val + + # first pass impl where resolution is passed as render + # time rather than encoding time, likely will be deprecated soon + grid_correct_old = {"keys": ["", "North West", "North East", "South West", "South East"], "data": {"South East": {"Name": "South East"}, "North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!!!! ##### ", " !!!!! ##### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$$ %%%%% ", " $$$$$ %%%%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "]} + + # now using svg rendering + grid_correct_old2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} + + grid_correct_old3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!! ### ", " !!! ### ", " !!! ### ", " !!! ### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$ %%% ", " $$$ %%% ", " $$$ %%% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} + + # previous rendering using agg ellipse directly + grid_correct_new = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} + + # newer rendering using svg + grid_correct_new2 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} + + grid_correct_new3 = {"data": {"North East": {"Name": "North East"}, "North West": {"Name": "North West"}, "South East": {"Name": "South East"}, "South West": {"Name": "South West"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "North West", "North East", "South West", "South East"]} + + def resolve(grid,row,col): + """ Resolve the attributes for a given pixel in a grid. + """ + row = grid['grid'][row] + utf_val = row[col] + #http://docs.python.org/library/functions.html#ord + codepoint = ord(utf_val) + if (codepoint >= 93): + codepoint-=1 + if (codepoint >= 35): + codepoint-=1 + codepoint -= 32 + key = grid['keys'][codepoint] + return grid['data'].get(key) + + + def create_grid_map(width,height,sym): + ds = mapnik.MemoryDatasource() + context = mapnik.Context() + context.push('Name') + f = mapnik.Feature(context,1) + f['Name'] = 'South East' + f.add_geometries_from_wkt('POINT (143.10 -38.60)') + ds.add_feature(f) + + f = mapnik.Feature(context,2) + f['Name'] = 'South West' + f.add_geometries_from_wkt('POINT (142.48 -38.60)') + ds.add_feature(f) + + f = mapnik.Feature(context,3) + f['Name'] = 'North West' + f.add_geometries_from_wkt('POINT (142.48 -38.38)') + ds.add_feature(f) + + f = mapnik.Feature(context,4) + f['Name'] = 'North East' + f.add_geometries_from_wkt('POINT (143.10 -38.38)') + ds.add_feature(f) + s = mapnik.Style() + r = mapnik.Rule() + sym.allow_overlap = True + r.symbols.append(sym) + s.rules.append(r) + lyr = mapnik.Layer('Places') + lyr.datasource = ds + lyr.styles.append('places_labels') + m = mapnik.Map(width,height) + m.append_style('places_labels',s) + m.layers.append(lyr) + return m + + def test_render_grid_old(): + """ test old method """ + width,height = 256,256 + symb = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png')) + sym = mapnik.MarkersSymbolizer() + sym.width = mapnik.Expression('10') + sym.height = mapnik.Expression('10') + m = create_grid_map(width,height,sym) + #print mapnik.save_map_to_string(m) + ul_lonlat = mapnik.Coord(142.30,-38.20) + lr_lonlat = mapnik.Coord(143.40,-38.80) + m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) + grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name']) + eq_(grid,grid_correct_old3,show_grids('old-markers',grid,grid_correct_old3)) + eq_(resolve(grid,0,0),None) + + # check every pixel of the nw symbol + expected = {"Name": "North West"} + + # top row + eq_(resolve(grid,23,9),expected) + eq_(resolve(grid,23,10),expected) + eq_(resolve(grid,23,11),expected) + + def test_render_grid_new(): + """ test old against new""" + width,height = 256,256 + sym = mapnik.MarkersSymbolizer() + sym.width = mapnik.Expression('10') + sym.height = mapnik.Expression('10') + m = create_grid_map(width,height,sym) + ul_lonlat = mapnik.Coord(142.30,-38.20) + lr_lonlat = mapnik.Coord(143.40,-38.80) + m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) + + # new method + grid = mapnik.Grid(m.width,m.height,key='Name') + mapnik.render_layer(m,grid,layer=0,fields=['Name']) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1,grid_correct_new3,show_grids('new-markers',utf1,grid_correct_new3)) + + # check a full view is the same as a full image + grid_view = grid.view(0,0,width,height) + # for kicks check at full res too + utf3 = grid.encode('utf',resolution=1) + utf4 = grid_view.encode('utf',resolution=1) + eq_(utf3['grid'],utf4['grid']) + eq_(utf3['keys'],utf4['keys']) + eq_(utf3['data'],utf4['data']) + + eq_(resolve(utf4,0,0),None) + + # resolve some center points in the + # resampled view + utf5 = grid_view.encode('utf',resolution=4) + eq_(resolve(utf5,25,10),{"Name": "North West"}) + eq_(resolve(utf5,25,46),{"Name": "North East"}) + eq_(resolve(utf5,38,10),{"Name": "South West"}) + eq_(resolve(utf5,38,46),{"Name": "South East"}) + + + grid_feat_id = {'keys': ['', '3', '4', '2', '1'], 'data': {'1': {'Name': 'South East'}, '3': {'Name': u'North West'}, '2': {'Name': 'South West'}, '4': {'Name': 'North East'}}, 'grid': [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' !! ## ', ' !!! ### ', ' !! ## ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' $$$ %% ', ' $$$ %%% ', ' $$ %% ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']} + + grid_feat_id2 = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]} + + grid_feat_id3 = {"data": {"1": {"Name": "South East", "__id__": 1}, "2": {"Name": "South West", "__id__": 2}, "3": {"Name": "North West", "__id__": 3}, "4": {"Name": "North East", "__id__": 4}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]} + + def test_render_grid3(): + """ test using feature id""" + width,height = 256,256 + sym = mapnik.MarkersSymbolizer() + sym.width = mapnik.Expression('10') + sym.height = mapnik.Expression('10') + m = create_grid_map(width,height,sym) + ul_lonlat = mapnik.Coord(142.30,-38.20) + lr_lonlat = mapnik.Coord(143.40,-38.80) + m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) + + grid = mapnik.Grid(m.width,m.height,key='__id__') + mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name']) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1,grid_feat_id3,show_grids('id-markers',utf1,grid_feat_id3)) + # check a full view is the same as a full image + grid_view = grid.view(0,0,width,height) + # for kicks check at full res too + utf3 = grid.encode('utf',resolution=1) + utf4 = grid_view.encode('utf',resolution=1) + eq_(utf3['grid'],utf4['grid']) + eq_(utf3['keys'],utf4['keys']) + eq_(utf3['data'],utf4['data']) + + eq_(resolve(utf4,0,0),None) + + # resolve some center points in the + # resampled view + utf5 = grid_view.encode('utf',resolution=4) + eq_(resolve(utf5,25,10),{"Name": "North West","__id__": 3}) + eq_(resolve(utf5,25,46),{"Name": "North East","__id__": 4}) + eq_(resolve(utf5,38,10),{"Name": "South West","__id__": 2}) + eq_(resolve(utf5,38,46),{"Name": "South East","__id__": 1}) + + + def gen_grid_for_id(pixel_key): + ds = mapnik.MemoryDatasource() + context = mapnik.Context() + context.push('Name') + f = mapnik.Feature(context,pixel_key) + f['Name'] = str(pixel_key) + f.add_geometries_from_wkt('POLYGON ((0 0, 0 256, 256 256, 256 0, 0 0))') + ds.add_feature(f) + s = mapnik.Style() + r = mapnik.Rule() + symb = mapnik.PolygonSymbolizer() + r.symbols.append(symb) + s.rules.append(r) + lyr = mapnik.Layer('Places') + lyr.datasource = ds + lyr.styles.append('places_labels') + width,height = 256,256 + m = mapnik.Map(width,height) + m.append_style('places_labels',s) + m.layers.append(lyr) + m.zoom_all() + grid = mapnik.Grid(m.width,m.height,key='__id__') + mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name']) + return grid + + def test_negative_id(): + grid = gen_grid_for_id(-1) + eq_(grid.get_pixel(128,128),-1) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],['-1']) + + def test_32bit_int_id(): + int32 = 2147483647 + grid = gen_grid_for_id(int32) + eq_(grid.get_pixel(128,128),int32) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],[str(int32)]) + max_neg = -(int32) + grid = gen_grid_for_id(max_neg) + eq_(grid.get_pixel(128,128),max_neg) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],[str(max_neg)]) + + def test_64bit_int_id(): + int64 = 0x7FFFFFFFFFFFFFFF + grid = gen_grid_for_id(int64) + eq_(grid.get_pixel(128,128),int64) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],[str(int64)]) + max_neg = -(int64) + grid = gen_grid_for_id(max_neg) + eq_(grid.get_pixel(128,128),max_neg) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],[str(max_neg)]) + + def test_id_zero(): + grid = gen_grid_for_id(0) + eq_(grid.get_pixel(128,128),0) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],['0']) + + line_expected = {"keys": ["", "1"], "data": {"1": {"Name": "1"}}, "grid": [" !", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", " !! ", "!! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! ", " ! "]} + + def test_line_rendering(): + ds = mapnik.MemoryDatasource() + context = mapnik.Context() + context.push('Name') + pixel_key = 1 + f = mapnik.Feature(context,pixel_key) + f['Name'] = str(pixel_key) + f.add_geometries_from_wkt('LINESTRING (30 10, 10 30, 40 40)') + ds.add_feature(f) + s = mapnik.Style() + r = mapnik.Rule() + symb = mapnik.LineSymbolizer() + r.symbols.append(symb) + s.rules.append(r) + lyr = mapnik.Layer('Places') + lyr.datasource = ds + lyr.styles.append('places_labels') + width,height = 256,256 + m = mapnik.Map(width,height) + m.append_style('places_labels',s) + m.layers.append(lyr) + m.zoom_all() + #mapnik.render_to_file(m,'test.png') + grid = mapnik.Grid(m.width,m.height,key='__id__') + mapnik.render_layer(m,grid,layer=0,fields=['Name']) + utf1 = grid.encode() + eq_(utf1,line_expected,show_grids('line',utf1,line_expected)) + + point_expected = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " !!!! #### ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " $$$$ %%%% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]} + + def test_point_symbolizer_grid(): + width,height = 256,256 + sym = mapnik.PointSymbolizer(mapnik.PathExpression('../data/images/dummy.png')) + m = create_grid_map(width,height,sym) + ul_lonlat = mapnik.Coord(142.30,-38.20) + lr_lonlat = mapnik.Coord(143.40,-38.80) + m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) + grid = mapnik.Grid(m.width,m.height) + mapnik.render_layer(m,grid,layer=0,fields=['Name']) + utf1 = grid.encode() + eq_(utf1,point_expected,show_grids('point-sym',utf1,point_expected)) + + + # should throw because this is a mis-usage + # https://github.com/mapnik/mapnik/issues/1325 + @raises(RuntimeError) + def test_render_to_grid_multiple_times(): + # create map with two layers + m = mapnik.Map(256,256) + s = mapnik.Style() + r = mapnik.Rule() + sym = mapnik.MarkersSymbolizer() + sym.allow_overlap = True + r.symbols.append(sym) + s.rules.append(r) + m.append_style('points',s) + + # NOTE: we use a csv datasource here + # because the memorydatasource fails silently for + # queries requesting fields that do not exist in the datasource + ds1 = mapnik.Datasource(**{"type":"csv","inline":''' + wkt,Name + "POINT (143.10 -38.60)",South East'''}) + lyr1 = mapnik.Layer('One') + lyr1.datasource = ds1 + lyr1.styles.append('points') + m.layers.append(lyr1) + + ds2 = mapnik.Datasource(**{"type":"csv","inline":''' + wkt,Value + "POINT (142.48 -38.60)",South West'''}) + lyr2 = mapnik.Layer('Two') + lyr2.datasource = ds2 + lyr2.styles.append('points') + m.layers.append(lyr2) + + ul_lonlat = mapnik.Coord(142.30,-38.20) + lr_lonlat = mapnik.Coord(143.40,-38.80) + m.zoom_to_box(mapnik.Box2d(ul_lonlat,lr_lonlat)) + grid = mapnik.Grid(m.width,m.height) + mapnik.render_layer(m,grid,layer=0,fields=['Name']) + # should throw right here since Name will be a property now on the `grid` object + # and it is not found on the second layer + mapnik.render_layer(m,grid,layer=1,fields=['Value']) + utf1 = grid.encode() if __name__ == "__main__": setup() diff --git a/tests/visual_tests/grids/marker-path-expression-500-100-1.0-grid-reference.json b/tests/visual_tests/grids/marker-path-expression-500-100-1.0-grid-reference.json new file mode 100644 index 000000000..20f9c8fc2 --- /dev/null +++ b/tests/visual_tests/grids/marker-path-expression-500-100-1.0-grid-reference.json @@ -0,0 +1,34 @@ +{ + "keys": [ + "", + "1" + ], + "data": {}, + "grid": [ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " !! ", + " !! ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + ] +} \ No newline at end of file diff --git a/tests/visual_tests/images/marker-path-expression-500-100-1.0-agg-reference.png b/tests/visual_tests/images/marker-path-expression-500-100-1.0-agg-reference.png new file mode 100644 index 000000000..df73ebf66 Binary files /dev/null and b/tests/visual_tests/images/marker-path-expression-500-100-1.0-agg-reference.png differ diff --git a/tests/visual_tests/images/marker-path-expression-500-100-1.0-cairo-reference.png b/tests/visual_tests/images/marker-path-expression-500-100-1.0-cairo-reference.png new file mode 100644 index 000000000..7efffd479 Binary files /dev/null and b/tests/visual_tests/images/marker-path-expression-500-100-1.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/marker-path-expression-500-100-2.0-agg-reference.png b/tests/visual_tests/images/marker-path-expression-500-100-2.0-agg-reference.png new file mode 100644 index 000000000..fdf07eaae Binary files /dev/null and b/tests/visual_tests/images/marker-path-expression-500-100-2.0-agg-reference.png differ diff --git a/tests/visual_tests/images/marker-path-expression-500-100-2.0-cairo-reference.png b/tests/visual_tests/images/marker-path-expression-500-100-2.0-cairo-reference.png new file mode 100644 index 000000000..3b77bf9f2 Binary files /dev/null and b/tests/visual_tests/images/marker-path-expression-500-100-2.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-1.0-agg-reference.png b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-1.0-agg-reference.png index 0fe1cacfb..1aeb7a534 100644 Binary files a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-1.0-agg-reference.png and b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-1.0-agg-reference.png differ diff --git a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-2.0-agg-reference.png b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-2.0-agg-reference.png index f766c3a28..46e816dcb 100644 Binary files a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-2.0-agg-reference.png and b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-257-256-2.0-agg-reference.png differ diff --git a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-1.0-agg-reference.png b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-1.0-agg-reference.png index 7da16b1cd..24708b9fd 100644 Binary files a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-1.0-agg-reference.png and b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-1.0-agg-reference.png differ diff --git a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-2.0-agg-reference.png b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-2.0-agg-reference.png index cdc496257..6ea357ad0 100644 Binary files a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-2.0-agg-reference.png and b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-400-600-2.0-agg-reference.png differ diff --git a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-1.0-agg-reference.png b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-1.0-agg-reference.png index 2a65704af..4c32e4d49 100644 Binary files a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-1.0-agg-reference.png and b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-1.0-agg-reference.png differ diff --git a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-2.0-agg-reference.png b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-2.0-agg-reference.png index 22d92db8d..79861fc0c 100644 Binary files a/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-2.0-agg-reference.png and b/tests/visual_tests/images/marker-with-background-image-and-hsla-transform-600-400-2.0-agg-reference.png differ diff --git a/tests/visual_tests/images/python-Format-reference.png b/tests/visual_tests/images/python-Format-reference.png new file mode 100644 index 000000000..95a0eea9f Binary files /dev/null and b/tests/visual_tests/images/python-Format-reference.png differ diff --git a/tests/visual_tests/images/python-IfElse-reference.png b/tests/visual_tests/images/python-IfElse-reference.png new file mode 100644 index 000000000..d71da4f85 Binary files /dev/null and b/tests/visual_tests/images/python-IfElse-reference.png differ diff --git a/tests/visual_tests/images/python-List-reference.png b/tests/visual_tests/images/python-List-reference.png new file mode 100644 index 000000000..2be43fc4f Binary files /dev/null and b/tests/visual_tests/images/python-List-reference.png differ diff --git a/tests/visual_tests/images/python-MyText-reference.png b/tests/visual_tests/images/python-MyText-reference.png new file mode 100644 index 000000000..775f4bce9 Binary files /dev/null and b/tests/visual_tests/images/python-MyText-reference.png differ diff --git a/tests/visual_tests/images/python-TextNode-reference.png b/tests/visual_tests/images/python-TextNode-reference.png new file mode 100644 index 000000000..db6bfa228 Binary files /dev/null and b/tests/visual_tests/images/python-TextNode-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-0,0-512-512-1.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-0,0-512-512-1.0-cairo-reference.png new file mode 100644 index 000000000..9a6e6d63c Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-0,0-512-512-1.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-0,0-512-512-2.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-0,0-512-512-2.0-cairo-reference.png new file mode 100644 index 000000000..9a6e6d63c Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-0,0-512-512-2.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-0,1-512-512-1.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-0,1-512-512-1.0-cairo-reference.png new file mode 100644 index 000000000..cc2ac3130 Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-0,1-512-512-1.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-0,1-512-512-2.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-0,1-512-512-2.0-cairo-reference.png new file mode 100644 index 000000000..cc2ac3130 Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-0,1-512-512-2.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-1,0-512-512-1.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-1,0-512-512-1.0-cairo-reference.png new file mode 100644 index 000000000..cdd138e47 Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-1,0-512-512-1.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-1,0-512-512-2.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-1,0-512-512-2.0-cairo-reference.png new file mode 100644 index 000000000..cdd138e47 Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-1,0-512-512-2.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-1,1-512-512-1.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-1,1-512-512-1.0-cairo-reference.png new file mode 100644 index 000000000..ad745d737 Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-1,1-512-512-1.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/style-level-compositing-tiled-1,1-512-512-2.0-cairo-reference.png b/tests/visual_tests/images/style-level-compositing-tiled-1,1-512-512-2.0-cairo-reference.png new file mode 100644 index 000000000..ad745d737 Binary files /dev/null and b/tests/visual_tests/images/style-level-compositing-tiled-1,1-512-512-2.0-cairo-reference.png differ diff --git a/tests/visual_tests/styles/marker-path-expression.xml b/tests/visual_tests/styles/marker-path-expression.xml new file mode 100644 index 000000000..1884e2b8f --- /dev/null +++ b/tests/visual_tests/styles/marker-path-expression.xml @@ -0,0 +1,42 @@ + + + + + + ellipse + + csv + +x,y,FILENAME,FILETYPE +2.5,2.5,rect2,svg + + + + + + + + + + frame + + csv + +x,y +0,0 +5,0 +0,5 +5,5 + + + + + \ No newline at end of file diff --git a/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml b/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml index 4d691fbaa..96a0756a3 100644 --- a/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml +++ b/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml @@ -1,7 +1,7 @@