Skip to content

Commit 40ef1a6

Browse files
authored
Merge pull request #2202 from joto/cleanup-misc
Various small cleanups
2 parents 5952d2a + d2799fd commit 40ef1a6

File tree

5 files changed

+24
-32
lines changed

5 files changed

+24
-32
lines changed

src/flex-lua-index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static void check_and_add_column(flex_table_t const &table,
2525
throw fmt_error("Unknown column '{}' in table '{}'.", column_name,
2626
table.name());
2727
}
28-
columns->push_back(column_name);
28+
columns->emplace_back(column_name);
2929
}
3030

3131
static void check_and_add_columns(flex_table_t const &table,

src/gen/osm2pgsql-gen.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,6 @@ class genproc_t
250250

251251
int app_define_table()
252252
{
253-
#if 0
254-
if (m_calling_context != calling_context::main) {
255-
throw std::runtime_error{
256-
"Database tables have to be defined in the"
257-
" main Lua code, not in any of the callbacks."};
258-
}
259-
#endif
260-
261253
return setup_flex_table(m_lua_state.get(), &m_tables, &m_expire_outputs,
262254
m_dbschema, true, m_append);
263255
}

src/geom-functions.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,18 @@ namespace {
252252
class without_first
253253
{
254254
public:
255-
explicit without_first(point_list_t const &list) : m_list(list) {}
255+
explicit without_first(point_list_t const &list) : m_list(&list) {}
256256

257257
point_list_t::const_iterator begin()
258258
{
259-
assert(m_list.begin() != m_list.end());
260-
return std::next(m_list.begin());
259+
assert(m_list->begin() != m_list->end());
260+
return std::next(m_list->begin());
261261
}
262262

263-
point_list_t::const_iterator end() { return m_list.end(); }
263+
point_list_t::const_iterator end() { return m_list->end(); }
264264

265265
private:
266-
point_list_t const &m_list;
266+
point_list_t const *m_list;
267267
}; // class without_first
268268

269269
} // anonymous namespace
@@ -593,10 +593,10 @@ void line_merge(geometry_t *output, geometry_t const &input)
593593
struct connection_t
594594
{
595595
std::size_t left = NOCONN;
596-
linestring_t const *ls;
596+
linestring_t const *linestring;
597597
std::size_t right = NOCONN;
598598

599-
explicit connection_t(linestring_t const *l) noexcept : ls(l) {}
599+
explicit connection_t(linestring_t const *l) noexcept : linestring(l) {}
600600
};
601601

602602
std::vector<connection_t> conns;
@@ -633,7 +633,7 @@ void line_merge(geometry_t *output, geometry_t const &input)
633633
std::size_t done_ways = 0;
634634
std::size_t const todo_ways = conns.size();
635635
for (std::size_t i = 0; i < todo_ways; ++i) {
636-
if (!conns[i].ls ||
636+
if (!conns[i].linestring ||
637637
(conns[i].left != NOCONN && conns[i].right != NOCONN)) {
638638
continue; // way already done or not the beginning of a segment
639639
}
@@ -645,8 +645,8 @@ void line_merge(geometry_t *output, geometry_t const &input)
645645

646646
do {
647647
auto &conn = conns[cur];
648-
assert(conn.ls);
649-
auto const &nl = *conn.ls;
648+
assert(conn.linestring);
649+
auto const &nl = *conn.linestring;
650650
bool const forward = conn.left == prev;
651651
prev = cur;
652652
// add line
@@ -660,7 +660,7 @@ void line_merge(geometry_t *output, geometry_t const &input)
660660
cur = conn.left;
661661
}
662662
// mark line as done
663-
conns[prev].ls = nullptr;
663+
conns[prev].linestring = nullptr;
664664
++done_ways;
665665
} while (cur != NOCONN);
666666
}
@@ -675,7 +675,7 @@ void line_merge(geometry_t *output, geometry_t const &input)
675675
// oh dear, there must be circular ways without an end
676676
// need to do the same shebang again
677677
for (std::size_t i = 0; i < todo_ways; ++i) {
678-
if (!conns[i].ls) {
678+
if (!conns[i].linestring) {
679679
continue; // way already done
680680
}
681681

@@ -686,12 +686,12 @@ void line_merge(geometry_t *output, geometry_t const &input)
686686

687687
do {
688688
auto &conn = conns[cur];
689-
assert(conn.ls);
690-
auto const &nl = *conn.ls;
689+
assert(conn.linestring);
690+
auto const &nl = *conn.linestring;
691691
bool const forward =
692692
(conn.left == prev &&
693-
(!conns[conn.left].ls ||
694-
conns[conn.left].ls->back() == nl.front()));
693+
(!conns[conn.left].linestring ||
694+
conns[conn.left].linestring->back() == nl.front()));
695695
prev = cur;
696696
if (forward) {
697697
// add line forwards
@@ -705,7 +705,7 @@ void line_merge(geometry_t *output, geometry_t const &input)
705705
cur = conn.left;
706706
}
707707
// mark line as done
708-
conns[prev].ls = nullptr;
708+
conns[prev].linestring = nullptr;
709709
} while (cur != i);
710710
}
711711

@@ -801,9 +801,9 @@ static bool simplify(linestring_t *output, linestring_t const &input,
801801
static bool simplify(multilinestring_t *output, multilinestring_t const &input,
802802
double tolerance)
803803
{
804-
for (auto const &ls : input) {
804+
for (auto const &linestring : input) {
805805
linestring_t simplified_ls;
806-
if (simplify(&simplified_ls, ls, tolerance)) {
806+
if (simplify(&simplified_ls, linestring, tolerance)) {
807807
output->add_geometry(std::move(simplified_ls));
808808
}
809809
}

src/output-pgsql.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
static double calculate_area(bool reproject_area,
4949
geom::geometry_t const &geom4326,
50-
geom::geometry_t const &geom)
50+
geom::geometry_t const &projected_geom)
5151
{
5252
static thread_local auto const proj3857 =
5353
reprojection::create_projection(3857);
@@ -56,7 +56,7 @@ static double calculate_area(bool reproject_area,
5656
auto const ogeom = geom::transform(geom4326, *proj3857);
5757
return geom::area(ogeom);
5858
}
59-
return geom::area(geom);
59+
return geom::area(projected_geom);
6060
}
6161

6262
void output_pgsql_t::pgsql_out_way(osmium::Way const &way, taglist_t *tags,

tests/test-wkb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,15 @@ TEST_CASE("wkb hex decode of valid hex string")
215215
static_cast<char>(0x99),
216216
static_cast<char>(0xff)};
217217

218-
auto const result = decode_hex(hex.c_str());
218+
auto const result = decode_hex(hex);
219219
REQUIRE(result.size() == hex.size() / 2);
220220
REQUIRE(result == data);
221221
}
222222

223223
TEST_CASE("wkb hex decode of empty string is okay")
224224
{
225225
std::string const hex{};
226-
REQUIRE(decode_hex(hex.c_str()).empty());
226+
REQUIRE(decode_hex(hex).empty());
227227
}
228228

229229
TEST_CASE("wkb hex decode of string with odd number of characters fails")

0 commit comments

Comments
 (0)