Skip to content

Commit f63421f

Browse files
authored
Merge pull request #2371 from joto/globals-uppercase
Use UPPER_CASE for more global constants
2 parents 19b5c0f + 879002b commit f63421f

16 files changed

+137
-137
lines changed

src/flex-table-column.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct column_type_lookup
3131
char const *name() const noexcept { return m_name; }
3232
};
3333

34-
std::vector<column_type_lookup> const column_types = {
34+
std::vector<column_type_lookup> const COLUMN_TYPES = {
3535
{{"text", table_column_type::text},
3636
{"boolean", table_column_type::boolean},
3737
{"bool", table_column_type::boolean},
@@ -60,7 +60,7 @@ std::vector<column_type_lookup> const column_types = {
6060

6161
table_column_type get_column_type_from_string(std::string const &type)
6262
{
63-
auto const *column_type = util::find_by_name(column_types, type);
63+
auto const *column_type = util::find_by_name(COLUMN_TYPES, type);
6464
if (!column_type) {
6565
throw fmt_error("Unknown column type '{}'.", type);
6666
}

src/geom-area-assembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
namespace geom {
1515

16-
osmium::area::AssemblerConfig const area_config;
16+
osmium::area::AssemblerConfig const AREA_CONFIG;
1717

1818
area_assembler_t::area_assembler_t(osmium::memory::Buffer *buffer)
19-
: osmium::area::detail::BasicAssembler(area_config), m_buffer(buffer)
19+
: osmium::area::detail::BasicAssembler(AREA_CONFIG), m_buffer(buffer)
2020
{
2121
}
2222

tests/test-expire-from-geometry.cpp

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ std::shared_ptr<reprojection> defproj{
2525

2626
// We are using zoom level 12 here, because at that level a tile is about
2727
// 10,000 units wide/high which gives us easy numbers to work with.
28-
constexpr uint32_t zoom = 12;
28+
constexpr uint32_t ZOOM = 12;
2929

3030
} // anonymous namespace
3131

3232
TEST_CASE("expire null geometry does nothing", "[NoDB]")
3333
{
3434
expire_config_t const expire_config;
35-
expire_tiles et{zoom, defproj};
35+
expire_tiles et{ZOOM, defproj};
3636

3737
SECTION("geom")
3838
{
@@ -53,7 +53,7 @@ TEST_CASE("expire null geometry does nothing", "[NoDB]")
5353
TEST_CASE("expire point at tile boundary", "[NoDB]")
5454
{
5555
expire_config_t const expire_config;
56-
expire_tiles et{zoom, defproj};
56+
expire_tiles et{ZOOM, defproj};
5757

5858
geom::point_t const pt{0.0, 0.0};
5959

@@ -74,16 +74,16 @@ TEST_CASE("expire point at tile boundary", "[NoDB]")
7474

7575
auto const tiles = et.get_tiles();
7676
REQUIRE(tiles.size() == 4);
77-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2047, 2047});
78-
CHECK(tile_t::from_quadkey(tiles[1], zoom) == tile_t{zoom, 2048, 2047});
79-
CHECK(tile_t::from_quadkey(tiles[2], zoom) == tile_t{zoom, 2047, 2048});
80-
CHECK(tile_t::from_quadkey(tiles[3], zoom) == tile_t{zoom, 2048, 2048});
77+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2047, 2047});
78+
CHECK(tile_t::from_quadkey(tiles[1], ZOOM) == tile_t{ZOOM, 2048, 2047});
79+
CHECK(tile_t::from_quadkey(tiles[2], ZOOM) == tile_t{ZOOM, 2047, 2048});
80+
CHECK(tile_t::from_quadkey(tiles[3], ZOOM) == tile_t{ZOOM, 2048, 2048});
8181
}
8282

8383
TEST_CASE("expire point away from tile boundary", "[NoDB]")
8484
{
8585
expire_config_t const expire_config;
86-
expire_tiles et{zoom, defproj};
86+
expire_tiles et{ZOOM, defproj};
8787

8888
geom::point_t const pt{5000.0, 5000.0};
8989

@@ -104,13 +104,13 @@ TEST_CASE("expire point away from tile boundary", "[NoDB]")
104104

105105
auto const tiles = et.get_tiles();
106106
REQUIRE(tiles.size() == 1);
107-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2048, 2047});
107+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2048, 2047});
108108
}
109109

