Skip to content

Commit ce75b4c

Browse files
committed
Fix two-stage processing when flat node file is used
This is an additional fix to the fix in 8d1a55e. If a flat node file is used, nodes are not stored in the database (unless --middle-with-nodes is specified, but also then only nodes with tags are stored in the database). There are two problems here: 1. The "get_node" prepared statement was not prepared in this case, so it fails when executes. This is fixed by only executing that statement if m_store_options.nodes is set in the middle. 2. If there is no node in the database, there might still be one in the flat node file. So we need to try this and create the node from the information in there. (It will only have the node id and location in it, but at least we get the location.) This commit contains both fixes.
1 parent f872d39 commit ce75b4c

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/middle-pgsql.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -762,17 +762,33 @@ bool middle_query_pgsql_t::node_get(osmid_t id,
762762
{
763763
assert(buffer);
764764

765-
auto const res = m_db_connection.exec_prepared("get_node", id);
765+
if (m_store_options.nodes) {
766+
auto const res = m_db_connection.exec_prepared("get_node", id);
766767

767-
if (res.num_tuples() != 1) {
768-
return false;
768+
if (res.num_tuples() == 1) {
769+
build_node(id, res, 0, 0, buffer, m_store_options.with_attributes);
770+
buffer->commit();
771+
return true;
772+
}
769773
}
770774

771-
build_node(id, res, 0, 0, buffer, m_store_options.with_attributes);
775+
if (m_store_options.use_flat_node_file) {
776+
auto const location = get_node_location_flatnodes(id);
777+
if (!location.valid()) {
778+
return false;
779+
}
772780

773-
buffer->commit();
781+
{
782+
osmium::builder::NodeBuilder builder{*buffer};
783+
builder.set_id(id);
784+
builder.set_location(location);
785+
}
774786

775-
return true;
787+
buffer->commit();
788+
return true;
789+
}
790+
791+
return false;
776792
}
777793

778794
bool middle_query_pgsql_t::way_get(osmid_t id,

0 commit comments

Comments
 (0)