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

Commit

Permalink
fix: Remove way_refs and rel_refs as they are unneeded now
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed May 23, 2024
1 parent bec413e commit 89147ed
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 40 deletions.
4 changes: 0 additions & 4 deletions setup/db/indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ CREATE UNIQUE INDEX nodes_id_idx ON public.nodes (osm_id DESC);
CREATE UNIQUE INDEX ways_poly_id_idx ON public.ways_poly (osm_id DESC);
CREATE UNIQUE INDEX ways_line_id_idx ON public.ways_line(osm_id DESC);
CREATE UNIQUE INDEX relations_id_idx ON public.relations(osm_id DESC);
CREATE INDEX way_refs_node_id_idx ON public.way_refs (node_id);
CREATE INDEX way_refs_way_id_idx ON public.way_refs (way_id);
CREATE INDEX rel_refs_rel_id_idx ON public.rel_refs (rel_id);
CREATE INDEX rel_refs_way_id_idx ON public.rel_refs (way_id);

CREATE INDEX nodes_version_idx ON public.nodes (version);
CREATE INDEX ways_poly_version_idx ON public.ways_poly (version);
Expand Down
15 changes: 0 additions & 15 deletions setup/db/underpass.sql
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,10 @@ CREATE TABLE IF NOT EXISTS public.relations (
ALTER TABLE ONLY public.relations
ADD CONSTRAINT relations_pkey PRIMARY KEY (osm_id);

CREATE TABLE IF NOT EXISTS public.way_refs (
way_id int8,
node_id int8
);

CREATE TABLE IF NOT EXISTS public.rel_refs (
rel_id int8,
way_id int8
);

CREATE UNIQUE INDEX nodes_id_idx ON public.nodes (osm_id DESC);
CREATE UNIQUE INDEX ways_poly_id_idx ON public.ways_poly (osm_id DESC);
CREATE UNIQUE INDEX ways_line_id_idx ON public.ways_line(osm_id DESC);
CREATE UNIQUE INDEX relations_id_idx ON public.relations(osm_id DESC);
CREATE INDEX way_refs_node_id_idx ON public.way_refs (node_id);
CREATE INDEX way_refs_way_id_idx ON public.way_refs (way_id);

CREATE INDEX rel_refs_rel_id_idx ON public.rel_refs (rel_id);
CREATE INDEX rel_refs_way_id_idx ON public.rel_refs (way_id);

CREATE INDEX nodes_version_idx ON public.nodes (version);
CREATE INDEX ways_poly_version_idx ON public.ways_poly (version);
Expand Down
7 changes: 0 additions & 7 deletions src/bootstrap/bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,13 @@ Bootstrap::threadBootstrapWayTask(WayTask wayTask)
if (i < ways->size()) {
auto way = ways->at(i);
wayval->push_back(validator->checkWay(way, "building"));
// Fill the way_refs table
if (!norefs) {
for (auto ref = way.refs.begin(); ref != way.refs.end(); ++ref) {
task.osmquery.push_back("INSERT INTO way_refs (way_id, node_id) VALUES (" + std::to_string(way.id) + "," + std::to_string(*ref) + "); ");
}
}
++processed;
}
}

auto result = queryvalidate->ways(wayval);
for (auto it = result->begin(); it != result->end(); ++it) {
task.query.push_back(*it);
log_debug("FOO: %1%", *it);
}

task.processed = processed;
Expand Down
21 changes: 7 additions & 14 deletions src/raw/queryraw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,6 @@ QueryRaw::applyChange(const OsmWay &way) const
query += fmt.str();
queries->push_back(query);

// Refresh all refs stored into the way_refs table
queries->push_back("DELETE FROM way_refs WHERE way_id = " + std::to_string(way.id) + ";");
for (auto ref = way.refs.begin(); ref != way.refs.end(); ++ref) {
queries->push_back("INSERT INTO way_refs (way_id, node_id) VALUES (" + std::to_string(way.id) + "," + std::to_string(*ref) + ");");
}

} else {

// Update only the Way's geometry. This is the case when a Way was indirectly
Expand Down Expand Up @@ -368,7 +362,6 @@ QueryRaw::applyChange(const OsmWay &way) const
}
} else if (way.action == osmobjects::remove) {
// Delete a Way geometry and its references.
queries->push_back("DELETE FROM way_refs WHERE way_id = " + std::to_string(way.id) + ";");
if (tableName == &QueryRaw::polyTable) {
queries->push_back("DELETE FROM " + QueryRaw::polyTable + " where osm_id = " + std::to_string(way.id) + ";");
} else {
Expand Down Expand Up @@ -741,7 +734,7 @@ void QueryRaw::buildGeometries(std::shared_ptr<OsmChangeFile> osmchanges, const
std::string nodesQuery = "SELECT osm_id, st_x(geom) as lat, st_y(geom) as lon FROM nodes where osm_id in (" + referencedNodeIds + ");";
auto result = dbconn->query(nodesQuery);
if (result.size() == 0) {
log_error("No results returned!");
log_debug("No results returned!");
return;
}
// Fill nodecache
Expand Down Expand Up @@ -848,7 +841,7 @@ QueryRaw::getNodeCacheFromWays(std::shared_ptr<std::vector<OsmWay>> ways, std::m
std::string nodesQuery = "SELECT osm_id, st_x(geom) as lat, st_y(geom) as lon FROM nodes where osm_id in (" + nodeIds + ") and st_x(geom) is not null and st_y(geom) is not null;";
auto result = dbconn->query(nodesQuery);
if (result.size() == 0) {
log_error("No results returned!");
log_debug("No results returned!");
return;
}

Expand Down Expand Up @@ -885,7 +878,7 @@ QueryRaw::getWaysByNodesRefs(std::string &nodeIds) const

auto ways_result = dbconn->query(*it);
if (ways_result.size() == 0) {
log_error("No results returned!");
log_debug("No results returned!");
return ways;
}

Expand Down Expand Up @@ -941,7 +934,7 @@ QueryRaw::getNodesFromDB(long lastid, int pageSize) {
auto nodes = std::make_shared<std::vector<OsmNode>>();
auto nodes_result = dbconn->query(nodesQuery);
if (nodes_result.size() == 0) {
log_error("No results returned!");
log_debug("No results returned!");
return nodes;
}

Expand Down Expand Up @@ -990,7 +983,7 @@ QueryRaw::getWaysFromDB(long lastid, int pageSize, const std::string &tableName)
auto ways = std::make_shared<std::vector<OsmWay>>();
auto ways_result = dbconn->query(waysQuery);
if (ways_result.size() == 0) {
log_error("No results returned!");
log_debug("No results returned!");
return ways;
}

Expand Down Expand Up @@ -1045,7 +1038,7 @@ QueryRaw::getWaysFromDBWithoutRefs(long lastid, int pageSize, const std::string
auto ways = std::make_shared<std::vector<OsmWay>>();
auto ways_result = dbconn->query(waysQuery);
if (ways_result.size() == 0) {
log_error("No results returned!");
log_debug("No results returned!");
return ways;
}

Expand Down Expand Up @@ -1091,7 +1084,7 @@ QueryRaw::getRelationsFromDB(long lastid, int pageSize) {
auto relations = std::make_shared<std::vector<OsmRelation>>();
auto relations_result = dbconn->query(relationsQuery);
if (relations_result.size() == 0) {
log_error("No results returned!");
log_debug("No results returned!");
return relations;
}
// Fill vector of OsmRelation objects
Expand Down

0 comments on commit 89147ed

Please sign in to comment.