110110
TEST_CASE("expire linestring away from tile boundary", "[NoDB]")
111111
{
112112
expire_config_t const expire_config;
113-
expire_tiles et{zoom, defproj};
113+
expire_tiles et{ZOOM, defproj};
114114

115115
SECTION("line")
116116
{
@@ -135,13 +135,13 @@ TEST_CASE("expire linestring away from tile boundary", "[NoDB]")
135135

136136
auto const tiles = et.get_tiles();
137137
REQUIRE(tiles.size() == 1);
138-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2048, 2047});
138+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2048, 2047});
139139
}
140140

141141
TEST_CASE("expire linestring crossing tile boundary", "[NoDB]")
142142
{
143143
expire_config_t const expire_config;
144-
expire_tiles et{zoom, defproj};
144+
expire_tiles et{ZOOM, defproj};
145145

146146
SECTION("line")
147147
{
@@ -166,14 +166,14 @@ TEST_CASE("expire linestring crossing tile boundary", "[NoDB]")
166166

167167
auto const tiles = et.get_tiles();
168168
REQUIRE(tiles.size() == 2);
169-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2048, 2046});
170-
CHECK(tile_t::from_quadkey(tiles[1], zoom) == tile_t{zoom, 2048, 2047});
169+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2048, 2046});
170+
CHECK(tile_t::from_quadkey(tiles[1], ZOOM) == tile_t{ZOOM, 2048, 2047});
171171
}
172172

173173
TEST_CASE("expire small polygon", "[NoDB]")
174174
{
175175
expire_config_t const expire_config;
176-
expire_tiles et{zoom, defproj};
176+
expire_tiles et{ZOOM, defproj};
177177

178178
SECTION("polygon")
179179
{
@@ -210,15 +210,15 @@ TEST_CASE("expire small polygon", "[NoDB]")
210210

211211
auto const tiles = et.get_tiles();
212212
REQUIRE(tiles.size() == 1);
213-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2048, 2047});
213+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2048, 2047});
214214
}
215215

216216
TEST_CASE("expire large polygon as bbox", "[NoDB]")
217217
{
218218
expire_config_t expire_config;
219219
expire_config.mode = expire_mode::hybrid;
220220
expire_config.full_area_limit = 40000;
221-
expire_tiles et{zoom, defproj};
221+
expire_tiles et{ZOOM, defproj};
222222

223223
SECTION("polygon")
224224
{
@@ -255,25 +255,25 @@ TEST_CASE("expire large polygon as bbox", "[NoDB]")
255255

256256
auto const tiles = et.get_tiles();
257257
REQUIRE(tiles.size() == 9);
258-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2048, 2045});
259-
CHECK(tile_t::from_quadkey(tiles[1], zoom) == tile_t{zoom, 2049, 2045});
260-
CHECK(tile_t::from_quadkey(tiles[2], zoom) == tile_t{zoom, 2050, 2045});
258+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2048, 2045});
259+
CHECK(tile_t::from_quadkey(tiles[1], ZOOM) == tile_t{ZOOM, 2049, 2045});
260+
CHECK(tile_t::from_quadkey(tiles[2], ZOOM) == tile_t{ZOOM, 2050, 2045});
261261

