Pass relation data to way and node functions
This commit is contained in:
committed by
Michael Krasnyk
parent
f2b63ba0aa
commit
f79bcc6b8d
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -45,15 +46,39 @@ struct ExtractionRelation
|
||||
return values[id.Hash()];
|
||||
}
|
||||
|
||||
// AttributesMap & operator[] (util::OsmIDTyped id)
|
||||
// {
|
||||
// return values[id];
|
||||
// }
|
||||
|
||||
bool is_restriction;
|
||||
std::unordered_map<util::OsmIDTyped::HashType, AttributesMap> values;
|
||||
};
|
||||
|
||||
// It contains data of all parsed relations for each node/way element
|
||||
class ExtractionRelationContainer
|
||||
{
|
||||
public:
|
||||
using AttributesMap = ExtractionRelation::AttributesMap;
|
||||
using RelationList = std::vector<AttributesMap>;
|
||||
|
||||
void AddRelation(const ExtractionRelation & rel)
|
||||
{
|
||||
BOOST_ASSERT(!rel.is_restriction);
|
||||
for (auto it : rel.values)
|
||||
data[it.first].push_back(it.second);
|
||||
}
|
||||
|
||||
const RelationList & Get(const util::OsmIDTyped & id) const
|
||||
{
|
||||
const auto it = data.find(id.Hash());
|
||||
if (it != data.end())
|
||||
return it->second;
|
||||
|
||||
static RelationList empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO: need to store more common data
|
||||
std::unordered_map<util::OsmIDTyped::HashType, RelationList> data;
|
||||
};
|
||||
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace osmium
|
||||
{
|
||||
class Node;
|
||||
class Way;
|
||||
class Relation;
|
||||
}
|
||||
|
||||
namespace std
|
||||
@@ -44,6 +45,7 @@ namespace extractor
|
||||
class ExtractionContainers;
|
||||
struct ExtractionNode;
|
||||
struct ExtractionWay;
|
||||
struct ExtractionRelation;
|
||||
struct ProfileProperties;
|
||||
struct InputConditionalTurnRestriction;
|
||||
|
||||
@@ -88,6 +90,7 @@ class ExtractorCallbacks
|
||||
// warning: caller needs to take care of synchronization!
|
||||
void ProcessWay(const osmium::Way ¤t_way, const ExtractionWay &result_way);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace extractor
|
||||
{
|
||||
|
||||
class RestrictionParser;
|
||||
class ExtractionRelationContainer;
|
||||
struct ExtractionNode;
|
||||
struct ExtractionWay;
|
||||
struct ExtractionRelation;
|
||||
@@ -64,6 +65,7 @@ class ScriptingEnvironment
|
||||
virtual void
|
||||
ProcessElements(const osmium::memory::Buffer &buffer,
|
||||
const RestrictionParser &restriction_parser,
|
||||
const ExtractionRelationContainer &relations,
|
||||
std::vector<std::pair<const osmium::Node &, ExtractionNode>> &resulting_nodes,
|
||||
std::vector<std::pair<const osmium::Way &, ExtractionWay>> &resulting_ways,
|
||||
std::vector<std::pair<const osmium::Relation &, ExtractionRelation>> &resulting_relations,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "extractor/raster_source.hpp"
|
||||
#include "extractor/scripting_environment.hpp"
|
||||
#include "extractor/extraction_relation.hpp"
|
||||
|
||||
#include <tbb/enumerable_thread_specific.h>
|
||||
|
||||
@@ -19,8 +20,8 @@ namespace extractor
|
||||
|
||||
struct LuaScriptingContext final
|
||||
{
|
||||
void ProcessNode(const osmium::Node &, ExtractionNode &result);
|
||||
void ProcessWay(const osmium::Way &, ExtractionWay &result);
|
||||
void ProcessNode(const osmium::Node &, ExtractionNode &result, const ExtractionRelationContainer::RelationList &relations);
|
||||
void ProcessWay(const osmium::Way &, ExtractionWay &result, const ExtractionRelationContainer::RelationList &relations);
|
||||
void ProcessRelation(const osmium::Relation &, ExtractionRelation &result);
|
||||
|
||||
ProfileProperties properties;
|
||||
@@ -71,6 +72,7 @@ class Sol2ScriptingEnvironment final : public ScriptingEnvironment
|
||||
void
|
||||
ProcessElements(const osmium::memory::Buffer &buffer,
|
||||
const RestrictionParser &restriction_parser,
|
||||
const ExtractionRelationContainer &relations,
|
||||
std::vector<std::pair<const osmium::Node &, ExtractionNode>> &resulting_nodes,
|
||||
std::vector<std::pair<const osmium::Way &, ExtractionWay>> &resulting_ways,
|
||||
std::vector<std::pair<const osmium::Relation &, ExtractionRelation>> &resulting_relations,
|
||||
|
||||
Reference in New Issue
Block a user