From 9f05389754a15ffe47cfd1de7cbce9669a933019 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 3 Aug 2014 21:28:19 -0700 Subject: [PATCH] fix handling of all sym enums as expressions - fixes tests from #2328 --- bindings/python/mapnik_gamma_method.cpp | 2 +- include/mapnik/agg_helpers.hpp | 2 +- include/mapnik/agg_renderer.hpp | 2 +- include/mapnik/gamma_method.hpp | 43 ---------------------- include/mapnik/symbolizer.hpp | 35 +++++++++++------- include/mapnik/symbolizer_enumerations.hpp | 11 ++++++ src/build.py | 1 - src/gamma_method.cpp | 41 --------------------- src/load_map.cpp | 1 - src/symbolizer_enumerations.cpp | 11 ++++++ src/symbolizer_keys.cpp | 1 - src/xml_tree.cpp | 2 - 12 files changed, 47 insertions(+), 105 deletions(-) delete mode 100644 include/mapnik/gamma_method.hpp delete mode 100644 src/gamma_method.cpp diff --git a/bindings/python/mapnik_gamma_method.cpp b/bindings/python/mapnik_gamma_method.cpp index 23b832d6d..f3f777453 100644 --- a/bindings/python/mapnik_gamma_method.cpp +++ b/bindings/python/mapnik_gamma_method.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include "mapnik_enumeration.hpp" void export_gamma_method() diff --git a/include/mapnik/agg_helpers.hpp b/include/mapnik/agg_helpers.hpp index 78127d2df..c3bc759d2 100644 --- a/include/mapnik/agg_helpers.hpp +++ b/include/mapnik/agg_helpers.hpp @@ -24,7 +24,7 @@ #define MAPNIK_AGG_HELPERS_HPP // mapnik -#include +#include // agg #include "agg_gamma_functions.h" diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index cd6e30c8b..d01c00685 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -34,7 +34,7 @@ #include // for composite_mode_e #include #include -#include +#include #include #include // boost diff --git a/include/mapnik/gamma_method.hpp b/include/mapnik/gamma_method.hpp deleted file mode 100644 index b8a7bd189..000000000 --- a/include/mapnik/gamma_method.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** - * - * 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_GAMMA_METHOD_HPP -#define MAPNIK_GAMMA_METHOD_HPP - -#include - -namespace mapnik { - -enum gamma_method_enum { - GAMMA_POWER, //agg::gamma_power - GAMMA_LINEAR, //agg::gamma_linear - GAMMA_NONE, //agg::gamma_none - GAMMA_THRESHOLD, //agg::gamma_threshold - GAMMA_MULTIPLY, //agg::gamma_multiply - gamma_method_enum_MAX -}; - -DEFINE_ENUM (gamma_method_e, gamma_method_enum ); - -} - -#endif // MAPNIK_GAMMA_METHOD_HPP diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 1a77ca768..56a55e852 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include #include #include @@ -38,7 +39,6 @@ #include #include #include -#include #include #include @@ -185,14 +185,7 @@ struct evaluate_path_wrapper namespace detail { template -struct enum_traits -{ - using result_type = boost::optional; - static result_type from_string(std::string const& str) - { - return result_type(); - } -}; +struct enum_traits {}; template <> struct enum_traits @@ -204,6 +197,16 @@ struct enum_traits } }; +template <> +struct enum_traits +{ + using result_type = boost::optional; + static result_type from_string(std::string const& str) + { + return scaling_method_from_string(str); + } +}; + template <> struct enum_traits { @@ -232,16 +235,22 @@ template <> struct enum_traits { \ } \ };\ -ENUM_FROM_STRING( pattern_alignment_enum ) -ENUM_FROM_STRING( line_join_enum ) ENUM_FROM_STRING( line_cap_enum ) +ENUM_FROM_STRING( line_join_enum ) ENUM_FROM_STRING( point_placement_enum ) -ENUM_FROM_STRING( marker_placement_enum ) -ENUM_FROM_STRING( gamma_method_enum ) ENUM_FROM_STRING( line_rasterizer_enum ) +ENUM_FROM_STRING( marker_placement_enum ) ENUM_FROM_STRING( marker_multi_policy_enum ) +ENUM_FROM_STRING( debug_symbolizer_mode_enum ) +ENUM_FROM_STRING( pattern_alignment_enum ) ENUM_FROM_STRING( halo_rasterizer_enum ) +ENUM_FROM_STRING( label_placement_enum ) +ENUM_FROM_STRING( vertical_alignment_enum ) +ENUM_FROM_STRING( horizontal_alignment_enum ) +ENUM_FROM_STRING( justify_alignment_enum ) ENUM_FROM_STRING( text_transform_enum ) +ENUM_FROM_STRING( text_upright_enum ) +ENUM_FROM_STRING( gamma_method_enum ) // enum template diff --git a/include/mapnik/symbolizer_enumerations.hpp b/include/mapnik/symbolizer_enumerations.hpp index 11ec98df4..0b3179815 100644 --- a/include/mapnik/symbolizer_enumerations.hpp +++ b/include/mapnik/symbolizer_enumerations.hpp @@ -184,6 +184,17 @@ enum text_upright_enum DEFINE_ENUM(text_upright_e, text_upright_enum); +enum gamma_method_enum { + GAMMA_POWER, //agg::gamma_power + GAMMA_LINEAR, //agg::gamma_linear + GAMMA_NONE, //agg::gamma_none + GAMMA_THRESHOLD, //agg::gamma_threshold + GAMMA_MULTIPLY, //agg::gamma_multiply + gamma_method_enum_MAX +}; + +DEFINE_ENUM (gamma_method_e, gamma_method_enum ); + } diff --git a/src/build.py b/src/build.py index 709a357f3..1d9617671 100644 --- a/src/build.py +++ b/src/build.py @@ -168,7 +168,6 @@ source = Split( feature_type_style.cpp font_engine_freetype.cpp font_set.cpp - gamma_method.cpp gradient.cpp graphics.cpp parse_path.cpp diff --git a/src/gamma_method.cpp b/src/gamma_method.cpp deleted file mode 100644 index f1adf99e2..000000000 --- a/src/gamma_method.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 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 - * - *****************************************************************************/ - -// mapnik -#include -#include - -namespace mapnik -{ - -static const char * gamma_method_strings[] = { - "power", //agg::gamma_power - "linear", //agg::gamma_linear - "none", //agg::gamma_none - "threshold", //agg::gamma_threshold - "multiply", //agg::gamma_multiply", - "" -}; - -IMPLEMENT_ENUM( gamma_method_e, gamma_method_strings ) - -} diff --git a/src/load_map.cpp b/src/load_map.cpp index 0d4931d9d..195c25366 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/src/symbolizer_enumerations.cpp b/src/symbolizer_enumerations.cpp index e56df9290..27e3f9b14 100644 --- a/src/symbolizer_enumerations.cpp +++ b/src/symbolizer_enumerations.cpp @@ -172,4 +172,15 @@ static const char * text_upright_strings[] = { }; IMPLEMENT_ENUM(text_upright_e, text_upright_strings) +static const char * gamma_method_strings[] = { + "power", //agg::gamma_power + "linear", //agg::gamma_linear + "none", //agg::gamma_none + "threshold", //agg::gamma_threshold + "multiply", //agg::gamma_multiply", + "" +}; + +IMPLEMENT_ENUM( gamma_method_e, gamma_method_strings ) + } // namespace mapnik diff --git a/src/symbolizer_keys.cpp b/src/symbolizer_keys.cpp index 6756c5052..b802c453e 100644 --- a/src/symbolizer_keys.cpp +++ b/src/symbolizer_keys.cpp @@ -22,7 +22,6 @@ #include #include -#include #include // boost diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp index 96786834b..1c7ee10b9 100644 --- a/src/xml_tree.cpp +++ b/src/xml_tree.cpp @@ -27,13 +27,11 @@ #include #include #include -#include #include #include #include #include #include - #include // stl