Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #503 from hotosm/fix/validationQueries
Browse files Browse the repository at this point in the history
Fix for validation DB queries
  • Loading branch information
emi420 authored Jun 18, 2024
2 parents d02341c + bd1162a commit b256496
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
8 changes: 3 additions & 5 deletions src/raw/queryraw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ QueryRaw::getWaysByIds(std::string &waysIds, std::map<long, std::shared_ptr<osmo
#endif
// Get Ways and it's geometries (Polygon and LineString)
std::string waysQuery = "SELECT distinct(osm_id), ST_AsText(geom, 4326), 'polygon' as type from ways_poly wp where osm_id = any(ARRAY[" + waysIds + "]) ";
waysQuery += "UNION SELECT distinct(osm_id), ST_AsText(geom, 4326), 'linestring' as type from ways_line wp where osm_id = any(ARRAY[" + waysIds + "])";
waysQuery += "UNION SELECT distinct(osm_id), ST_AsText(geom, 4326), 'linestring' as type from ways_line wp where osm_id = any(ARRAY[" + waysIds + "]);";
auto ways_result = dbconn->query(waysQuery);
if (ways_result.size() == 0) {
log_debug("No results returned!");
Expand Down Expand Up @@ -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) {

Expand Down
25 changes: 12 additions & 13 deletions src/replicator/threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit b256496

Please sign in to comment.