262-
CHECK(tile_t::from_quadkey(tiles[3], zoom) == tile_t{zoom, 2048, 2046});
263-
CHECK(tile_t::from_quadkey(tiles[4], zoom) == tile_t{zoom, 2049, 2046});
264-
CHECK(tile_t::from_quadkey(tiles[7], zoom) == tile_t{zoom, 2050, 2046});
262+
CHECK(tile_t::from_quadkey(tiles[3], ZOOM) == tile_t{ZOOM, 2048, 2046});
263+
CHECK(tile_t::from_quadkey(tiles[4], ZOOM) == tile_t{ZOOM, 2049, 2046});
264+
CHECK(tile_t::from_quadkey(tiles[7], ZOOM) == tile_t{ZOOM, 2050, 2046});
265265

266-
CHECK(tile_t::from_quadkey(tiles[5], zoom) == tile_t{zoom, 2048, 2047});
267-
CHECK(tile_t::from_quadkey(tiles[6], zoom) == tile_t{zoom, 2049, 2047});
268-
CHECK(tile_t::from_quadkey(tiles[8], zoom) == tile_t{zoom, 2050, 2047});
266+
CHECK(tile_t::from_quadkey(tiles[5], ZOOM) == tile_t{ZOOM, 2048, 2047});
267+
CHECK(tile_t::from_quadkey(tiles[6], ZOOM) == tile_t{ZOOM, 2049, 2047});
268+
CHECK(tile_t::from_quadkey(tiles[8], ZOOM) == tile_t{ZOOM, 2050, 2047});
269269
}
270270

271271
TEST_CASE("expire large polygon as boundary", "[NoDB]")
272272
{
273273
expire_config_t expire_config;
274274
expire_config.mode = expire_mode::hybrid;
275275
expire_config.full_area_limit = 10000;
276-
expire_tiles et{zoom, defproj};
276+
expire_tiles et{ZOOM, defproj};
277277

278278
SECTION("polygon")
279279
{
@@ -320,22 +320,22 @@ TEST_CASE("expire large polygon as boundary", "[NoDB]")
320320

321321
auto const tiles = et.get_tiles();
322322
REQUIRE(tiles.size() == 8);
323-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2048, 2045});
324-
CHECK(tile_t::from_quadkey(tiles[1], zoom) == tile_t{zoom, 2049, 2045});
325-
CHECK(tile_t::from_quadkey(tiles[2], zoom) == tile_t{zoom, 2050, 2045});
323+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2048, 2045});
324+
CHECK(tile_t::from_quadkey(tiles[1], ZOOM) == tile_t{ZOOM, 2049, 2045});
325+
CHECK(tile_t::from_quadkey(tiles[2], ZOOM) == tile_t{ZOOM, 2050, 2045});
326326

327-
CHECK(tile_t::from_quadkey(tiles[3], zoom) == tile_t{zoom, 2048, 2046});
328-
CHECK(tile_t::from_quadkey(tiles[6], zoom) == tile_t{zoom, 2050, 2046});
327+
CHECK(tile_t::from_quadkey(tiles[3], ZOOM) == tile_t{ZOOM, 2048, 2046});
328+
CHECK(tile_t::from_quadkey(tiles[6], ZOOM) == tile_t{ZOOM, 2050, 2046});
329329

330-
CHECK(tile_t::from_quadkey(tiles[4], zoom) == tile_t{zoom, 2048, 2047});
331-
CHECK(tile_t::from_quadkey(tiles[5], zoom) == tile_t{zoom, 2049, 2047});
332-
CHECK(tile_t::from_quadkey(tiles[7], zoom) == tile_t{zoom, 2050, 2047});
330+
CHECK(tile_t::from_quadkey(tiles[4], ZOOM) == tile_t{ZOOM, 2048, 2047});
331+
CHECK(tile_t::from_quadkey(tiles[5], ZOOM) == tile_t{ZOOM, 2049, 2047});
332+
CHECK(tile_t::from_quadkey(tiles[7], ZOOM) == tile_t{ZOOM, 2050, 2047});
333333
}
334334

335335
TEST_CASE("expire multipoint geometry", "[NoDB]")
336336
{
337337
expire_config_t const expire_config;
338-
expire_tiles et{zoom, defproj};
338+
expire_tiles et{ZOOM, defproj};
339339

340340
geom::point_t const p1{0.0, 0.0};
341341
geom::point_t const p2{15000.0, 15000.0};
@@ -369,17 +369,17 @@ TEST_CASE("expire multipoint geometry", "[NoDB]")
369369

370370
auto const tiles = et.get_tiles();
371371
REQUIRE(tiles.size() == 5);
372-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2047, 2047});
373-
CHECK(tile_t::from_quadkey(tiles[1], zoom) == tile_t{zoom, 2049, 2046});
374-
CHECK(tile_t::from_quadkey(tiles[2], zoom) == tile_t{zoom, 2048, 2047});
375-
CHECK(tile_t::from_quadkey(tiles[3], zoom) == tile_t{zoom, 2047, 2048});
376-
CHECK(tile_t::from_quadkey(tiles[4], zoom) == tile_t{zoom, 2048, 2048});
372+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2047, 2047});
373+
CHECK(tile_t::from_quadkey(tiles[1], ZOOM) == tile_t{ZOOM, 2049, 2046});
374+
CHECK(tile_t::from_quadkey(tiles[2], ZOOM) == tile_t{ZOOM, 2048, 2047});
375+
CHECK(tile_t::from_quadkey(tiles[3], ZOOM) == tile_t{ZOOM, 2047, 2048});
376+
CHECK(tile_t::from_quadkey(tiles[4], ZOOM) == tile_t{ZOOM, 2048, 2048});
377377
}
378378

379379
TEST_CASE("expire multilinestring geometry", "[NoDB]")
380380
{
381381
expire_config_t const expire_config;
382-
expire_tiles et{zoom, defproj};
382+
expire_tiles et{ZOOM, defproj};
383383

384384
geom::linestring_t l1{{2000.0, 2000.0}, {3000.0, 3000.0}};
385385
geom::linestring_t l2{{15000.0, 15000.0}, {25000.0, 15000.0}};
@@ -397,17 +397,17 @@ TEST_CASE("expire multilinestring geometry", "[NoDB]")
397397

398398
auto const tiles = et.get_tiles();
399399
REQUIRE(tiles.size() == 3);
400-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2049, 2046});
401-
CHECK(tile_t::from_quadkey(tiles[1], zoom) == tile_t{zoom, 2048, 2047});
402-
CHECK(tile_t::from_quadkey(tiles[2], zoom) == tile_t{zoom, 2050, 2046});
400+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2049, 2046});
401+
CHECK(tile_t::from_quadkey(tiles[1], ZOOM) == tile_t{ZOOM, 2048, 2047});
402+
CHECK(tile_t::from_quadkey(tiles[2], ZOOM) == tile_t{ZOOM, 2050, 2046});
403403
}
404404

