Skip to content

Commit

Permalink
add option --no-untagged-nodes-geometric-relations to ignore untagged…
Browse files Browse the repository at this point in the history
… nodes during computation of the geometric relations
  • Loading branch information
patrickbr committed Dec 17, 2024
1 parent cf015f7 commit f51dba8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
2 changes: 2 additions & 0 deletions include/osm2rdf/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ struct Config {
bool addUntaggedRelations = true;
bool addUntaggedAreas = true;

bool addSpatialRelsForUntaggedNodes = true;

int numThreads = std::thread::hardware_concurrency();

// Default settings for data
Expand Down
8 changes: 8 additions & 0 deletions include/osm2rdf/config/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ const static inline std::string NO_WAY_GEOM_RELATIONS_OPTION_LONG =
const static inline std::string NO_WAY_GEOM_RELATIONS_OPTION_HELP =
"Do not dump way geometric relations";

const static inline std::string NO_UNTAGGED_NODES_SPATIAL_RELS_INFO =
"Do not compute spatial relations involving untagged nodes";
const static inline std::string NO_UNTAGGED_NODES_SPATIAL_RELS_OPTION_SHORT = "";
const static inline std::string NO_UNTAGGED_NODES_SPATIAL_RELS_OPTION_LONG =
"no-untagged-nodes-geometric-relations";
const static inline std::string NO_UNTAGGED_NODES_SPATIAL_RELS_OPTION_HELP =
"Do not compute spatial relations involving untagged nodes";

const static inline std::string NO_UNTAGGED_NODES_INFO =
"Do not output untagged nodes";
const static inline std::string NO_UNTAGGED_NODES_OPTION_SHORT = "";
Expand Down
47 changes: 28 additions & 19 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ std::string osm2rdf::config::Config::getInfo(std::string_view prefix) const {
oss << "\n"
<< prefix << osm2rdf::config::constants::NO_UNTAGGED_AREAS_INFO;
}
if (!addSpatialRelsForUntaggedNodes) {
oss << "\n"
<< prefix
<< osm2rdf::config::constants::NO_UNTAGGED_NODES_SPATIAL_RELS_INFO;
}
if (simplifyWKT > 0) {
oss << "\n" << prefix << osm2rdf::config::constants::SIMPLIFY_WKT_INFO;
oss << "\n"
Expand Down Expand Up @@ -280,29 +285,32 @@ void osm2rdf::config::Config::fromArgs(int argc, char** argv) {
osm2rdf::config::constants::ADD_AREA_WAY_LINESTRINGS_OPTION_LONG,
osm2rdf::config::constants::ADD_AREA_WAY_LINESTRINGS_OPTION_HELP);

auto noUntaggedNodesOp =
parser.add<popl::Switch, popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_NODES_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_NODES_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_NODES_OPTION_HELP);
auto noUntaggedNodesSpatialRelsOp = parser.add<popl::Switch,
popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_NODES_SPATIAL_RELS_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_NODES_SPATIAL_RELS_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_NODES_SPATIAL_RELS_OPTION_HELP);

auto noUntaggedWaysOp =
parser.add<popl::Switch, popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_WAYS_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_WAYS_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_WAYS_OPTION_HELP);
auto noUntaggedNodesOp = parser.add<popl::Switch, popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_NODES_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_NODES_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_NODES_OPTION_HELP);

auto noUntaggedWaysOp = parser.add<popl::Switch, popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_WAYS_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_WAYS_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_WAYS_OPTION_HELP);

auto noUntaggedRelationsOp =
parser.add<popl::Switch, popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_RELATIONS_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_RELATIONS_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_RELATIONS_OPTION_HELP);

auto noUntaggedAreasOp =
parser.add<popl::Switch, popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_AREAS_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_AREAS_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_AREAS_OPTION_HELP);
auto noUntaggedAreasOp = parser.add<popl::Switch, popl::Attribute::expert>(
osm2rdf::config::constants::NO_UNTAGGED_AREAS_OPTION_SHORT,
osm2rdf::config::constants::NO_UNTAGGED_AREAS_OPTION_LONG,
osm2rdf::config::constants::NO_UNTAGGED_AREAS_OPTION_HELP);

auto addWayMetadataOp = parser.add<popl::Switch>(
osm2rdf::config::constants::ADD_WAY_METADATA_OPTION_SHORT,
Expand Down Expand Up @@ -482,6 +490,8 @@ void osm2rdf::config::Config::fromArgs(int argc, char** argv) {
wktDeviation = wktDeviationOp->value();
wktPrecision = wktPrecisionOp->value();

addSpatialRelsForUntaggedNodes = !noUntaggedNodesSpatialRelsOp->is_set();

addUntaggedNodes = !noUntaggedNodesOp->is_set();
addUntaggedWays = !noUntaggedWaysOp->is_set();
addUntaggedRelations = !noUntaggedRelationsOp->is_set();
Expand Down Expand Up @@ -514,10 +524,9 @@ void osm2rdf::config::Config::fromArgs(int argc, char** argv) {
} else if (outputCompressOp->value() == "bz2") {
outputCompress = BZ2;
} else {
throw popl::invalid_option(
outputCompressOp.get(),
popl::invalid_option::Error::invalid_argument,
popl::OptionName::long_name, outputCompressOp->value(), "");
throw popl::invalid_option(
outputCompressOp.get(), popl::invalid_option::Error::invalid_argument,
popl::OptionName::long_name, outputCompressOp->value(), "");
}

outputKeepFiles = outputKeepFilesOp->is_set();
Expand Down
3 changes: 2 additions & 1 deletion src/osm/OsmiumHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ void osm2rdf::osm::OsmiumHandler<W>::node(const osmium::Node& node) {
_progressBar.update(_numTasksDone++);
}
}
if (!_config.noGeometricRelations && !_config.noNodeGeometricRelations) {
if (!_config.noGeometricRelations && !_config.noNodeGeometricRelations &&
(!osmNode.tags().empty() || _config.addSpatialRelsForUntaggedNodes)) {
_geometryHandler->node(osmNode);
#pragma omp critical(progress)
{
Expand Down

0 comments on commit f51dba8

Please sign in to comment.