From bd1162aac5d1319e70d90a6e4f50fbe6eb5a80ac Mon Sep 17 00:00:00 2001 From: Emilio Mariscal Date: Tue, 18 Jun 2024 15:13:39 -0300 Subject: [PATCH] Fix for validation DB queries --- src/raw/queryraw.cc | 8 +++----- src/replicator/threads.cc | 25 ++++++++++++------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/raw/queryraw.cc b/src/raw/queryraw.cc index d7e30a4e..085d3c45 100644 --- a/src/raw/queryraw.cc +++ b/src/raw/queryraw.cc @@ -562,7 +562,7 @@ QueryRaw::getWaysByIds(std::string &waysIds, std::mapquery(waysQuery); if (ways_result.size() == 0) { log_debug("No results returned!"); @@ -862,10 +862,8 @@ QueryRaw::getWaysByNodesRefs(std::string &nodeIds) const // Get all Ways that have references to Nodes from the DB, including Polygons and LineString geometries // std::string waysQuery = "SELECT distinct(osm_id), refs, version, tags, uid, changeset from way_refs join ways_poly wp on wp.osm_id = way_id where node_id = any(ARRAY[" + nodeIds + "])"; - queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_poly where refs @> '{" + nodeIds + "}'"); - - queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_line where refs @> '{" + nodeIds + "}'"); - // waysQuery += " UNION SELECT distinct(osm_id), refs, version, tags, uid, changeset from way_refs join ways_line wl on wl.osm_id = way_id where node_id = any(ARRAY[" + nodeIds + "]);"; + queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_poly where refs @> '{" + nodeIds + "}';"); + queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_line where refs @> '{" + nodeIds + "}';"); for (auto it = queries.begin(); it != queries.end(); ++it) { diff --git a/src/replicator/threads.cc b/src/replicator/threads.cc index 49860fcf..5b09cee0 100644 --- a/src/replicator/threads.cc +++ b/src/replicator/threads.cc @@ -614,30 +614,29 @@ threadOsmChange(OsmChangeTask osmChangeTask) } } - // // Update validation table + // Update validation table if (!config->disable_validation) { // Validate ways auto wayval = osmchanges->validateWays(poly, plugin); - for (auto it = task.query.begin(); it != task.query.end(); ++it) { - auto result = queryvalidate->ways(wayval, validation_removals); - for (auto itt = result->begin(); itt != result->end(); ++itt) { - task.query.push_back(*itt); - } + auto wayval_queries = queryvalidate->ways(wayval, validation_removals); + for (auto itt = wayval_queries->begin(); itt != wayval_queries->end(); ++itt) { + task.query.push_back(*itt); } // Validate nodes auto nodeval = osmchanges->validateNodes(poly, plugin); - for (auto it = task.query.begin(); it != task.query.end(); ++it) { - auto result = queryvalidate->nodes(nodeval, validation_removals); - for (auto itt = result->begin(); itt != result->end(); ++itt) { - task.query.push_back(*itt); - } + auto nodeval_queries = queryvalidate->nodes(nodeval, validation_removals); + for (auto itt = nodeval_queries->begin(); itt != nodeval_queries->end(); ++itt) { + task.query.push_back(*itt); } // Validate relations - // relval = osmchanges->validateRelations(poly, plugin); - // queryvalidate->relations(relval, task.query, validation_removals); + // auto relval = osmchanges->validateRelations(poly, plugin); + // auto relval_queries = queryvalidate->relations(relval, validation_removals); + // for (auto itt = relval_queries->begin(); itt != relval_queries->end(); ++itt) { + // task.query.push_back(*itt); + // } // Remove validation entries for removed objects task.query.push_back(*queryvalidate->updateValidation(validation_removals));