Skip to content

Commit f533ab8

Browse files
authored
Merge pull request #2303 from joto/fix-get-node2
Fix two-stage processing when flat node file is used
2 parents f872d39 + 45d16e0 commit f533ab8

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
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,

src/middle-ram.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,32 @@ bool middle_ram_t::node_get(osmid_t id, osmium::memory::Buffer *buffer) const
283283
assert(buffer);
284284

285285
if (m_store_options.nodes) {
286-
return get_object(osmium::item_type::node, id, buffer);
286+
auto const got_it = get_object(osmium::item_type::node, id, buffer);
287+
if (got_it) {
288+
return true;
289+
}
287290
}
291+
292+
if (m_store_options.locations) {
293+
osmium::Location location{};
294+
if (m_persistent_cache) {
295+
location = m_persistent_cache->get(id);
296+
}
297+
if (!location.valid()) {
298+
location = m_node_locations.get(id);
299+
}
300+
if (location.valid()) {
301+
{
302+
osmium::builder::NodeBuilder builder{*buffer};
303+
builder.set_id(id);
304+
builder.set_location(location);
305+
}
306+
307+
buffer->commit();
308+
return true;
309+
}
310+
}
311+
288312
return false;
289313
}
290314

0 commit comments

Comments
 (0)