405405
TEST_CASE("expire multipolygon geometry", "[NoDB]")
406406
{
407407
expire_config_t expire_config;
408408
expire_config.mode = expire_mode::hybrid;
409409
expire_config.full_area_limit = 10000;
410-
expire_tiles et{zoom, defproj};
410+
expire_tiles et{ZOOM, defproj};
411411

412412
geom::polygon_t p1{{{2000.0, 2000.0},
413413
{2000.0, 3000.0},
@@ -447,11 +447,11 @@ TEST_CASE("expire multipolygon geometry", "[NoDB]")
447447
}
448448

449449
std::set<quadkey_t> expected;
450-
expected.insert(tile_t{zoom, 2048, 2047}.quadkey()); // p1
450+
expected.insert(tile_t{ZOOM, 2048, 2047}.quadkey()); // p1
451451

452452
for (uint32_t x = 2049; x <= 2052; ++x) {
453453
for (uint32_t y = 2043; y <= 2046; ++y) {
454-
expected.insert(tile_t{zoom, x, y}.quadkey()); // p2
454+
expected.insert(tile_t{ZOOM, x, y}.quadkey()); // p2
455455
}
456456
}
457457
REQUIRE(expected == result);
@@ -460,7 +460,7 @@ TEST_CASE("expire multipolygon geometry", "[NoDB]")
460460
TEST_CASE("expire geometry collection", "[NoDB]")
461461
{
462462
expire_config_t const expire_config;
463-
expire_tiles et{zoom, defproj};
463+
expire_tiles et{ZOOM, defproj};
464464

465465
geom::collection_t collection;
466466
collection.add_geometry(geom::geometry_t{geom::point_t{0.0, 0.0}});
@@ -472,18 +472,18 @@ TEST_CASE("expire geometry collection", "[NoDB]")
472472

473473
auto const tiles = et.get_tiles();
474474
REQUIRE(tiles.size() == 6);
475-
CHECK(tile_t::from_quadkey(tiles[0], zoom) == tile_t{zoom, 2047, 2047});
476-
CHECK(tile_t::from_quadkey(tiles[1], zoom) == tile_t{zoom, 2049, 2046});
477-
CHECK(tile_t::from_quadkey(tiles[2], zoom) == tile_t{zoom, 2048, 2047});
478-
CHECK(tile_t::from_quadkey(tiles[3], zoom) == tile_t{zoom, 2050, 2046});
479-
CHECK(tile_t::from_quadkey(tiles[4], zoom) == tile_t{zoom, 2047, 2048});
480-
CHECK(tile_t::from_quadkey(tiles[5], zoom) == tile_t{zoom, 2048, 2048});
475+
CHECK(tile_t::from_quadkey(tiles[0], ZOOM) == tile_t{ZOOM, 2047, 2047});
476+
CHECK(tile_t::from_quadkey(tiles[1], ZOOM) == tile_t{ZOOM, 2049, 2046});
477+
CHECK(tile_t::from_quadkey(tiles[2], ZOOM) == tile_t{ZOOM, 2048, 2047});
478+
CHECK(tile_t::from_quadkey(tiles[3], ZOOM) == tile_t{ZOOM, 2050, 2046});
479+
CHECK(tile_t::from_quadkey(tiles[4], ZOOM) == tile_t{ZOOM, 2047, 2048});
480+
CHECK(tile_t::from_quadkey(tiles[5], ZOOM) == tile_t{ZOOM, 2048, 2048});
481481
}
482482

483483
TEST_CASE("expire works if in 3857", "[NoDB]")
484484
{
485485
expire_config_t const expire_config;
486-
expire_tiles et{zoom, defproj};
486+
expire_tiles et{ZOOM, defproj};
487487

488488
geom::geometry_t geom{geom::point_t{0.0, 0.0}};
489489
geom.set_srid(PROJ_SPHERE_MERC);
@@ -496,7 +496,7 @@ TEST_CASE("expire works if in 3857", "[NoDB]")
496496
TEST_CASE("expire doesn't do anything if not in 3857", "[NoDB]")
497497
{
498498
expire_config_t const expire_config;
499-
expire_tiles et{zoom, defproj};
499+
expire_tiles et{ZOOM, defproj};
500500

501501
geom::geometry_t geom{geom::point_t{0.0, 0.0}};
502502
geom.set_srid(1234);

tests/test-output-flex-example-configs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace {
2323

2424
testing::db::import_t db;
2525

26-
char const *const data_file = "liechtenstein-2013-08-03.osm.pbf";
26+
char const *const DATA_FILE = "liechtenstein-2013-08-03.osm.pbf";
2727

2828
std::vector<std::string> get_files() {
2929
// NOLINTNEXTLINE(concurrency-mt-unsafe)
@@ -43,7 +43,7 @@ TEST_CASE("minimal test for flex example configs")
4343
auto const conf_file = "../../flex-config/" + file + ".lua";
4444
options_t const options = testing::opt_t().flex(conf_file.c_str());
4545

46-
REQUIRE_NOTHROW(db.run_file(options, data_file));
46+
REQUIRE_NOTHROW(db.run_file(options, DATA_FILE));
4747

4848
auto conn = db.db().connect();
4949
}

0 commit comments

Comments
 (0)