From 3db46e9b805bd3eaa289cd8fb5e692387c20e633 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Wed, 20 Aug 2025 13:42:28 +0200 Subject: [PATCH 1/5] Use uppercase for constants --- tests/test-ordered-index.cpp | 32 ++++++++++++++++---------------- tests/test-output-flex-nodes.cpp | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/test-ordered-index.cpp b/tests/test-ordered-index.cpp index 5a06abc00..cd9f62afb 100644 --- a/tests/test-ordered-index.cpp +++ b/tests/test-ordered-index.cpp @@ -13,8 +13,8 @@ TEST_CASE("ordered index basics", "[NoDB]") { - constexpr std::size_t block_size = 16; - ordered_index_t index{block_size}; + constexpr std::size_t BLOCK_SIZE = 16; + ordered_index_t index{BLOCK_SIZE}; REQUIRE(index.size() == 0); REQUIRE(index.capacity() == 0); @@ -22,12 +22,12 @@ TEST_CASE("ordered index basics", "[NoDB]") index.add(17, 32); REQUIRE(index.size() == 1); - REQUIRE(index.capacity() == block_size); + REQUIRE(index.capacity() == BLOCK_SIZE); REQUIRE(index.used_memory() > 0); index.add(19, 33); REQUIRE(index.size() == 2); - REQUIRE(index.capacity() == block_size); + REQUIRE(index.capacity() == BLOCK_SIZE); REQUIRE(index.used_memory() > 0); index.clear(); @@ -38,8 +38,8 @@ TEST_CASE("ordered index basics", "[NoDB]") TEST_CASE("ordered index set/get", "[NoDB]") { - constexpr std::size_t block_size = 16; - ordered_index_t index{block_size}; + constexpr std::size_t BLOCK_SIZE = 16; + ordered_index_t index{BLOCK_SIZE}; index.add(19, 0); index.add(22, 10); @@ -64,15 +64,15 @@ TEST_CASE("ordered index set/get", "[NoDB]") TEST_CASE("ordered index set/get with multiple second-level blocks", "[NoDB]") { - constexpr std::size_t block_size = 4; - ordered_index_t index{block_size}; + constexpr std::size_t BLOCK_SIZE = 4; + ordered_index_t index{BLOCK_SIZE}; index.add(19, 0); index.add(22, 10); index.add(23, 22); index.add(26, 24); REQUIRE(index.size() == 4); - REQUIRE(index.capacity() == block_size); + REQUIRE(index.capacity() == BLOCK_SIZE); REQUIRE(index.get(31) == index.not_found_value()); @@ -80,7 +80,7 @@ TEST_CASE("ordered index set/get with multiple second-level blocks", "[NoDB]") index.add(42, 30); index.add(65, 32); REQUIRE(index.size() == 7); - REQUIRE(index.capacity() == block_size * (1 + 2)); + REQUIRE(index.capacity() == BLOCK_SIZE * (1 + 2)); REQUIRE(index.get(22) == 10); REQUIRE(index.get(23) == 22); @@ -106,24 +106,24 @@ TEST_CASE("ordered index set/get with multiple second-level blocks", "[NoDB]") TEST_CASE("ordered index with huge gaps in ids", "[NoDB]") { - constexpr std::size_t block_size = 4; - ordered_index_t index{block_size}; + constexpr std::size_t BLOCK_SIZE = 4; + ordered_index_t index{BLOCK_SIZE}; index.add(1, 0); REQUIRE(index.size() == 1); - REQUIRE(index.capacity() == block_size); + REQUIRE(index.capacity() == BLOCK_SIZE); index.add((1ULL << 32U) + 3U, 1); REQUIRE(index.size() == 2); - REQUIRE(index.capacity() == block_size * (1 + 2)); + REQUIRE(index.capacity() == BLOCK_SIZE * (1 + 2)); index.add((1ULL << 32U) + 4U, 2); REQUIRE(index.size() == 3); - REQUIRE(index.capacity() == block_size * (1 + 2)); + REQUIRE(index.capacity() == BLOCK_SIZE * (1 + 2)); index.add((2ULL << 32U) + 9U, 3); REQUIRE(index.size() == 4); - REQUIRE(index.capacity() == block_size * (1 + 2 + 4)); + REQUIRE(index.capacity() == BLOCK_SIZE * (1 + 2 + 4)); REQUIRE(index.used_memory() > (index.capacity() * 8)); diff --git a/tests/test-output-flex-nodes.cpp b/tests/test-output-flex-nodes.cpp index f4a8ed9ae..9f999eda3 100644 --- a/tests/test-output-flex-nodes.cpp +++ b/tests/test-output-flex-nodes.cpp @@ -63,7 +63,7 @@ enum class node_relationship : std::uint8_t template struct node_rel { - static constexpr node_relationship rs = R; + static constexpr node_relationship RS = R; }; using node_rel_none = node_rel; @@ -87,9 +87,9 @@ TEMPLATE_TEST_CASE("change nodes", "", node_rel_none, node_rel_in_way, options.append = true; - if (TestType{}.rs == node_relationship::in_way) { + if (TestType{}.RS == node_relationship::in_way) { REQUIRE_NOTHROW(db.run_import(options, "w20 v1 dV Nn14,n15,n16\n")); - } else if (TestType{}.rs == node_relationship::in_relation) { + } else if (TestType{}.RS == node_relationship::in_relation) { REQUIRE_NOTHROW(db.run_import(options, "r30 v1 dV Mn14@,n15@,n16@\n")); } @@ -174,9 +174,9 @@ TEMPLATE_TEST_CASE("delete nodes", "", node_rel_none, node_rel_in_way, options.append = true; - if (TestType{}.rs == node_relationship::in_way) { + if (TestType{}.RS == node_relationship::in_way) { REQUIRE_NOTHROW(db.run_import(options, "w20 v1 dV Nn14,n15,n16\n")); - } else if (TestType{}.rs == node_relationship::in_relation) { + } else if (TestType{}.RS == node_relationship::in_relation) { REQUIRE_NOTHROW(db.run_import(options, "r30 v1 dV Mn14@,n15@,n16@\n")); } From 522d94d118518be90a789a7aa4ecf82f2ae2ca3e Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Wed, 20 Aug 2025 13:46:58 +0200 Subject: [PATCH 2/5] Rename Cell struct to cell_t --- src/geom-pole-of-inaccessibility.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/geom-pole-of-inaccessibility.cpp b/src/geom-pole-of-inaccessibility.cpp index daa6e2173..7173c7a39 100644 --- a/src/geom-pole-of-inaccessibility.cpp +++ b/src/geom-pole-of-inaccessibility.cpp @@ -116,28 +116,29 @@ auto point_to_polygon_distance(point_t point, polygon_t const &polygon, return (inside ? 1 : -1) * std::sqrt(min_dist_squared); } -struct Cell +struct cell_t { static constexpr double SQRT2 = 1.4142135623730951; - Cell(point_t c, double h, polygon_t const &polygon, double stretch) + cell_t(point_t c, double h, polygon_t const &polygon, double stretch) : center(c), half_size(h), dist(point_to_polygon_distance(center, polygon, stretch)), max(dist + half_size * SQRT2) - {} + { + } point_t center; // cell center double half_size; // half the cell size double dist; // distance from cell center to polygon double max; // max distance to polygon within a cell - friend bool operator<(Cell const &a, Cell const &b) noexcept + friend bool operator<(cell_t const &a, cell_t const &b) noexcept { return a.max < b.max; } }; -Cell make_centroid_cell(polygon_t const &polygon, double stretch) +cell_t make_centroid_cell(polygon_t const &polygon, double stretch) { point_t centroid{0, 0}; boost::geometry::centroid(polygon, centroid); @@ -166,7 +167,7 @@ point_t pole_of_inaccessibility(polygon_t const &polygon, double precision, return envelope.min(); } - std::priority_queue> cell_queue; + std::priority_queue> cell_queue; // cover polygon with initial cells if (stretched_envelope.width() == stretched_envelope.height()) { @@ -201,7 +202,7 @@ point_t pole_of_inaccessibility(polygon_t const &polygon, double precision, auto best_cell = make_centroid_cell(polygon, stretch); // second guess: bounding box centroid - Cell const bbox_cell{stretched_envelope.center(), 0, polygon, stretch}; + cell_t const bbox_cell{stretched_envelope.center(), 0, polygon, stretch}; if (bbox_cell.dist > best_cell.dist) { best_cell = bbox_cell; } @@ -227,8 +228,8 @@ point_t pole_of_inaccessibility(polygon_t const &polygon, double precision, for (auto const dy : {-h, h}) { for (auto const dx : {-h, h}) { - Cell const c{point_t{center.x() + dx, center.y() + dy}, h, - polygon, stretch}; + cell_t const c{point_t{center.x() + dx, center.y() + dy}, h, + polygon, stretch}; if (c.max > best_cell.dist) { cell_queue.push(c); } From d589ea7c8497cecf959ae933784955e4039472db Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Wed, 20 Aug 2025 14:18:06 +0200 Subject: [PATCH 3/5] Use east const --- src/geom-boost-adaptor.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geom-boost-adaptor.hpp b/src/geom-boost-adaptor.hpp index 7eac5fbf9..fb64d2bf5 100644 --- a/src/geom-boost-adaptor.hpp +++ b/src/geom-boost-adaptor.hpp @@ -35,7 +35,7 @@ namespace boost::geometry::traits { template <> struct point_order<::geom::ring_t> { - static const order_selector value = counterclockwise; + static order_selector const value = counterclockwise; }; template <> From d3b46f68934f37c83cf5e4d1a7e3f559eeb84dfc Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Wed, 20 Aug 2025 13:56:02 +0200 Subject: [PATCH 4/5] Fix some formatting issues (clang-format) --- .clang-format | 6 +++--- src/command-line-parser.cpp | 3 ++- src/db-copy-mgr.hpp | 2 +- src/db-copy.hpp | 2 +- src/expire-tiles.cpp | 3 ++- src/flex-index.hpp | 5 +---- src/flex-lua-locator.cpp | 2 +- src/flex-lua-table.cpp | 7 +++---- src/flex-table.hpp | 15 ++++++++------- src/geom-area-assembler.hpp | 2 +- src/geom-boost-adaptor.hpp | 20 ++++---------------- src/geom-from-osm.hpp | 3 +-- src/logging.cpp | 2 +- src/middle-pgsql.cpp | 9 +++++---- src/middle-ram.cpp | 3 +-- src/node-locations.hpp | 3 ++- src/ordered-index.cpp | 4 ++-- src/osmtypes.hpp | 2 +- src/output-flex.cpp | 13 ++++++++----- src/output-flex.hpp | 11 ++++------- src/pgsql-helper.cpp | 3 ++- src/pgsql-helper.hpp | 1 - src/pgsql.hpp | 3 ++- src/progress-display.hpp | 1 - src/reprojection-generic-none.cpp | 1 - src/reprojection-generic-proj6.cpp | 7 ++----- src/table.cpp | 1 - src/taginfo.cpp | 4 ++-- src/tagtransform-c.cpp | 10 ++++++---- src/template.cpp | 3 ++- tests/test-check-input.cpp | 1 - tests/test-geom-multilinestrings.cpp | 3 +-- tests/test-json-writer.cpp | 1 - tests/test-options-projection.cpp | 2 +- tests/test-ordered-index.cpp | 1 - tests/test-output-flex-example-configs.cpp | 5 +++-- tests/test-output-flex-types.cpp | 13 ++++++------- tests/test-output-pgsql-style-file.cpp | 4 +--- tests/test-persistent-cache.cpp | 3 ++- tests/test-taginfo.cpp | 13 ++++++++----- tests/test-wkb.cpp | 1 - 41 files changed, 90 insertions(+), 108 deletions(-) diff --git a/.clang-format b/.clang-format index 5f5881dc3..747ef09e7 100644 --- a/.clang-format +++ b/.clang-format @@ -1,9 +1,9 @@ --- -Language: Cpp -BasedOnStyle: LLVM +Language: Cpp +BasedOnStyle: LLVM AccessModifierOffset: -4 BreakBeforeBraces: Mozilla -IndentWidth: 4 +IndentWidth: 4 ConstructorInitializerIndentWidth: 0 ReflowComments: false AlwaysBreakTemplateDeclarations: true diff --git a/src/command-line-parser.cpp b/src/command-line-parser.cpp index 51d728d88..8d6b1791f 100644 --- a/src/command-line-parser.cpp +++ b/src/command-line-parser.cpp @@ -225,7 +225,8 @@ void check_options(options_t *options) } } -void check_options_expire(options_t *options) { +void check_options_expire(options_t *options) +{ // Zoom level 31 is the technical limit because we use 32-bit integers for // the x and y index of a tile ID. if (options->expire_tiles_zoom_min > 31) { diff --git a/src/db-copy-mgr.hpp b/src/db-copy-mgr.hpp index 971f17d82..5e7fdd69f 100644 --- a/src/db-copy-mgr.hpp +++ b/src/db-copy-mgr.hpp @@ -248,7 +248,7 @@ class db_copy_mgr_t * following the delete_object() are inserted. */ template - void delete_object(ARGS &&... args) + void delete_object(ARGS &&...args) { assert(m_current); m_current.add_deletable(std::forward(args)...); diff --git a/src/db-copy.hpp b/src/db-copy.hpp index c1c1c3a57..6cda44368 100644 --- a/src/db-copy.hpp +++ b/src/db-copy.hpp @@ -197,7 +197,7 @@ class db_cmd_copy_delete_t : public db_cmd_copy_t } template - void add_deletable(ARGS &&... args) + void add_deletable(ARGS &&...args) { m_deleter.add(std::forward(args)...); } diff --git a/src/expire-tiles.cpp b/src/expire-tiles.cpp index 1cd584f25..f140ba234 100644 --- a/src/expire-tiles.cpp +++ b/src/expire-tiles.cpp @@ -177,7 +177,8 @@ void expire_tiles::from_line_segment(geom::point_t const &a, } double const y_len = tilec_b.y() - tilec_a.y(); - double const hyp_len = std::sqrt(x_len * x_len + y_len * y_len); /* Pythagoras */ + double const hyp_len = + std::sqrt(x_len * x_len + y_len * y_len); /* Pythagoras */ double const x_step = x_len / hyp_len; double const y_step = y_len / hyp_len; diff --git a/src/flex-index.hpp b/src/flex-index.hpp index 9b805c135..8432a5dc7 100644 --- a/src/flex-index.hpp +++ b/src/flex-index.hpp @@ -50,10 +50,7 @@ class flex_index_t std::string const &name() const noexcept { return m_name; } - void set_name(std::string name) - { - m_name = std::move(name); - } + void set_name(std::string name) { m_name = std::move(name); } std::string const &expression() const noexcept { return m_expression; } diff --git a/src/flex-lua-locator.cpp b/src/flex-lua-locator.cpp index 002e1c000..150457661 100644 --- a/src/flex-lua-locator.cpp +++ b/src/flex-lua-locator.cpp @@ -140,7 +140,7 @@ int lua_wrapper_locator::all_intersecting() auto const names = self().all_intersecting(*geometry); lua_createtable(lua_state(), (int)names.size(), 0); int n = 0; - for (auto const& name : names) { + for (auto const &name : names) { lua_pushinteger(lua_state(), ++n); luaX_pushstring(lua_state(), name); lua_rawset(lua_state(), -3); diff --git a/src/flex-lua-table.cpp b/src/flex-lua-table.cpp index ea82beed8..72978ecc5 100644 --- a/src/flex-lua-table.cpp +++ b/src/flex-lua-table.cpp @@ -26,10 +26,9 @@ namespace { void check_tablespace(std::string const &tablespace) { if (!has_tablespace(tablespace)) { - throw fmt_error( - "Tablespace '{0}' not available." - " Use 'CREATE TABLESPACE \"{0}\" ...;' to create it.", - tablespace); + throw fmt_error("Tablespace '{0}' not available." + " Use 'CREATE TABLESPACE \"{0}\" ...;' to create it.", + tablespace); } } diff --git a/src/flex-table.hpp b/src/flex-table.hpp index 489496bf2..3616d8393 100644 --- a/src/flex-table.hpp +++ b/src/flex-table.hpp @@ -37,12 +37,13 @@ * output. This is not a real primary key, because the values are not * necessarily unique. */ -enum class flex_table_index_type : uint8_t { +enum class flex_table_index_type : uint8_t +{ no_index, - node, // index by node id - way, // index by way id - relation, // index by relation id - area, // index by way (positive) or relation (negative) id + node, // index by node id + way, // index by way id + relation, // index by relation id + area, // index by way (positive) or relation (negative) id any_object, // any OSM object, two columns for type and id tile // index by tile with x and y columns (used for generalized data) }; @@ -54,12 +55,12 @@ class flex_table_t { public: - /** * Table creation type: interim tables are created as UNLOGGED and with * autovacuum disabled. */ - enum class table_type : uint8_t { + enum class table_type : uint8_t + { interim, permanent }; diff --git a/src/geom-area-assembler.hpp b/src/geom-area-assembler.hpp index a83c27ee6..c7efab075 100644 --- a/src/geom-area-assembler.hpp +++ b/src/geom-area-assembler.hpp @@ -58,7 +58,7 @@ class area_assembler_t : public osmium::area::detail::BasicAssembler private: bool make_area(); - osmium::memory::Buffer* m_buffer; + osmium::memory::Buffer *m_buffer; }; // class area_assembler_t diff --git a/src/geom-boost-adaptor.hpp b/src/geom-boost-adaptor.hpp index fb64d2bf5..62f882f01 100644 --- a/src/geom-boost-adaptor.hpp +++ b/src/geom-boost-adaptor.hpp @@ -86,40 +86,28 @@ template <> struct indexed_access<::geom::box_t, min_corner, 0> { static double get(::geom::box_t const &b) { return b.min_x(); } - static void set(::geom::box_t &b, double value) - { - b.set_min_x(value); - } + static void set(::geom::box_t &b, double value) { b.set_min_x(value); } }; template <> struct indexed_access<::geom::box_t, min_corner, 1> { static double get(::geom::box_t const &b) { return b.min_y(); } - static void set(::geom::box_t &b, double value) - { - b.set_min_y(value); - } + static void set(::geom::box_t &b, double value) { b.set_min_y(value); } }; template <> struct indexed_access<::geom::box_t, max_corner, 0> { static double get(::geom::box_t const &b) { return b.max_x(); } - static void set(::geom::box_t &b, double value) - { - b.set_max_x(value); - } + static void set(::geom::box_t &b, double value) { b.set_max_x(value); } }; template <> struct indexed_access<::geom::box_t, max_corner, 1> { static double get(::geom::box_t const &b) { return b.max_y(); } - static void set(::geom::box_t &b, double value) - { - b.set_max_y(value); - } + static void set(::geom::box_t &b, double value) { b.set_max_y(value); } }; } // namespace boost::geometry::traits diff --git a/src/geom-from-osm.hpp b/src/geom-from-osm.hpp index a2c59e4da..4db2c8654 100644 --- a/src/geom-from-osm.hpp +++ b/src/geom-from-osm.hpp @@ -200,8 +200,7 @@ create_multipolygon(osmium::Relation const &relation, * \param buffer Buffer with OSM objects. Nodes are turned into points, * ways into linestrings, anything else in the buffer is ignored. */ -void create_collection(geometry_t *geom, - osmium::memory::Buffer const &buffer); +void create_collection(geometry_t *geom, osmium::memory::Buffer const &buffer); /** * Create a geometry collection from nodes and ways, usually used for diff --git a/src/logging.cpp b/src/logging.cpp index e5e149490..d30c1c5be 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -27,7 +27,7 @@ void logger::generate_common_prefix(std::string *str, fmt::text_style const &ts, char const *prefix) const { *str += fmt::format("{:%Y-%m-%d %H:%M:%S} ", - fmt::localtime(std::time(nullptr))); + fmt::localtime(std::time(nullptr))); if (m_current_level == log_level::debug) { *str += fmt::format(ts, "[{:02d}] ", this_thread_num); diff --git a/src/middle-pgsql.cpp b/src/middle-pgsql.cpp index 7d6aae5ee..a3ee43c64 100644 --- a/src/middle-pgsql.cpp +++ b/src/middle-pgsql.cpp @@ -447,7 +447,8 @@ void middle_pgsql_t::node(osmium::Node const &node) } } -void middle_pgsql_t::way(osmium::Way const &way) { +void middle_pgsql_t::way(osmium::Way const &way) +{ assert(m_middle_state == middle_state::way); if (way.deleted()) { @@ -460,7 +461,8 @@ void middle_pgsql_t::way(osmium::Way const &way) { } } -void middle_pgsql_t::relation(osmium::Relation const &relation) { +void middle_pgsql_t::relation(osmium::Relation const &relation) +{ assert(m_middle_state == middle_state::relation); if (relation.deleted()) { @@ -1270,8 +1272,7 @@ void middle_pgsql_t::set_requirements( log_debug(" with_attributes: {}", m_store_options.with_attributes); } -std::shared_ptr -middle_pgsql_t::get_query_instance() +std::shared_ptr middle_pgsql_t::get_query_instance() { // NOTE: this is thread safe for use in pending async processing only // because during that process they are only read from diff --git a/src/middle-ram.cpp b/src/middle-ram.cpp index 2a06201c9..54c87bc23 100644 --- a/src/middle-ram.cpp +++ b/src/middle-ram.cpp @@ -358,8 +358,7 @@ middle_ram_t::rel_members_get(osmium::Relation const &rel, break; case osmium::item_type::way: if (m_store_options.ways) { - auto const offset = - m_object_index.ways().get(member.ref()); + auto const offset = m_object_index.ways().get(member.ref()); if (offset != ordered_index_t::not_found_value()) { buffer->add_item(m_object_buffer.get(offset)); buffer->commit(); diff --git a/src/node-locations.hpp b/src/node-locations.hpp index d520d03d5..83befe2c6 100644 --- a/src/node-locations.hpp +++ b/src/node-locations.hpp @@ -93,7 +93,8 @@ class node_locations_t } /// The maximum number of bytes an entry will need in storage. - constexpr static std::size_t max_bytes_per_entry() noexcept { + constexpr static std::size_t max_bytes_per_entry() noexcept + { return 10UL /*max varint length*/ * 3UL /*id, x, y*/; } diff --git a/src/ordered-index.cpp b/src/ordered-index.cpp index 7803f4a99..a6901f97b 100644 --- a/src/ordered-index.cpp +++ b/src/ordered-index.cpp @@ -40,8 +40,8 @@ void ordered_index_t::add(osmid_t id, std::size_t offset) ++m_size; } -std::pair ordered_index_t::get_internal(osmid_t id) const - noexcept +std::pair +ordered_index_t::get_internal(osmid_t id) const noexcept { if (m_ranges.empty()) { return {0, not_found_value()}; diff --git a/src/osmtypes.hpp b/src/osmtypes.hpp index ce9ecc6ac..1ac127506 100644 --- a/src/osmtypes.hpp +++ b/src/osmtypes.hpp @@ -188,7 +188,7 @@ class taglist_t /// Add tag to list without checking for duplicates template - void add_tag(char const *key, T&& value) + void add_tag(char const *key, T &&value) { m_tags.emplace_back(key, std::forward(value)); } diff --git a/src/output-flex.cpp b/src/output-flex.cpp index d16624a82..f29ff5f15 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -169,7 +169,8 @@ void push_osm_object_to_lua_stack(lua_State *lua_state, lua_pushinteger(lua_state, wn.ref()); }); } else if (object.type() == osmium::item_type::relation) { - auto const &relation = static_cast(object); + auto const &relation = + static_cast(object); luaX_add_table_array( lua_state, "members", relation.members(), [&](osmium::RelationMember const &member) { @@ -807,7 +808,7 @@ void output_flex_t::call_lua_function(prepared_lua_function_t func, { m_calling_context = func.context(); - lua_pushvalue(lua_state(), func.index()); // the function to call + lua_pushvalue(lua_state(), func.index()); // the function to call push_osm_object_to_lua_stack(lua_state(), object); // the single argument luaX_set_context(lua_state(), this); @@ -1112,7 +1113,8 @@ void output_flex_t::way_delete(osmium::Way *way) { if (m_process_deleted_way) { m_way_cache.init(way); - get_mutex_and_call_lua_function(m_process_deleted_way, m_way_cache.get()); + get_mutex_and_call_lua_function(m_process_deleted_way, + m_way_cache.get()); } way_delete(way->id()); @@ -1362,8 +1364,9 @@ void output_flex_t::init_lua(std::string const &filename, lua_state(), calling_context::process_node, "process_deleted_node"}; m_process_deleted_way = prepared_lua_function_t{ lua_state(), calling_context::process_way, "process_deleted_way"}; - m_process_deleted_relation = prepared_lua_function_t{ - lua_state(), calling_context::process_relation, "process_deleted_relation"}; + m_process_deleted_relation = + prepared_lua_function_t{lua_state(), calling_context::process_relation, + "process_deleted_relation"}; m_select_relation_members = prepared_lua_function_t{ lua_state(), calling_context::select_relation_members, diff --git a/src/output-flex.hpp b/src/output-flex.hpp index 1cda3068c..5af451c3a 100644 --- a/src/output-flex.hpp +++ b/src/output-flex.hpp @@ -43,8 +43,8 @@ struct options_t; enum class calling_context : std::uint8_t { main = 0, ///< In main context, i.e. the Lua script outside any callbacks - process_node = 1, ///< Inside a callback where a node is handled - process_way = 2, ///< Inside a callback where a way is handled + process_node = 1, ///< Inside a callback where a node is handled + process_way = 2, ///< Inside a callback where a way is handled process_relation = 3, ///< Inside a callback where a relation is handled select_relation_members = 4 ///< In the select_relation_members() callback }; @@ -76,7 +76,7 @@ class prepared_lua_function_t int index() const noexcept { return m_index; } /// The name of the function. - char const* name() const noexcept { return m_name; } + char const *name() const noexcept { return m_name; } /// The number of results this function is expected to have. int nresults() const noexcept { return m_nresults; } @@ -247,10 +247,7 @@ class output_flex_t : public output_t */ bool add_members(middle_query_t const &middle); - osmium::Relation const &get() const noexcept - { - return *m_relation; - } + osmium::Relation const &get() const noexcept { return *m_relation; } osmium::memory::Buffer const &members_buffer() const noexcept { diff --git a/src/pgsql-helper.cpp b/src/pgsql-helper.cpp index de857dd86..cb72891bc 100644 --- a/src/pgsql-helper.cpp +++ b/src/pgsql-helper.cpp @@ -15,7 +15,8 @@ #include -idlist_t get_ids_from_result(pg_result_t const &result) { +idlist_t get_ids_from_result(pg_result_t const &result) +{ assert(result.num_tuples() >= 0); idlist_t ids; diff --git a/src/pgsql-helper.hpp b/src/pgsql-helper.hpp index b507b4e24..d499f89b3 100644 --- a/src/pgsql-helper.hpp +++ b/src/pgsql-helper.hpp @@ -18,7 +18,6 @@ class pg_conn_t; class pg_result_t; - /** * Iterate over the result from a pgsql query and generate a list of all the * ids from the first column. diff --git a/src/pgsql.hpp b/src/pgsql.hpp index 38f49a981..0638a5532 100644 --- a/src/pgsql.hpp +++ b/src/pgsql.hpp @@ -116,7 +116,8 @@ class pg_result_t } /// Get the PostgreSQL internal type of a field. - unsigned int field_type(int col) const noexcept { + unsigned int field_type(int col) const noexcept + { assert(col >= 0 && col < num_fields()); return PQftype(m_result.get(), col); } diff --git a/src/progress-display.hpp b/src/progress-display.hpp index 95229f85e..29ceb37de 100644 --- a/src/progress-display.hpp +++ b/src/progress-display.hpp @@ -57,7 +57,6 @@ class progress_display_t : public osmium::handler::Handler } } - void relation(osmium::Relation const &) { if (++m_rel.count % 10 == 0) { diff --git a/src/reprojection-generic-none.cpp b/src/reprojection-generic-none.cpp index 25c61b7e4..690363a93 100644 --- a/src/reprojection-generic-none.cpp +++ b/src/reprojection-generic-none.cpp @@ -17,4 +17,3 @@ std::shared_ptr reprojection::make_generic_projection(int) } std::string get_proj_version() { return "[disabled]"; } - diff --git a/src/reprojection-generic-proj6.cpp b/src/reprojection-generic-proj6.cpp index 636ccd99a..6efbf56ce 100644 --- a/src/reprojection-generic-proj6.cpp +++ b/src/reprojection-generic-proj6.cpp @@ -20,14 +20,12 @@ class generic_reprojection_t : public reprojection m_transformation_tile(create_transformation(srs, PROJ_SPHERE_MERC)) {} - geom::point_t - reproject(geom::point_t point) const noexcept override + geom::point_t reproject(geom::point_t point) const noexcept override { return transform(m_transformation.get(), point); } - geom::point_t - target_to_tile(geom::point_t point) const override + geom::point_t target_to_tile(geom::point_t point) const override { return transform(m_transformation_tile.get(), point); } @@ -121,4 +119,3 @@ std::string get_proj_version() { return fmt::format("{}", proj_info().version); } - diff --git a/src/table.cpp b/src/table.cpp index 4d4dc511f..a3dddfb69 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -432,4 +432,3 @@ pg_result_t table_t::get_wkb(osmid_t id) { return m_db_connection->exec_prepared_as_binary("get_wkb", id); } - diff --git a/src/taginfo.cpp b/src/taginfo.cpp index 208f8b019..78d5c2bda 100644 --- a/src/taginfo.cpp +++ b/src/taginfo.cpp @@ -24,8 +24,8 @@ void export_list::add(osmium::item_type type, taginfo const &info) m_export_list(type).push_back(info); } -std::vector const &export_list::get(osmium::item_type type) const - noexcept +std::vector const & +export_list::get(osmium::item_type type) const noexcept { return m_export_list(type); } diff --git a/src/tagtransform-c.cpp b/src/tagtransform-c.cpp index c1b87b69c..dd98a1014 100644 --- a/src/tagtransform-c.cpp +++ b/src/tagtransform-c.cpp @@ -220,10 +220,12 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, bool *polygon, return filter; } -bool c_tagtransform_t::filter_rel_member_tags( - taglist_t const &rel_tags, osmium::memory::Buffer const &, - rolelist_t const &, bool *make_boundary, bool *make_polygon, bool *roads, - taglist_t *out_tags) +bool c_tagtransform_t::filter_rel_member_tags(taglist_t const &rel_tags, + osmium::memory::Buffer const &, + rolelist_t const &, + bool *make_boundary, + bool *make_polygon, bool *roads, + taglist_t *out_tags) { std::string const *type = rel_tags.get("type"); if (!type) { diff --git a/src/template.cpp b/src/template.cpp index 2fc677475..29d17661d 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -9,7 +9,8 @@ #include "template.hpp" -void template_t::set_params(params_t const ¶ms) { +void template_t::set_params(params_t const ¶ms) +{ for (auto const &[key, value] : params) { m_format_store.push_back(fmt::arg(key.c_str(), to_string(value))); } diff --git a/tests/test-check-input.cpp b/tests/test-check-input.cpp index 06f00fda2..edfee76e4 100644 --- a/tests/test-check-input.cpp +++ b/tests/test-check-input.cpp @@ -82,4 +82,3 @@ TEST_CASE("no object may appear twice", "[NoDB]") check_input(tiv1, tiv2), "Input data is not ordered: way id 42 appears more than once."); } - diff --git a/tests/test-geom-multilinestrings.cpp b/tests/test-geom-multilinestrings.cpp index 2fbeb54d9..0eee538db 100644 --- a/tests/test-geom-multilinestrings.cpp +++ b/tests/test-geom-multilinestrings.cpp @@ -340,8 +340,7 @@ TEST_CASE("create_multilinestring and simplify", "[NoDB]") buffer.add_way("w20 Nn10x1y1,n11x1y2,n12x1y3"); buffer.add_way("w21 Nn12x1y3,n13x2y3,n11x1y2"); - auto const geom = - geom::create_multilinestring(buffer.buffer()); + auto const geom = geom::create_multilinestring(buffer.buffer()); REQUIRE(geom.is_multilinestring()); REQUIRE(geom.srid() == PROJ_LATLONG); diff --git a/tests/test-json-writer.cpp b/tests/test-json-writer.cpp index 5fd39d8b1..734cc8bf5 100644 --- a/tests/test-json-writer.cpp +++ b/tests/test-json-writer.cpp @@ -165,4 +165,3 @@ TEST_CASE("json writer with even stranger chars in string", "[NoDB]") writer.string("abc-\x01-\x1f-abc"); REQUIRE(writer.json() == "\"abc-\\u0001-\\u001f-abc\""); } - diff --git a/tests/test-options-projection.cpp b/tests/test-options-projection.cpp index 03667b953..204ec5ff1 100644 --- a/tests/test-options-projection.cpp +++ b/tests/test-options-projection.cpp @@ -24,7 +24,7 @@ testing::db::import_t db; TEST_CASE("Projection setup") { - char const* const style_file = OSM2PGSQLDATA_DIR "default.style"; + char const *const style_file = OSM2PGSQLDATA_DIR "default.style"; std::vector option_params = {"osm2pgsql", "--output=pgsql", "-S", style_file, diff --git a/tests/test-ordered-index.cpp b/tests/test-ordered-index.cpp index cd9f62afb..e75b4a346 100644 --- a/tests/test-ordered-index.cpp +++ b/tests/test-ordered-index.cpp @@ -143,4 +143,3 @@ TEST_CASE("ordered index with huge gaps in ids", "[NoDB]") REQUIRE(index.get_block((2ULL << 32U) + 9U) == 3); REQUIRE(index.get_block((3ULL << 32U) + 2U) == 3); } - diff --git a/tests/test-output-flex-example-configs.cpp b/tests/test-output-flex-example-configs.cpp index f5da24111..b745efaee 100644 --- a/tests/test-output-flex-example-configs.cpp +++ b/tests/test-output-flex-example-configs.cpp @@ -25,7 +25,8 @@ testing::db::import_t db; char const *const DATA_FILE = "liechtenstein-2013-08-03.osm.pbf"; -std::vector get_files() { +std::vector get_files() +{ // NOLINTNEXTLINE(concurrency-mt-unsafe) char const *env = std::getenv("EXAMPLE_FILES"); REQUIRE(env); @@ -38,7 +39,7 @@ TEST_CASE("minimal test for flex example configs") { auto const files = get_files(); - for (auto const& file : files) { + for (auto const &file : files) { fmt::print(stderr, "Testing example config '{}.lua'\n", file); auto const conf_file = "../../flex-config/" + file + ".lua"; options_t const options = testing::opt_t().flex(conf_file.c_str()); diff --git a/tests/test-output-flex-types.cpp b/tests/test-output-flex-types.cpp index 689208894..f28e514ca 100644 --- a/tests/test-output-flex-types.cpp +++ b/tests/test-output-flex-types.cpp @@ -32,13 +32,12 @@ TEST_CASE("type nil") auto conn = db.db().connect(); CHECK(1 == conn.get_count("nodes")); - CHECK(1 == - conn.get_count( - "nodes", - "ttext IS NULL AND tbool IS NULL AND tint2 IS NULL AND " - "tint4 IS NULL AND tint8 IS NULL AND treal IS NULL AND " - "thstr IS NULL AND tjson IS NULL AND tdirn IS NULL AND " - "tsqlt IS NULL")); + CHECK(1 == conn.get_count( + "nodes", + "ttext IS NULL AND tbool IS NULL AND tint2 IS NULL AND " + "tint4 IS NULL AND tint8 IS NULL AND treal IS NULL AND " + "thstr IS NULL AND tjson IS NULL AND tdirn IS NULL AND " + "tsqlt IS NULL")); } TEST_CASE("type boolean") diff --git a/tests/test-output-pgsql-style-file.cpp b/tests/test-output-pgsql-style-file.cpp index b52de06ef..268354d89 100644 --- a/tests/test-output-pgsql-style-file.cpp +++ b/tests/test-output-pgsql-style-file.cpp @@ -22,7 +22,6 @@ TEST_CASE("Parse default style file") REQUIRE(exlist.get(osmium::item_type::node).size() == 98); REQUIRE(exlist.get(osmium::item_type::way).size() == 104); - } TEST_CASE("Parse empty style file") @@ -30,8 +29,7 @@ TEST_CASE("Parse empty style file") export_list exlist; REQUIRE_THROWS_WITH( - read_style_file(OSM2PGSQLDATA_DIR "tests/style/empty.style", - &exlist), + read_style_file(OSM2PGSQLDATA_DIR "tests/style/empty.style", &exlist), "Unable to parse any valid columns from the style file. Aborting."); } diff --git a/tests/test-persistent-cache.cpp b/tests/test-persistent-cache.cpp index 96cf150ac..4cdccdd9d 100644 --- a/tests/test-persistent-cache.cpp +++ b/tests/test-persistent-cache.cpp @@ -108,7 +108,8 @@ TEST_CASE("Persistent cache", "[NoDB]") } } -TEST_CASE("Opening non-existent persistent cache should fail in append mode", "[NoDB]") +TEST_CASE("Opening non-existent persistent cache should fail in append mode", + "[NoDB]") { std::string const flat_node_file = "test_middle_flat.nonexistent.flat.nodes.bin"; diff --git a/tests/test-taginfo.cpp b/tests/test-taginfo.cpp index 49ef5c7c8..5765dab45 100644 --- a/tests/test-taginfo.cpp +++ b/tests/test-taginfo.cpp @@ -21,9 +21,12 @@ TEST_CASE("parse_tag_flags", "[NoDB]") CHECK(parse_tag_flags("delete", 0) == FLAG_DELETE); CHECK(parse_tag_flags("nocache", 0) == FLAG_NOCACHE); CHECK(parse_tag_flags("UNKNOWN", 0) == 0); - CHECK(parse_tag_flags("polygon,phstore", 0) == (FLAG_POLYGON | FLAG_PHSTORE)); - CHECK(parse_tag_flags("polygon\nnocache", 0) == (FLAG_POLYGON | FLAG_NOCACHE)); - CHECK(parse_tag_flags("polygon\nnocache,delete", 0) == (FLAG_POLYGON | FLAG_NOCACHE | FLAG_DELETE)); - CHECK(parse_tag_flags("polygon, nocache,delete", 0) == (FLAG_POLYGON | FLAG_DELETE)); + CHECK(parse_tag_flags("polygon,phstore", 0) == + (FLAG_POLYGON | FLAG_PHSTORE)); + CHECK(parse_tag_flags("polygon\nnocache", 0) == + (FLAG_POLYGON | FLAG_NOCACHE)); + CHECK(parse_tag_flags("polygon\nnocache,delete", 0) == + (FLAG_POLYGON | FLAG_NOCACHE | FLAG_DELETE)); + CHECK(parse_tag_flags("polygon, nocache,delete", 0) == + (FLAG_POLYGON | FLAG_DELETE)); } - diff --git a/tests/test-wkb.cpp b/tests/test-wkb.cpp index 1f1c796d4..6ce11f474 100644 --- a/tests/test-wkb.cpp +++ b/tests/test-wkb.cpp @@ -188,4 +188,3 @@ TEST_CASE("wkb: geometrycollection", "[NoDB]") } TEST_CASE("wkb: invalid", "[NoDB]") { REQUIRE_THROWS(ewkb_to_geom("INVALID")); } - From 4af1d4f617d48f9faff594008e95c1e14c83949a Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Wed, 20 Aug 2025 14:56:02 +0200 Subject: [PATCH 5/5] Use "east const" in clang-format --- .clang-format | 1 + 1 file changed, 1 insertion(+) diff --git a/.clang-format b/.clang-format index 747ef09e7..cf38aeba3 100644 --- a/.clang-format +++ b/.clang-format @@ -7,3 +7,4 @@ IndentWidth: 4 ConstructorInitializerIndentWidth: 0 ReflowComments: false AlwaysBreakTemplateDeclarations: true +QualifierAlignment: Right