Refactored osmp
This commit is contained in:
parent
87046f5d18
commit
569812c0a5
14 changed files with 171 additions and 92 deletions
|
@ -24,7 +24,7 @@ namespace osmp
|
|||
|
||||
[[nodiscard]] IMember::Type GetType() const;
|
||||
|
||||
[[nodiscard]] const std::vector<Tag>& GetTags() const;
|
||||
[[nodiscard]] const TagList& GetTags() const;
|
||||
[[nodiscard]] size_t GetTagsSize() const;
|
||||
[[nodiscard]] const Tag& GetTag(size_t index) const;
|
||||
[[nodiscard]] std::string GetTag(const std::string& key) const;
|
||||
|
@ -36,8 +36,7 @@ namespace osmp
|
|||
IMember::Type type;
|
||||
Object* parent;
|
||||
|
||||
std::vector<Tag> tags;
|
||||
// std::map<std::string, std::string> tags;
|
||||
TagList tags;
|
||||
|
||||
public:
|
||||
uint64_t id;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#include "util.hpp"
|
||||
#include <util.hpp>
|
||||
#include <osmimember.hpp>
|
||||
#include <osmtag.hpp>
|
||||
|
||||
|
@ -9,10 +9,17 @@ namespace osmp
|
|||
{
|
||||
class Object;
|
||||
|
||||
class Node : public IMember
|
||||
class INode : public IMember
|
||||
{
|
||||
public:
|
||||
Node(const tinyxml2::XMLElement* xml, Object* parent);
|
||||
INode(const INode& other) = delete;
|
||||
INode(const INode&& other) = delete;
|
||||
virtual ~INode() {}
|
||||
|
||||
friend Node CreateNode(const tinyxml2::XMLElement* element, Object* parent);
|
||||
|
||||
protected:
|
||||
INode(const tinyxml2::XMLElement* xml, Object* parent);
|
||||
|
||||
public:
|
||||
double lat, lon;
|
||||
|
|
|
@ -8,27 +8,23 @@
|
|||
|
||||
namespace osmp
|
||||
{
|
||||
class Node;
|
||||
class Way;
|
||||
class Relation;
|
||||
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
explicit Object(const std::string& file);
|
||||
~Object();
|
||||
|
||||
[[nodiscard]] std::vector<std::shared_ptr<Node>> GetNodes() const;
|
||||
[[nodiscard]] Nodes GetNodes() const;
|
||||
[[nodiscard]] size_t GetNodesSize() const;
|
||||
[[nodiscard]] std::shared_ptr<Node> GetNode(uint64_t id) const;
|
||||
[[nodiscard]] Node GetNode(uint64_t id) const;
|
||||
|
||||
[[nodiscard]] std::vector<std::shared_ptr<Way>> GetWays() const;
|
||||
[[nodiscard]] Ways GetWays() const;
|
||||
[[nodiscard]] size_t GetWaysSize() const;
|
||||
[[nodiscard]] std::shared_ptr<Way> GetWay(uint64_t id) const;
|
||||
[[nodiscard]] Way GetWay(uint64_t id) const;
|
||||
|
||||
[[nodiscard]] std::vector<std::shared_ptr<Relation>> GetRelations() const;
|
||||
[[nodiscard]] Relations GetRelations() const;
|
||||
[[nodiscard]] size_t GetRelationsSize() const;
|
||||
[[nodiscard]] std::shared_ptr<Relation> GetRelation(uint64_t id) const;
|
||||
[[nodiscard]] Relation GetRelation(uint64_t id) const;
|
||||
|
||||
public:
|
||||
const std::string version;
|
||||
|
@ -37,8 +33,8 @@ namespace osmp
|
|||
Bounds bounds;
|
||||
|
||||
private:
|
||||
std::map<uint64_t, std::shared_ptr<Node>> nodes;
|
||||
std::map<uint64_t, std::shared_ptr<Way>> ways;
|
||||
std::map<uint64_t, std::shared_ptr<Relation>> relations;
|
||||
std::map<uint64_t, Node> nodes;
|
||||
std::map<uint64_t, Way> ways;
|
||||
std::map<uint64_t, Relation> relations;
|
||||
};
|
||||
}
|
|
@ -9,35 +9,50 @@
|
|||
namespace osmp
|
||||
{
|
||||
class Object;
|
||||
class IMember;
|
||||
|
||||
class Relation : public IMember
|
||||
typedef struct sMemberNode {
|
||||
Node node;
|
||||
std::string role;
|
||||
} MemberNode;
|
||||
|
||||
typedef struct sMemberWay {
|
||||
Way way;
|
||||
std::string role;
|
||||
} MemberWay;
|
||||
|
||||
typedef std::vector<MemberNode> MemberNodes;
|
||||
typedef std::vector<MemberWay> MemberWays;
|
||||
|
||||
class IRelation : public IMember
|
||||
{
|
||||
public:
|
||||
typedef struct sMember {
|
||||
std::shared_ptr<IMember> member;
|
||||
std::string role;
|
||||
} Member;
|
||||
IRelation(const IRelation& other) = delete;
|
||||
IRelation(const IRelation&& other) = delete;
|
||||
virtual ~IRelation() {}
|
||||
|
||||
public:
|
||||
Relation(const tinyxml2::XMLElement* xml, Object* parent);
|
||||
friend Relation CreateRelation(const tinyxml2::XMLElement* xml, Object* parent);
|
||||
|
||||
[[nodiscard]] std::string GetRelationType();
|
||||
[[nodiscard]] std::string GetRelationType() const;
|
||||
|
||||
[[nodiscard]] const std::vector<Member>& GetNodes() const;
|
||||
[[nodiscard]] const MemberNodes& GetNodes() const;
|
||||
[[nodiscard]] size_t GetNodesSize() const;
|
||||
[[nodiscard]] const Member& GetNode(size_t index) const;
|
||||
[[nodiscard]] const MemberNode& GetNode(size_t index) const;
|
||||
|
||||
[[nodiscard]] const std::vector<Member>& GetWays() const;
|
||||
[[nodiscard]] const MemberWays& GetWays() const;
|
||||
[[nodiscard]] size_t GetWaysSize() const;
|
||||
[[nodiscard]] const Member& GetWay(size_t index) const;
|
||||
[[nodiscard]] const MemberWay& GetWay(size_t index) const;
|
||||
|
||||
[[nodiscard]] bool HasNullMembers() const { return hasNullMembers; }
|
||||
|
||||
protected:
|
||||
IRelation(const tinyxml2::XMLElement* xml, Object* parent);
|
||||
|
||||
private:
|
||||
std::string relationType;
|
||||
bool hasNullMembers;
|
||||
|
||||
std::vector<Member> nodes;
|
||||
std::vector<Member> ways;
|
||||
MemberNodes nodes;
|
||||
MemberWays ways;
|
||||
};
|
||||
}
|
|
@ -33,4 +33,6 @@ namespace osmp
|
|||
std::string k; // TODO: Should/could be an enum
|
||||
std::string v;
|
||||
} Tag;
|
||||
|
||||
typedef std::vector<Tag> TagList;
|
||||
}
|
||||
|
|
|
@ -9,21 +9,27 @@
|
|||
namespace osmp
|
||||
{
|
||||
class Object;
|
||||
class Node;
|
||||
|
||||
class Way : public IMember
|
||||
class IWay : public IMember
|
||||
{
|
||||
public:
|
||||
Way(const tinyxml2::XMLElement* way_elem, Object* parent);
|
||||
IWay(const IWay& other) = delete;
|
||||
IWay(const IWay&& other) = delete;
|
||||
virtual ~IWay() {}
|
||||
|
||||
[[nodiscard]] const std::vector<std::shared_ptr<Node>>& GetNodes() const;
|
||||
friend Way CreateWay(const tinyxml2::XMLElement* way_elem, Object* parent);
|
||||
|
||||
[[nodiscard]] const Nodes& GetNodes() const;
|
||||
[[nodiscard]] size_t GetNodesSize() const;
|
||||
[[nodiscard]] const std::shared_ptr<Node>& GetNode(size_t index) const;
|
||||
[[nodiscard]] Node GetNode(size_t index) const;
|
||||
|
||||
protected:
|
||||
IWay(const tinyxml2::XMLElement* way_elem, Object* parent);
|
||||
|
||||
public:
|
||||
bool area, closed; // Closed := Startpoint = endpoint, Area := Closed AND certain conditions are not met
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<Node>> nodes;
|
||||
Nodes nodes;
|
||||
};
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace tinyxml2
|
||||
{
|
||||
|
@ -9,6 +11,18 @@ namespace tinyxml2
|
|||
|
||||
namespace osmp
|
||||
{
|
||||
class INode;
|
||||
class IWay;
|
||||
class IRelation;
|
||||
|
||||
typedef std::shared_ptr<INode> Node;
|
||||
typedef std::shared_ptr<IWay> Way;
|
||||
typedef std::shared_ptr<IRelation> Relation;
|
||||
|
||||
typedef std::vector<Node> Nodes;
|
||||
typedef std::vector<Way> Ways;
|
||||
typedef std::vector<Relation> Relations;
|
||||
|
||||
typedef struct sBounds
|
||||
{
|
||||
double minlat, minlon, maxlat, maxlon;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue