diff --git a/src/middle-pgsql.cpp b/src/middle-pgsql.cpp index c0fd0c36f..655617ddb 100644 --- a/src/middle-pgsql.cpp +++ b/src/middle-pgsql.cpp @@ -762,17 +762,33 @@ bool middle_query_pgsql_t::node_get(osmid_t id, { assert(buffer); - auto const res = m_db_connection.exec_prepared("get_node", id); + if (m_store_options.nodes) { + auto const res = m_db_connection.exec_prepared("get_node", id); - if (res.num_tuples() != 1) { - return false; + if (res.num_tuples() == 1) { + build_node(id, res, 0, 0, buffer, m_store_options.with_attributes); + buffer->commit(); + return true; + } } - build_node(id, res, 0, 0, buffer, m_store_options.with_attributes); + if (m_store_options.use_flat_node_file) { + auto const location = get_node_location_flatnodes(id); + if (!location.valid()) { + return false; + } - buffer->commit(); + { + osmium::builder::NodeBuilder builder{*buffer}; + builder.set_id(id); + builder.set_location(location); + } - return true; + buffer->commit(); + return true; + } + + return false; } bool middle_query_pgsql_t::way_get(osmid_t id, diff --git a/src/middle-ram.cpp b/src/middle-ram.cpp index 4c5bf995b..10c095960 100644 --- a/src/middle-ram.cpp +++ b/src/middle-ram.cpp @@ -283,8 +283,32 @@ bool middle_ram_t::node_get(osmid_t id, osmium::memory::Buffer *buffer) const assert(buffer); if (m_store_options.nodes) { - return get_object(osmium::item_type::node, id, buffer); + auto const got_it = get_object(osmium::item_type::node, id, buffer); + if (got_it) { + return true; + } } + + if (m_store_options.locations) { + osmium::Location location{}; + if (m_persistent_cache) { + location = m_persistent_cache->get(id); + } + if (!location.valid()) { + location = m_node_locations.get(id); + } + if (location.valid()) { + { + osmium::builder::NodeBuilder builder{*buffer}; + builder.set_id(id); + builder.set_location(location); + } + + buffer->commit(); + return true; + } + } + return false; }