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

Commit

Permalink
Delete outdated geometries, fix for Relations multigeometries, add ve…
Browse files Browse the repository at this point in the history
…rbosito for raw test
  • Loading branch information
emi420 committed Apr 8, 2024
1 parent 3a66efc commit 5daa466
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/osm/osmchange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ OsmChangeFile::buildRelationGeometry(osmobjects::OsmRelation &relation) {
// Way is not available in cache,
// possibily because Relation is not in the priority area
// or way was deleted
std::cout << "No Way!" << std::endl;
return;
}

Expand All @@ -213,7 +212,6 @@ OsmChangeFile::buildRelationGeometry(osmobjects::OsmRelation &relation) {
// Way is not available in cache,
// possibily because Relation is not in the priority area
// or way was deleted
std::cout << "No Way!" << std::endl;
return;
}
nextWay = waycache.at(nextWayId);
Expand Down Expand Up @@ -379,22 +377,26 @@ OsmChangeFile::buildRelationGeometry(osmobjects::OsmRelation &relation) {
std::string geometry_str;
++i;
if (relation.isMultiPolygon()) {
ss << std::setprecision(12) << bg::wkt(pit->polygon);
geometry_str = ss.str();
// Erase "POLYGON("
geometry_str.erase(0,8);
geometry_str.erase(geometry_str.size() - 1);
if (geometry_str.size() > 0) {
geometry += geometry_str + ",";
if (bg::num_points(pit->polygon.outer()) > 0) {
ss << std::setprecision(12) << bg::wkt(pit->polygon);
geometry_str = ss.str();
// Erase "POLYGON("
geometry_str.erase(0,8);
geometry_str.erase(geometry_str.size() - 1);
if (geometry_str.size() > 0) {
geometry += geometry_str + ",";
}
}
} else {
ss << std::setprecision(12) << bg::wkt(pit->linestring);
geometry_str = ss.str();
// Erase "LINESTRING("
geometry_str.erase(0,11);
geometry_str.erase(geometry_str.size() - 1);
if (geometry_str.size() > 0) {
geometry += "(" + geometry_str + "),";
if (bg::num_points(pit->linestring) > 0) {
ss << std::setprecision(12) << bg::wkt(pit->linestring);
geometry_str = ss.str();
// Erase "LINESTRING("
geometry_str.erase(0,11);
geometry_str.erase(geometry_str.size() - 1);
if (geometry_str.size() > 0) {
geometry += "(" + geometry_str + "),";
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/raw/queryraw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ QueryRaw::applyChange(const OsmWay &way) const

query += fmt.str();
}
std::string delquery = "DELETE FROM %s WHERE osm_id=%d;";
boost::format delquery_fmt(delquery);
if (tableName == &QueryRaw::polyTable) {
delquery_fmt % QueryRaw::lineTable;
} else {
delquery_fmt % QueryRaw::polyTable;
}
delquery_fmt % way.id;
query += delquery_fmt.str();
}
} else if (way.action == osmobjects::remove) {
query += "DELETE FROM way_refs WHERE way_id=" + std::to_string(way.id) + ";";
Expand Down
2 changes: 2 additions & 0 deletions src/testsuite/libunderpass.all/raw-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ main(int argc, char *argv[])
}


} else {
std::cout << "ERROR: can't connect to the test DB (" << dbconn << " dbname=underpass_test" << ")" << std::endl;
}


Expand Down

0 comments on commit 5daa466

Please sign in to comment.