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

Commit b256496

Browse files
authored
Merge pull request #503 from hotosm/fix/validationQueries
Fix for validation DB queries
2 parents d02341c + bd1162a commit b256496

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/raw/queryraw.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ QueryRaw::getWaysByIds(std::string &waysIds, std::map<long, std::shared_ptr<osmo
562562
#endif
563563
// Get Ways and it's geometries (Polygon and LineString)
564564
std::string waysQuery = "SELECT distinct(osm_id), ST_AsText(geom, 4326), 'polygon' as type from ways_poly wp where osm_id = any(ARRAY[" + waysIds + "]) ";
565-
waysQuery += "UNION SELECT distinct(osm_id), ST_AsText(geom, 4326), 'linestring' as type from ways_line wp where osm_id = any(ARRAY[" + waysIds + "])";
565+
waysQuery += "UNION SELECT distinct(osm_id), ST_AsText(geom, 4326), 'linestring' as type from ways_line wp where osm_id = any(ARRAY[" + waysIds + "]);";
566566
auto ways_result = dbconn->query(waysQuery);
567567
if (ways_result.size() == 0) {
568568
log_debug("No results returned!");
@@ -862,10 +862,8 @@ QueryRaw::getWaysByNodesRefs(std::string &nodeIds) const
862862

863863
// Get all Ways that have references to Nodes from the DB, including Polygons and LineString geometries
864864
// 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 + "])";
865-
queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_poly where refs @> '{" + nodeIds + "}'");
866-
867-
queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_line where refs @> '{" + nodeIds + "}'");
868-
// 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 + "]);";
865+
queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_poly where refs @> '{" + nodeIds + "}';");
866+
queries.push_back("SELECT distinct(osm_id), refs, version, tags, uid, changeset from ways_line where refs @> '{" + nodeIds + "}';");
869867

870868
for (auto it = queries.begin(); it != queries.end(); ++it) {
871869

src/replicator/threads.cc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -614,30 +614,29 @@ threadOsmChange(OsmChangeTask osmChangeTask)
614614
}
615615
}
616616

617-
// // Update validation table
617+
// Update validation table
618618
if (!config->disable_validation) {
619619

620620
// Validate ways
621621
auto wayval = osmchanges->validateWays(poly, plugin);
622-
for (auto it = task.query.begin(); it != task.query.end(); ++it) {
623-
auto result = queryvalidate->ways(wayval, validation_removals);
624-
for (auto itt = result->begin(); itt != result->end(); ++itt) {
625-
task.query.push_back(*itt);
626-
}
622+
auto wayval_queries = queryvalidate->ways(wayval, validation_removals);
623+
for (auto itt = wayval_queries->begin(); itt != wayval_queries->end(); ++itt) {
624+
task.query.push_back(*itt);
627625
}
628626

629627
// Validate nodes
630628
auto nodeval = osmchanges->validateNodes(poly, plugin);
631-
for (auto it = task.query.begin(); it != task.query.end(); ++it) {
632-
auto result = queryvalidate->nodes(nodeval, validation_removals);
633-
for (auto itt = result->begin(); itt != result->end(); ++itt) {
634-
task.query.push_back(*itt);
635-
}
629+
auto nodeval_queries = queryvalidate->nodes(nodeval, validation_removals);
630+
for (auto itt = nodeval_queries->begin(); itt != nodeval_queries->end(); ++itt) {
631+
task.query.push_back(*itt);
636632
}
637633

638634
// Validate relations
639-
// relval = osmchanges->validateRelations(poly, plugin);
640-
// queryvalidate->relations(relval, task.query, validation_removals);
635+
// auto relval = osmchanges->validateRelations(poly, plugin);
636+
// auto relval_queries = queryvalidate->relations(relval, validation_removals);
637+
// for (auto itt = relval_queries->begin(); itt != relval_queries->end(); ++itt) {
638+
// task.query.push_back(*itt);
639+
// }
641640

642641
// Remove validation entries for removed objects
643642
task.query.push_back(*queryvalidate->updateValidation(validation_removals));

0 commit comments

Comments
 (0)