From 26052486ee644e7f643bdf46d62be2b87d33b4cf Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 20 Jan 2022 22:52:43 +0100 Subject: [PATCH 01/11] remove cxx11_support.hpp --- include/mapnik/cxx11_support.hpp | 43 -------------------------------- include/mapnik/value/types.hpp | 11 ++++---- 2 files changed, 5 insertions(+), 49 deletions(-) delete mode 100644 include/mapnik/cxx11_support.hpp diff --git a/include/mapnik/cxx11_support.hpp b/include/mapnik/cxx11_support.hpp deleted file mode 100644 index f298a2074..000000000 --- a/include/mapnik/cxx11_support.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2021 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_CXX11_SUPPORT_HPP -#define MAPNIK_CXX11_SUPPORT_HPP - -#include - -namespace mapnik { -namespace detail { - -template -using conditional_t = typename std::conditional::type; - -template -using decay_t = typename std::decay::type; - -template -using enable_if_t = typename std::enable_if::type; - -} // namespace detail -} // namespace mapnik - -#endif // MAPNIK_CXX11_SUPPORT_HPP diff --git a/include/mapnik/value/types.hpp b/include/mapnik/value/types.hpp index a69c01fdb..39932125b 100644 --- a/include/mapnik/value/types.hpp +++ b/include/mapnik/value/types.hpp @@ -25,9 +25,8 @@ // mapnik #include -#include #include - +#include #include MAPNIK_DISABLE_WARNING_PUSH @@ -161,13 +160,13 @@ namespace detail { // value_double if T is a floating-point type // T && otherwise -template > +template > using mapnik_value_type_t = - conditional_t< + std::conditional_t< std::is_same::value, value_bool, - conditional_t< + std::conditional_t< std::is_integral
::value, value_integer, - conditional_t< + std::conditional_t< std::is_floating_point
::value, value_double, T && >>>; From 6fe46f61e2e1e5e157c92f84dbb43adbe1d70beb Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 26 Jan 2022 01:21:45 +0100 Subject: [PATCH 02/11] add clang-format fix clang-format fix clang-format adjust pointer and reference aligment add cmake script to format all files run with: cmake -P cmake/clang-format.cmake fix sort includes change format cmake script --- .clang-format | 94 ++++++++++++++++++++++++++++++++++++++++ cmake/clang-format.cmake | 16 +++++++ 2 files changed, 110 insertions(+) create mode 100644 .clang-format create mode 100644 cmake/clang-format.cmake diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..ad4509ef2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,94 @@ +Language: Cpp +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: None +AlignConsecutiveDeclarations: None +AlignConsecutiveMacros: Consecutive +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Inline +# AlwaysBreakAfterReturnType: +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BitFieldColonSpacing: After +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: Always + AfterEnum: false # see AllowShortEnumsOnASingleLine + AfterFunction: true # see AllowShortFunctionsOnASingleLine + AfterNamespace: false + AfterStruct: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakInheritanceList: AfterComma +BreakStringLiterals: true +ColumnLimit: 120 +CompactNamespaces: false +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: true +DeriveLineEnding: true +EmptyLineAfterAccessModifier: Leave +EmptyLineBeforeAccessModifier: LogicalBlock +FixNamespaceComments: true +IncludeBlocks: Preserve +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: NoIndent +IndentPPDirectives: None +IndentRequires: true +IndentWidth: 4 +IndentWrappedFunctionNames: true +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +# PackConstructorInitializers: CurrentLine # only clang-format > 14 +PointerAlignment: Left +#QualifierAlignment: Left # only clang-format > 14 +ReferenceAlignment: Left +ReflowComments: true +SortIncludes: Never +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeInheritanceColon: true +Standard: c++14 +BinPackParameters: false +BreakBeforeInheritanceComma: false +IncludeCategories: + # Headers in <> without extension. + - Regex: '<([A-Za-z0-9\Q/-_\E])+>' + Priority: 1 + # Headers in <> from specific external libraries. + - Regex: '<(boost)\/' + Priority: 2 + # Headers in <> from specific external libraries. + - Regex: '<(mapnik)\/' + Priority: 3 + # Headers in <> with extension. + - Regex: '<([A-Za-z0-9.\Q/-_\E])+>' + Priority: 4 + # Headers in "" with extension. + - Regex: '"([A-Za-z0-9.\Q/-_\E])+"' + Priority: 5 diff --git a/cmake/clang-format.cmake b/cmake/clang-format.cmake new file mode 100644 index 000000000..7681ffbf2 --- /dev/null +++ b/cmake/clang-format.cmake @@ -0,0 +1,16 @@ +function(format_dir dir) + file(GLOB_RECURSE sources + "${dir}/*.cpp" + "${dir}/*.hpp" + ) + execute_process(COMMAND clang-format -style=file -i ${sources}) +endfunction() + + +format_dir(benchmark) +format_dir(demo) +format_dir(include) +format_dir(plugins) +format_dir(src) +format_dir(test) +format_dir(utils) From e7c3d043090ae22b3581ab78acebbc26dfd7355a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 26 Jan 2022 10:43:31 +0100 Subject: [PATCH 03/11] format dir include and src format all files Revert "format all files" This reverts commit 95d5812e49e7f916b68e786596f5a8eb5bcac414. Revert "format some files" This reverts commit ed3c8762d4d828b2b28e7b18809fc33f4f8ccaf5. format all files fix formatting in dir include fix formatting of debug macro --- include/mapnik/adaptive_smooth.hpp | 48 +- include/mapnik/agg/render_polygon_pattern.hpp | 41 +- include/mapnik/agg_helpers.hpp | 40 +- include/mapnik/agg_pattern_source.hpp | 27 +- include/mapnik/agg_rasterizer.hpp | 7 +- include/mapnik/agg_render_marker.hpp | 77 +- include/mapnik/agg_renderer.hpp | 190 +- include/mapnik/attribute.hpp | 18 +- include/mapnik/attribute_collector.hpp | 153 +- include/mapnik/attribute_descriptor.hpp | 72 +- include/mapnik/boolean.hpp | 42 +- include/mapnik/boost_spirit_instantiate.hpp | 22 +- include/mapnik/cairo/cairo_context.hpp | 222 ++- include/mapnik/cairo/cairo_image_util.hpp | 24 +- include/mapnik/cairo/cairo_render_vector.hpp | 8 +- include/mapnik/cairo/cairo_renderer.hpp | 116 +- .../mapnik/cairo/render_polygon_pattern.hpp | 81 +- include/mapnik/cairo_io.hpp | 10 +- include/mapnik/color.hpp | 147 +- include/mapnik/color_factory.hpp | 2 +- include/mapnik/config.hpp | 42 +- include/mapnik/config_error.hpp | 16 +- include/mapnik/coord.hpp | 173 +- include/mapnik/css/css_color_grammar_x3.hpp | 9 +- .../mapnik/css/css_color_grammar_x3_def.hpp | 108 +- include/mapnik/css/css_grammar_x3.hpp | 17 +- include/mapnik/css/css_grammar_x3_def.hpp | 72 +- include/mapnik/css/css_unit_value.hpp | 48 +- include/mapnik/csv/csv_grammar_x3.hpp | 8 +- include/mapnik/csv/csv_grammar_x3_def.hpp | 60 +- include/mapnik/csv/csv_types.hpp | 2 +- include/mapnik/cxx11_support.hpp | 6 +- include/mapnik/datasource.hpp | 79 +- include/mapnik/datasource_cache.hpp | 15 +- include/mapnik/datasource_geometry_type.hpp | 9 +- include/mapnik/debug.hpp | 119 +- include/mapnik/enumeration.hpp | 175 +- include/mapnik/evaluate_global_attributes.hpp | 211 +-- include/mapnik/expression.hpp | 7 +- include/mapnik/expression_evaluator.hpp | 83 +- include/mapnik/expression_grammar_x3.hpp | 7 +- .../mapnik/expression_grammar_x3_config.hpp | 10 +- include/mapnik/expression_grammar_x3_def.hpp | 476 +++-- include/mapnik/expression_node.hpp | 148 +- include/mapnik/expression_node_types.hpp | 151 +- include/mapnik/expression_string.hpp | 9 +- include/mapnik/extend_converter.hpp | 184 +- include/mapnik/factory.hpp | 34 +- include/mapnik/feature.hpp | 140 +- include/mapnik/feature_factory.hpp | 13 +- include/mapnik/feature_kv_iterator.hpp | 25 +- include/mapnik/feature_layer_desc.hpp | 87 +- include/mapnik/feature_style_processor.hpp | 48 +- .../feature_style_processor_context.hpp | 10 +- .../mapnik/feature_style_processor_impl.hpp | 199 +-- include/mapnik/feature_type_style.hpp | 34 +- include/mapnik/featureset.hpp | 7 +- include/mapnik/filter_featureset.hpp | 14 +- include/mapnik/font_engine_freetype.hpp | 57 +- include/mapnik/font_set.hpp | 13 +- include/mapnik/function_call.hpp | 44 +- include/mapnik/geom_util.hpp | 211 ++- include/mapnik/geometry.hpp | 31 +- include/mapnik/geometry/boost_adapters.hpp | 203 +-- .../geometry/boost_spirit_karma_adapter.hpp | 79 +- include/mapnik/geometry/box2d.hpp | 69 +- include/mapnik/geometry/box2d_impl.hpp | 340 ++-- include/mapnik/geometry/centroid.hpp | 78 +- include/mapnik/geometry/closest_point.hpp | 9 +- include/mapnik/geometry/correct.hpp | 45 +- include/mapnik/geometry/envelope.hpp | 6 +- include/mapnik/geometry/envelope_impl.hpp | 64 +- include/mapnik/geometry/fusion_adapted.hpp | 13 +- include/mapnik/geometry/geometry_type.hpp | 32 +- include/mapnik/geometry/geometry_types.hpp | 11 +- include/mapnik/geometry/interior.hpp | 12 +- include/mapnik/geometry/is_empty.hpp | 49 +- include/mapnik/geometry/is_simple.hpp | 58 +- include/mapnik/geometry/is_valid.hpp | 165 +- include/mapnik/geometry/line_string.hpp | 8 +- include/mapnik/geometry/multi_line_string.hpp | 8 +- include/mapnik/geometry/multi_point.hpp | 8 +- include/mapnik/geometry/multi_polygon.hpp | 9 +- include/mapnik/geometry/point.hpp | 8 +- include/mapnik/geometry/polygon.hpp | 10 +- .../geometry/polygon_vertex_processor.hpp | 12 +- include/mapnik/geometry/polylabel.hpp | 17 +- include/mapnik/geometry/remove_empty.hpp | 25 +- include/mapnik/geometry/reprojection.hpp | 26 +- include/mapnik/geometry/reprojection_impl.hpp | 192 +- include/mapnik/geometry/strategy.hpp | 154 +- include/mapnik/geometry/to_path.hpp | 65 +- include/mapnik/geometry/transform.hpp | 82 +- include/mapnik/global.hpp | 106 +- include/mapnik/gradient.hpp | 34 +- include/mapnik/grid/grid.hpp | 111 +- include/mapnik/grid/grid_pixel.hpp | 179 +- include/mapnik/grid/grid_pixfmt.hpp | 356 ++-- include/mapnik/grid/grid_rasterizer.hpp | 8 +- include/mapnik/grid/grid_render_marker.hpp | 28 +- include/mapnik/grid/grid_renderer.hpp | 136 +- include/mapnik/grid/grid_renderer_base.hpp | 4 +- include/mapnik/grid/grid_rendering_buffer.hpp | 2 +- include/mapnik/grid/grid_view.hpp | 141 +- include/mapnik/grid_vertex_converter.hpp | 103 +- include/mapnik/group/group_layout.hpp | 67 +- include/mapnik/group/group_layout_manager.hpp | 37 +- include/mapnik/group/group_rule.hpp | 68 +- .../mapnik/group/group_symbolizer_helper.hpp | 20 +- .../group/group_symbolizer_properties.hpp | 19 +- include/mapnik/hextree.hpp | 225 ++- include/mapnik/hit_test_filter.hpp | 107 +- include/mapnik/image.hpp | 54 +- include/mapnik/image_any.hpp | 11 +- include/mapnik/image_compositing.hpp | 16 +- include/mapnik/image_copy.hpp | 29 +- include/mapnik/image_filter.hpp | 576 +++--- include/mapnik/image_filter_grammar_x3.hpp | 11 +- .../mapnik/image_filter_grammar_x3_def.hpp | 139 +- include/mapnik/image_filter_types.hpp | 237 ++- include/mapnik/image_impl.hpp | 195 +- include/mapnik/image_null.hpp | 31 +- include/mapnik/image_options.hpp | 10 +- include/mapnik/image_reader.hpp | 28 +- include/mapnik/image_scaling.hpp | 46 +- include/mapnik/image_scaling_traits.hpp | 148 +- include/mapnik/image_util.hpp | 388 ++-- include/mapnik/image_util_jpeg.hpp | 11 +- include/mapnik/image_util_png.hpp | 20 +- include/mapnik/image_util_tiff.hpp | 11 +- include/mapnik/image_util_webp.hpp | 11 +- include/mapnik/image_view.hpp | 10 +- include/mapnik/image_view_any.hpp | 10 +- include/mapnik/image_view_impl.hpp | 64 +- include/mapnik/image_view_null.hpp | 17 +- include/mapnik/jpeg_io.hpp | 60 +- .../mapnik/json/attribute_value_visitor.hpp | 22 +- include/mapnik/json/create_feature.hpp | 80 +- include/mapnik/json/create_geometry.hpp | 146 +- .../mapnik/json/extract_bounding_boxes_x3.hpp | 12 +- .../json/extract_bounding_boxes_x3_config.hpp | 64 +- .../mapnik/json/feature_generator_grammar.hpp | 73 +- .../json/feature_generator_grammar_impl.hpp | 22 +- include/mapnik/json/feature_grammar_x3.hpp | 10 +- .../mapnik/json/feature_grammar_x3_def.hpp | 150 +- include/mapnik/json/feature_parser.hpp | 8 +- .../mapnik/json/generic_json_grammar_x3.hpp | 7 +- .../json/generic_json_grammar_x3_def.hpp | 75 +- include/mapnik/json/geojson_grammar_x3.hpp | 32 +- .../mapnik/json/geojson_grammar_x3_def.hpp | 72 +- .../json/geometry_generator_grammar.hpp | 35 +- .../json/geometry_generator_grammar_impl.hpp | 11 +- include/mapnik/json/geometry_parser.hpp | 8 +- include/mapnik/json/json_grammar_config.hpp | 86 +- include/mapnik/json/json_value.hpp | 24 +- include/mapnik/json/parse_feature.hpp | 17 +- include/mapnik/json/positions_grammar_x3.hpp | 7 +- .../mapnik/json/positions_grammar_x3_def.hpp | 26 +- include/mapnik/json/positions_x3.hpp | 9 +- .../json/properties_generator_grammar.hpp | 22 +- .../properties_generator_grammar_impl.hpp | 51 +- include/mapnik/json/stringifier.hpp | 37 +- include/mapnik/json/topojson_grammar_x3.hpp | 10 +- .../mapnik/json/topojson_grammar_x3_def.hpp | 205 +-- include/mapnik/json/topojson_utils.hpp | 152 +- include/mapnik/json/topology.hpp | 29 +- .../mapnik/json/unicode_string_grammar_x3.hpp | 9 +- .../json/unicode_string_grammar_x3_def.hpp | 55 +- include/mapnik/json/value_converters.hpp | 13 +- include/mapnik/label_collision_detector.hpp | 141 +- include/mapnik/layer.hpp | 21 +- include/mapnik/load_map.hpp | 9 +- include/mapnik/map.hpp | 92 +- include/mapnik/mapped_memory_cache.hpp | 24 +- include/mapnik/marker.hpp | 124 +- include/mapnik/marker_cache.hpp | 22 +- include/mapnik/marker_helpers.hpp | 98 +- include/mapnik/markers_placement.hpp | 143 +- include/mapnik/markers_placements/basic.hpp | 9 +- .../mapnik/markers_placements/interior.hpp | 12 +- include/mapnik/markers_placements/line.hpp | 28 +- include/mapnik/markers_placements/point.hpp | 35 +- .../mapnik/markers_placements/polylabel.hpp | 11 +- .../markers_placements/vertex_first.hpp | 8 +- .../mapnik/markers_placements/vertex_last.hpp | 8 +- include/mapnik/memory_datasource.hpp | 10 +- include/mapnik/memory_featureset.hpp | 26 +- include/mapnik/octree.hpp | 163 +- include/mapnik/offset_converter.hpp | 154 +- include/mapnik/palette.hpp | 74 +- include/mapnik/params.hpp | 73 +- include/mapnik/params_impl.hpp | 80 +- include/mapnik/parse_path.hpp | 4 +- include/mapnik/path.hpp | 111 +- include/mapnik/path_expression.hpp | 7 +- include/mapnik/path_expression_grammar_x3.hpp | 8 +- .../mapnik/path_expression_grammar_x3_def.hpp | 26 +- include/mapnik/pixel_position.hpp | 43 +- include/mapnik/pixel_types.hpp | 77 +- include/mapnik/plugin.hpp | 21 +- include/mapnik/png_io.hpp | 362 ++-- include/mapnik/pool.hpp | 31 +- include/mapnik/proj_strategy.hpp | 33 +- include/mapnik/proj_transform.hpp | 34 +- include/mapnik/proj_transform_cache.hpp | 5 +- include/mapnik/projection.hpp | 34 +- include/mapnik/ptree_helpers.hpp | 4 +- include/mapnik/quad_tree.hpp | 146 +- include/mapnik/query.hpp | 147 +- include/mapnik/raster.hpp | 57 +- include/mapnik/raster_colorizer.hpp | 72 +- include/mapnik/renderer_common.hpp | 63 +- .../apply_vertex_converter.hpp | 22 +- .../renderer_common/clipping_extent.hpp | 5 +- .../renderer_common/pattern_alignment.hpp | 15 +- .../process_building_symbolizer.hpp | 17 +- .../process_point_symbolizer.hpp | 50 +- .../process_polygon_symbolizer.hpp | 38 +- .../process_raster_symbolizer.hpp | 280 ++- .../render_group_symbolizer.hpp | 8 +- .../render_markers_symbolizer.hpp | 6 +- .../mapnik/renderer_common/render_pattern.hpp | 8 +- .../mapnik/renderer_common/render_thunk.hpp | 38 +- .../render_thunk_extractor.hpp | 25 +- include/mapnik/request.hpp | 14 +- include/mapnik/rule.hpp | 24 +- include/mapnik/rule_cache.hpp | 45 +- include/mapnik/safe_cast.hpp | 102 +- include/mapnik/save_map.hpp | 5 +- include/mapnik/simplify.hpp | 13 +- include/mapnik/simplify_converter.hpp | 232 ++- include/mapnik/span_image_filter.hpp | 87 +- include/mapnik/sql_utils.hpp | 312 ++-- include/mapnik/sse.hpp | 51 +- include/mapnik/stringify_macro.hpp | 2 +- include/mapnik/svg/geometry_svg_generator.hpp | 72 +- .../svg/geometry_svg_generator_impl.hpp | 72 +- include/mapnik/svg/output/svg_generator.hpp | 49 +- .../svg/output/svg_output_attributes.hpp | 298 ++-- .../mapnik/svg/output/svg_output_grammars.hpp | 30 +- .../svg/output/svg_output_grammars_impl.hpp | 110 +- .../mapnik/svg/output/svg_path_iterator.hpp | 52 +- include/mapnik/svg/output/svg_renderer.hpp | 140 +- include/mapnik/svg/svg_converter.hpp | 206 +-- include/mapnik/svg/svg_grammar_config_x3.hpp | 15 +- include/mapnik/svg/svg_parser.hpp | 50 +- include/mapnik/svg/svg_parser_exception.hpp | 20 +- include/mapnik/svg/svg_path_adapter.hpp | 323 ++-- include/mapnik/svg/svg_path_attributes.hpp | 175 +- include/mapnik/svg/svg_path_commands.hpp | 55 +- include/mapnik/svg/svg_path_grammar_x3.hpp | 11 +- .../mapnik/svg/svg_path_grammar_x3_def.hpp | 100 +- include/mapnik/svg/svg_path_parser.hpp | 12 +- include/mapnik/svg/svg_renderer_agg.hpp | 198 ++- include/mapnik/svg/svg_storage.hpp | 49 +- .../mapnik/svg/svg_transform_grammar_x3.hpp | 8 +- .../svg/svg_transform_grammar_x3_def.hpp | 72 +- include/mapnik/symbolizer.hpp | 285 ++- include/mapnik/symbolizer_base.hpp | 79 +- include/mapnik/symbolizer_default_values.hpp | 106 +- include/mapnik/symbolizer_dispatch.hpp | 70 +- include/mapnik/symbolizer_enumerations.hpp | 138 +- include/mapnik/symbolizer_hash.hpp | 34 +- include/mapnik/symbolizer_keys.hpp | 4 +- include/mapnik/symbolizer_utils.hpp | 204 +-- include/mapnik/text/color_font_renderer.hpp | 17 +- .../text/evaluated_format_properties_ptr.hpp | 5 +- include/mapnik/text/face.hpp | 54 +- include/mapnik/text/font_feature_settings.hpp | 25 +- include/mapnik/text/font_library.hpp | 11 +- include/mapnik/text/formatting/base.hpp | 15 +- include/mapnik/text/formatting/format.hpp | 19 +- include/mapnik/text/formatting/layout.hpp | 22 +- include/mapnik/text/formatting/list.hpp | 26 +- include/mapnik/text/formatting/registry.hpp | 21 +- include/mapnik/text/formatting/text.hpp | 31 +- include/mapnik/text/glyph_info.hpp | 57 +- include/mapnik/text/glyph_positions.hpp | 31 +- include/mapnik/text/harfbuzz_shaper.hpp | 509 +++--- include/mapnik/text/icu_shaper.hpp | 142 +- include/mapnik/text/itemizer.hpp | 59 +- include/mapnik/text/placement_finder.hpp | 37 +- include/mapnik/text/placement_finder_impl.hpp | 43 +- include/mapnik/text/placements/base.hpp | 17 +- include/mapnik/text/placements/dummy.hpp | 22 +- include/mapnik/text/placements/list.hpp | 32 +- include/mapnik/text/placements/registry.hpp | 24 +- include/mapnik/text/placements/simple.hpp | 21 +- include/mapnik/text/properties_util.hpp | 66 +- include/mapnik/text/renderer.hpp | 111 +- include/mapnik/text/rotation.hpp | 37 +- include/mapnik/text/scrptrun.hpp | 22 +- include/mapnik/text/symbolizer_helpers.hpp | 51 +- include/mapnik/text/text_layout.hpp | 51 +- include/mapnik/text/text_line.hpp | 15 +- include/mapnik/text/text_properties.hpp | 33 +- include/mapnik/tiff_io.hpp | 232 ++- include/mapnik/timer.hpp | 47 +- include/mapnik/tolerance_iterator.hpp | 35 +- include/mapnik/transform/parse_transform.hpp | 5 +- .../mapnik/transform/transform_expression.hpp | 128 +- .../transform_expression_grammar_x3.hpp | 3 +- .../transform_expression_grammar_x3_def.hpp | 94 +- .../mapnik/transform/transform_processor.hpp | 96 +- include/mapnik/transform_path_adapter.hpp | 74 +- include/mapnik/unicode.hpp | 15 +- include/mapnik/util/char_array_buffer.hpp | 44 +- .../mapnik/util/const_rendering_buffer.hpp | 27 +- include/mapnik/util/container_adapter.hpp | 46 +- include/mapnik/util/conversions.hpp | 36 +- include/mapnik/util/dasharray_parser.hpp | 8 +- include/mapnik/util/feature_to_geojson.hpp | 8 +- include/mapnik/util/featureset_buffer.hpp | 22 +- include/mapnik/util/file_io.hpp | 52 +- include/mapnik/util/from_u8string.hpp | 24 +- include/mapnik/util/fs.hpp | 8 +- include/mapnik/util/geometry_to_ds_type.hpp | 25 +- include/mapnik/util/geometry_to_geojson.hpp | 8 +- include/mapnik/util/geometry_to_svg.hpp | 9 +- include/mapnik/util/geometry_to_wkb.hpp | 152 +- include/mapnik/util/geometry_to_wkt.hpp | 12 +- include/mapnik/util/hsl.hpp | 41 +- include/mapnik/util/is_clockwise.hpp | 10 +- include/mapnik/util/mapped_memory_file.hpp | 51 +- include/mapnik/util/math.hpp | 8 +- include/mapnik/util/name_to_int.hpp | 8 +- include/mapnik/util/noncopyable.hpp | 25 +- include/mapnik/util/path_iterator.hpp | 84 +- include/mapnik/util/rounding_cast.hpp | 30 +- include/mapnik/util/singleton.hpp | 173 +- include/mapnik/util/spatial_index.hpp | 80 +- include/mapnik/util/timer.hpp | 20 +- include/mapnik/util/trim.hpp | 29 +- include/mapnik/util/utf_conv_win.hpp | 11 +- include/mapnik/util/variant.hpp | 28 +- include/mapnik/util/variant_io.hpp | 42 +- include/mapnik/value.hpp | 71 +- include/mapnik/value/error.hpp | 25 +- include/mapnik/value/hash.hpp | 14 +- include/mapnik/value/types.hpp | 84 +- include/mapnik/version.hpp | 16 +- include/mapnik/vertex.hpp | 70 +- include/mapnik/vertex_adapters.hpp | 67 +- include/mapnik/vertex_cache.hpp | 128 +- include/mapnik/vertex_converters.hpp | 302 ++-- include/mapnik/vertex_processor.hpp | 49 +- include/mapnik/vertex_vector.hpp | 74 +- include/mapnik/view_strategy.hpp | 32 +- include/mapnik/view_transform.hpp | 89 +- include/mapnik/warning.hpp | 252 +-- include/mapnik/warning_ignore.hpp | 5 +- include/mapnik/warning_ignore_agg.hpp | 3 +- include/mapnik/warp.hpp | 32 +- include/mapnik/webp_io.hpp | 105 +- include/mapnik/well_known_srs.hpp | 26 +- include/mapnik/wkb.hpp | 24 +- include/mapnik/wkt/wkt_factory.hpp | 2 +- include/mapnik/wkt/wkt_generator_grammar.hpp | 40 +- .../mapnik/wkt/wkt_generator_grammar_impl.hpp | 11 +- include/mapnik/wkt/wkt_grammar_x3.hpp | 7 +- include/mapnik/wkt/wkt_grammar_x3_def.hpp | 102 +- include/mapnik/xml_attribute_cast.hpp | 64 +- include/mapnik/xml_loader.hpp | 9 +- include/mapnik/xml_node.hpp | 66 +- include/mapnik/xml_tree.hpp | 19 +- plugins/input/csv/csv_datasource.cpp | 128 +- plugins/input/csv/csv_datasource.hpp | 38 +- plugins/input/csv/csv_featureset.cpp | 49 +- plugins/input/csv/csv_featureset.hpp | 13 +- plugins/input/csv/csv_getline.hpp | 14 +- plugins/input/csv/csv_index_featureset.cpp | 52 +- plugins/input/csv/csv_index_featureset.hpp | 11 +- plugins/input/csv/csv_inline_featureset.cpp | 23 +- plugins/input/csv/csv_inline_featureset.hpp | 9 +- plugins/input/csv/csv_utils.cpp | 172 +- plugins/input/csv/csv_utils.hpp | 47 +- plugins/input/gdal/gdal_datasource.cpp | 100 +- plugins/input/gdal/gdal_datasource.hpp | 7 +- plugins/input/gdal/gdal_featureset.cpp | 717 +++++--- plugins/input/gdal/gdal_featureset.hpp | 27 +- plugins/input/geobuf/geobuf.hpp | 505 +++--- plugins/input/geobuf/geobuf_datasource.cpp | 85 +- plugins/input/geobuf/geobuf_datasource.hpp | 33 +- plugins/input/geobuf/geobuf_featureset.cpp | 15 +- plugins/input/geobuf/geobuf_featureset.hpp | 7 +- plugins/input/geojson/geojson_datasource.cpp | 210 +-- plugins/input/geojson/geojson_datasource.hpp | 38 +- plugins/input/geojson/geojson_featureset.cpp | 14 +- plugins/input/geojson/geojson_featureset.hpp | 8 +- .../geojson/geojson_index_featureset.cpp | 46 +- .../geojson/geojson_index_featureset.hpp | 9 +- .../geojson_memory_index_featureset.cpp | 22 +- .../geojson_memory_index_featureset.hpp | 9 +- plugins/input/ogr/ogr_converter.cpp | 62 +- plugins/input/ogr/ogr_converter.hpp | 18 +- plugins/input/ogr/ogr_datasource.cpp | 219 ++- plugins/input/ogr/ogr_datasource.hpp | 8 +- plugins/input/ogr/ogr_featureset.cpp | 154 +- plugins/input/ogr/ogr_featureset.hpp | 12 +- plugins/input/ogr/ogr_index.hpp | 29 +- plugins/input/ogr/ogr_index_featureset.cpp | 160 +- plugins/input/ogr/ogr_index_featureset.hpp | 7 +- plugins/input/ogr/ogr_layer_ptr.hpp | 46 +- .../input/pgraster/pgraster_datasource.cpp | 522 +++--- .../input/pgraster/pgraster_datasource.hpp | 52 +- .../input/pgraster/pgraster_featureset.cpp | 57 +- .../input/pgraster/pgraster_featureset.hpp | 16 +- .../input/pgraster/pgraster_wkb_reader.cpp | 632 ++++--- .../input/pgraster/pgraster_wkb_reader.hpp | 78 +- plugins/input/postgis/asyncresultset.hpp | 101 +- plugins/input/postgis/connection.hpp | 106 +- plugins/input/postgis/connection_manager.hpp | 76 +- plugins/input/postgis/cursorresultset.hpp | 84 +- plugins/input/postgis/numeric2string.hpp | 57 +- plugins/input/postgis/postgis_datasource.cpp | 394 ++-- plugins/input/postgis/postgis_datasource.hpp | 37 +- plugins/input/postgis/postgis_featureset.cpp | 57 +- plugins/input/postgis/postgis_featureset.hpp | 10 +- plugins/input/postgis/resultset.hpp | 67 +- plugins/input/raster/raster_datasource.cpp | 59 +- plugins/input/raster/raster_datasource.hpp | 7 +- plugins/input/raster/raster_featureset.cpp | 86 +- plugins/input/raster/raster_featureset.hpp | 175 +- plugins/input/raster/raster_info.cpp | 35 +- plugins/input/raster/raster_info.hpp | 16 +- plugins/input/shape/dbf_test.cpp | 28 +- plugins/input/shape/dbfile.cpp | 200 +-- plugins/input/shape/dbfile.hpp | 13 +- plugins/input/shape/shape_datasource.cpp | 205 ++- plugins/input/shape/shape_datasource.hpp | 15 +- plugins/input/shape/shape_featureset.cpp | 132 +- plugins/input/shape/shape_featureset.hpp | 18 +- .../input/shape/shape_index_featureset.cpp | 150 +- .../input/shape/shape_index_featureset.hpp | 30 +- plugins/input/shape/shape_io.cpp | 40 +- plugins/input/shape/shape_io.hpp | 30 +- plugins/input/shape/shape_utils.cpp | 8 +- plugins/input/shape/shape_utils.hpp | 4 +- plugins/input/shape/shapefile.hpp | 91 +- plugins/input/sqlite/sqlite_connection.hpp | 55 +- plugins/input/sqlite/sqlite_datasource.cpp | 179 +- plugins/input/sqlite/sqlite_datasource.hpp | 8 +- plugins/input/sqlite/sqlite_featureset.cpp | 87 +- plugins/input/sqlite/sqlite_featureset.hpp | 6 +- plugins/input/sqlite/sqlite_prepared.hpp | 32 +- plugins/input/sqlite/sqlite_resultset.hpp | 97 +- plugins/input/sqlite/sqlite_utils.hpp | 262 ++- .../input/topojson/topojson_datasource.cpp | 99 +- .../input/topojson/topojson_datasource.hpp | 18 +- .../input/topojson/topojson_featureset.cpp | 23 +- .../input/topojson/topojson_featureset.hpp | 8 +- src/agg/agg_renderer.cpp | 373 ++-- src/agg/process_building_symbolizer.cpp | 87 +- src/agg/process_debug_symbolizer.cpp | 130 +- src/agg/process_dot_symbolizer.cpp | 81 +- src/agg/process_group_symbolizer.cpp | 70 +- src/agg/process_line_pattern_symbolizer.cpp | 140 +- src/agg/process_line_symbolizer.cpp | 134 +- src/agg/process_markers_symbolizer.cpp | 72 +- src/agg/process_point_symbolizer.cpp | 26 +- .../process_polygon_pattern_symbolizer.cpp | 100 +- src/agg/process_polygon_symbolizer.cpp | 77 +- src/agg/process_raster_symbolizer.cpp | 29 +- src/agg/process_shield_symbolizer.cpp | 45 +- src/agg/process_text_symbolizer.cpp | 39 +- src/cairo/cairo_context.cpp | 274 +-- src/cairo/cairo_render_vector.cpp | 45 +- src/cairo/cairo_renderer.cpp | 162 +- src/cairo/process_building_symbolizer.cpp | 70 +- src/cairo/process_debug_symbolizer.cpp | 46 +- src/cairo/process_group_symbolizer.cpp | 48 +- src/cairo/process_line_pattern_symbolizer.cpp | 99 +- src/cairo/process_line_symbolizer.cpp | 55 +- src/cairo/process_markers_symbolizer.cpp | 40 +- src/cairo/process_point_symbolizer.cpp | 31 +- .../process_polygon_pattern_symbolizer.cpp | 31 +- src/cairo/process_polygon_symbolizer.cpp | 40 +- src/cairo/process_raster_symbolizer.cpp | 31 +- src/cairo/process_text_symbolizer.cpp | 82 +- src/cairo_io.cpp | 31 +- src/color.cpp | 43 +- src/color_factory.cpp | 4 +- src/config_error.cpp | 64 +- src/conversions_numeric.cpp | 9 +- src/conversions_string.cpp | 5 +- src/css/css_color_grammar_x3.cpp | 13 +- src/css/css_grammar_x3.cpp | 7 +- src/dasharray_parser.cpp | 28 +- src/datasource_cache.cpp | 52 +- src/datasource_cache_static.cpp | 146 +- src/debug.cpp | 22 +- src/expression.cpp | 24 +- src/expression_grammar_x3.cpp | 6 +- src/expression_node.cpp | 80 +- src/expression_string.cpp | 67 +- src/feature_kv_iterator.cpp | 17 +- src/feature_style_processor.cpp | 13 +- src/feature_type_style.cpp | 81 +- src/font_engine_freetype.cpp | 174 +- src/font_set.cpp | 31 +- src/fs.cpp | 141 +- src/function_call.cpp | 40 +- src/generate_image_filters.cpp | 5 +- src/geometry/box2d.cpp | 4 +- src/geometry/closest_point.cpp | 70 +- src/geometry/envelope.cpp | 7 +- src/geometry/interior.cpp | 90 +- src/geometry/polylabel.cpp | 22 +- src/geometry/reprojection.cpp | 108 +- src/glibc_workaround.cpp | 9 +- src/gradient.cpp | 92 +- src/grid/grid.cpp | 83 +- src/grid/grid_renderer.cpp | 115 +- src/grid/process_building_symbolizer.cpp | 63 +- src/grid/process_group_symbolizer.cpp | 61 +- src/grid/process_line_pattern_symbolizer.cpp | 67 +- src/grid/process_line_symbolizer.cpp | 57 +- src/grid/process_markers_symbolizer.cpp | 70 +- src/grid/process_point_symbolizer.cpp | 27 +- .../process_polygon_pattern_symbolizer.cpp | 44 +- src/grid/process_polygon_symbolizer.cpp | 47 +- src/grid/process_raster_symbolizer.cpp | 13 +- src/grid/process_shield_symbolizer.cpp | 45 +- src/grid/process_text_symbolizer.cpp | 35 +- src/group/group_layout_manager.cpp | 34 +- src/group/group_rule.cpp | 35 +- src/group/group_symbolizer_helper.cpp | 86 +- src/image.cpp | 47 +- src/image_any.cpp | 148 +- src/image_compositing.cpp | 153 +- src/image_copy.cpp | 75 +- src/image_filter_grammar_x3.cpp | 6 +- src/image_options.cpp | 62 +- src/image_reader.cpp | 21 +- src/image_scaling.cpp | 178 +- src/image_util.cpp | 1583 +++++++++-------- src/image_util_jpeg.cpp | 80 +- src/image_util_png.cpp | 192 +- src/image_util_tiff.cpp | 78 +- src/image_util_webp.cpp | 186 +- src/image_view.cpp | 5 +- src/image_view_any.cpp | 34 +- src/jpeg_reader.cpp | 154 +- src/json/extract_bounding_boxes_x3.cpp | 131 +- src/json/feature_from_geojson.cpp | 12 +- src/json/feature_grammar_x3.cpp | 8 +- src/json/generic_json_grammar_x3.cpp | 8 +- src/json/geojson_grammar_x3.cpp | 9 +- src/json/geometry_from_geojson.cpp | 13 +- src/json/mapnik_feature_to_geojson.cpp | 8 +- src/json/mapnik_geometry_to_geojson.cpp | 10 +- src/json/mapnik_json_generator_grammar.cpp | 2 +- src/json/parse_feature.cpp | 25 +- src/json/positions_grammar_x3.cpp | 9 +- src/json/topojson_grammar_x3.cpp | 8 +- src/json/unicode_string_grammar_x3.cpp | 16 +- src/layer.cpp | 143 +- src/libxml2_loader.cpp | 106 +- src/load_map.cpp | 808 +++++---- src/map.cpp | 421 +++-- src/mapped_memory_cache.cpp | 18 +- src/marker_cache.cpp | 86 +- src/marker_helpers.cpp | 118 +- src/memory_datasource.cpp | 37 +- src/palette.cpp | 53 +- src/params.cpp | 14 +- src/parse_image_filters.cpp | 10 +- src/parse_path.cpp | 108 +- src/parse_transform.cpp | 15 +- src/path_expression_grammar_x3.cpp | 6 +- src/plugin.cpp | 114 +- src/png_reader.cpp | 174 +- src/proj_transform.cpp | 158 +- src/proj_transform_cache.cpp | 19 +- src/projection.cpp | 57 +- src/rapidxml_loader.cpp | 106 +- src/raster_colorizer.cpp | 291 ++- src/renderer_common.cpp | 119 +- src/renderer_common/pattern_alignment.cpp | 45 +- .../render_group_symbolizer.cpp | 45 +- .../render_markers_symbolizer.cpp | 96 +- src/renderer_common/render_pattern.cpp | 15 +- .../render_thunk_extractor.cpp | 82 +- src/request.cpp | 22 +- src/rule.cpp | 98 +- src/save_map.cpp | 369 ++-- src/scale_denominator.cpp | 5 +- src/simplify.cpp | 15 +- src/svg/output/process_line_symbolizer.cpp | 19 +- src/svg/output/process_polygon_symbolizer.cpp | 21 +- src/svg/output/process_symbolizers.cpp | 53 +- src/svg/output/svg_generator.cpp | 140 +- src/svg/output/svg_output_attributes.cpp | 392 ++-- src/svg/output/svg_output_grammars.cpp | 8 +- src/svg/output/svg_renderer.cpp | 60 +- src/svg/svg_parser.cpp | 1096 ++++++------ src/svg/svg_path_grammar_x3.cpp | 8 +- src/svg/svg_path_parser.cpp | 18 +- src/svg/svg_points_parser.cpp | 18 +- src/svg/svg_transform_parser.cpp | 18 +- src/symbolizer.cpp | 7 +- src/symbolizer_enumerations.cpp | 206 +-- src/symbolizer_keys.cpp | 311 ++-- src/text/color_font_renderer.cpp | 60 +- src/text/face.cpp | 34 +- src/text/font_feature_settings.cpp | 18 +- src/text/font_library.cpp | 14 +- src/text/formatting/base.cpp | 12 +- src/text/formatting/format.cpp | 147 +- src/text/formatting/layout.cpp | 168 +- src/text/formatting/list.cpp | 15 +- src/text/formatting/registry.cpp | 20 +- src/text/formatting/text.cpp | 66 +- src/text/glyph_positions.cpp | 18 +- src/text/itemizer.cpp | 60 +- src/text/placement_finder.cpp | 162 +- src/text/placements/base.cpp | 17 +- src/text/placements/dummy.cpp | 12 +- src/text/placements/list.cpp | 45 +- src/text/placements/registry.cpp | 23 +- src/text/placements/simple.cpp | 152 +- src/text/properties_util.cpp | 60 +- src/text/renderer.cpp | 223 +-- src/text/scrptrun.cpp | 114 +- src/text/symbolizer_helpers.cpp | 357 ++-- src/text/text_layout.cpp | 291 +-- src/text/text_line.cpp | 46 +- src/text/text_properties.cpp | 305 ++-- src/tiff_reader.cpp | 585 +++--- src/transform_expression.cpp | 63 +- src/transform_expression_grammar_x3.cpp | 6 +- src/twkb.cpp | 133 +- src/unicode.cpp | 16 +- src/util/mapped_memory_file.cpp | 103 +- src/util/math.cpp | 42 +- src/util/utf_conv_win.cpp | 4 +- src/value.cpp | 417 ++--- src/vertex_adapters.cpp | 89 +- src/vertex_cache.cpp | 136 +- src/warp.cpp | 242 ++- src/webp_reader.cpp | 135 +- src/well_known_srs.cpp | 36 +- src/wkb.cpp | 426 +++-- src/wkt/geometry_to_wkt.cpp | 10 +- src/wkt/mapnik_wkt_generator_grammar.cpp | 6 +- src/wkt/wkt_factory.cpp | 13 +- src/wkt/wkt_grammar_x3.cpp | 6 +- src/xml_tree.cpp | 168 +- 648 files changed, 25217 insertions(+), 26024 deletions(-) diff --git a/include/mapnik/adaptive_smooth.hpp b/include/mapnik/adaptive_smooth.hpp index 274f42891..0f5748f3c 100644 --- a/include/mapnik/adaptive_smooth.hpp +++ b/include/mapnik/adaptive_smooth.hpp @@ -9,8 +9,7 @@ MAPNIK_DISABLE_WARNING_PUSH #include "agg_conv_smooth_poly1.h" MAPNIK_DISABLE_WARNING_POP -namespace mapnik -{ +namespace mapnik { struct vcgen_smooth_calucate_adaptive { @@ -57,12 +56,8 @@ struct vcgen_smooth_calucate_adaptive } } - return { - {v1.x + s1 * smooth_value * (v2.x - xm1), - v1.y + s1 * smooth_value * (v2.y - ym1)}, - {v2.x + s2 * smooth_value * (v1.x - xm2), - v2.y + s2 * smooth_value * (v1.y - ym2)} - }; + return {{v1.x + s1 * smooth_value * (v2.x - xm1), v1.y + s1 * smooth_value * (v2.y - ym1)}, + {v2.x + s2 * smooth_value * (v1.x - xm2), v2.y + s2 * smooth_value * (v1.y - ym2)}}; } }; @@ -71,7 +66,7 @@ using vcgen_smooth_adaptive = agg::vcgen_smooth; template using conv_smooth_adaptive = agg::conv_smooth_curve; -template +template class smooth_converter { Geometry geom_; @@ -81,9 +76,9 @@ class smooth_converter using impl_type = util::variant; impl_type impl_; - impl_type init_impl(smooth_algorithm_enum algo, Geometry & geom) const + impl_type init_impl(smooth_algorithm_enum algo, Geometry& geom) const { - switch(algo) + switch (algo) { case SMOOTH_ALGORITHM_ADAPTIVE: return adaptive_impl_type(geom); @@ -94,46 +89,35 @@ class smooth_converter return basic_impl_type(geom); } -public: - smooth_converter(Geometry & geom) : - geom_(geom), - impl_(std::move(init_impl(SMOOTH_ALGORITHM_BASIC, geom))) + public: + smooth_converter(Geometry& geom) + : geom_(geom) + , impl_(std::move(init_impl(SMOOTH_ALGORITHM_BASIC, geom))) {} - void algorithm(smooth_algorithm_enum algo) - { - impl_ = init_impl(algo, geom_); - } + void algorithm(smooth_algorithm_enum algo) { impl_ = init_impl(algo, geom_); } void smooth_value(double v) { - return util::apply_visitor([=](auto & impl) { - impl.smooth_value(v); - }, impl_); + return util::apply_visitor([=](auto& impl) { impl.smooth_value(v); }, impl_); } void rewind(unsigned path_id) { - return util::apply_visitor([=](auto & impl) { - return impl.rewind(path_id); - }, impl_); + return util::apply_visitor([=](auto& impl) { return impl.rewind(path_id); }, impl_); } unsigned vertex(double* x, double* y) { - return util::apply_visitor([=](auto & impl) { - return impl.vertex(x, y); - }, impl_); + return util::apply_visitor([=](auto& impl) { return impl.vertex(x, y); }, impl_); } unsigned type() const { - return util::apply_visitor([](auto const& impl) { - return impl.type(); - }, impl_); + return util::apply_visitor([](auto const& impl) { return impl.type(); }, impl_); } }; -} +} // namespace mapnik #endif // MAPNIK_ADAPTIVE_SMOOTH_HPP diff --git a/include/mapnik/agg/render_polygon_pattern.hpp b/include/mapnik/agg/render_polygon_pattern.hpp index b33b8a03e..4a5c2c051 100644 --- a/include/mapnik/agg/render_polygon_pattern.hpp +++ b/include/mapnik/agg/render_polygon_pattern.hpp @@ -69,7 +69,7 @@ struct agg_pattern_base } }; -template +template struct agg_polygon_pattern : agg_pattern_base { using color_type = agg::rgba8; @@ -78,41 +78,40 @@ struct agg_polygon_pattern : agg_pattern_base using pixfmt_type = agg::pixfmt_custom_blend_rgba; using wrap_x_type = agg::wrap_mode_repeat; using wrap_y_type = agg::wrap_mode_repeat; - using img_source_type = agg::image_accessor_wrap; + using img_source_type = agg::image_accessor_wrap; using span_gen_type = agg::span_pattern_rgba; using renderer_base = agg::renderer_base; - using renderer_type = agg::renderer_scanline_aa_alpha, - span_gen_type>; + using renderer_type = + agg::renderer_scanline_aa_alpha, span_gen_type>; agg_polygon_pattern(image_rgba8 const& pattern_img, renderer_common const& common, symbolizer_base const& sym, mapnik::feature_impl const& feature, proj_transform const& prj_trans) - : agg_pattern_base{pattern_img, common, sym, feature, prj_trans}, - clip_(get(sym_, feature_, common_.vars_)), - clip_box_(clipping_extent(common)), - tr_(geom_transform()), - converter_(clip_box_, sym, common.t_, prj_trans, tr_, - feature, common.vars_, common.scale_factor_) + : agg_pattern_base{pattern_img, common, sym, feature, prj_trans} + , clip_(get(sym_, feature_, common_.vars_)) + , clip_box_(clipping_extent(common)) + , tr_(geom_transform()) + , converter_(clip_box_, sym, common.t_, prj_trans, tr_, feature, common.vars_, common.scale_factor_) { value_double simplify_tolerance = get(sym_, feature_, common_.vars_); value_double smooth = get(sym_, feature_, common_.vars_); - if (simplify_tolerance > 0.0) converter_.template set(); + if (simplify_tolerance > 0.0) + converter_.template set(); converter_.template set(); - if (smooth > 0.0) converter_.template set(); + if (smooth > 0.0) + converter_.template set(); } - void render(renderer_base & ren_base, rasterizer & ras) + void render(renderer_base& ren_base, rasterizer& ras) { - coord offset(pattern_offset(sym_, feature_, prj_trans_, common_, - pattern_img_.width(), pattern_img_.height())); + coord offset( + pattern_offset(sym_, feature_, prj_trans_, common_, pattern_img_.width(), pattern_img_.height())); agg::rendering_buffer pattern_rbuf((agg::int8u*)pattern_img_.bytes(), - pattern_img_.width(), pattern_img_.height(), + pattern_img_.width(), + pattern_img_.height(), pattern_img_.width() * 4); agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf); img_source_type img_src(pixf_pattern); @@ -122,8 +121,7 @@ struct agg_polygon_pattern : agg_pattern_base value_double opacity = get(sym_, feature_, common_.vars_); renderer_type rp(ren_base, sa, sg, unsigned(opacity * 255)); - using apply_vertex_converter_type = detail::apply_vertex_converter< - VertexConverter, rasterizer>; + using apply_vertex_converter_type = detail::apply_vertex_converter; using vertex_processor_type = geometry::vertex_processor; apply_vertex_converter_type apply(converter_, ras); mapnik::util::apply_visitor(vertex_processor_type(apply), feature_.get_geometry()); @@ -139,5 +137,4 @@ struct agg_polygon_pattern : agg_pattern_base } // namespace mapnik - #endif // MAPNIK_RENDER_POLYGON_PATTERN_HPP diff --git a/include/mapnik/agg_helpers.hpp b/include/mapnik/agg_helpers.hpp index bc5c938ab..00a419287 100644 --- a/include/mapnik/agg_helpers.hpp +++ b/include/mapnik/agg_helpers.hpp @@ -34,31 +34,31 @@ MAPNIK_DISABLE_WARNING_POP namespace mapnik { -template -void set_gamma_method(T & ras_ptr, double gamma, gamma_method_enum method) +template +void set_gamma_method(T& ras_ptr, double gamma, gamma_method_enum method) { switch (method) { - case GAMMA_POWER: - ras_ptr->gamma(agg::gamma_power(gamma)); - break; - case GAMMA_LINEAR: - ras_ptr->gamma(agg::gamma_linear(0.0, gamma)); - break; - case GAMMA_NONE: - ras_ptr->gamma(agg::gamma_none()); - break; - case GAMMA_THRESHOLD: - ras_ptr->gamma(agg::gamma_threshold(gamma)); - break; - case GAMMA_MULTIPLY: - ras_ptr->gamma(agg::gamma_multiply(gamma)); - break; - default: - ras_ptr->gamma(agg::gamma_power(gamma)); + case GAMMA_POWER: + ras_ptr->gamma(agg::gamma_power(gamma)); + break; + case GAMMA_LINEAR: + ras_ptr->gamma(agg::gamma_linear(0.0, gamma)); + break; + case GAMMA_NONE: + ras_ptr->gamma(agg::gamma_none()); + break; + case GAMMA_THRESHOLD: + ras_ptr->gamma(agg::gamma_threshold(gamma)); + break; + case GAMMA_MULTIPLY: + ras_ptr->gamma(agg::gamma_multiply(gamma)); + break; + default: + ras_ptr->gamma(agg::gamma_power(gamma)); } } -} +} // namespace mapnik #endif // MAPNIK_AGG_HELPERS_HPP diff --git a/include/mapnik/agg_pattern_source.hpp b/include/mapnik/agg_pattern_source.hpp index 4eb8a0647..097fe5312 100644 --- a/include/mapnik/agg_pattern_source.hpp +++ b/include/mapnik/agg_pattern_source.hpp @@ -33,36 +33,31 @@ MAPNIK_DISABLE_WARNING_PUSH #include "agg_color_rgba.h" MAPNIK_DISABLE_WARNING_POP -namespace mapnik -{ +namespace mapnik { class pattern_source : private util::noncopyable { -public: + public: pattern_source(image_rgba8 const& pattern, double opacity = 1.0) - : pattern_(pattern), - opacity_(opacity) {} + : pattern_(pattern) + , opacity_(opacity) + {} - unsigned int width() const - { - return pattern_.width(); - } - unsigned int height() const - { - return pattern_.height(); - } + unsigned int width() const { return pattern_.width(); } + unsigned int height() const { return pattern_.height(); } agg::rgba8 pixel(int x, int y) const { - unsigned c = pattern_(x,y); + unsigned c = pattern_(x, y); return agg::rgba8(static_cast((c & 0xff) * opacity_), static_cast(((c >> 8) & 0xff) * opacity_), static_cast(((c >> 16) & 0xff) * opacity_), static_cast(((c >> 24) & 0xff) * opacity_)); } -private: + + private: image_rgba8 const& pattern_; double opacity_; }; -} +} // namespace mapnik #endif // MAPNIK_AGG_PATTERN_SOURCE_HPP diff --git a/include/mapnik/agg_rasterizer.hpp b/include/mapnik/agg_rasterizer.hpp index a369454e1..32cef517a 100644 --- a/include/mapnik/agg_rasterizer.hpp +++ b/include/mapnik/agg_rasterizer.hpp @@ -26,7 +26,6 @@ // mapnik #include - #include MAPNIK_DISABLE_WARNING_PUSH #include @@ -35,8 +34,10 @@ MAPNIK_DISABLE_WARNING_POP namespace mapnik { -struct rasterizer : agg::rasterizer_scanline_aa, util::noncopyable {}; +struct rasterizer : agg::rasterizer_scanline_aa, + util::noncopyable +{}; -} +} // namespace mapnik #endif // MAPNIK_AGG_RASTERIZER_HPP diff --git a/include/mapnik/agg_render_marker.hpp b/include/mapnik/agg_render_marker.hpp index a0101bebe..1be9e2da3 100644 --- a/include/mapnik/agg_render_marker.hpp +++ b/include/mapnik/agg_render_marker.hpp @@ -52,10 +52,14 @@ MAPNIK_DISABLE_WARNING_POP namespace mapnik { -template -void render_vector_marker(SvgRenderer & svg_renderer, RasterizerType & ras, RendererBaseType & renb, - box2d const& bbox, agg::trans_affine const& tr, - double opacity, bool snap_to_pixels) +template +void render_vector_marker(SvgRenderer& svg_renderer, + RasterizerType& ras, + RendererBaseType& renb, + box2d const& bbox, + agg::trans_affine const& tr, + double opacity, + bool snap_to_pixels) { agg::scanline_u8 sl; if (snap_to_pixels) @@ -72,23 +76,25 @@ void render_vector_marker(SvgRenderer & svg_renderer, RasterizerType & ras, Rend } } -template -void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 const& src, - agg::trans_affine const& tr, double opacity, - float scale_factor, bool snap_to_pixels) +template +void render_raster_marker(RendererType renb, + RasterizerType& ras, + image_rgba8 const& src, + agg::trans_affine const& tr, + double opacity, + float scale_factor, + bool snap_to_pixels) { using color_type = agg::rgba8; using const_rendering_buffer = util::rendering_buffer; using pixfmt_pre = agg::pixfmt_alpha_blend_rgba; agg::scanline_u8 sl; - double width = src.width(); + double width = src.width(); double height = src.height(); - if (std::fabs(1.0 - scale_factor) < 0.001 - && (std::fabs(1.0 - tr.sx) < agg::affine_epsilon) - && (std::fabs(0.0 - tr.shy) < agg::affine_epsilon) - && (std::fabs(0.0 - tr.shx) < agg::affine_epsilon) - && (std::fabs(1.0 - tr.sy) < agg::affine_epsilon)) + if (std::fabs(1.0 - scale_factor) < 0.001 && (std::fabs(1.0 - tr.sx) < agg::affine_epsilon) && + (std::fabs(0.0 - tr.shy) < agg::affine_epsilon) && (std::fabs(0.0 - tr.shx) < agg::affine_epsilon) && + (std::fabs(1.0 - tr.sy) < agg::affine_epsilon)) { const_rendering_buffer src_buffer(src); pixfmt_pre pixf_mask(src_buffer); @@ -98,32 +104,31 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c 0, static_cast(std::floor(tr.tx + .5)), static_cast(std::floor(tr.ty + .5)), - unsigned(255*opacity)); + unsigned(255 * opacity)); } else { - renb.blend_from(pixf_mask, - 0, - static_cast(tr.tx), - static_cast(tr.ty), - unsigned(255*opacity)); + renb.blend_from(pixf_mask, 0, static_cast(tr.tx), static_cast(tr.ty), unsigned(255 * opacity)); } } else { using img_accessor_type = agg::image_accessor_clone; using interpolator_type = agg::span_interpolator_linear<>; - //using span_gen_type = agg::span_image_filter_rgba_2x2; + // using span_gen_type = agg::span_image_filter_rgba_2x2; using span_gen_type = agg::span_image_resample_rgba_affine; - using renderer_type = agg::renderer_scanline_aa_alpha, - span_gen_type>; + using renderer_type = + agg::renderer_scanline_aa_alpha, span_gen_type>; double p[8]; - p[0] = 0; p[1] = 0; - p[2] = width; p[3] = 0; - p[4] = width; p[5] = height; - p[6] = 0; p[7] = height; + p[0] = 0; + p[1] = 0; + p[2] = width; + p[3] = 0; + p[4] = width; + p[5] = height; + p[6] = 0; + p[7] = height; tr.transform(&p[0], &p[1]); tr.transform(&p[2], &p[3]); tr.transform(&p[4], &p[5]); @@ -137,20 +142,20 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c agg::trans_affine final_tr(p, 0, 0, width, height); if (snap_to_pixels) { - final_tr.tx = std::floor(final_tr.tx+.5); - final_tr.ty = std::floor(final_tr.ty+.5); + final_tr.tx = std::floor(final_tr.tx + .5); + final_tr.ty = std::floor(final_tr.ty + .5); } interpolator_type interpolator(final_tr); span_gen_type sg(ia, interpolator, filter); - renderer_type rp(renb, sa, sg, unsigned(opacity*255)); - ras.move_to_d(p[0],p[1]); - ras.line_to_d(p[2],p[3]); - ras.line_to_d(p[4],p[5]); - ras.line_to_d(p[6],p[7]); + renderer_type rp(renb, sa, sg, unsigned(opacity * 255)); + ras.move_to_d(p[0], p[1]); + ras.line_to_d(p[2], p[3]); + ras.line_to_d(p[4], p[5]); + ras.line_to_d(p[6], p[7]); agg::render_scanlines(ras, sl, rp); } } -} +} // namespace mapnik #endif // MAPNIK_AGG_RENDER_MARKER_HPP diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 0a60ddd6e..d73ea3e8e 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -24,13 +24,13 @@ #define MAPNIK_AGG_RENDERER_HPP // mapnik -#include // for MAPNIK_DECL +#include // for MAPNIK_DECL #include -#include // for noncopyable +#include // for noncopyable #include // for rule, symbolizers -#include // for box2d +#include // for box2d #include // for view_transform -#include // for composite_mode_e +#include // for composite_mode_e #include #include #include @@ -41,38 +41,40 @@ #include // fwd declaration to avoid dependence on agg headers -namespace agg { struct trans_affine; } +namespace agg { +struct trans_affine; +} // fwd declarations to speed up compile namespace mapnik { - class Map; - class feature_impl; - class feature_type_style; - class label_collision_detector4; - class layer; - class color; - struct marker; - class proj_transform; - struct rasterizer; - struct rgba8_t; - template class image; -} +class Map; +class feature_impl; +class feature_type_style; +class label_collision_detector4; +class layer; +class color; +struct marker; +class proj_transform; +struct rasterizer; +struct rgba8_t; +template +class image; +} // namespace mapnik namespace mapnik { -template +template class buffer_stack { -public: + public: buffer_stack(std::size_t width, std::size_t height) - : width_(width), - height_(height), - buffers_(), - position_(buffers_.begin()) - { - } + : width_(width) + , height_(height) + , buffers_() + , position_(buffers_.begin()) + {} - T & push() + T& push() { if (position_ == buffers_.begin()) { @@ -86,10 +88,7 @@ public: } return *position_; } - bool in_range() const - { - return (position_ != buffers_.end()); - } + bool in_range() const { return (position_ != buffers_.end()); } void pop() { @@ -98,34 +97,44 @@ public: ++position_; } - T & top() const - { - return *position_; - } + T& top() const { return *position_; } -private: + private: const std::size_t width_; const std::size_t height_; std::deque buffers_; typename std::deque::iterator position_; }; -template -class MAPNIK_DECL agg_renderer : public feature_style_processor >, +template +class MAPNIK_DECL agg_renderer : public feature_style_processor>, private util::noncopyable { - -public: + public: using buffer_type = T0; using processor_impl_type = agg_renderer; using detector_type = T1; // create with default, empty placement detector - agg_renderer(Map const& m, buffer_type & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); + agg_renderer(Map const& m, + buffer_type& pixmap, + double scale_factor = 1.0, + unsigned offset_x = 0, + unsigned offset_y = 0); // create with external placement detector, possibly non-empty - agg_renderer(Map const &m, buffer_type & pixmap, std::shared_ptr detector, - double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); + agg_renderer(Map const& m, + buffer_type& pixmap, + std::shared_ptr detector, + double scale_factor = 1.0, + unsigned offset_x = 0, + unsigned offset_y = 0); // pass in mapnik::request object to provide the mutable things per render - agg_renderer(Map const& m, request const& req, attributes const& vars, buffer_type & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); + agg_renderer(Map const& m, + request const& req, + attributes const& vars, + buffer_type& pixmap, + double scale_factor = 1.0, + unsigned offset_x = 0, + unsigned offset_y = 0); ~agg_renderer(); void start_map_processing(Map const& map); void end_map_processing(Map const& map); @@ -135,52 +144,27 @@ public: void start_style_processing(feature_type_style const& st); void end_style_processing(feature_type_style const& st); - void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, - double opacity, composite_mode_e comp_op); + void render_marker(pixel_position const& pos, + marker const& marker, + agg::trans_affine const& tr, + double opacity, + composite_mode_e comp_op); - void process(point_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(line_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(line_pattern_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(polygon_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(polygon_pattern_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(raster_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(shield_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(text_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(building_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(markers_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(group_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(debug_symbolizer const& sym, - feature_impl & feature, - proj_transform const& prj_trans); - void process(dot_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); + void process(point_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(line_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(line_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(polygon_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(raster_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(shield_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(text_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(building_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(markers_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(group_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(debug_symbolizer const& sym, feature_impl& feature, proj_transform const& prj_trans); + void process(dot_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); - inline bool process(rule::symbolizers const&, - mapnik::feature_impl&, - proj_transform const& ) + inline bool process(rule::symbolizers const&, mapnik::feature_impl&, proj_transform const&) { // agg renderer doesn't support processing of multiple symbolizers. return false; @@ -189,29 +173,19 @@ public: void painted(bool painted); bool painted(); - inline eAttributeCollectionPolicy attribute_collection_policy() const - { - return DEFAULT; - } + inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; } - inline double scale_factor() const - { - return common_.scale_factor_; - } + inline double scale_factor() const { return common_.scale_factor_; } - inline attributes const& variables() const - { - return common_.vars_; - } -protected: - template - void debug_draw_box(R& buf, box2d const& extent, - double x, double y, double angle = 0.0); - void debug_draw_box(box2d const& extent, - double x, double y, double angle = 0.0); - void draw_geo_extent(box2d const& extent,mapnik::color const& color); + inline attributes const& variables() const { return common_.vars_; } -private: + protected: + template + void debug_draw_box(R& buf, box2d const& extent, double x, double y, double angle = 0.0); + void debug_draw_box(box2d const& extent, double x, double y, double angle = 0.0); + void draw_geo_extent(box2d const& extent, mapnik::color const& color); + + private: std::stack> buffers_; buffer_stack internal_buffers_; std::unique_ptr inflated_buffer_; @@ -219,7 +193,7 @@ private: gamma_method_enum gamma_method_; double gamma_; renderer_common common_; - void setup(Map const & m, buffer_type & pixmap); + void setup(Map const& m, buffer_type& pixmap); }; extern template class MAPNIK_DECL agg_renderer>; diff --git a/include/mapnik/attribute.hpp b/include/mapnik/attribute.hpp index 57db9e013..e4f036579 100644 --- a/include/mapnik/attribute.hpp +++ b/include/mapnik/attribute.hpp @@ -37,20 +37,21 @@ struct attribute { std::string name_; explicit attribute(std::string const& _name) - : name_(_name) {} + : name_(_name) + {} - template + template V const& value(F const& f) const { return f.get(name_); } - std::string const& name() const { return name_;} + std::string const& name() const { return name_; } }; struct geometry_type_attribute { - template + template V value(F const& f) const { return static_cast(util::to_ds_type(f.get_geometry())); @@ -61,10 +62,11 @@ struct global_attribute { std::string name; explicit global_attribute(std::string const& name_) - : name(name_) {} + : name(name_) + {} - template - V const& operator() (C const& ctx) + template + V const& operator()(C const& ctx) { return ctx.get(name); } @@ -72,6 +74,6 @@ struct global_attribute using attributes = std::unordered_map; -} +} // namespace mapnik #endif // MAPNIK_ATTRIBUTE_HPP diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index 25ee5db8d..771406faf 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -28,11 +28,11 @@ #include #include #include -#include // for expression_ptr, etc +#include // for expression_ptr, etc #include -#include // for path_processor_type -#include // for path_expression_ptr -#include // for text_placements +#include // for path_processor_type +#include // for path_expression_ptr +#include // for text_placements #include #include #include @@ -51,76 +51,71 @@ MAPNIK_DISABLE_WARNING_POP namespace mapnik { -template +template struct expression_attributes { explicit expression_attributes(Container& names) - : names_(names) {} + : names_(names) + {} - void operator() (attribute const& attr) const - { - names_.emplace(attr.name()); - } + void operator()(attribute const& attr) const { names_.emplace(attr.name()); } - template - void operator() (binary_node const& x) const + template + void operator()(binary_node const& x) const { util::apply_visitor(*this, x.left); util::apply_visitor(*this, x.right); } - template - void operator() (unary_node const& x) const + template + void operator()(unary_node const& x) const { util::apply_visitor(*this, x.expr); } - void operator() (regex_match_node const& x) const - { - util::apply_visitor(*this, x.expr); - } + void operator()(regex_match_node const& x) const { util::apply_visitor(*this, x.expr); } - void operator() (regex_replace_node const& x) const - { - util::apply_visitor(*this, x.expr); - } + void operator()(regex_replace_node const& x) const { util::apply_visitor(*this, x.expr); } - template - void operator() (T const&) const {} + template + void operator()(T const&) const + {} -private: + private: Container& names_; }; class group_attribute_collector : public util::noncopyable { -private: + private: std::set& names_; bool expand_index_columns_; -public: - group_attribute_collector(std::set& names, - bool expand_index_columns) - : names_(names), - expand_index_columns_(expand_index_columns) {} - void operator() (group_symbolizer const& sym); + public: + group_attribute_collector(std::set& names, bool expand_index_columns) + : names_(names) + , expand_index_columns_(expand_index_columns) + {} + + void operator()(group_symbolizer const& sym); }; -template +template struct extract_attribute_names { explicit extract_attribute_names(Container& names) - : names_(names), - f_attr_(names) {} + : names_(names) + , f_attr_(names) + {} - void operator() (mapnik::expression_ptr const& expr) const + void operator()(mapnik::expression_ptr const& expr) const { if (expr) { util::apply_visitor(f_attr_, *expr); } } - void operator() (mapnik::transform_type const& expr) const + void operator()(mapnik::transform_type const& expr) const { if (expr) { @@ -128,7 +123,7 @@ struct extract_attribute_names } } - void operator() (mapnik::text_placements_ptr const& expr) const + void operator()(mapnik::text_placements_ptr const& expr) const { if (expr) { @@ -136,39 +131,41 @@ struct extract_attribute_names expression_set expressions; // TODO - optimize (dane) expr->add_expressions(expressions); - for (it=expressions.begin(); it != expressions.end(); ++it) + for (it = expressions.begin(); it != expressions.end(); ++it) { - if (*it) util::apply_visitor(f_attr_, **it); + if (*it) + util::apply_visitor(f_attr_, **it); } } } - void operator() (mapnik::path_expression_ptr const& expr) const + void operator()(mapnik::path_expression_ptr const& expr) const { if (expr) { - path_processor_type::collect_attributes(*expr,names_); + path_processor_type::collect_attributes(*expr, names_); } } - template - void operator() (T const&) const {} + template + void operator()(T const&) const + {} -private: + private: Container& names_; - expression_attributes > f_attr_; + expression_attributes> f_attr_; }; struct symbolizer_attributes { - symbolizer_attributes(std::set& names, - double & filter_factor) - : filter_factor_(filter_factor), - f_attrs_(names), - g_attrs_(names, true) {} + symbolizer_attributes(std::set& names, double& filter_factor) + : filter_factor_(filter_factor) + , f_attrs_(names) + , g_attrs_(names, true) + {} - template - void operator () (T const& sym) + template + void operator()(T const& sym) { for (auto const& prop : sym.properties) { @@ -176,7 +173,7 @@ struct symbolizer_attributes } } - void operator () (raster_symbolizer const& sym) + void operator()(raster_symbolizer const& sym) { boost::optional filter_factor = get_optional(sym, keys::filter_factor); if (filter_factor) @@ -197,57 +194,51 @@ struct symbolizer_attributes } } - void operator () (group_symbolizer const& sym) - { - g_attrs_(sym); - } + void operator()(group_symbolizer const& sym) { g_attrs_(sym); } -private: - double & filter_factor_; - extract_attribute_names > f_attrs_; + private: + double& filter_factor_; + extract_attribute_names> f_attrs_; group_attribute_collector g_attrs_; }; - class attribute_collector : public util::noncopyable { -private: - std::set & names_; + private: + std::set& names_; double filter_factor_; - expression_attributes > f_attr; -public: + expression_attributes> f_attr; + + public: attribute_collector(std::set& names) - : names_(names), - filter_factor_(1.0), - f_attr(names) {} - template - void operator() (RuleType const& r) + : names_(names) + , filter_factor_(1.0) + , f_attr(names) + {} + template + void operator()(RuleType const& r) { typename RuleType::symbolizers const& symbols = r.get_symbolizers(); - symbolizer_attributes s_attr(names_,filter_factor_); + symbolizer_attributes s_attr(names_, filter_factor_); for (auto const& sym : symbols) { util::apply_visitor(std::ref(s_attr), sym); } expression_ptr const& expr = r.get_filter(); - util::apply_visitor(f_attr,*expr); + util::apply_visitor(f_attr, *expr); } - double get_filter_factor() const - { - return filter_factor_; - } + double get_filter_factor() const { return filter_factor_; } }; - -inline void group_attribute_collector::operator() (group_symbolizer const& sym) +inline void group_attribute_collector::operator()(group_symbolizer const& sym) { // find all column names referenced in the group symbolizer std::set group_columns; attribute_collector column_collector(group_columns); - expression_attributes > rk_attr(group_columns); + expression_attributes> rk_attr(group_columns); // get columns from symbolizer repeat key expression_ptr repeat_key = get(sym, keys::repeat_key); @@ -289,7 +280,7 @@ inline void group_attribute_collector::operator() (group_symbolizer const& sym) for (value_integer col_idx = start; col_idx < end; ++col_idx) { std::string col_idx_str; - if (mapnik::util::to_string(col_idx_str,col_idx)) + if (mapnik::util::to_string(col_idx_str, col_idx)) { std::string col_idx_name = col_name; boost::replace_all(col_idx_name, "%", col_idx_str); diff --git a/include/mapnik/attribute_descriptor.hpp b/include/mapnik/attribute_descriptor.hpp index 46a3e21c2..ea9067ef6 100644 --- a/include/mapnik/attribute_descriptor.hpp +++ b/include/mapnik/attribute_descriptor.hpp @@ -27,35 +27,30 @@ namespace mapnik { -enum eAttributeType { - Integer=1, - Float =2, - Double =3, - String =4, - Boolean =5, - Geometry=6, - Object=7 -}; +enum eAttributeType { Integer = 1, Float = 2, Double = 3, String = 4, Boolean = 5, Geometry = 6, Object = 7 }; class attribute_descriptor { -public: - attribute_descriptor(std::string const& name,unsigned type, - bool primary_key=false, - int size=-1, - int precision=-1) - : name_(name), - type_(type), - size_(size), - precision_(precision), - primary_key_(primary_key) {} + public: + attribute_descriptor(std::string const& name, + unsigned type, + bool primary_key = false, + int size = -1, + int precision = -1) + : name_(name) + , type_(type) + , size_(size) + , precision_(precision) + , primary_key_(primary_key) + {} attribute_descriptor(attribute_descriptor const& other) - : name_(other.name_), - type_(other.type_), - size_(other.size_), - precision_(other.precision_), - primary_key_(other.primary_key_) {} + : name_(other.name_) + , type_(other.type_) + , size_(other.size_) + , precision_(other.precision_) + , primary_key_(other.primary_key_) + {} attribute_descriptor& operator=(attribute_descriptor rhs) { @@ -68,32 +63,17 @@ public: return *this; } - std::string const& get_name() const - { - return name_; - } + std::string const& get_name() const { return name_; } - unsigned int get_type() const - { - return type_; - } + unsigned int get_type() const { return type_; } - bool is_primary_key() const - { - return primary_key_; - } + bool is_primary_key() const { return primary_key_; } - int get_size() const - { - return size_; - } + int get_size() const { return size_; } - int get_precision() const - { - return precision_; - } + int get_precision() const { return precision_; } -private: + private: std::string name_; unsigned int type_; int size_; @@ -101,6 +81,6 @@ private: bool primary_key_; }; -} +} // namespace mapnik #endif // MAPNIK_ATTRIBUTE_DESCRIPTOR_HPP diff --git a/include/mapnik/boolean.hpp b/include/mapnik/boolean.hpp index e3d277f80..1e2b2468e 100644 --- a/include/mapnik/boolean.hpp +++ b/include/mapnik/boolean.hpp @@ -30,25 +30,24 @@ #include #include -namespace mapnik -{ +namespace mapnik { class MAPNIK_DECL boolean_type { -public: + public: boolean_type() - : b_(false) {} + : b_(false) + {} boolean_type(bool b) - : b_(b) {} + : b_(b) + {} boolean_type(boolean_type const& b) - : b_(b.b_) {} + : b_(b.b_) + {} - operator bool() const - { - return b_; - } + operator bool() const { return b_; } - boolean_type & operator =(boolean_type const& other) + boolean_type& operator=(boolean_type const& other) { if (this == &other) return *this; @@ -56,33 +55,32 @@ public: return *this; } -private: + private: bool b_; }; // Special stream input operator for boolean_type values -template -std::basic_istream & -operator >> ( std::basic_istream & s, boolean_type & b ) +template +std::basic_istream& operator>>(std::basic_istream& s, boolean_type& b) { - if ( s ) + if (s) { std::string word; s >> word; bool result; - if (util::string2bool(word,result)) b = result; + if (util::string2bool(word, result)) + b = result; } return s; } -template -std::basic_ostream & -operator << ( std::basic_ostream & s, boolean_type const& b ) +template +std::basic_ostream& operator<<(std::basic_ostream& s, boolean_type const& b) { - s << ( b ? "true" : "false" ); + s << (b ? "true" : "false"); return s; } -} +} // namespace mapnik #endif // MAPNIK_BOOLEAN_HPP diff --git a/include/mapnik/boost_spirit_instantiate.hpp b/include/mapnik/boost_spirit_instantiate.hpp index 8e7f16416..7074fc3c0 100644 --- a/include/mapnik/boost_spirit_instantiate.hpp +++ b/include/mapnik/boost_spirit_instantiate.hpp @@ -23,17 +23,21 @@ #ifndef MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP #define MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP -namespace boost { namespace spirit { namespace x3 -{ +namespace boost { +namespace spirit { +namespace x3 { // helper macro -#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \ - template bool parse_rule( \ - rule_type rule_ \ - , Iterator& first, Iterator const& last \ - , Context const& context, boost::spirit::x3::unused_type const& ); \ +#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \ + template bool parse_rule( \ + rule_type rule_, \ + Iterator & first, \ + Iterator const& last, \ + Context const& context, \ + boost::spirit::x3::unused_type const&); \ /***/ -}}} - +} // namespace x3 +} // namespace spirit +} // namespace boost #endif // MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP diff --git a/include/mapnik/cairo/cairo_context.hpp b/include/mapnik/cairo/cairo_context.hpp index f429d6afd..15fab8345 100644 --- a/include/mapnik/cairo/cairo_context.hpp +++ b/include/mapnik/cairo/cairo_context.hpp @@ -20,7 +20,6 @@ * *****************************************************************************/ - #ifndef MAPNIK_CAIRO_CONTEXT_HPP #define MAPNIK_CAIRO_CONTEXT_HPP @@ -57,7 +56,8 @@ MAPNIK_DISABLE_WARNING_POP namespace mapnik { -template class box2d; +template +class box2d; using ErrorStatus = cairo_status_t; @@ -67,10 +67,10 @@ inline void throw_exception(ErrorStatus status) throw std::runtime_error(std::string("cairo: ") + cairo_status_to_string(status)); } -//We inline this because it is called so often. +// We inline this because it is called so often. inline void check_status_and_throw_exception(ErrorStatus status) { - if(status != CAIRO_STATUS_SUCCESS) + if (status != CAIRO_STATUS_SUCCESS) throw_exception(status); } @@ -82,60 +82,65 @@ void check_object_status_and_throw_exception(T const& object) class cairo_face : private util::noncopyable { -public: + public: cairo_face(std::shared_ptr const& library, face_ptr const& face); ~cairo_face(); - cairo_font_face_t * face() const; -private: + cairo_font_face_t* face() const; + + private: class handle { - public: + public: handle(std::shared_ptr const& library, face_ptr const& face) - : library_(library), face_(face) {} + : library_(library) + , face_(face) + {} - private: + private: std::shared_ptr library_; face_ptr face_; }; - static void destroy(void *data) + static void destroy(void* data) { - handle *h = static_cast(data); + handle* h = static_cast(data); delete h; } -private: + private: face_ptr face_; - cairo_font_face_t *c_face_; + cairo_font_face_t* c_face_; }; using cairo_face_ptr = std::shared_ptr; class cairo_face_manager : private util::noncopyable { -public: + public: cairo_face_manager(std::shared_ptr library); cairo_face_ptr get_face(face_ptr face); -private: - using cairo_face_cache = std::map; + private: + using cairo_face_cache = std::map; std::shared_ptr font_library_; cairo_face_cache cache_; }; struct cairo_closer { - void operator() (cairo_t * obj) + void operator()(cairo_t* obj) { - if (obj) cairo_destroy(obj); + if (obj) + cairo_destroy(obj); } }; struct cairo_surface_closer { - void operator() (cairo_surface_t * surface) + void operator()(cairo_surface_t* surface) { - if (surface) cairo_surface_destroy(surface); + if (surface) + cairo_surface_destroy(surface); } }; @@ -144,28 +149,25 @@ using cairo_surface_ptr = std::shared_ptr; inline cairo_ptr create_context(cairo_surface_ptr const& surface) { - return cairo_ptr(cairo_create(&*surface),cairo_closer()); + return cairo_ptr(cairo_create(&*surface), cairo_closer()); } class cairo_pattern : private util::noncopyable { -public: + public: explicit cairo_pattern(image_rgba8 const& data, double opacity = 1.0) { std::size_t pixels = data.width() * data.height(); - const unsigned int *in_ptr = data.data(); - const unsigned int *in_end = in_ptr + pixels; - unsigned int *out_ptr; + const unsigned int* in_ptr = data.data(); + const unsigned int* in_end = in_ptr + pixels; + unsigned int* out_ptr; - surface_ = cairo_surface_ptr( - cairo_image_surface_create( - CAIRO_FORMAT_ARGB32, - static_cast(data.width()), - static_cast(data.height())), - cairo_surface_closer()); + surface_ = cairo_surface_ptr(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + static_cast(data.width()), + static_cast(data.height())), + cairo_surface_closer()); - out_ptr = reinterpret_cast( - cairo_image_surface_get_data(surface_.get())); + out_ptr = reinterpret_cast(cairo_image_surface_get_data(surface_.get())); while (in_ptr < in_end) { @@ -175,9 +177,9 @@ public: unsigned int b = static_cast(((in >> 16) & 0xff) * opacity); unsigned int a = static_cast(((in >> 24) & 0xff) * opacity); - //r = r * a / 255; - //g = g * a / 255; - //b = b * a / 255; + // r = r * a / 255; + // g = g * a / 255; + // b = b * a / 255; *out_ptr++ = (a << 24) | (r << 16) | (g << 8) | b; } @@ -186,78 +188,65 @@ public: pattern_ = cairo_pattern_create_for_surface(surface_.get()); } - cairo_pattern(cairo_surface_ptr const& surface) : - surface_(surface), - pattern_(cairo_pattern_create_for_surface(surface_.get())) - { - } + cairo_pattern(cairo_surface_ptr const& surface) + : surface_(surface) + , pattern_(cairo_pattern_create_for_surface(surface_.get())) + {} ~cairo_pattern() { - if (pattern_) cairo_pattern_destroy(pattern_); + if (pattern_) + cairo_pattern_destroy(pattern_); } - void set_matrix(cairo_matrix_t const& matrix) - { - cairo_pattern_set_matrix(pattern_, &matrix); - } + void set_matrix(cairo_matrix_t const& matrix) { cairo_pattern_set_matrix(pattern_, &matrix); } void set_origin(double x, double y) { cairo_matrix_t matrix; - cairo_pattern_get_matrix(pattern_,&matrix); + cairo_pattern_get_matrix(pattern_, &matrix); matrix.x0 = -x; matrix.y0 = -y; - cairo_pattern_set_matrix(pattern_,&matrix); + cairo_pattern_set_matrix(pattern_, &matrix); } - void set_extend(cairo_extend_t extend) - { - cairo_pattern_set_extend(pattern_, extend); - } + void set_extend(cairo_extend_t extend) { cairo_pattern_set_extend(pattern_, extend); } - void set_filter(cairo_filter_t filter) - { - cairo_pattern_set_filter(pattern_, filter); - } + void set_filter(cairo_filter_t filter) { cairo_pattern_set_filter(pattern_, filter); } - cairo_pattern_t * pattern() const - { - return pattern_; - } + cairo_pattern_t* pattern() const { return pattern_; } -private: + private: cairo_surface_ptr surface_; - cairo_pattern_t * pattern_; + cairo_pattern_t* pattern_; }; - class cairo_gradient : private util::noncopyable { -public: - cairo_gradient(mapnik::gradient const& grad, double opacity=1.0) + public: + cairo_gradient(mapnik::gradient const& grad, double opacity = 1.0) { - double x1,x2,y1,y2,rad; - grad.get_control_points(x1,y1,x2,y2,rad); + double x1, x2, y1, y2, rad; + grad.get_control_points(x1, y1, x2, y2, rad); if (grad.get_gradient_type() == LINEAR) { pattern_ = cairo_pattern_create_linear(x1, y1, x2, y2); } else { - pattern_ = cairo_pattern_create_radial(x1, y1, 0, x2, y2, rad); + pattern_ = cairo_pattern_create_radial(x1, y1, 0, x2, y2, rad); } units_ = grad.get_units(); - for ( mapnik::stop_pair const& st : grad.get_stop_array() ) + for (mapnik::stop_pair const& st : grad.get_stop_array()) { mapnik::color const& stop_color = st.second; - double r= static_cast (stop_color.red())/255.0; - double g= static_cast (stop_color.green())/255.0; - double b= static_cast (stop_color.blue())/255.0; - double a= static_cast (stop_color.alpha())/255.0; - cairo_pattern_add_color_stop_rgba(pattern_,st.first, r, g, b, a*opacity); + double r = static_cast(stop_color.red()) / 255.0; + double g = static_cast(stop_color.green()) / 255.0; + double b = static_cast(stop_color.blue()) / 255.0; + double a = static_cast(stop_color.alpha()) / 255.0; + cairo_pattern_add_color_stop_rgba(pattern_, st.first, r, g, b, a * opacity); } double m[6]; @@ -265,7 +254,7 @@ public: tr.invert(); tr.store_to(m); cairo_matrix_t matrix; - cairo_matrix_init(&matrix,m[0],m[1],m[2],m[3],m[4],m[5]); + cairo_matrix_init(&matrix, m[0], m[1], m[2], m[3], m[4], m[5]); cairo_pattern_set_matrix(pattern_, &matrix); } @@ -275,43 +264,32 @@ public: cairo_pattern_destroy(pattern_); } + cairo_pattern_t* gradient() const { return pattern_; } - cairo_pattern_t * gradient() const - { - return pattern_; - } + gradient_unit_e units() const { return units_; } - gradient_unit_e units() const - { - return units_; - } - -private: - cairo_pattern_t * pattern_; + private: + cairo_pattern_t* pattern_; gradient_unit_e units_; - }; class cairo_context : private util::noncopyable { -public: + public: cairo_context(cairo_ptr const& cairo); - inline ErrorStatus get_status() const - { - return cairo_status(cairo_.get()); - } + inline ErrorStatus get_status() const { return cairo_status(cairo_.get()); } void clip(); void show_page(); - void set_color(color const &color, double opacity = 1.0); + void set_color(color const& color, double opacity = 1.0); void set_color(double r, double g, double b, double opacity = 1.0); void set_operator(composite_mode_e comp_op); void set_line_join(line_join_e join); void set_line_cap(line_cap_e cap); void set_miter_limit(double limit); void set_line_width(double width); - void set_dash(dash_array const &dashes, double scale_factor); + void set_dash(dash_array const& dashes, double scale_factor); void set_fill_rule(cairo_fill_rule_t fill_rule); void move_to(double x, double y); void curve_to(double ct1_x, double ct1_y, double ct2_x, double ct2_y, double end_x, double end_y); @@ -326,7 +304,7 @@ public: void set_gradient(cairo_gradient const& pattern, box2d const& bbox); void add_image(double x, double y, image_rgba8 const& data, double opacity = 1.0); void add_image(agg::trans_affine const& tr, image_rgba8 const& data, double opacity = 1.0); - void set_font_face(cairo_face_manager & manager, face_ptr face); + void set_font_face(cairo_face_manager& manager, face_ptr face); void set_font_matrix(cairo_matrix_t const& matrix); void set_matrix(cairo_matrix_t const& matrix); void transform(cairo_matrix_t const& matrix); @@ -336,7 +314,7 @@ public: void show_glyph(unsigned long index, pixel_position const& pos); void glyph_path(unsigned long index, pixel_position const& pos); void add_text(glyph_positions const& pos, - cairo_face_manager & manager, + cairo_face_manager& manager, composite_mode_e comp_op = src_over, composite_mode_e halo_comp_op = src_over, double scale_factor = 1.0); @@ -344,7 +322,7 @@ public: void push_group(); void pop_group(); - template + template void add_path(T& path, unsigned start_index = 0) { double x, y; @@ -366,11 +344,11 @@ public: } } - template + template void add_agg_path(T& path, unsigned start_index = 0) { - double x=0; - double y=0; + double x = 0; + double y = 0; path.rewind(start_index); @@ -384,26 +362,26 @@ public: { if (agg::is_curve3(cm)) { - double end_x=0; - double end_y=0; + double end_x = 0; + double end_y = 0; MAPNIK_LOG_WARN(cairo_renderer) << "Curve 3 not implemented"; path.vertex(&end_x, &end_y); - curve_to(x,y,x,y,end_x,end_y); + curve_to(x, y, x, y, end_x, end_y); } else if (agg::is_curve4(cm)) { - double ct2_x=0; - double ct2_y=0; - double end_x=0; - double end_y=0; + double ct2_x = 0; + double ct2_y = 0; + double end_x = 0; + double end_y = 0; path.vertex(&ct2_x, &ct2_y); path.vertex(&end_x, &end_y); - curve_to(x,y,ct2_x,ct2_y,end_x,end_y); + curve_to(x, y, ct2_x, ct2_y, end_x, end_y); } else if (agg::is_line_to(cm)) { @@ -426,21 +404,22 @@ public: } } -private: + private: cairo_ptr cairo_; }; -template +template struct line_pattern_rasterizer { - line_pattern_rasterizer(Context & context, cairo_pattern & pattern, unsigned width, unsigned height) - : context_(context), - pattern_(pattern), - width_(width), - height_(height) {} + line_pattern_rasterizer(Context& context, cairo_pattern& pattern, unsigned width, unsigned height) + : context_(context) + , pattern_(pattern) + , width_(width) + , height_(height) + {} - template - void add_path(T & path, unsigned start_index = 0) + template + void add_path(T& path, unsigned start_index = 0) { double length = 0.0; double x0 = 0.0; @@ -479,13 +458,12 @@ struct line_pattern_rasterizer } } - Context & context_; - cairo_pattern & pattern_; + Context& context_; + cairo_pattern& pattern_; unsigned width_; unsigned height_; }; -} - +} // namespace mapnik #endif // MAPNIK_CAIRO_CONTEXT_HPP diff --git a/include/mapnik/cairo/cairo_image_util.hpp b/include/mapnik/cairo/cairo_image_util.hpp index 18c190fbd..dd9afe3d4 100644 --- a/include/mapnik/cairo/cairo_image_util.hpp +++ b/include/mapnik/cairo/cairo_image_util.hpp @@ -20,7 +20,6 @@ * *****************************************************************************/ - #ifndef MAPNIK_CAIRO_IMAGE_UTIL_HPP #define MAPNIK_CAIRO_IMAGE_UTIL_HPP @@ -33,8 +32,7 @@ namespace mapnik { -static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data, - cairo_surface_ptr const& surface) +static inline void cairo_image_to_rgba8(mapnik::image_rgba8& data, cairo_surface_ptr const& surface) { if (cairo_image_surface_get_format(&*surface) != CAIRO_FORMAT_ARGB32) { @@ -50,7 +48,7 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data, int stride = cairo_image_surface_get_stride(&*surface) / 4; const std::unique_ptr out_row(new unsigned int[data.width()]); - const unsigned int *in_row = (const unsigned int *)cairo_image_surface_get_data(&*surface); + const unsigned int* in_row = (const unsigned int*)cairo_image_surface_get_data(&*surface); for (unsigned int row = 0; row < data.height(); row++, in_row += stride) { @@ -62,11 +60,16 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data, unsigned int g = (in >> 8) & 0xff; unsigned int b = (in >> 0) & 0xff; -#define DE_ALPHA(x) do { \ - if (a == 0) x = 0; \ - else x = x * 255 / a; \ - if (x > 255) x = 255; \ - } while(0) +#define DE_ALPHA(x) \ + do \ + { \ + if (a == 0) \ + x = 0; \ + else \ + x = x * 255 / a; \ + if (x > 255) \ + x = 255; \ + } while (0) DE_ALPHA(r); DE_ALPHA(g); @@ -78,7 +81,6 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data, } } -} - +} // namespace mapnik #endif // MAPNIK_CAIRO_IMAGE_UTIL_HPP diff --git a/include/mapnik/cairo/cairo_render_vector.hpp b/include/mapnik/cairo/cairo_render_vector.hpp index ebadb1d0d..e28f499f4 100644 --- a/include/mapnik/cairo/cairo_render_vector.hpp +++ b/include/mapnik/cairo/cairo_render_vector.hpp @@ -32,12 +32,14 @@ namespace mapnik { class cairo_context; -void render_vector_marker(cairo_context & context, svg_path_adapter & svg_path, +void render_vector_marker(cairo_context& context, + svg_path_adapter& svg_path, svg_attribute_type const& attributes, - box2d const& bbox, agg::trans_affine const& tr, + box2d const& bbox, + agg::trans_affine const& tr, double opacity); -} +} // namespace mapnik #endif // MAPNIK_CAIRO_RENDER_VECTOR_HPP diff --git a/include/mapnik/cairo/cairo_renderer.hpp b/include/mapnik/cairo/cairo_renderer.hpp index 432bd7950..94bbec037 100644 --- a/include/mapnik/cairo/cairo_renderer.hpp +++ b/include/mapnik/cairo/cairo_renderer.hpp @@ -53,42 +53,35 @@ class request; struct pixel_position; struct cairo_save_restore { - cairo_save_restore(cairo_context & context) + cairo_save_restore(cairo_context& context) : context_(context) { context_.save(); } - ~cairo_save_restore() - { - context_.restore(); - } - cairo_context & context_; + ~cairo_save_restore() { context_.restore(); } + cairo_context& context_; }; -template -class MAPNIK_DECL cairo_renderer : public feature_style_processor >, +template +class MAPNIK_DECL cairo_renderer : public feature_style_processor>, private util::noncopyable { -public: + public: using processor_impl_type = cairo_renderer; - cairo_renderer(Map const& m, - T const& obj, - double scale_factor=1.0, - unsigned offset_x=0, - unsigned offset_y=0); + cairo_renderer(Map const& m, T const& obj, double scale_factor = 1.0, unsigned offset_x = 0, unsigned offset_y = 0); cairo_renderer(Map const& m, request const& req, attributes const& vars, T const& obj, - double scale_factor=1.0, - unsigned offset_x=0, - unsigned offset_y=0); + double scale_factor = 1.0, + unsigned offset_x = 0, + unsigned offset_y = 0); cairo_renderer(Map const& m, T const& obj, std::shared_ptr detector, - double scale_factor=1.0, - unsigned offset_x=0, - unsigned offset_y=0); + double scale_factor = 1.0, + unsigned offset_x = 0, + unsigned offset_y = 0); ~cairo_renderer(); void start_map_processing(Map const& map); @@ -97,93 +90,56 @@ public: 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 process(point_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(line_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(line_pattern_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(polygon_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(polygon_pattern_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(raster_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(shield_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(text_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(building_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(markers_symbolizer const& sym, - mapnik::feature_impl & feature, - proj_transform const& prj_trans); - void process(group_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); - inline bool process(rule::symbolizers const& /*syms*/, - mapnik::feature_impl & /*feature*/, - proj_transform const& /*prj_trans*/) + void process(point_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(line_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(line_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(polygon_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(raster_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(shield_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(text_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(building_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(markers_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans); + void process(group_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); + inline bool + process(rule::symbolizers const& /*syms*/, mapnik::feature_impl& /*feature*/, proj_transform const& /*prj_trans*/) { // cairo renderer doesn't support processing of multiple symbolizers. return false; } - bool painted() - { - return true; - } + bool painted() { return true; } void painted(bool /*painted*/) { // nothing to do } - inline eAttributeCollectionPolicy attribute_collection_policy() const - { - return DEFAULT; - } + inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; } - inline double scale_factor() const - { - return common_.scale_factor_; - } + inline double scale_factor() const { return common_.scale_factor_; } - inline attributes const& variables() const - { - return common_.vars_; - } + inline attributes const& variables() const { return common_.vars_; } void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& mtx, - double opacity=1.0, - bool recenter=true); -protected: + double opacity = 1.0, + bool recenter = true); + + protected: Map const& m_; cairo_context context_; renderer_common common_; cairo_face_manager face_manager_; bool style_level_compositing_; void setup(Map const& m); - }; extern template class MAPNIK_DECL cairo_renderer; -} +} // namespace mapnik #endif // MAPNIK_CAIRO_RENDERER_HPP diff --git a/include/mapnik/cairo/render_polygon_pattern.hpp b/include/mapnik/cairo/render_polygon_pattern.hpp index c311704ac..89dba18e3 100644 --- a/include/mapnik/cairo/render_polygon_pattern.hpp +++ b/include/mapnik/cairo/render_polygon_pattern.hpp @@ -36,36 +36,31 @@ namespace mapnik { struct cairo_renderer_process_visitor_p { - cairo_renderer_process_visitor_p(agg::trans_affine const& image_tr, - double opacity) - : image_tr_(image_tr), - opacity_(opacity) + cairo_renderer_process_visitor_p(agg::trans_affine const& image_tr, double opacity) + : image_tr_(image_tr) + , opacity_(opacity) {} - cairo_surface_ptr operator()(marker_svg const & marker) const + cairo_surface_ptr operator()(marker_svg const& marker) const { box2d bbox(marker.bounding_box()); agg::trans_affine tr(transform(bbox)); double width = std::max(1.0, std::round(bbox.width())); double height = std::max(1.0, std::round(bbox.height())); - cairo_rectangle_t extent { 0, 0, width, height }; - cairo_surface_ptr surface( - cairo_recording_surface_create( - CAIRO_CONTENT_COLOR_ALPHA, &extent), - cairo_surface_closer()); + cairo_rectangle_t extent{0, 0, width, height}; + cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &extent), + cairo_surface_closer()); cairo_ptr cairo = create_context(surface); cairo_context context(cairo); - svg_storage_type & svg = *marker.get_data(); + svg_storage_type& svg = *marker.get_data(); svg_attribute_type const& svg_attributes = svg.attributes(); - svg::vertex_stl_adapter stl_storage( - svg.source()); + svg::vertex_stl_adapter stl_storage(svg.source()); svg::svg_path_adapter svg_path(stl_storage); - render_vector_marker(context, svg_path, svg_attributes, - bbox, tr, opacity_); + render_vector_marker(context, svg_path, svg_attributes, bbox, tr, opacity_); return surface; } @@ -75,11 +70,9 @@ struct cairo_renderer_process_visitor_p box2d bbox(marker.bounding_box()); agg::trans_affine tr(transform(bbox)); - cairo_rectangle_t extent { 0, 0, bbox.width(), bbox.height() }; - cairo_surface_ptr surface( - cairo_recording_surface_create( - CAIRO_CONTENT_COLOR_ALPHA, &extent), - cairo_surface_closer()); + cairo_rectangle_t extent{0, 0, bbox.width(), bbox.height()}; + cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &extent), + cairo_surface_closer()); cairo_ptr cairo = create_context(surface); cairo_context context(cairo); @@ -89,25 +82,21 @@ struct cairo_renderer_process_visitor_p return surface; } - cairo_surface_ptr operator() (marker_null const&) const + cairo_surface_ptr operator()(marker_null const&) const { - cairo_surface_ptr surface( - cairo_recording_surface_create( - CAIRO_CONTENT_COLOR_ALPHA, nullptr), - cairo_surface_closer()); + cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, nullptr), + cairo_surface_closer()); cairo_ptr cairo = create_context(surface); cairo_context context(cairo); return surface; } -private: - agg::trans_affine transform(box2d & bbox) const + private: + agg::trans_affine transform(box2d& bbox) const { bbox *= image_tr_; coord c = bbox.center(); - agg::trans_affine mtx = agg::trans_affine_translation( - 0.5 * bbox.width() - c.x, - 0.5 * bbox.height() - c.y); + agg::trans_affine mtx = agg::trans_affine_translation(0.5 * bbox.width() - c.x, 0.5 * bbox.height() - c.y); return image_tr_ * mtx; } @@ -135,7 +124,7 @@ struct cairo_pattern_base } }; -template +template struct cairo_polygon_pattern : cairo_pattern_base { cairo_polygon_pattern(mapnik::marker const& marker, @@ -143,22 +132,23 @@ struct cairo_polygon_pattern : cairo_pattern_base symbolizer_base const& sym, mapnik::feature_impl const& feature, proj_transform const& prj_trans) - : cairo_pattern_base{marker, common, sym, feature, prj_trans}, - clip_(get(sym_, feature_, common_.vars_)), - clip_box_(clipping_extent(common)), - tr_(geom_transform()), - converter_(clip_box_, sym, common.t_, prj_trans, tr_, - feature, common.vars_, common.scale_factor_) + : cairo_pattern_base{marker, common, sym, feature, prj_trans} + , clip_(get(sym_, feature_, common_.vars_)) + , clip_box_(clipping_extent(common)) + , tr_(geom_transform()) + , converter_(clip_box_, sym, common.t_, prj_trans, tr_, feature, common.vars_, common.scale_factor_) { value_double simplify_tolerance = get(sym, feature, common_.vars_); value_double smooth = get(sym, feature, common_.vars_); converter_.template set(); - if (simplify_tolerance > 0.0) converter_.template set(); - if (smooth > 0.0) converter_.template set(); + if (simplify_tolerance > 0.0) + converter_.template set(); + if (smooth > 0.0) + converter_.template set(); } - void render(cairo_fill_rule_t fill_rule, cairo_context & context) + void render(cairo_fill_rule_t fill_rule, cairo_context& context) { value_double opacity = get(sym_, feature_, common_.vars_); agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_); @@ -181,8 +171,12 @@ struct cairo_polygon_pattern : cairo_pattern_base cairo_rectangle_t pattern_surface_extent; if (cairo_recording_surface_get_extents(surface.get(), &pattern_surface_extent)) { - offset = pattern_offset(sym_, feature_, prj_trans_, common_, - pattern_surface_extent.width, pattern_surface_extent.height); + offset = pattern_offset(sym_, + feature_, + prj_trans_, + common_, + pattern_surface_extent.width, + pattern_surface_extent.height); } cairo_pattern pattern(surface); @@ -193,7 +187,7 @@ struct cairo_polygon_pattern : cairo_pattern_base using apply_vertex_converter_type = detail::apply_vertex_converter; using vertex_processor_type = geometry::vertex_processor; apply_vertex_converter_type apply(converter_, context); - mapnik::util::apply_visitor(vertex_processor_type(apply),feature_.get_geometry()); + mapnik::util::apply_visitor(vertex_processor_type(apply), feature_.get_geometry()); // fill polygon context.set_fill_rule(fill_rule); context.fill(); @@ -207,5 +201,4 @@ struct cairo_polygon_pattern : cairo_pattern_base } // namespace mapnik - #endif // MAPNIK_CAIRO_RENDER_POLYGON_PATTERN_HPP diff --git a/include/mapnik/cairo_io.hpp b/include/mapnik/cairo_io.hpp index 705ded1d8..a251db97c 100644 --- a/include/mapnik/cairo_io.hpp +++ b/include/mapnik/cairo_io.hpp @@ -35,15 +35,15 @@ namespace mapnik { #if defined(HAVE_CAIRO) MAPNIK_DECL void save_to_cairo_file(mapnik::Map const& map, std::string const& filename, - double scale_factor=1.0, - double scale_denominator=0.0); + double scale_factor = 1.0, + double scale_denominator = 0.0); MAPNIK_DECL void save_to_cairo_file(mapnik::Map const& map, std::string const& filename, std::string const& type, - double scale_factor=1.0, - double scale_denominator=0.0); + double scale_factor = 1.0, + double scale_denominator = 0.0); #endif -} // end ns +} // namespace mapnik #endif // MAPNIK_CAIRO_IO_HPP diff --git a/include/mapnik/color.hpp b/include/mapnik/color.hpp index 754649017..8ce33e342 100644 --- a/include/mapnik/color.hpp +++ b/include/mapnik/color.hpp @@ -41,7 +41,7 @@ namespace mapnik { class MAPNIK_DECL color : boost::equality_comparable { -public: + public: std::uint8_t red_; std::uint8_t green_; std::uint8_t blue_; @@ -50,46 +50,52 @@ public: // default ctor color() - : red_(0xff), - green_(0xff), - blue_(0xff), - alpha_(0xff), - premultiplied_(false) - {} + : red_(0xff) + , green_(0xff) + , blue_(0xff) + , alpha_(0xff) + , premultiplied_(false) + {} - color(std::uint8_t _red, std::uint8_t _green, std::uint8_t _blue, std::uint8_t _alpha = 0xff, bool premultiplied = false) - : red_(_red), - green_(_green), - blue_(_blue), - alpha_(_alpha), - premultiplied_(premultiplied) - {} + color(std::uint8_t _red, + std::uint8_t _green, + std::uint8_t _blue, + std::uint8_t _alpha = 0xff, + bool premultiplied = false) + : red_(_red) + , green_(_green) + , blue_(_blue) + , alpha_(_alpha) + , premultiplied_(premultiplied) + {} color(std::uint32_t _rgba, bool premultiplied = false) - : red_(_rgba & 0xff), - green_((_rgba >> 8) & 0xff), - blue_((_rgba >> 16) & 0xff), - alpha_((_rgba >> 24) & 0xff), - premultiplied_(premultiplied) {} + : red_(_rgba & 0xff) + , green_((_rgba >> 8) & 0xff) + , blue_((_rgba >> 16) & 0xff) + , alpha_((_rgba >> 24) & 0xff) + , premultiplied_(premultiplied) + {} // copy ctor color(const color& rhs) - : red_(rhs.red_), - green_(rhs.green_), - blue_(rhs.blue_), - alpha_(rhs.alpha_), - premultiplied_(rhs.premultiplied_) - {} + : red_(rhs.red_) + , green_(rhs.green_) + , blue_(rhs.blue_) + , alpha_(rhs.alpha_) + , premultiplied_(rhs.premultiplied_) + {} // move ctor - color(color && rhs) - : red_(std::move(rhs.red_)), - green_(std::move(rhs.green_)), - blue_(std::move(rhs.blue_)), - alpha_(std::move(rhs.alpha_)), - premultiplied_(std::move(rhs.premultiplied_)) {} + color(color&& rhs) + : red_(std::move(rhs.red_)) + , green_(std::move(rhs.green_)) + , blue_(std::move(rhs.blue_)) + , alpha_(std::move(rhs.alpha_)) + , premultiplied_(std::move(rhs.premultiplied_)) + {} - color( std::string const& str, bool premultiplied = false); + color(std::string const& str, bool premultiplied = false); std::string to_string() const; std::string to_hex_string() const; @@ -104,78 +110,45 @@ public: inline bool operator==(color const& rhs) const { - return (red_== rhs.red_) && - (green_ == rhs.green_) && - (blue_ == rhs.blue_) && - (alpha_ == rhs.alpha_) && - (premultiplied_ == rhs.premultiplied_); + return (red_ == rhs.red_) && (green_ == rhs.green_) && (blue_ == rhs.blue_) && (alpha_ == rhs.alpha_) && + (premultiplied_ == rhs.premultiplied_); } - inline std::uint8_t red() const - { - return red_; - } + inline std::uint8_t red() const { return red_; } - inline std::uint8_t green() const - { - return green_; - } + inline std::uint8_t green() const { return green_; } - inline std::uint8_t blue() const - { - return blue_; - } + inline std::uint8_t blue() const { return blue_; } - inline std::uint8_t alpha() const - { - return alpha_; - } + inline std::uint8_t alpha() const { return alpha_; } - inline void set_red(std::uint8_t _red) - { - red_ = _red; - } + inline void set_red(std::uint8_t _red) { red_ = _red; } - inline void set_green(std::uint8_t _green) - { - green_ = _green; - } + inline void set_green(std::uint8_t _green) { green_ = _green; } - inline void set_blue(std::uint8_t _blue) - { - blue_ = _blue; - } - inline void set_alpha(std::uint8_t _alpha) - { - alpha_ = _alpha; - } - inline bool get_premultiplied() const - { - return premultiplied_; - } - inline void set_premultiplied(bool val) - { - premultiplied_ = val; - } + inline void set_blue(std::uint8_t _blue) { blue_ = _blue; } + inline void set_alpha(std::uint8_t _alpha) { alpha_ = _alpha; } + inline bool get_premultiplied() const { return premultiplied_; } + inline void set_premultiplied(bool val) { premultiplied_ = val; } inline unsigned rgba() const { - return static_cast((alpha_ << 24) | (blue_ << 16) | (green_ << 8) | (red_)) ; + return static_cast((alpha_ << 24) | (blue_ << 16) | (green_ << 8) | (red_)); } -private: - void swap(color & rhs) + + private: + void swap(color& rhs) { std::swap(red_, rhs.red_); - std::swap(green_,rhs.green_); - std::swap(blue_,rhs.blue_); - std::swap(alpha_,rhs.alpha_); + std::swap(green_, rhs.green_); + std::swap(blue_, rhs.blue_); + std::swap(alpha_, rhs.alpha_); std::swap(premultiplied_, rhs.premultiplied_); } }; -template -std::basic_ostream & -operator << ( std::basic_ostream & s, mapnik::color const& c ) +template +std::basic_ostream& operator<<(std::basic_ostream& s, mapnik::color const& c) { s << c.to_string(); return s; @@ -187,6 +160,6 @@ inline std::size_t hash_value(color const& c) return c.rgba(); } -} +} // namespace mapnik #endif // MAPNIK_COLOR_HPP diff --git a/include/mapnik/color_factory.hpp b/include/mapnik/color_factory.hpp index 1c8d191e9..ea0014e78 100644 --- a/include/mapnik/color_factory.hpp +++ b/include/mapnik/color_factory.hpp @@ -26,7 +26,7 @@ // mapnik #include -//stl +// stl #include namespace mapnik { diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index 99f2bae3c..0370de1f8 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -26,28 +26,28 @@ // Windows DLL support #ifdef _WIN32 -# define MAPNIK_EXP __declspec (dllexport) -# define MAPNIK_IMP __declspec (dllimport) -# ifdef MAPNIK_EXPORTS -# define MAPNIK_DECL __declspec (dllexport) -# else -# define MAPNIK_DECL __declspec (dllimport) -# endif -# pragma warning( disable: 4251 ) -# pragma warning( disable: 4275 ) -# if (_MSC_VER >= 1400) // vc8 -# pragma warning(disable : 4996) //_CRT_SECURE_NO_DEPRECATE -# endif +#define MAPNIK_EXP __declspec(dllexport) +#define MAPNIK_IMP __declspec(dllimport) +#ifdef MAPNIK_EXPORTS +#define MAPNIK_DECL __declspec(dllexport) #else -# if __GNUC__ >= 4 -# define MAPNIK_EXP __attribute__ ((visibility ("default"))) -# define MAPNIK_DECL __attribute__ ((visibility ("default"))) -# define MAPNIK_IMP __attribute__ ((visibility ("default"))) -# else -# define MAPNIK_EXP -# define MAPNIK_DECL -# define MAPNIK_IMP -# endif +#define MAPNIK_DECL __declspec(dllimport) +#endif +#pragma warning(disable: 4251) +#pragma warning(disable: 4275) +#if (_MSC_VER >= 1400) // vc8 +#pragma warning(disable: 4996) //_CRT_SECURE_NO_DEPRECATE +#endif +#else +#if __GNUC__ >= 4 +#define MAPNIK_EXP __attribute__((visibility("default"))) +#define MAPNIK_DECL __attribute__((visibility("default"))) +#define MAPNIK_IMP __attribute__((visibility("default"))) +#else +#define MAPNIK_EXP +#define MAPNIK_DECL +#define MAPNIK_IMP +#endif #endif #define PROJ_ENVELOPE_POINTS 20 diff --git a/include/mapnik/config_error.hpp b/include/mapnik/config_error.hpp index 9206ec7f7..8827dc67e 100644 --- a/include/mapnik/config_error.hpp +++ b/include/mapnik/config_error.hpp @@ -34,19 +34,17 @@ class xml_node; class config_error : public std::exception { -public: + public: config_error(std::string const& what); - config_error(std::string const& what, - xml_node const& node); - config_error(std::string const& what, - unsigned line_number, - std::string const& filename); + config_error(std::string const& what, xml_node const& node); + config_error(std::string const& what, unsigned line_number, std::string const& filename); virtual ~config_error() {} - virtual const char * what() const noexcept; + virtual const char* what() const noexcept; void append_context(std::string const& ctx) const; void append_context(std::string const& ctx, xml_node const& node) const; void append_context(xml_node const& node) const; -protected: + + protected: mutable std::string what_; mutable unsigned line_number_; mutable std::string file_; @@ -54,6 +52,6 @@ protected: mutable std::string msg_; }; -} +} // namespace mapnik #endif // MAPNIK_CONFIG_ERROR_HPP diff --git a/include/mapnik/coord.hpp b/include/mapnik/coord.hpp index 15dadeb82..093c18636 100644 --- a/include/mapnik/coord.hpp +++ b/include/mapnik/coord.hpp @@ -30,150 +30,173 @@ MAPNIK_DISABLE_WARNING_PUSH MAPNIK_DISABLE_WARNING_POP namespace mapnik { -template -struct coord { +template +struct coord +{ using type = T; }; -template -struct coord - : boost::addable, - boost::addable2,T, - boost::subtractable, - boost::subtractable2,T, - boost::dividable2, T, - boost::multipliable2, T > > > > > > +template +struct coord + : boost::addable< + coord, + boost::addable2< + coord, + T, + boost::subtractable< + coord, + boost:: + subtractable2, T, boost::dividable2, T, boost::multipliable2, T>>>>>> { using type = T; T x; T y; -public: + + public: coord() - : x(),y() {} - coord(T x_,T y_) - : x(x_),y(y_) {} + : x() + , y() + {} + coord(T x_, T y_) + : x(x_) + , y(y_) + {} - coord(coord const& rhs) - : x(rhs.x), - y(rhs.y) {} + coord(coord const& rhs) + : x(rhs.x) + , y(rhs.y) + {} - template - coord (coord const& rhs) - : x(type(rhs.x)), - y(type(rhs.y)) {} + template + coord(coord const& rhs) + : x(type(rhs.x)) + , y(type(rhs.y)) + {} - coord(coord && rhs) noexcept - : x(std::move(rhs.x)), - y(std::move(rhs.y)) {} + coord(coord&& rhs) noexcept + : x(std::move(rhs.x)) + , y(std::move(rhs.y)) + {} - coord& operator=(coord rhs) + coord& operator=(coord rhs) { swap(rhs); return *this; } - template - coord& operator=(const coord& rhs) + template + coord& operator=(const coord& rhs) { - coord tmp(rhs); + coord tmp(rhs); swap(rhs); return *this; } - template - bool operator==(coord const& rhs) + template + bool operator==(coord const& rhs) { return x == rhs.x && y == rhs.y; } - coord& operator+=(coord const& rhs) + coord& operator+=(coord const& rhs) { - x+=rhs.x; - y+=rhs.y; + x += rhs.x; + y += rhs.y; return *this; } - coord& operator+=(T rhs) + coord& operator+=(T rhs) { - x+=rhs; - y+=rhs; + x += rhs; + y += rhs; return *this; } - coord& operator-=(coord const& rhs) + coord& operator-=(coord const& rhs) { - x-=rhs.x; - y-=rhs.y; + x -= rhs.x; + y -= rhs.y; return *this; } - coord& operator-=(T rhs) + coord& operator-=(T rhs) { - x-=rhs; - y-=rhs; + x -= rhs; + y -= rhs; return *this; } - coord& operator*=(T t) + coord& operator*=(T t) { - x*=t; - y*=t; + x *= t; + y *= t; return *this; } - coord& operator/=(T t) + coord& operator/=(T t) { - x/=t; - y/=t; + x /= t; + y /= t; return *this; } -private: - void swap(coord & rhs) + + private: + void swap(coord& rhs) { std::swap(this->x, rhs.x); std::swap(this->y, rhs.y); } }; -template -struct coord +template +struct coord { using type = T; T x; T y; T z; -public: + + public: coord() - : x(),y(),z() {} - coord(T x_,T y_,T z_) - : x(x_),y(y_),z(z_) {} + : x() + , y() + , z() + {} + coord(T x_, T y_, T z_) + : x(x_) + , y(y_) + , z(z_) + {} - template - coord (coord const& rhs) - : x(type(rhs.x)), - y(type(rhs.y)), - z(type(rhs.z)) {} + template + coord(coord const& rhs) + : x(type(rhs.x)) + , y(type(rhs.y)) + , z(type(rhs.z)) + {} - coord(coord && rhs) noexcept - : x(std::move(rhs.x)), - y(std::move(rhs.y)), - z(std::move(rhs.z)) {} + coord(coord&& rhs) noexcept + : x(std::move(rhs.x)) + , y(std::move(rhs.y)) + , z(std::move(rhs.z)) + {} - coord operator=(coord rhs) + coord operator=(coord rhs) { swap(rhs); return *this; } - template - coord& operator=(coord const& rhs) + template + coord& operator=(coord const& rhs) { - coord tmp(rhs); + coord tmp(rhs); swap(tmp); return *this; } -private: - void swap(coord & rhs) + + private: + void swap(coord& rhs) { std::swap(this->x, rhs.x); std::swap(this->y, rhs.y); @@ -181,10 +204,10 @@ private: } }; -using coord2d = coord; -using coord2f = coord; -using coord2i = coord; +using coord2d = coord; +using coord2f = coord; +using coord2i = coord; -} +} // namespace mapnik #endif // MAPNIK_COORD_HPP diff --git a/include/mapnik/css/css_color_grammar_x3.hpp b/include/mapnik/css/css_color_grammar_x3.hpp index e6d8f2eee..0ed03cbf3 100644 --- a/include/mapnik/css/css_color_grammar_x3.hpp +++ b/include/mapnik/css/css_color_grammar_x3.hpp @@ -31,13 +31,11 @@ MAPNIK_DISABLE_WARNING_PUSH #include MAPNIK_DISABLE_WARNING_POP -namespace mapnik -{ +namespace mapnik { namespace x3 = boost::spirit::x3; -namespace css_color_grammar -{ +namespace css_color_grammar { struct css_color_class; using css_color_grammar_type = x3::rule; @@ -46,6 +44,7 @@ css_color_grammar_type const css_color = "css_color"; BOOST_SPIRIT_DECLARE(css_color_grammar_type); -}} +} // namespace css_color_grammar +} // namespace mapnik #endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP diff --git a/include/mapnik/css/css_color_grammar_x3_def.hpp b/include/mapnik/css/css_color_grammar_x3_def.hpp index 5db0d9c92..2b07f0dea 100644 --- a/include/mapnik/css/css_color_grammar_x3_def.hpp +++ b/include/mapnik/css/css_color_grammar_x3_def.hpp @@ -37,13 +37,8 @@ MAPNIK_DISABLE_WARNING_PUSH #include MAPNIK_DISABLE_WARNING_POP -BOOST_FUSION_ADAPT_STRUCT ( - mapnik::color, - (std::uint8_t, red_) - (std::uint8_t, green_) - (std::uint8_t, blue_) - (std::uint8_t, alpha_) - ) +BOOST_FUSION_ADAPT_STRUCT(mapnik::color, + (std::uint8_t, red_)(std::uint8_t, green_)(std::uint8_t, blue_)(std::uint8_t, alpha_)) namespace mapnik { @@ -51,20 +46,21 @@ namespace x3 = boost::spirit::x3; namespace css_color_grammar { -using x3::lit; -using x3::uint_parser; -using x3::hex; -using x3::symbols; -using x3::omit; using x3::attr; using x3::double_; +using x3::hex; +using x3::lit; using x3::no_case; using x3::no_skip; +using x3::omit; +using x3::symbols; +using x3::uint_parser; struct named_colors_ : x3::symbols { named_colors_() { + // clang-format off add ("aliceblue", color(240, 248, 255)) ("antiquewhite", color(250, 235, 215)) @@ -216,6 +212,7 @@ struct named_colors_ : x3::symbols ("yellowgreen", color(154, 205, 50)) ("transparent", color(0, 0, 0, 0)) ; + // clang-format on } } named_colors; @@ -226,7 +223,7 @@ x3::uint_parser dec3; // rules x3::rule const hex2_color("hex2_color"); x3::rule const hex1_color("hex1_color"); -x3::rule const rgb_color("rgb_color"); +x3::rule const rgb_color("rgb_color"); x3::rule const rgba_color("rgba_color"); x3::rule const rgb_color_percent("rgb_color_percent"); x3::rule const rgba_color_percent("rgba_color_percent"); @@ -235,97 +232,80 @@ struct clip_opacity { static double call(double val) { - if (val > 1.0) return 1.0; - if (val < 0.0) return 0.0; + if (val > 1.0) + return 1.0; + if (val < 0.0) + return 0.0; return val; } }; struct percent_converter { - static std::uint8_t call(double val) - { - return safe_cast(std::lround((255.0 * val)/100.0)); - } + static std::uint8_t call(double val) { return safe_cast(std::lround((255.0 * val) / 100.0)); } }; -auto dec_red = [](auto& ctx) -{ +auto dec_red = [](auto& ctx) { _val(ctx).red_ = _attr(ctx); }; -auto dec_green = [](auto& ctx) -{ +auto dec_green = [](auto& ctx) { _val(ctx).green_ = _attr(ctx); }; -auto dec_blue = [](auto& ctx) -{ +auto dec_blue = [](auto& ctx) { _val(ctx).blue_ = _attr(ctx); }; -auto opacity = [](auto& ctx) -{ +auto opacity = [](auto& ctx) { _val(ctx).alpha_ = uint8_t((255.0 * clip_opacity::call(_attr(ctx))) + 0.5); }; -auto percent_red = [] (auto & ctx) -{ +auto percent_red = [](auto& ctx) { _val(ctx).red_ = percent_converter::call(_attr(ctx)); }; -auto percent_green = [] (auto & ctx) -{ +auto percent_green = [](auto& ctx) { _val(ctx).green_ = percent_converter::call(_attr(ctx)); }; -auto percent_blue = [] (auto & ctx) -{ +auto percent_blue = [](auto& ctx) { _val(ctx).blue_ = percent_converter::call(_attr(ctx)); }; -auto hex1_red = [](auto& ctx) -{ +auto hex1_red = [](auto& ctx) { _val(ctx).red_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex1_green = [](auto& ctx) -{ +auto hex1_green = [](auto& ctx) { _val(ctx).green_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex1_blue = [](auto& ctx) -{ +auto hex1_blue = [](auto& ctx) { _val(ctx).blue_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex1_opacity = [](auto& ctx) -{ +auto hex1_opacity = [](auto& ctx) { _val(ctx).alpha_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex2_red = [](auto& ctx) -{ +auto hex2_red = [](auto& ctx) { _val(ctx).red_ = _attr(ctx); }; -auto hex2_green = [](auto& ctx) -{ +auto hex2_green = [](auto& ctx) { _val(ctx).green_ = _attr(ctx); }; -auto hex2_blue = [](auto& ctx) -{ +auto hex2_blue = [](auto& ctx) { _val(ctx).blue_ = _attr(ctx); }; -auto hex2_opacity = [](auto& ctx) -{ +auto hex2_opacity = [](auto& ctx) { _val(ctx).alpha_ = _attr(ctx); }; -auto hsl_to_rgba = [] (auto& ctx) -{ +auto hsl_to_rgba = [](auto& ctx) { double h = std::get<0>(_attr(ctx)); double s = std::get<1>(_attr(ctx)); double l = std::get<2>(_attr(ctx)); @@ -341,20 +321,20 @@ auto hsl_to_rgba = [] (auto& ctx) } else { - m2 = l + s - l*s; + m2 = l + s - l * s; } m1 = l * 2 - m2; - double r = hue_to_rgb(m1, m2, h + 1.0/3.0); + double r = hue_to_rgb(m1, m2, h + 1.0 / 3.0); double g = hue_to_rgb(m1, m2, h); - double b = hue_to_rgb(m1, m2, h - 1.0/3.0); + double b = hue_to_rgb(m1, m2, h - 1.0 / 3.0); uint8_t alpha = uint8_t((255.0 * clip_opacity::call(std::get<3>(_attr(ctx)))) + 0.5); _val(ctx) = color(safe_cast(std::lround(255.0 * r)), safe_cast(std::lround(255.0 * g)), safe_cast(std::lround(255.0 * b)), alpha); }; - +// clang-format off auto const hex2_color_def = no_skip[lit('#') >> hex2[hex2_red] >> hex2[hex2_green] @@ -429,21 +409,13 @@ auto const css_color_def = | hsla_color ; - +// clang-format on MAPNIK_DISABLE_WARNING_PUSH #include -BOOST_SPIRIT_DEFINE( - css_color, - hex2_color, - hex1_color, - rgb_color, - rgba_color, - rgb_color_percent, - rgba_color_percent - ); +BOOST_SPIRIT_DEFINE(css_color, hex2_color, hex1_color, rgb_color, rgba_color, rgb_color_percent, rgba_color_percent); MAPNIK_DISABLE_WARNING_POP -} // ns -} //ns mapnik +} // namespace css_color_grammar +} // namespace mapnik -#endif //MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP +#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP diff --git a/include/mapnik/css/css_grammar_x3.hpp b/include/mapnik/css/css_grammar_x3.hpp index b182e9993..8f8a92d1e 100644 --- a/include/mapnik/css/css_grammar_x3.hpp +++ b/include/mapnik/css/css_grammar_x3.hpp @@ -1,4 +1,4 @@ - /***************************************************************************** +/***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) * @@ -31,8 +31,7 @@ MAPNIK_DISABLE_WARNING_PUSH #include MAPNIK_DISABLE_WARNING_POP -namespace mapnik -{ +namespace mapnik { using property_value_type = boost::iterator_range; using css_key_value = std::pair; using definition_type = std::vector; @@ -40,8 +39,7 @@ using css_data = std::unordered_multimap; namespace x3 = boost::spirit::x3; -namespace css_grammar -{ +namespace css_grammar { class css_tag; class ident_tag; @@ -58,17 +56,14 @@ css_grammar_type const css_grammar{"css"}; css_skipper_type const css_skipper{"css skipper"}; css_classes_type const css_classes{"css classes"}; -BOOST_SPIRIT_DECLARE(ident_grammar_type, - css_classes_type, - css_grammar_type, - css_skipper_type); +BOOST_SPIRIT_DECLARE(ident_grammar_type, css_classes_type, css_grammar_type, css_skipper_type); -} +} // namespace css_grammar css_grammar::ident_grammar_type const ident_grammar(); css_grammar::css_classes_type const classes(); css_grammar::css_grammar_type const grammar(); css_grammar::css_skipper_type const skipper(); -} +} // namespace mapnik #endif // MAPNIK_CSS_GRAMMAR_X3_HPP diff --git a/include/mapnik/css/css_grammar_x3_def.hpp b/include/mapnik/css/css_grammar_x3_def.hpp index 1105f2ffa..a4f533c47 100644 --- a/include/mapnik/css/css_grammar_x3_def.hpp +++ b/include/mapnik/css/css_grammar_x3_def.hpp @@ -20,7 +20,6 @@ * *****************************************************************************/ - #ifndef MAPNIK_CSS_GRAMMAR_X3_DEF_HPP #define MAPNIK_CSS_GRAMMAR_X3_DEF_HPP @@ -33,9 +32,10 @@ MAPNIK_DISABLE_WARNING_PUSH #include MAPNIK_DISABLE_WARNING_POP - /* -The grammar below is LL(1) (but note that most UA's should not use it directly, since it doesn't express the parsing conventions, only the CSS1 syntax). The format of the productions is optimized for human consumption and some shorthand notation beyond yacc [15] is used: +The grammar below is LL(1) (but note that most UA's should not use it directly, since it doesn't express the parsing +conventions, only the CSS1 syntax). The format of the productions is optimized for human consumption and some shorthand +notation beyond yacc [15] is used: * : 0 or more + : 1 or more @@ -148,46 +148,48 @@ namespace x3 = boost::spirit::x3; namespace css_grammar { -using x3::lit; +using x3::alnum; +using x3::alpha; using x3::attr; +using x3::char_; +using x3::lexeme; +using x3::lit; using x3::no_case; using x3::no_skip; -using x3::lexeme; -using x3::alpha; -using x3::alnum; -using x3::char_; using x3::raw; using x3::standard::space; // import unicode string rule -namespace { auto const& css_string = mapnik::json::grammar::unicode_string; } +namespace { +auto const& css_string = mapnik::json::grammar::unicode_string; +} -auto assign_def = [] (auto const& ctx) -{ +auto assign_def = [](auto const& ctx) { for (auto const& k : std::get<0>(_attr(ctx))) { _val(ctx).emplace(k, std::get<1>(_attr(ctx))); } }; -auto assign_key = [] (auto const& ctx) -{ +auto assign_key = [](auto const& ctx) { _val(ctx).first = std::move(_attr(ctx)); }; -auto assign_value = [] (auto const& ctx) {_val(ctx).second = std::move(_attr(ctx));}; +auto assign_value = [](auto const& ctx) { + _val(ctx).second = std::move(_attr(ctx)); +}; // rules -x3::rule const simple_selector {"Simple selector"}; -x3::rule> const selector {"Selector"}; -x3::rule const value {"Value"}; -x3::rule const key_value {"CSS Key/Value"}; -x3::rule, definition_type>> const definition {"CSS Definition"}; +x3::rule const simple_selector{"Simple selector"}; +x3::rule> const selector{"Selector"}; +x3::rule const value{"Value"}; +x3::rule const key_value{"CSS Key/Value"}; +x3::rule, definition_type>> const definition{"CSS Definition"}; auto const ident_def = alpha >> *(alnum | char_('-')); -auto const simple_selector_def = lexeme[ident >> -((char_('.') | char_('#') | char_(':')) >> ident)] - | lexeme[char_('#') >> ident >> -((char_('.') | char_(':')) >> ident)] - | lexeme[char_('.') >> ident >> -(char_(':') >> ident)]; +auto const simple_selector_def = lexeme[ident >> -((char_('.') | char_('#') | char_(':')) >> ident)] | + lexeme[char_('#') >> ident >> -((char_('.') | char_(':')) >> ident)] | + lexeme[char_('.') >> ident >> -(char_(':') >> ident)]; auto const selector_def = simple_selector % lit(','); auto const value_def = raw[lexeme[+~char_(";}")]]; @@ -202,21 +204,19 @@ auto const css_classes_def = +lexeme[ident]; #include MAPNIK_DISABLE_WARNING_PUSH #include -BOOST_SPIRIT_DEFINE( - ident, - css_classes, - simple_selector, - selector, - value, - key_value, - definition, - css_grammar, - css_skipper - ); +BOOST_SPIRIT_DEFINE(ident, + css_classes, + simple_selector, + selector, + value, + key_value, + definition, + css_grammar, + css_skipper); MAPNIK_DISABLE_WARNING_POP -} //css_grammar -} //mapnik +} // namespace css_grammar +} // namespace mapnik -#endif //MAPNIK_CSS_GRAMMAR_X3_DEF_HPP +#endif // MAPNIK_CSS_GRAMMAR_X3_DEF_HPP diff --git a/include/mapnik/css/css_unit_value.hpp b/include/mapnik/css/css_unit_value.hpp index 2bf99d421..537e59b89 100644 --- a/include/mapnik/css/css_unit_value.hpp +++ b/include/mapnik/css/css_unit_value.hpp @@ -20,7 +20,6 @@ * *****************************************************************************/ - #ifndef MAPNIK_CSS_UNIT_VALUE_HPP #define MAPNIK_CSS_UNIT_VALUE_HPP @@ -36,15 +35,15 @@ struct css_unit_value : x3::symbols constexpr static double DPI = 96; css_unit_value() { - add - ("px", 1.0) // pixels - ("pt", DPI/72.0) // points - ("pc", DPI/6.0) // picas - ("mm", DPI/25.4) // milimeters - ("Q" , DPI/101.6)// quarter-milimeters - ("cm", DPI/2.54) // centimeters - ("in", static_cast(DPI)) // inches - ; + add // + ("px", 1.0) // pixels + ("pt", DPI / 72.0) // points + ("pc", DPI / 6.0) // picas + ("mm", DPI / 25.4) // milimeters + ("Q", DPI / 101.6) // quarter-milimeters + ("cm", DPI / 2.54) // centimeters + ("in", static_cast(DPI)) // inches + ; } }; @@ -53,15 +52,15 @@ struct css_absolute_size : x3::symbols constexpr static double EM = 10.0; // 1em == 10px css_absolute_size() { - add - ("xx-small", 0.6 * EM) - ("x-small", 0.75 * EM) - ("small", 0.88 * EM) - ("medium", 1.0 * EM) - ("large", 1.2 * EM) - ("x-large", 1.5 * EM) - ("xx-large", 2.0 * EM) - ; + add // + ("xx-small", 0.6 * EM) // + ("x-small", 0.75 * EM) // + ("small", 0.88 * EM) // + ("medium", 1.0 * EM) // + ("large", 1.2 * EM) // + ("x-large", 1.5 * EM) // + ("xx-large", 2.0 * EM) // + ; } }; @@ -69,13 +68,12 @@ struct css_relative_size : x3::symbols { css_relative_size() { - add - ("larger", 1.2) - ("smaller", 0.8) - ; + add // + ("larger", 1.2) // + ("smaller", 0.8); } }; -} //mapnik +} // namespace mapnik -#endif //MAPNIK_CSS_GRAMMAR_X3_DEF_HPP +#endif // MAPNIK_CSS_GRAMMAR_X3_DEF_HPP diff --git a/include/mapnik/csv/csv_grammar_x3.hpp b/include/mapnik/csv/csv_grammar_x3.hpp index 55a30f63d..72806a7dd 100644 --- a/include/mapnik/csv/csv_grammar_x3.hpp +++ b/include/mapnik/csv/csv_grammar_x3.hpp @@ -35,9 +35,8 @@ struct csv_white_space_skipper : x3::parser using attribute_type = x3::unused_type; static bool const has_attribute = false; - template - bool parse(Iterator& first, Iterator const& last, - Context const& context, x3::unused_type, Attribute& ) const + template + bool parse(Iterator& first, Iterator const& last, Context const& context, x3::unused_type, Attribute&) const { x3::skip_over(first, last, context); if (first != last && *first == ' ') @@ -64,6 +63,7 @@ csv_line_grammar_type const line = "csv-line"; BOOST_SPIRIT_DECLARE(csv_line_grammar_type); -}} +} // namespace grammar +} // namespace mapnik #endif // MAPNIK_CSV_GRAMMAR_X3_HPP diff --git a/include/mapnik/csv/csv_grammar_x3_def.hpp b/include/mapnik/csv/csv_grammar_x3_def.hpp index c4dcb0f6b..2fc1f021e 100644 --- a/include/mapnik/csv/csv_grammar_x3_def.hpp +++ b/include/mapnik/csv/csv_grammar_x3_def.hpp @@ -29,45 +29,44 @@ MAPNIK_DISABLE_WARNING_PUSH #include MAPNIK_DISABLE_WARNING_POP - -namespace mapnik { namespace grammar { +namespace mapnik { +namespace grammar { namespace x3 = boost::spirit::x3; namespace standard = boost::spirit::x3::standard; -using x3::lit; -using x3::lexeme; using standard::char_; +using x3::lexeme; +using x3::lit; struct unesc_char_ : x3::symbols { unesc_char_() { - add("\\a", '\a') - ("\\b", '\b') - ("\\f", '\f') - ("\\n", '\n') - ("\\r", '\r') - ("\\t", '\t') - ("\\v", '\v') - ("\\\\",'\\') - ("\\\'", '\'') - ("\\\"", '\"') - ("\"\"", '\"') // double quote - ; + add("\\a", '\a') // + ("\\b", '\b') // + ("\\f", '\f') // + ("\\n", '\n') // + ("\\r", '\r') // + ("\\t", '\t') // + ("\\v", '\v') // + ("\\\\", '\\') // + ("\\\'", '\'') // + ("\\\"", '\"') // + ("\"\"", '\"') // double quote + ; } } unesc_char; -template +template struct literal : x3::parser> { using attribute_type = x3::unused_type; using context_tag = T; static bool const has_attribute = false; - template - bool parse(Iterator& first, Iterator const& last, - Context const& context, x3::unused_type, Attribute& ) const + template + bool parse(Iterator& first, Iterator const& last, Context const& context, x3::unused_type, Attribute&) const { x3::skip_over(first, last, context); if (first != last && *first == x3::get(context)) @@ -87,27 +86,18 @@ x3::rule const column("csv-column"); x3::rule const text("csv-text"); x3::rule const quoted_text("csv-quoted-text"); -auto const line_def = -lit('\r') > -lit('\n') > lexeme[column] % separator - ; +auto const line_def = -lit('\r') > -lit('\n') > lexeme[column] % separator; -auto const column_def = quoted_text | *(char_ - separator) - ; +auto const column_def = quoted_text | *(char_ - separator); auto const quoted_text_def = quote > text > quote // support unmatched quotes or not (??) - ; + ; -auto const text_def = *(unesc_char | (char_ - quote)) - ; +auto const text_def = *(unesc_char | (char_ - quote)); -BOOST_SPIRIT_DEFINE ( - line, - column, - quoted_text, - text - ); +BOOST_SPIRIT_DEFINE(line, column, quoted_text, text); -} // grammar +} // namespace grammar } // namespace mapnik - #endif // MAPNIK_CSV_GRAMMAR_X3_DEF_HPP diff --git a/include/mapnik/csv/csv_types.hpp b/include/mapnik/csv/csv_types.hpp index 1e8695ca8..1f1618f25 100644 --- a/include/mapnik/csv/csv_types.hpp +++ b/include/mapnik/csv/csv_types.hpp @@ -32,6 +32,6 @@ using csv_value = std::string; using csv_line = std::vector; using csv_data = std::vector; -} +} // namespace mapnik #endif // MAPNIK_CSV_TYPES_HPP diff --git a/include/mapnik/cxx11_support.hpp b/include/mapnik/cxx11_support.hpp index f298a2074..2ab0b6ad5 100644 --- a/include/mapnik/cxx11_support.hpp +++ b/include/mapnik/cxx11_support.hpp @@ -28,13 +28,13 @@ namespace mapnik { namespace detail { -template +template using conditional_t = typename std::conditional::type; -template +template using decay_t = typename std::decay::type; -template +template using enable_if_t = typename std::enable_if::type; } // namespace detail diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 9525c1fb7..adc33fef6 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -43,31 +43,27 @@ namespace mapnik { class MAPNIK_DECL datasource_exception : public std::exception { -public: + public: datasource_exception(std::string const& message) - : message_(message) + : message_(message) {} ~datasource_exception() {} - virtual const char* what() const noexcept - { - return message_.c_str(); - } -private: + virtual const char* what() const noexcept { return message_.c_str(); } + + private: std::string message_; }; class MAPNIK_DECL datasource : private util::noncopyable { -public: - enum datasource_t : std::uint8_t { - Vector, - Raster - }; + public: + enum datasource_t : std::uint8_t { Vector, Raster }; - datasource (parameters const& _params) - : params_(_params) {} + datasource(parameters const& _params) + : params_(_params) + {} /*! * @brief Get the configuration parameters of the data source. @@ -76,25 +72,13 @@ public: * * @return The configuration parameters of the data source. */ - parameters const& params() const - { - return params_; - } + parameters const& params() const { return params_; } - parameters & params() - { - return params_; - } + parameters& params() { return params_; } - bool operator==(datasource const& rhs) const - { - return params_ == rhs.params(); - } + bool operator==(datasource const& rhs) const { return params_ == rhs.params(); } - bool operator!=(datasource const& rhs) const - { - return !(*this == rhs); - } + bool operator!=(datasource const& rhs) const { return !(*this == rhs); } /*! * @brief Get the type of the datasource @@ -113,43 +97,32 @@ public: virtual box2d envelope() const = 0; virtual layer_descriptor get_descriptor() const = 0; virtual ~datasource() {} -protected: + + protected: parameters params_; }; using datasource_name = const char* (*)(); -using create_ds = datasource* (*) (parameters const&); -using destroy_ds = void (*) (datasource *); +using create_ds = datasource* (*)(parameters const&); +using destroy_ds = void (*)(datasource*); class datasource_deleter { -public: - void operator() (datasource* ds) - { - delete ds; - } + public: + void operator()(datasource* ds) { delete ds; } }; using datasource_ptr = std::shared_ptr; #ifdef MAPNIK_STATIC_PLUGINS - #define DATASOURCE_PLUGIN(classname) +#define DATASOURCE_PLUGIN(classname) #else - #define DATASOURCE_PLUGIN(classname) \ - extern "C" MAPNIK_EXP const char * datasource_name() \ - { \ - return classname::name(); \ - } \ - extern "C" MAPNIK_EXP datasource* create(parameters const& params) \ - { \ - return new classname(params); \ - } \ - extern "C" MAPNIK_EXP void destroy(datasource *ds) \ - { \ - delete ds; \ - } +#define DATASOURCE_PLUGIN(classname) \ + extern "C" MAPNIK_EXP const char* datasource_name() { return classname::name(); } \ + extern "C" MAPNIK_EXP datasource* create(parameters const& params) { return new classname(params); } \ + extern "C" MAPNIK_EXP void destroy(datasource* ds) { delete ds; } #endif -} +} // namespace mapnik #endif // MAPNIK_DATASOURCE_HPP diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index c9353612d..8504b05c2 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -41,21 +41,22 @@ class datasource; class parameters; class PluginInfo; -class MAPNIK_DECL datasource_cache - : public singleton, - private util::noncopyable +class MAPNIK_DECL datasource_cache : public singleton, + private util::noncopyable { friend class CreateStatic; -public: + + public: std::vector plugin_names(); std::string plugin_directories(); bool register_datasources(std::string const& path, bool recurse = false); bool register_datasource(std::string const& path); std::shared_ptr create(parameters const& params); -private: + + private: datasource_cache(); ~datasource_cache(); - std::map > plugins_; + std::map> plugins_; std::set plugin_directories_; // the singleton has a mutex protecting the instance pointer, // but the instance also needs its own mutex to protect the @@ -66,6 +67,6 @@ private: extern template class MAPNIK_DECL singleton; -} +} // namespace mapnik #endif // MAPNIK_DATASOURCE_CACHE_HPP diff --git a/include/mapnik/datasource_geometry_type.hpp b/include/mapnik/datasource_geometry_type.hpp index 56a3eb817..9185798d8 100644 --- a/include/mapnik/datasource_geometry_type.hpp +++ b/include/mapnik/datasource_geometry_type.hpp @@ -27,15 +27,8 @@ namespace mapnik { -enum datasource_geometry_t : std::uint8_t { - Unknown = 0, - Point = 1, - LineString = 2, - Polygon = 3, - Collection = 4 -}; +enum datasource_geometry_t : std::uint8_t { Unknown = 0, Point = 1, LineString = 2, Polygon = 3, Collection = 4 }; } - #endif // MAPNIK_DATASOURCE_GEOMETRY_TYPE_HPP diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp index b56e50710..33f0f1ff1 100644 --- a/include/mapnik/debug.hpp +++ b/include/mapnik/debug.hpp @@ -42,35 +42,21 @@ namespace mapnik { - // Global logger class that holds the configuration of severity, format // and file/console redirection. -class MAPNIK_DECL logger : - public singleton, - private util::noncopyable +class MAPNIK_DECL logger : public singleton, + private util::noncopyable { -public: - enum severity_type - { - debug = 0, - warn = 1, - error = 2, - none = 3 - }; + public: + enum severity_type { debug = 0, warn = 1, error = 2, none = 3 }; using severity_map = std::unordered_map; // global security level - static severity_type get_severity() - { - return severity_level_; - } + static severity_type get_severity() { return severity_level_; } - static void set_severity(severity_type severity_level) - { - severity_level_ = severity_level; - } + static void set_severity(severity_type severity_level) { severity_level_ = severity_level; } // per object security levels static severity_type get_object_severity(std::string const& object_name) @@ -89,8 +75,7 @@ public: } } - static void set_object_severity(std::string const& object_name, - severity_type const& security_level) + static void set_object_severity(std::string const& object_name, severity_type const& security_level) { if (!object_name.empty()) { @@ -111,10 +96,7 @@ public: } // format - static std::string const& get_format() - { - return format_; - } + static std::string const& get_format() { return format_; } static void set_format(std::string const& format) { @@ -131,7 +113,7 @@ public: static void use_file(std::string const& filepath); static void use_console(); -private: + private: static severity_map object_severity_level_; static std::string format_; static std::ofstream file_output_; @@ -151,7 +133,6 @@ private: #endif }; - namespace detail { // Default sink, it regulates access to clog @@ -159,7 +140,7 @@ namespace detail { template class clog_sink { -public: + public: using stream_buffer = std::basic_ostringstream; void operator()(logger::severity_type const& /*severity*/, stream_buffer const& s) @@ -177,14 +158,14 @@ public: // This is used for debug/warn reporting that should not output // anything when not compiling for speed. -template