Skip to content

Commit 6072cb3

Browse files
authored
Merge pull request #1350 from joto/cleanups
Various Cleanups
2 parents 0a23889 + 5cdd8c7 commit 6072cb3

File tree

7 files changed

+22
-54
lines changed

7 files changed

+22
-54
lines changed

src/input-handler.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,8 @@ input_handler_t::input_handler_t(osmium::Box const &bbox, bool append,
1010
: m_data(osmdata), m_bbox(bbox), m_append(append)
1111
{}
1212

13-
void input_handler_t::negative_id_warning()
14-
{
15-
fmt::print(
16-
stderr,
17-
"\nWARNING: The input file contains at least one object with a\n"
18-
" negative id. Negative ids are not properly supported\n"
19-
" in osm2pgsql (and never were). They will not work in\n"
20-
" future versions at all. You can use the osmium tool to\n"
21-
" 'renumber' your file.\n\n");
22-
m_issued_warning_negative_id = true;
23-
}
24-
2513
void input_handler_t::node(osmium::Node const &node)
2614
{
27-
if (node.id() < 0 && !m_issued_warning_negative_id) {
28-
negative_id_warning();
29-
}
30-
3115
if (m_type != osmium::item_type::node) {
3216
m_type = osmium::item_type::node;
3317
m_data->flush();
@@ -62,10 +46,6 @@ void input_handler_t::node(osmium::Node const &node)
6246

6347
void input_handler_t::way(osmium::Way &way)
6448
{
65-
if (way.id() < 0 && !m_issued_warning_negative_id) {
66-
negative_id_warning();
67-
}
68-
6949
if (m_type != osmium::item_type::way) {
7050
m_type = osmium::item_type::way;
7151
m_data->flush();
@@ -89,10 +69,6 @@ void input_handler_t::way(osmium::Way &way)
8969

9070
void input_handler_t::relation(osmium::Relation const &rel)
9171
{
92-
if (rel.id() < 0 && !m_issued_warning_negative_id) {
93-
negative_id_warning();
94-
}
95-
9672
if (m_type != osmium::item_type::relation) {
9773
m_type = osmium::item_type::relation;
9874
m_data->flush();

src/input-handler.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class input_handler_t : public osmium::handler::Handler
3636
progress_display_t const &progress() const noexcept { return m_progress; }
3737

3838
private:
39-
void negative_id_warning();
40-
4139
osmdata_t const *m_data;
4240

4341
// Bounding box for node import (or invalid Box if everything should be
@@ -52,9 +50,6 @@ class input_handler_t : public osmium::handler::Handler
5250

5351
// Are we running in append mode?
5452
bool m_append;
55-
56-
// Has a warning about a negative id already been issued?
57-
bool m_issued_warning_negative_id = false;
5853
};
5954

6055
#endif // OSM2PGSQL_INPUT_HANDLER_HPP

src/middle-pgsql.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ middle_pgsql_t::middle_pgsql_t(options_t const *options)
760760
bool const has_bucket_index =
761761
check_bucket_index(&m_db_connection, options->prefix);
762762

763-
if (!has_bucket_index && options->append) {
763+
if (!has_bucket_index && options->append &&
764+
options->with_forward_dependencies) {
764765
log_warn("You don't have a bucket index. See manual for details.");
765766
}
766767

src/node-ram-cache.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,9 @@ void node_ram_cache::set_dense(osmid_t id, osmium::Location location)
240240
}
241241

242242
if (queue[expectedpos] != &blocks[block]) {
243-
if (m_warn_node_order) {
244-
log_warn("Found out of order node {}"
245-
" ({},{}) - this will impact the cache efficiency",
246-
id, block, offset);
247-
248-
// Only warn once
249-
m_warn_node_order = false;
250-
}
243+
// This can only happen if the node is out of order which it
244+
// should never be because of earlier checks for that.
245+
// Ignore the node.
251246
return;
252247
}
253248
}

src/node-ram-cache.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ class node_ram_cache
124124
osmid_t totalNodes = 0;
125125
long nodesCacheHits = 0;
126126
long nodesCacheLookups = 0;
127-
128-
bool m_warn_node_order = true;
129127
};
130128

131129
#endif // OSM2PGSQL_NODE_RAM_CACHE_HPP

src/options.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,17 @@ options_t::options_t(int argc, char *argv[]) : options_t()
556556
break;
557557
case 205:
558558
num_procs = atoi(optarg);
559+
if (num_procs < 1) {
560+
log_warn("--number-processes must be at least 1. Using 1.");
561+
num_procs = 1;
562+
} else if (num_procs > 32) {
563+
// The threads will open up database connections which will
564+
// run out at some point. It depends on the number of tables
565+
// how many connections there are. The number 32 is way beyond
566+
// anything that will make sense here.
567+
log_warn("--number-processes too large. Set to 32.");
568+
num_procs = 32;
569+
}
559570
break;
560571
case 206:
561572
droptemp = true;
@@ -706,7 +717,8 @@ void options_t::check_options()
706717

707718
if (enable_hstore_index && hstore_mode == hstore_column::none &&
708719
hstore_columns.empty()) {
709-
log_warn("--hstore-add-index only makes sense with hstore enabled.");
720+
log_warn("--hstore-add-index only makes sense with hstore enabled; "
721+
"ignored.");
710722
enable_hstore_index = false;
711723
}
712724

@@ -726,24 +738,14 @@ void options_t::check_options()
726738
}
727739
}
728740

729-
if (num_procs < 1) {
730-
num_procs = 1;
731-
log_warn("Must use at least 1 process.");
732-
}
733-
734-
if (sizeof(int *) == 4 && !slim) {
735-
log_warn(
736-
"This is a 32bit system with not a lot of RAM. Try using --slim.");
737-
}
738-
739741
// zoom level 31 is the technical limit because we use 32-bit integers for the x and y index of a tile ID
740-
if (expire_tiles_zoom_min >= 32) {
742+
if (expire_tiles_zoom_min > 31) {
741743
expire_tiles_zoom_min = 31;
742744
log_warn("Minimum zoom level for tile expiry is too "
743745
"large and has been set to 31.");
744746
}
745747

746-
if (expire_tiles_zoom >= 32) {
748+
if (expire_tiles_zoom > 31) {
747749
expire_tiles_zoom = 31;
748750
log_warn("Maximum zoom level for tile expiry is too "
749751
"large and has been set to 31.");

src/osm2pgsql.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ prepare_input_files(options_t const &options)
6464
if (file.format() == osmium::io::file_format::unknown) {
6565
if (options.input_format.empty()) {
6666
throw std::runtime_error{
67-
"Cannot detect file format. Try using -r."};
67+
"Cannot detect file format for '{}'. Try using -r."_format(
68+
filename)};
6869
}
6970
throw std::runtime_error{
7071
"Unknown file format '{}'."_format(options.input_format)};

0 commit comments

Comments
 (0)