Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/flex-lua-expire-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ create_expire_output(lua_State *lua_state, std::string const &default_schema,
return new_expire_output;
}

TRAMPOLINE_WRAPPED_OBJECT(expire_output, __tostring)
TRAMPOLINE_WRAPPED_OBJECT(expire_output, tostring)
TRAMPOLINE_WRAPPED_OBJECT(expire_output, filename)
TRAMPOLINE_WRAPPED_OBJECT(expire_output, maxzoom)
TRAMPOLINE_WRAPPED_OBJECT(expire_output, minzoom)
Expand Down Expand Up @@ -112,7 +112,7 @@ void lua_wrapper_expire_output::init(lua_State *lua_state)
lua_pushvalue(lua_state, -1);
lua_setfield(lua_state, -2, "__index");
luaX_add_table_func(lua_state, "__tostring",
lua_trampoline_expire_output___tostring);
lua_trampoline_expire_output_tostring);
luaX_add_table_func(lua_state, "filename",
lua_trampoline_expire_output_filename);
luaX_add_table_func(lua_state, "maxzoom",
Expand All @@ -126,7 +126,7 @@ void lua_wrapper_expire_output::init(lua_State *lua_state)
lua_pop(lua_state, 2);
}

int lua_wrapper_expire_output::__tostring() const
int lua_wrapper_expire_output::tostring() const
{
std::string const str =
fmt::format("osm2pgsql.ExpireOutput[minzoom={},maxzoom={},filename={},"
Expand Down
2 changes: 1 addition & 1 deletion src/flex-lua-expire-output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class lua_wrapper_expire_output : public lua_wrapper_base<expire_output_t>
{
}

int __tostring() const;
int tostring() const;
int filename() const;
int maxzoom() const;
int minzoom() const;
Expand Down
6 changes: 3 additions & 3 deletions src/flex-lua-locator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ locator_t &create_locator(lua_State *lua_state,
return new_locator;
}

TRAMPOLINE_WRAPPED_OBJECT(locator, __tostring)
TRAMPOLINE_WRAPPED_OBJECT(locator, tostring)
TRAMPOLINE_WRAPPED_OBJECT(locator, name)
TRAMPOLINE_WRAPPED_OBJECT(locator, add_bbox)
TRAMPOLINE_WRAPPED_OBJECT(locator, add_from_db)
Expand Down Expand Up @@ -83,7 +83,7 @@ void lua_wrapper_locator::init(lua_State *lua_state,
lua_pushvalue(lua_state, -1);
lua_setfield(lua_state, -2, "__index");
luaX_add_table_func(lua_state, "__tostring",
lua_trampoline_locator___tostring);
lua_trampoline_locator_tostring);
luaX_add_table_func(lua_state, "name", lua_trampoline_locator_name);
luaX_add_table_func(lua_state, "add_bbox", lua_trampoline_locator_add_bbox);
luaX_add_table_func(lua_state, "add_from_db",
Expand All @@ -96,7 +96,7 @@ void lua_wrapper_locator::init(lua_State *lua_state,
lua_pop(lua_state, 2);
}

int lua_wrapper_locator::__tostring() const
int lua_wrapper_locator::tostring() const
{
std::string const str{fmt::format("osm2pgsql.Locator[name={},size={}]",
self().name(), self().size())};
Expand Down
2 changes: 1 addition & 1 deletion src/flex-lua-locator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class lua_wrapper_locator : public lua_wrapper_base<locator_t>
{
}

int __tostring() const;
int tostring() const;
int name() const;
int add_bbox();
int add_from_db();
Expand Down
6 changes: 3 additions & 3 deletions src/flex-lua-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void setup_flex_table_indexes(lua_State *lua_state, flex_table_t *table,
lua_pop(lua_state, 1); // "indexes"
}

TRAMPOLINE_WRAPPED_OBJECT(table, __tostring)
TRAMPOLINE_WRAPPED_OBJECT(table, tostring)
TRAMPOLINE_WRAPPED_OBJECT(table, cluster)
TRAMPOLINE_WRAPPED_OBJECT(table, columns)
TRAMPOLINE_WRAPPED_OBJECT(table, name)
Expand Down Expand Up @@ -469,7 +469,7 @@ void lua_wrapper_table::init(lua_State *lua_state)
lua_pushvalue(lua_state, -1);
lua_setfield(lua_state, -2, "__index");
luaX_add_table_func(lua_state, "__tostring",
lua_trampoline_table___tostring);
lua_trampoline_table_tostring);
luaX_add_table_func(lua_state, "insert", lua_trampoline_table_insert);
luaX_add_table_func(lua_state, "name", lua_trampoline_table_name);
luaX_add_table_func(lua_state, "schema", lua_trampoline_table_schema);
Expand All @@ -479,7 +479,7 @@ void lua_wrapper_table::init(lua_State *lua_state)
lua_pop(lua_state, 2);
}

int lua_wrapper_table::__tostring() const
int lua_wrapper_table::tostring() const
{
std::string const str{fmt::format("osm2pgsql.Table[{}]", self().name())};
luaX_pushstring(lua_state(), str);
Expand Down
2 changes: 1 addition & 1 deletion src/flex-lua-table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class lua_wrapper_table : public lua_wrapper_base<flex_table_t>
{
}

int __tostring() const;
int tostring() const;
int cluster() const;
int columns() const;
int name() const;
Expand Down
1 change: 1 addition & 0 deletions src/flex-lua-wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <cassert>
#include <exception>

// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define TRAMPOLINE_WRAPPED_OBJECT(obj_name, func_name) \
int lua_trampoline_##obj_name##_##func_name(lua_State *lua_state) \
{ \
Expand Down
4 changes: 1 addition & 3 deletions src/gen/gen-discrete-isolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ FROM {src} WHERE {importance_column} > 0
double const dx = coords[m].first - coords[n].first;
double const dy = coords[m].second - coords[n].second;
double const dist = dx * dx + dy * dy;
if (dist < min) {
min = dist;
}
min = std::min(dist, min);
}
data[n].di = std::sqrt(min);
}
Expand Down
34 changes: 9 additions & 25 deletions src/geom-box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@

#include "geom-box.hpp"

#include <algorithm>
#include <variant>

namespace geom {

box_t &box_t::extend(point_t const &point) noexcept
{
if (point.x() < m_min_x) {
m_min_x = point.x();
}
if (point.y() < m_min_y) {
m_min_y = point.y();
}
if (point.x() > m_max_x) {
m_max_x = point.x();
}
if (point.y() > m_max_y) {
m_max_y = point.y();
}

m_min_x = std::min(point.x(), m_min_x);
m_min_y = std::min(point.y(), m_min_y);
m_max_x = std::max(point.x(), m_max_x);
m_max_y = std::max(point.y(), m_max_y);
return *this;
}

Expand All @@ -40,18 +32,10 @@ void box_t::extend(point_list_t const &list) noexcept

void box_t::extend(box_t const &box) noexcept
{
if (box.min_x() < m_min_x) {
m_min_x = box.min_x();
}
if (box.min_y() < m_min_y) {
m_min_y = box.min_y();
}
if (box.max_x() > m_max_x) {
m_max_x = box.max_x();
}
if (box.max_y() > m_max_y) {
m_max_y = box.max_y();
}
m_min_x = std::min(box.min_x(), m_min_x);
m_min_y = std::min(box.min_y(), m_min_y);
m_max_x = std::max(box.max_x(), m_max_x);
m_max_y = std::max(box.max_y(), m_max_y);
}

box_t envelope(geom::nullgeom_t const & /*geom*/) { return box_t{}; }
Expand Down
8 changes: 2 additions & 6 deletions src/geom-pole-of-inaccessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ bool point_to_ring_distance_squared(point_t point, ring_t const &ring,

double const d =
point_to_segment_distance_squared(point, a, b, stretch);
if (d < *min_dist_squared) {
*min_dist_squared = d;
}
*min_dist_squared = std::min(d, *min_dist_squared);
}

return inside;
Expand Down Expand Up @@ -158,9 +156,7 @@ point_t pole_of_inaccessibility(const polygon_t &polygon, double precision,

double const min_precision =
std::max(envelope.width(), envelope.height()) / 1000.0;
if (min_precision > precision) {
precision = min_precision;
}
precision = std::max(min_precision, precision);

box_t const stretched_envelope{envelope.min_x(), envelope.min_y() * stretch,
envelope.max_x(),
Expand Down
4 changes: 4 additions & 0 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@

#include <osmium/thread/util.hpp>

namespace {

thread_local unsigned int this_thread_num = 0;

/// Global logger singleton
logger the_logger{};

} // anonymous namespace

/// Access the global logger singleton
logger &get_logger() noexcept { return the_logger; }

Expand Down
2 changes: 1 addition & 1 deletion src/params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class params_t
typename K, typename V,
std::enable_if_t<!std::is_arithmetic_v<std::remove_reference_t<V>>,
bool> = true>
void set(K &&key, V &&value)
void set(K &&key, V const &value)
{
m_map.insert_or_assign(std::forward<K>(key), std::string(value));
}
Expand Down