Skip to content

Commit

Permalink
Issue #1045 - Cleanup of MapPainter
Browse files Browse the repository at this point in the history
- Moved the painter statistics code to separate files to reduce code size and build time of MapPainter
- Tuned clang-tidy configuration
  • Loading branch information
Framstag committed Apr 9, 2023
1 parent bc9f7ba commit 89279c0
Show file tree
Hide file tree
Showing 8 changed files with 400 additions and 262 deletions.
45 changes: 22 additions & 23 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
---
Checks: '-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines,misc-*,modernize-*,performance-*,readability-*,clang-diagnostic-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type,-readability-redundant-access-specifiers,-readability-uppercase-literal-suffix,-readability-magic-numbers,-readability-isolate-declaration,-modernize-use-auto,-misc-non-private-member-variables-in-classes,-cert-dcl21-cpp,-modernize-pass-by-value,-readability-convert-member-functions-to-static,-readability-identifier-length,-bugprone-too-small-loop-variable'
Checks: '-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,misc-*,modernize-*,performance-*,readability-*,clang-diagnostic-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type,-readability-redundant-access-specifiers,-readability-uppercase-literal-suffix,-readability-magic-numbers,-readability-isolate-declaration,-modernize-use-auto,-misc-non-private-member-variables-in-classes,-cert-dcl21-cpp,-modernize-pass-by-value,-readability-convert-member-functions-to-static,-readability-identifier-length,-bugprone-too-small-loop-variable,-misc-const-correctness'
WarningsAsErrors: ''
HeaderFilterRegex: '.*/libosmscout.*/.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'

2 changes: 2 additions & 0 deletions libosmscout-map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(HEADER_FILES
include/osmscoutmap/oss/Scanner.h
include/osmscoutmap/LabelLayouter.h
include/osmscoutmap/MapPainter.h
include/osmscoutmap/MapPainterStatistics.h
include/osmscoutmap/MapParameter.h
include/osmscoutmap/MapData.h
include/osmscoutmap/MapService.h
Expand All @@ -25,6 +26,7 @@ set(SOURCE_FILES
src/osmscoutmap/oss/Scanner.cpp
src/osmscoutmap/LabelLayouter.cpp
src/osmscoutmap/MapPainter.cpp
src/osmscoutmap/MapPainterStatistics.cpp
src/osmscoutmap/MapParameter.cpp
src/osmscoutmap/MapData.cpp
src/osmscoutmap/MapService.cpp
Expand Down
1 change: 1 addition & 0 deletions libosmscout-map/include/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ osmscoutmapHeader = [
'osmscoutmap/oss/Parser.h',
'osmscoutmap/LabelLayouter.h',
'osmscoutmap/MapPainter.h',
'osmscoutmap/MapPainterStatistics.h',
'osmscoutmap/MapParameter.h',
'osmscoutmap/LabelProvider.h',
'osmscoutmap/LabelPath.h',
Expand Down
9 changes: 0 additions & 9 deletions libosmscout-map/include/osmscoutmap/MapPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,6 @@ namespace osmscout {
//@}

private:
/**
Debugging
*/
//@{
void DumpDataStatistics(const Projection& projection,
const MapParameter& parameter,
const MapData& data) const;
//@}

/**
Private draw algorithm implementation routines.
*/
Expand Down
94 changes: 94 additions & 0 deletions libosmscout-map/include/osmscoutmap/MapPainterStatistics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#ifndef OSMSCOUT_MAP_MAPPAINTERSTATISTICS_H
#define OSMSCOUT_MAP_MAPPAINTERSTATISTICS_H

/*
This source is part of the libosmscout-map library
Copyright (C) 2023 Tim Teulings
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <osmscoutmap/MapImportExport.h>

#include <osmscout/TypeConfig.h>
#include <osmscout/util/Projection.h>

#include <osmscoutmap/MapParameter.h>
#include <osmscoutmap/MapData.h>
#include <osmscoutmap/StyleConfig.h>

namespace osmscout {

class OSMSCOUT_MAP_API MapPainterStatistics
{
private:
/**
* Structure used for internal statistic collection
*/
struct OSMSCOUT_MAP_API DataStatistic
{
TypeInfoRef type; //!< Type
size_t objectCount=0; //!< Sum of nodeCount, wayCount, areaCont
size_t nodeCount =0; //!< Number of Node objects
size_t wayCount =0; //!< Number of Way objects
size_t areaCount =0; //!< Number of Area objects
size_t coordCount =0; //!< Number of coordinates
size_t labelCount =0; //!< Number of labels
size_t iconCount =0; //!< Number of icons

DataStatistic() = default;
};

private:
void DumpDataStatistics(const std::list<DataStatistic>& statistics);

std::list<DataStatistic> MapToSortedList(const std::unordered_map<TypeInfoRef,DataStatistic>& statistics);

void DumpDataStatistics(const StyleConfig& styleConfig,
const Projection& projection,
const MapParameter& parameter,
const MapData& data);

void CalculateStatistics(const Projection& projection,
const MapParameter& parameter,
const StyleConfig& styleConfig,
const NodeRef& node,
DataStatistic& statistic);

void CalculateStatistics(const Projection& projection,
const MapParameter& parameter,
const StyleConfig& styleConfig,
const WayRef& way,
DataStatistic& statistic);

void CalculateStatistics(const Projection& projection,
const MapParameter& parameter,
const StyleConfig& styleConfig,
const AreaRef& area,
DataStatistic& statistic);

void DumpStatisticWarnings(const MapParameter& parameter,
const std::unordered_map<TypeInfoRef,DataStatistic>& statistics);

public:
MapPainterStatistics() = default;

void DumpMapPainterStatistics(const StyleConfig& styleConfig,
const Projection& projection,
const MapParameter& parameter,
const MapData& data);
};
}
#endif
1 change: 1 addition & 0 deletions libosmscout-map/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ osmscoutmapSrc = [
'src/osmscoutmap/oss/Parser.cpp',
'src/osmscoutmap/LabelLayouter.cpp',
'src/osmscoutmap/MapPainter.cpp',
'src/osmscoutmap/MapPainterStatistics.cpp',
'src/osmscoutmap/MapParameter.cpp',
'src/osmscoutmap/LabelProvider.cpp',
'src/osmscoutmap/LabelPath.cpp',
Expand Down
Loading

0 comments on commit 89279c0

Please sign in to comment.