Skip to content

Commit

Permalink
Merge branch 'danpat_parallel_hashmap_tilebuilding' of github.com:val…
Browse files Browse the repository at this point in the history
…halla/valhalla into danpat_parallel_hashmap_tilebuilding
  • Loading branch information
danpat committed May 5, 2020
2 parents 01f8e1a + 8c176dc commit 723ca48
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -72,6 +72,7 @@
* ADDED: Support decimal precision for height values in elevation service. Also support polyline5 for encoded polylines input and output to elevation service. [2324](https://github.com/valhalla/valhalla/pull/2324)
* ADDED: Use both imminent and distant verbal multi-cue phrases. [2353](https://github.com/valhalla/valhalla/pull/2353)
* CHANGED: Speed up graph enhancing by avoiding continuous unordered_set rebuilding [#2349](https://github.com/valhalla/valhalla/pull/2349)
* CHANGED: Skip calling out to Lua for nodes/ways/relations with not tags - speeds up parsing. [#2351](https://github.com/valhalla/valhalla/pull/2351)

## Release Date: 2019-11-21 Valhalla 3.0.9
* **Bug Fix**
Expand Down
45 changes: 30 additions & 15 deletions src/mjolnir/pbfgraphparser.cc
Expand Up @@ -81,6 +81,10 @@ struct graph_callback : public OSMPBF::Callback {
infer_turn_channels_ = pt.get<bool>("data_processing.infer_turn_channels", true);
use_direction_on_ways_ = pt.get<bool>("data_processing.use_direction_on_ways", false);
allow_alt_name_ = pt.get<bool>("data_processing.allow_alt_name", false);

empty_node_results_ = lua_.Transform(OSMType::kNode, {});
empty_way_results_ = lua_.Transform(OSMType::kWay, {});
empty_relation_results_ = lua_.Transform(OSMType::kRelation, {});
}

static std::string get_lua(const boost::property_tree::ptree& pt) {
Expand All @@ -100,8 +104,12 @@ struct graph_callback : public OSMPBF::Callback {
node_callback(uint64_t osmid, double lng, double lat, const OSMPBF::Tags& tags) override {
boost::optional<Tags> results = boost::none;
if (bss_nodes_) {
// Get tags
results = lua_.Transform(OSMType::kNode, tags);
// Get tags - do't bother with Lua callout if the taglist is empty
if (tags.size() > 0) {
results = lua_.Transform(OSMType::kNode, tags);
} else {
results = empty_node_results_;
}

for (auto& key_value : *results) {
if (key_value.first == "amenity" && key_value.second == "bicycle_rental") {
Expand All @@ -120,10 +128,12 @@ struct graph_callback : public OSMPBF::Callback {
return;
}

// Get tags if not already available
results = results ? results : lua_.Transform(OSMType::kNode, tags);
if (results->size() == 0) {
return;
// Get tags if not already available. Don't bother calling Lua if there
// are no OSM tags to process.
if (tags.size() > 0) {
results = results ? results : lua_.Transform(OSMType::kNode, tags);
} else {
results = results ? results : empty_node_results_;
}

// unsorted extracts are just plain nasty, so they can bugger off!
Expand Down Expand Up @@ -265,17 +275,10 @@ struct graph_callback : public OSMPBF::Callback {
return;
}

// Transform tags. If no results that means the way does not have tags
// suitable for use in routing.
Tags results = lua_.Transform(OSMType::kWay, tags);
if (results.size() == 0) {
return;
}

// Throw away closed features with following tags: building, landuse,
// leisure, natural. See: http://wiki.openstreetmap.org/wiki/Key:area
if (nodes[0] == nodes[nodes.size() - 1]) {
for (const auto& tag : results) {
for (const auto& tag : tags) {
if (tag.first == "building" || tag.first == "landuse" || tag.first == "leisure" ||
tag.first == "natural") {
// LOG_INFO("Loop wayid " + std::to_string(osmid) + " Discard?");
Expand All @@ -284,6 +287,13 @@ struct graph_callback : public OSMPBF::Callback {
}
}

// Transform tags. If no results that means the way does not have tags
// suitable for use in routing.
Tags results = tags.size() == 0 ? empty_way_results_ : lua_.Transform(OSMType::kWay, tags);
if (results.size() == 0) {
return;
}

// Throw away driveways if include_driveways_ is false
Tags::const_iterator driveways;
try {
Expand Down Expand Up @@ -1352,7 +1362,7 @@ struct graph_callback : public OSMPBF::Callback {
const OSMPBF::Tags& tags,
const std::vector<OSMPBF::Member>& members) override {
// Get tags
Tags results = lua_.Transform(OSMType::kRelation, tags);
Tags results = tags.empty() ? empty_relation_results_ : lua_.Transform(OSMType::kRelation, tags);
if (results.size() == 0) {
return;
}
Expand Down Expand Up @@ -1846,6 +1856,11 @@ struct graph_callback : public OSMPBF::Callback {

// bss nodes
std::unique_ptr<sequence<OSMNode>> bss_nodes_;

// empty objects initialized with defaults to use when no tags are present on objects
Tags empty_node_results_;
Tags empty_way_results_;
Tags empty_relation_results_;
};

} // namespace
Expand Down

0 comments on commit 723ca48

Please sign in to comment.