@@ -270,8 +270,8 @@ class string_id_list
270270
271271}; // class string_id_list
272272
273- size_t
274- middle_query_pgsql_t ::local_nodes_get_list( osmium::WayNodeList *nodes) const
273+ std:: size_t middle_query_pgsql_t::get_way_node_locations_db (
274+ osmium::WayNodeList *nodes) const
275275{
276276 size_t count = 0 ;
277277 string_id_list id_list;
@@ -330,10 +330,29 @@ void middle_pgsql_t::node_set(osmium::Node const &node)
330330 }
331331}
332332
333+ std::size_t middle_query_pgsql_t::get_way_node_locations_flatnodes (
334+ osmium::WayNodeList *nodes) const
335+ {
336+ std::size_t count = 0 ;
337+
338+ for (auto &n : *nodes) {
339+ auto loc = m_cache->get (n.ref ());
340+ if (!loc.valid () && n.ref () >= 0 ) {
341+ loc = m_persistent_cache->get (n.ref ());
342+ }
343+ n.set_location (loc);
344+ if (loc.valid ()) {
345+ ++count;
346+ }
347+ }
348+
349+ return count;
350+ }
351+
333352size_t middle_query_pgsql_t::nodes_get_list (osmium::WayNodeList *nodes) const
334353{
335- return m_persistent_cache ? m_persistent_cache-> get_list (nodes)
336- : local_nodes_get_list (nodes);
354+ return m_persistent_cache ? get_way_node_locations_flatnodes (nodes)
355+ : get_way_node_locations_db (nodes);
337356}
338357
339358void middle_pgsql_t::node_delete (osmid_t osm_id)
@@ -756,7 +775,7 @@ middle_pgsql_t::middle_pgsql_t(options_t const *options)
756775 m_db_copy(m_copy_thread)
757776{
758777 if (options->flat_node_cache_enabled ) {
759- m_persistent_cache.reset (new node_persistent_cache{options, m_cache });
778+ m_persistent_cache.reset (new node_persistent_cache{options});
760779 }
761780
762781 log_debug (" Mid: pgsql, cache={}" , options->cache );
0 commit comments