@@ -271,8 +271,8 @@ class string_id_list
271271
272272}; // class string_id_list
273273
274- size_t
275- middle_query_pgsql_t ::local_nodes_get_list( osmium::WayNodeList *nodes) const
274+ std:: size_t middle_query_pgsql_t::get_way_node_locations_db (
275+ osmium::WayNodeList *nodes) const
276276{
277277 size_t count = 0 ;
278278 string_id_list id_list;
@@ -331,10 +331,29 @@ void middle_pgsql_t::node_set(osmium::Node const &node)
331331 }
332332}
333333
334+ std::size_t middle_query_pgsql_t::get_way_node_locations_flatnodes (
335+ osmium::WayNodeList *nodes) const
336+ {
337+ std::size_t count = 0 ;
338+
339+ for (auto &n : *nodes) {
340+ auto loc = m_cache->get (n.ref ());
341+ if (!loc.valid () && n.ref () >= 0 ) {
342+ loc = m_persistent_cache->get (n.ref ());
343+ }
344+ n.set_location (loc);
345+ if (loc.valid ()) {
346+ ++count;
347+ }
348+ }
349+
350+ return count;
351+ }
352+
334353size_t middle_query_pgsql_t::nodes_get_list (osmium::WayNodeList *nodes) const
335354{
336- return m_persistent_cache ? m_persistent_cache-> get_list (nodes)
337- : local_nodes_get_list (nodes);
355+ return m_persistent_cache ? get_way_node_locations_flatnodes (nodes)
356+ : get_way_node_locations_db (nodes);
338357}
339358
340359void middle_pgsql_t::node_delete (osmid_t osm_id)
@@ -757,7 +776,7 @@ middle_pgsql_t::middle_pgsql_t(options_t const *options)
757776 m_db_copy(m_copy_thread)
758777{
759778 if (options->flat_node_cache_enabled ) {
760- m_persistent_cache.reset (new node_persistent_cache{options, m_cache });
779+ m_persistent_cache.reset (new node_persistent_cache{options});
761780 }
762781
763782 log_debug (" Mid: pgsql, cache={}" , options->cache );
0 commit comments