Various code cleanups

* Fix typos
* Modernize C++
* Fix clang-tidy warnings
* Formatting cleanups
This commit is contained in:
Jochen Topf
2020-03-25 09:06:32 +01:00
parent 7892613cd7
commit e2b6d1afe7
22 changed files with 126 additions and 129 deletions

View File

@ -13,7 +13,7 @@ template <typename DELETER>
class db_copy_mgr_t
{
public:
db_copy_mgr_t(std::shared_ptr<db_copy_thread_t> const &processor)
explicit db_copy_mgr_t(std::shared_ptr<db_copy_thread_t> const &processor)
: m_processor(processor)
{}
@ -49,7 +49,7 @@ public:
// Expect that a column has been written last which ended in a '\t'.
// Replace it with the row delimiter '\n'.
auto sz = buf.size();
auto const sz = buf.size();
assert(buf[sz - 1] == '\t');
buf[sz - 1] = '\n';
@ -67,7 +67,7 @@ public:
void add_columns(T value, ARGS &&... args)
{
add_column(value);
add_columns(args...);
add_columns(std::forward<ARGS>(args)...);
}
template <typename T>
@ -79,7 +79,7 @@ public:
/**
* Add a column entry of simple type.
*
* Writes the column with the escaping apporpriate for the type and
* Writes the column with the escaping appropriate for the type and
* a column delimiter.
*/
template <typename T>
@ -136,7 +136,7 @@ public:
*/
void finish_array()
{
auto idx = m_current->buffer.size() - 1;
auto const idx = m_current->buffer.size() - 1;
if (m_current->buffer[idx] == '{')
m_current->buffer += '}';
else
@ -222,7 +222,7 @@ public:
*/
void finish_hash()
{
auto idx = m_current->buffer.size() - 1;
auto const idx = m_current->buffer.size() - 1;
if (!m_current->buffer.empty() && m_current->buffer[idx] == ',') {
m_current->buffer[idx] = '\t';
} else {
@ -237,7 +237,7 @@ public:
*/
void add_hex_geom(std::string const &wkb)
{
char const *lookup_hex = "0123456789ABCDEF";
char const *const lookup_hex = "0123456789ABCDEF";
for (char c : wkb) {
m_current->buffer += lookup_hex[(c >> 4) & 0xf];

View File

@ -225,7 +225,7 @@ struct db_cmd_finish_t : public db_cmd_t
class db_copy_thread_t
{
public:
db_copy_thread_t(std::string const &conninfo);
explicit db_copy_thread_t(std::string const &conninfo);
db_copy_thread_t(db_copy_thread_t const &) = delete;
db_copy_thread_t &operator=(db_copy_thread_t const &) = delete;

View File

@ -6,7 +6,6 @@
#include <cstring>
#include <string>
/**
* Returns the tag specific name, if applicable.
*

View File

@ -452,7 +452,7 @@ void expire_tiles::merge_and_destroy(expire_tiles &other)
tile_width, other.tile_width)};
}
if (m_dirty_tiles.size() == 0) {
if (m_dirty_tiles.empty()) {
m_dirty_tiles = std::move(other.m_dirty_tiles);
} else {
m_dirty_tiles.insert(other.m_dirty_tiles.begin(),

View File

@ -17,7 +17,7 @@ enum : int
MAX_ADMINLEVEL = 15
};
}
} // anonymous namespace
namespace pt = boost::property_tree;

View File

@ -20,17 +20,17 @@ namespace {
*/
struct block
{
block() : bits(BLOCK_SIZE >> 5, 0) {}
block() : bits(BLOCK_SIZE >> 5U, 0) {}
inline bool operator[](size_t i) const
{
return (bits[i >> 5] & (1 << (i & 0x1f))) > 0;
return (bits[i >> 5U] & (1U << (i & 0x1fU))) > 0;
}
//returns true if the value actually caused a bit to flip
inline bool set(size_t i, bool value)
{
uint32_t &bit = bits[i >> 5];
uint32_t &bit = bits[i >> 5U];
uint32_t old = bit;
uint32_t mask = 1 << (i & 0x1f);
uint32_t mask = 1U << (i & 0x1fU);
//allow the bit to become 1 if not already
if (value) {
bit |= mask;
@ -48,20 +48,20 @@ struct block
// returns BLOCK_SIZE if a set bit isn't found
size_t next_set(size_t start) const
{
uint32_t bit_i = start >> 5;
uint32_t bit_i = start >> 5U;
while ((bit_i < (BLOCK_SIZE >> 5)) && (bits[bit_i] == 0)) {
while ((bit_i < (BLOCK_SIZE >> 5U)) && (bits[bit_i] == 0)) {
++bit_i;
}
if (bit_i >= (BLOCK_SIZE >> 5)) {
if (bit_i >= (BLOCK_SIZE >> 5U)) {
return BLOCK_SIZE;
}
uint32_t bit = bits[bit_i];
size_t idx = bit_i << 5;
while ((bit & 1) == 0) {
size_t idx = bit_i << 5U;
while ((bit & 1U) == 0) {
++idx;
bit >>= 1;
bit >>= 1U;
}
return idx;
}
@ -80,7 +80,7 @@ struct id_tracker::pimpl
bool set(osmid_t id, bool value);
osmid_t pop_min();
typedef std::map<osmid_t, block> map_t;
using map_t = std::map<osmid_t, block>;
map_t pending;
osmid_t old_id;
size_t count;
@ -92,21 +92,22 @@ struct id_tracker::pimpl
bool id_tracker::pimpl::get(osmid_t id) const
{
const osmid_t block = id >> BLOCK_BITS, offset = id & BLOCK_MASK;
map_t::const_iterator itr = pending.find(block);
bool result = false;
osmid_t const block = id >> BLOCK_BITS;
osmid_t const offset = id & BLOCK_MASK;
auto const itr = pending.find(block);
if (itr != pending.end()) {
result = itr->second[offset];
if (itr == pending.end()) {
return false;
}
return result;
return itr->second[offset];
}
bool id_tracker::pimpl::set(osmid_t id, bool value)
{
const osmid_t block = id >> BLOCK_BITS, offset = id & BLOCK_MASK;
bool flipped = pending[block].set(offset, value);
osmid_t const block = id >> BLOCK_BITS;
osmid_t const offset = id & BLOCK_MASK;
bool const flipped = pending[block].set(offset, value);
// a set may potentially invalidate a next_start, as the bit
// set might be before the position of next_start.
if (next_start) {

View File

@ -565,8 +565,8 @@ void middle_pgsql_t::relations_set(osmium::Relation const &rel)
// parts
m_db_copy.new_array();
for (int i = 0; i < 3; ++i) {
for (auto it : parts[i]) {
for (auto const &part : parts) {
for (auto it : part) {
m_db_copy.add_array_elem(it);
}
}
@ -813,9 +813,9 @@ middle_pgsql_t::get_query_instance(std::shared_ptr<middle_t> const &from) const
// NOTE: this is thread safe for use in pending async processing only because
// during that process they are only read from
std::unique_ptr<middle_query_pgsql_t> mid(new middle_query_pgsql_t(
src->out_options->database_options.conninfo().c_str(), src->cache,
src->persistent_cache));
std::unique_ptr<middle_query_pgsql_t> mid(new middle_query_pgsql_t{
src->out_options->database_options.conninfo(), src->cache,
src->persistent_cache});
// We use a connection per table to enable the use of COPY
for (int i = 0; i < NUM_TABLES; ++i) {

View File

@ -202,8 +202,9 @@ void long_usage(char *arg0, bool verbose = false)
pbf - OSM binary format.\n\
-O|--output Output backend.\n\
pgsql - Output to a PostGIS database (default)\n\
flex - More flexible output to PostGIS database\n\
multi - Multiple Custom Table Output to a PostGIS \n\
database (requires style file for configuration)\n\
database (deprecated)\n\
gazetteer - Output to a PostGIS database for Nominatim\n\
null - No output. Useful for testing. Still creates tables if --slim is specified.\n");
#ifdef HAVE_LUA
@ -345,7 +346,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
#ifdef HAVE_GENERIC_PROJ
projection = reprojection::create_projection(atoi(optarg));
#else
throw std::runtime_error("Generic projections not available.");
throw std::runtime_error{"Generic projections not available."};
#endif
break;
case 'p':
@ -389,18 +390,18 @@ options_t::options_t(int argc, char *argv[]) : options_t()
break;
case 'e':
if (!optarg || optarg[0] == '-') {
throw std::runtime_error(
throw std::runtime_error{
"Missing argument for option --expire-tiles. Zoom "
"levels must be positive.\n");
"levels must be positive.\n"};
}
char *next_char;
expire_tiles_zoom_min =
static_cast<uint32_t>(std::strtoul(optarg, &next_char, 10));
if (expire_tiles_zoom_min == 0) {
throw std::runtime_error(
throw std::runtime_error{
"Bad argument for option --expire-tiles. "
"Minimum zoom level must be larger "
"than 0.\n");
"than 0.\n"};
}
// The first character after the number is ignored because that is the separating hyphen.
if (*next_char == '-') {
@ -411,20 +412,20 @@ options_t::options_t(int argc, char *argv[]) : options_t()
expire_tiles_zoom = static_cast<uint32_t>(
std::strtoul(next_char, &after_maxzoom, 10));
if (expire_tiles_zoom == 0 || *after_maxzoom != '\0') {
throw std::runtime_error("Invalid maximum zoom level "
"given for tile expiry.\n");
throw std::runtime_error{"Invalid maximum zoom level "
"given for tile expiry.\n"};
}
} else {
throw std::runtime_error(
"Invalid maximum zoom level given for tile expiry.\n");
throw std::runtime_error{
"Invalid maximum zoom level given for tile expiry.\n"};
}
} else if (*next_char == '\0') {
// end of string, no second zoom level given
expire_tiles_zoom = expire_tiles_zoom_min;
} else {
throw std::runtime_error("Minimum and maximum zoom level for "
throw std::runtime_error{"Minimum and maximum zoom level for "
"tile expiry must be separated by "
"'-'.\n");
"'-'.\n"};
}
break;
case 'o':
@ -446,8 +447,8 @@ options_t::options_t(int argc, char *argv[]) : options_t()
break;
case 'k':
if (hstore_mode != HSTORE_NONE) {
throw std::runtime_error("You can not specify both --hstore "
"(-k) and --hstore-all (-j)\n");
throw std::runtime_error{"You can not specify both --hstore "
"(-k) and --hstore-all (-j)\n"};
}
hstore_mode = HSTORE_NORM;
break;
@ -456,13 +457,13 @@ options_t::options_t(int argc, char *argv[]) : options_t()
break;
case 'j':
if (hstore_mode != HSTORE_NONE) {
throw std::runtime_error("You can not specify both --hstore "
"(-k) and --hstore-all (-j)\n");
throw std::runtime_error{"You can not specify both --hstore "
"(-k) and --hstore-all (-j)\n"};
}
hstore_mode = HSTORE_ALL;
break;
case 'z':
hstore_columns.push_back(optarg);
hstore_columns.emplace_back(optarg);
break;
case 'G':
enable_multi = true;
@ -477,13 +478,13 @@ options_t::options_t(int argc, char *argv[]) : options_t()
parallel_indexing = false;
break;
case 204:
if (strcmp(optarg, "dense") == 0) {
if (std::strcmp(optarg, "dense") == 0) {
alloc_chunkwise = ALLOC_DENSE;
} else if (strcmp(optarg, "chunk") == 0) {
} else if (std::strcmp(optarg, "chunk") == 0) {
alloc_chunkwise = ALLOC_DENSE | ALLOC_DENSE_CHUNK;
} else if (strcmp(optarg, "sparse") == 0) {
} else if (std::strcmp(optarg, "sparse") == 0) {
alloc_chunkwise = ALLOC_SPARSE;
} else if (strcmp(optarg, "optimized") == 0) {
} else if (std::strcmp(optarg, "optimized") == 0) {
alloc_chunkwise = ALLOC_DENSE | ALLOC_SPARSE;
} else {
throw std::runtime_error{
@ -543,7 +544,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
//get the input files
while (optind < argc) {
input_files.push_back(std::string(argv[optind]));
input_files.emplace_back(argv[optind]);
optind++;
}
@ -566,19 +567,19 @@ options_t::options_t(int argc, char *argv[]) : options_t()
void options_t::check_options()
{
if (append && create) {
throw std::runtime_error("--append and --create options can not be "
"used at the same time!\n");
throw std::runtime_error{"--append and --create options can not be "
"used at the same time!\n"};
}
if (append && !slim) {
throw std::runtime_error("--append can only be used with slim mode!\n");
throw std::runtime_error{"--append can only be used with slim mode!\n"};
}
if (droptemp && !slim) {
throw std::runtime_error("--drop only makes sense with --slim.\n");
throw std::runtime_error{"--drop only makes sense with --slim.\n"};
}
if (hstore_mode == HSTORE_NONE && hstore_columns.size() == 0 &&
if (hstore_mode == HSTORE_NONE && hstore_columns.empty() &&
hstore_match_only) {
fprintf(stderr,
"Warning: --hstore-match-only only makes sense with --hstore, "
@ -587,7 +588,7 @@ void options_t::check_options()
}
if (enable_hstore_index && hstore_mode == HSTORE_NONE &&
hstore_columns.size() == 0) {
hstore_columns.empty()) {
fprintf(stderr, "Warning: --hstore-add-index only makes sense with "
"hstore enabled.\n");
enable_hstore_index = false;
@ -601,8 +602,8 @@ void options_t::check_options()
if (cache == 0) {
if (!slim) {
throw std::runtime_error(
"Ram node cache can only be disable in slim mode.\n");
throw std::runtime_error{
"Ram node cache can only be disable in slim mode.\n"};
}
if (!flat_node_cache_enabled) {
fprintf(stderr, "WARNING: ram cache is disabled. This will likely "

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
*/
parse_stats_t stats;
//read in the input files one by one
for (auto const filename : options.input_files) {
for (auto const &filename : options.input_files) {
//read the actual input
fprintf(stderr, "\nReading in file: %s\n", filename.c_str());
time_t start = time(nullptr);

View File

@ -245,7 +245,7 @@ struct pending_threaded_processor : public middle_t::pending_processor
~pending_threaded_processor() {}
void enqueue_ways(osmid_t id)
void enqueue_ways(osmid_t id) override
{
for (size_t i = 0; i < outs.size(); ++i) {
outs[i]->enqueue_ways(queue, id, i, ids_queued);
@ -253,7 +253,7 @@ struct pending_threaded_processor : public middle_t::pending_processor
}
//waits for the completion of all outstanding jobs
void process_ways()
void process_ways() override
{
//reset the number we've done
ids_done = 0;
@ -315,14 +315,14 @@ struct pending_threaded_processor : public middle_t::pending_processor
}
}
void enqueue_relations(osmid_t id)
void enqueue_relations(osmid_t id) override
{
for (size_t i = 0; i < outs.size(); ++i) {
outs[i]->enqueue_relations(queue, id, i, ids_queued);
}
}
void process_relations()
void process_relations() override
{
//reset the number we've done
ids_done = 0;

View File

@ -378,28 +378,28 @@ osmium_builder_t::create_polygons(osmium::Area const &area)
try {
size_t num_rings = 0;
for (auto it = area.cbegin(); it != area.cend(); ++it) {
if (it->type() == osmium::item_type::outer_ring) {
auto &ring = static_cast<const osmium::OuterRing &>(*it);
for (const auto &item : area) {
if (item.type() == osmium::item_type::outer_ring) {
auto const &ring = static_cast<const osmium::OuterRing &>(item);
if (num_rings > 0) {
ret.push_back(m_writer.polygon_finish(num_rings));
num_rings = 0;
}
m_writer.polygon_start();
m_writer.polygon_ring_start();
auto num_points = add_mp_points(ring);
auto const num_points = add_mp_points(ring);
m_writer.polygon_ring_finish(num_points);
++num_rings;
} else if (it->type() == osmium::item_type::inner_ring) {
auto &ring = static_cast<const osmium::InnerRing &>(*it);
} else if (item.type() == osmium::item_type::inner_ring) {
auto const &ring = static_cast<const osmium::InnerRing &>(item);
m_writer.polygon_ring_start();
auto num_points = add_mp_points(ring);
auto const num_points = add_mp_points(ring);
m_writer.polygon_ring_finish(num_points);
++num_rings;
}
}
auto wkb = m_writer.polygon_finish(num_rings);
auto const wkb = m_writer.polygon_finish(num_rings);
if (num_rings > 0) {
ret.push_back(wkb);
}

View File

@ -18,7 +18,7 @@
#include <osmium/geom/coordinates.hpp>
#include <osmium/osm.hpp>
typedef int64_t osmid_t;
using osmid_t = std::int64_t;
#define strtoosmid strtoll
#define PRIdOSMID PRId64
#define POSTGRES_OSMID_TYPE "int8"

View File

@ -913,8 +913,8 @@ void output_flex_t::pending_way(osmid_t id, int exists)
if (exists) {
way_delete(id);
auto const rel_ids = m_mid->relations_using_way(id);
for (auto const id : rel_ids) {
m_rels_pending_tracker.mark(id);
for (auto const rel_id : rel_ids) {
m_rels_pending_tracker.mark(rel_id);
}
}

View File

@ -212,7 +212,7 @@ void output_multi_t::relation_add(osmium::Relation const &rel)
{
if (m_processor->interests(geometry_processor::interest_relation) &&
!rel.members().empty()) {
process_relation(rel, 0);
process_relation(rel, false);
}
}
@ -299,11 +299,9 @@ void output_multi_t::reprocess_way(osmium::Way *way, bool exists)
if (m_processor->interests(geometry_processor::interest_relation) &&
exists) {
way_delete(way->id());
const std::vector<osmid_t> rel_ids =
m_mid->relations_using_way(way->id());
for (std::vector<osmid_t>::const_iterator itr = rel_ids.begin();
itr != rel_ids.end(); ++itr) {
rels_pending_tracker.mark(*itr);
auto const rel_ids = m_mid->relations_using_way(way->id());
for (auto const rel_id : rel_ids) {
rels_pending_tracker.mark(rel_id);
}
}
@ -382,7 +380,7 @@ void output_multi_t::process_relation(osmium::Relation const &rel, bool exists)
m_relation_helper.add_way_locations(m_mid.get());
auto geoms = m_processor->process_relation(
rel, m_relation_helper.data, &m_builder);
for (const auto geom : geoms) {
for (const auto &geom : geoms) {
copy_to_table(-rel.id(), geom, outtags);
}
}

View File

@ -64,7 +64,8 @@ public:
*/
std::string get_value_as_string(int row, int col) const noexcept
{
return std::string(get_value(row, col), (std::size_t)get_length(row, col));
return std::string(get_value(row, col),
(std::size_t)get_length(row, col));
}
/**

View File

@ -14,6 +14,7 @@ public:
wkbs_t process_relation(osmium::Relation const &rel,
osmium::memory::Buffer const &ways,
geom::osmium_builder_t *builder) override;
private:
bool m_build_multigeoms;
};

View File

@ -4,5 +4,5 @@
std::shared_ptr<reprojection> reprojection::make_generic_projection(int srs)
{
throw std::runtime_error("No generic projection library available.");
throw std::runtime_error{"No generic projection library available."};
}

View File

@ -10,7 +10,7 @@ namespace {
class generic_reprojection_t : public reprojection
{
public:
generic_reprojection_t(int srs)
explicit generic_reprojection_t(int srs)
: m_target_srs(srs), pj_target(srs), pj_source(PROJ_LATLONG),
pj_tile(
"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 "
@ -58,5 +58,5 @@ private:
std::shared_ptr<reprojection> reprojection::make_generic_projection(int srs)
{
return std::shared_ptr<reprojection>(new generic_reprojection_t(srs));
return std::shared_ptr<reprojection>(new generic_reprojection_t{srs});
}

View File

@ -24,7 +24,7 @@ table_t::table_t(std::string const &name, std::string const &type,
m_copy(copy_thread)
{
// if we dont have any columns
if (columns.size() == 0 && hstore_mode != HSTORE_ALL) {
if (columns.empty() && hstore_mode != HSTORE_ALL) {
throw std::runtime_error{
"No columns provided for table {}"_format(name)};
}
@ -450,13 +450,13 @@ void table_t::escape_type(const std::string &value, ColumnType flags)
int items = sscanf(escaped.c_str(), "%lf-%lf", &from, &to);
if (items == 1) {
if (escaped.size() > 1 &&
escaped.substr(escaped.size() - 2).compare("ft") == 0) {
escaped.substr(escaped.size() - 2) == "ft") {
from *= 0.3048;
}
m_copy.add_column(from);
} else if (items == 2) {
if (escaped.size() > 1 &&
escaped.substr(escaped.size() - 2).compare("ft") == 0) {
escaped.substr(escaped.size() - 2) == "ft") {
from *= 0.3048;
to *= 0.3048;
}

View File

@ -35,12 +35,12 @@ static const unsigned int nLayers = (sizeof(layers) / sizeof(*layers));
void add_z_order(taglist_t &tags, int *roads)
{
const std::string *layer = tags.get("layer");
const std::string *highway = tags.get("highway");
bool bridge = tags.get_bool("bridge", false);
bool tunnel = tags.get_bool("tunnel", false);
const std::string *railway = tags.get("railway");
const std::string *boundary = tags.get("boundary");
std::string const *const layer = tags.get("layer");
std::string const *const highway = tags.get("highway");
bool const bridge = tags.get_bool("bridge", false);
bool const tunnel = tags.get_bool("tunnel", false);
std::string const *const railway = tags.get("railway");
std::string const *const boundary = tags.get("boundary");
int z_order = 0;
@ -90,7 +90,7 @@ c_tagtransform_t::c_tagtransform_t(options_t const *options,
std::unique_ptr<tagtransform_t> c_tagtransform_t::clone() const
{
return std::unique_ptr<tagtransform_t>(
new c_tagtransform_t(m_options, m_export_list));
new c_tagtransform_t{m_options, m_export_list});
}
bool c_tagtransform_t::check_key(std::vector<taginfo> const &infos,
@ -98,14 +98,12 @@ bool c_tagtransform_t::check_key(std::vector<taginfo> const &infos,
bool strict)
{
//go through the actual tags found on the item and keep the ones in the export list
size_t i = 0;
for (; i < infos.size(); i++) {
const taginfo &info = infos[i];
for (auto const &info : infos) {
if (info.flags & FLAG_DELETE) {
if (wildMatch(info.name.c_str(), k)) {
return false;
}
} else if (strcmp(info.name.c_str(), k) == 0) {
} else if (std::strcmp(info.name.c_str(), k) == 0) {
*filter = false;
*flags |= info.flags;
@ -124,11 +122,10 @@ bool c_tagtransform_t::check_key(std::vector<taginfo> const &infos,
}
/* with hstore, copy all tags... */
return true;
} else if (m_options->hstore_columns.size() > 0) {
} else if (!m_options->hstore_columns.empty()) {
/* does this column match any of the hstore column prefixes? */
size_t j = 0;
for (; j < m_options->hstore_columns.size(); ++j) {
if (boost::starts_with(k, m_options->hstore_columns[j])) {
for (auto const &column : m_options->hstore_columns) {
if (boost::starts_with(k, column)) {
/* ... but if hstore_match_only is set then don't take this
as a reason for keeping the object */
if (!m_options->hstore_match_only) {
@ -156,23 +153,24 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
if (o.type() == osmium::item_type::relation) {
export_type = osmium::item_type::way;
}
const std::vector<taginfo> &infos = m_export_list.get(export_type);
auto const &infos = m_export_list.get(export_type);
/* We used to only go far enough to determine if it's a polygon or not,
but now we go through and filter stuff we don't need
pop each tag off and keep it in the temp list if we like it */
for (auto const &item : o.tags()) {
char const *k = item.key();
char const *v = item.value();
char const *const k = item.key();
char const *const v = item.value();
//if we want to do more than the export list says
if (!strict) {
if (o.type() == osmium::item_type::relation &&
strcmp("type", k) == 0) {
std::strcmp("type", k) == 0) {
out_tags.add_tag(k, v);
continue;
}
/* Allow named islands to appear as polygons */
if (strcmp("natural", k) == 0 && strcmp("coastline", v) == 0) {
if (std::strcmp("natural", k) == 0 &&
std::strcmp("coastline", v) == 0) {
add_area_tag = 1;
/* Discard natural=coastline tags (we render these from a shapefile instead) */
@ -219,7 +217,7 @@ bool c_tagtransform_t::filter_rel_member_tags(
taglist_t &out_tags, bool allow_typeless)
{
//if it has a relation figure out what kind it is
const std::string *type = rel_tags.get("type");
std::string const *type = rel_tags.get("type");
bool is_route = false, is_boundary = false, is_multipolygon = false;
if (type) {
//what kind of relation is it
@ -238,7 +236,7 @@ bool c_tagtransform_t::filter_rel_member_tags(
}
/* Clone tags from relation */
for (const auto &rel_tag : rel_tags) {
for (auto const &rel_tag : rel_tags) {
//copy the name tag as "route_name"
if (is_route && (rel_tag.key == "name")) {
out_tags.add_tag_if_not_exists("route_name", rel_tag.value);
@ -254,11 +252,11 @@ bool c_tagtransform_t::filter_rel_member_tags(
}
if (is_route) {
const std::string *netw = rel_tags.get("network");
std::string const *netw = rel_tags.get("network");
int networknr = -1;
if (netw != nullptr) {
const std::string *state = rel_tags.get("state");
std::string const *state = rel_tags.get("state");
std::string statetype("yes");
if (state) {
if (*state == "alternate") {
@ -288,7 +286,7 @@ bool c_tagtransform_t::filter_rel_member_tags(
}
}
const std::string *prefcol = rel_tags.get("preferred_color");
std::string const *prefcol = rel_tags.get("preferred_color");
if (prefcol != nullptr && prefcol->size() == 1) {
if ((*prefcol)[0] == '0' || (*prefcol)[0] == '1' ||
(*prefcol)[0] == '2' || (*prefcol)[0] == '3' ||
@ -301,7 +299,7 @@ bool c_tagtransform_t::filter_rel_member_tags(
out_tags.add_tag_if_not_exists("route_pref_color", "0");
}
const std::string *relref = rel_tags.get("ref");
std::string const *relref = rel_tags.get("ref");
if (relref != nullptr) {
if (networknr == 10) {
out_tags.add_tag_if_not_exists("lcn_ref", *relref);

View File

@ -43,7 +43,7 @@ void add_array(copy_mgr_t &mgr, std::shared_ptr<db_target_descr_t> t, int id,
mgr.new_line(t);
mgr.add_column(id);
mgr.new_array();
for (auto v : values) {
for (auto const &v : values) {
mgr.add_array_elem(v);
}
mgr.finish_array();

View File

@ -14,12 +14,12 @@ class xyz
public:
xyz(uint32_t z_, int64_t x_, int64_t y_) : z(z_), x(x_), y(y_) {}
bool operator==(xyz const &other) const
bool operator==(xyz const &other) const noexcept
{
return ((z == other.z) && (x == other.x) && (y == other.y));
}
bool operator<(xyz const &other) const
bool operator<(xyz const &other) const noexcept
{
if (z < other.z) {
return true;
@ -40,7 +40,7 @@ public:
return false;
}
void to_centroid(double &cx, double &cy) const
void to_centroid(double &cx, double &cy) const noexcept
{
double const datum = 0.5 * (1U << z);
double const scale = EARTH_CIRCUMFERENCE / (1U << z);
@ -55,8 +55,6 @@ private:
struct tile_output_set
{
~tile_output_set() = default;
bool operator==(tile_output_set const &other) const
{
return tiles == other.tiles;
@ -70,7 +68,7 @@ struct tile_output_set
void output_dirty_tile(int64_t x, int64_t y, uint32_t zoom)
{
tiles.insert(xyz(zoom, x, y));
tiles.insert(xyz{zoom, x, y});
}
void expire_centroids(expire_tiles &et)