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
7 changes: 4 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
Language: Cpp
BasedOnStyle: LLVM
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
BreakBeforeBraces: Mozilla
IndentWidth: 4
IndentWidth: 4
ConstructorInitializerIndentWidth: 0
ReflowComments: false
AlwaysBreakTemplateDeclarations: true
QualifierAlignment: Right
3 changes: 2 additions & 1 deletion src/command-line-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/db-copy-mgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class db_copy_mgr_t
* following the delete_object() are inserted.
*/
template <typename... ARGS>
void delete_object(ARGS &&... args)
void delete_object(ARGS &&...args)
{
assert(m_current);
m_current.add_deletable(std::forward<ARGS>(args)...);
Expand Down
2 changes: 1 addition & 1 deletion src/db-copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class db_cmd_copy_delete_t : public db_cmd_copy_t
}

template <typename... ARGS>
void add_deletable(ARGS &&... args)
void add_deletable(ARGS &&...args)
{
m_deleter.add(std::forward<ARGS>(args)...);
}
Expand Down
3 changes: 2 additions & 1 deletion src/expire-tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 1 addition & 4 deletions src/flex-index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
2 changes: 1 addition & 1 deletion src/flex-lua-locator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions src/flex-lua-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/flex-table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand All @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion src/geom-area-assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 5 additions & 17 deletions src/geom-boost-adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <>
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/geom-from-osm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions src/geom-pole-of-inaccessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -166,7 +167,7 @@ point_t pole_of_inaccessibility(polygon_t const &polygon, double precision,
return envelope.min();
}

std::priority_queue<Cell, std::vector<Cell>> cell_queue;
std::priority_queue<cell_t, std::vector<cell_t>> cell_queue;

// cover polygon with initial cells
if (stretched_envelope.width() == stretched_envelope.height()) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/middle-pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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()) {
Expand Down Expand Up @@ -1270,8 +1272,7 @@ void middle_pgsql_t::set_requirements(
log_debug(" with_attributes: {}", m_store_options.with_attributes);
}

std::shared_ptr<middle_query_t>
middle_pgsql_t::get_query_instance()
std::shared_ptr<middle_query_t> 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
Expand Down
3 changes: 1 addition & 2 deletions src/middle-ram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<osmium::Way>(offset));
buffer->commit();
Expand Down
3 changes: 2 additions & 1 deletion src/node-locations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*/;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ordered-index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void ordered_index_t::add(osmid_t id, std::size_t offset)
++m_size;
}

std::pair<osmid_t, std::size_t> ordered_index_t::get_internal(osmid_t id) const
noexcept
std::pair<osmid_t, std::size_t>
ordered_index_t::get_internal(osmid_t id) const noexcept
{
if (m_ranges.empty()) {
return {0, not_found_value()};
Expand Down
2 changes: 1 addition & 1 deletion src/osmtypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class taglist_t

/// Add tag to list without checking for duplicates
template <typename T>
void add_tag(char const *key, T&& value)
void add_tag(char const *key, T &&value)
{
m_tags.emplace_back(key, std::forward<T>(value));
}
Expand Down
13 changes: 8 additions & 5 deletions src/output-flex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<osmium::Relation const &>(object);
auto const &relation =
static_cast<osmium::Relation const &>(object);
luaX_add_table_array(
lua_state, "members", relation.members(),
[&](osmium::RelationMember const &member) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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,
Expand Down
Loading
Loading