minor refactor
This commit is contained in:
parent
00bc940cff
commit
340774d8f6
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
[Oo]ut/
|
||||
[Bb]uild/
|
||||
|
||||
.vs/
|
||||
|
||||
*.json
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "vendor/tinyxml2"]
|
||||
path = vendor/tinyxml2
|
||||
url = git@github.com:leethomason/tinyxml2.git
|
|
@ -1,26 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
find_package(tinyxml2 CONFIG REQUIRED)
|
||||
project(osmparser)
|
||||
|
||||
file(GLOB_RECURSE CPP_FILES
|
||||
"src/*.cpp"
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE HPP_FILES
|
||||
"include/*.hpp"
|
||||
)
|
||||
|
||||
get_target_property(TINYXML2_INCLUDE_DIR tinyxml2::tinyxml2 INTERFACE_INCLUDE_DIRECTORIES)
|
||||
|
||||
add_library(osmp STATIC
|
||||
${CPP_FILES}
|
||||
)
|
||||
|
||||
target_include_directories(osmp PUBLIC
|
||||
include
|
||||
${TINYXML2_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(osmp PRIVATE
|
||||
tinyxml2::tinyxml2
|
||||
)
|
||||
add_subdirectory("vendor/tinyxml2")
|
||||
add_subdirectory("src")
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <util.hpp>
|
||||
|
||||
namespace osmp
|
||||
{
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
explicit Object(const std::string& file);
|
||||
~Object();
|
||||
|
||||
[[nodiscard]] Nodes GetNodes() const;
|
||||
[[nodiscard]] size_t GetNodesSize() const;
|
||||
[[nodiscard]] Node GetNode(uint64_t id) const;
|
||||
|
||||
[[nodiscard]] Ways GetWays() const;
|
||||
[[nodiscard]] size_t GetWaysSize() const;
|
||||
[[nodiscard]] Way GetWay(uint64_t id) const;
|
||||
|
||||
[[nodiscard]] Relations GetRelations() const;
|
||||
[[nodiscard]] size_t GetRelationsSize() const;
|
||||
[[nodiscard]] Relation GetRelation(uint64_t id) const;
|
||||
|
||||
public:
|
||||
const std::string version;
|
||||
const std::string generator;
|
||||
|
||||
Bounds bounds;
|
||||
|
||||
private:
|
||||
std::map<uint64_t, Node> nodes;
|
||||
std::map<uint64_t, Way> ways;
|
||||
std::map<uint64_t, Relation> relations;
|
||||
};
|
||||
}
|
14
src/CMakeLists.txt
Normal file
14
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
add_library(osmparser STATIC
|
||||
"osmimember.cpp"
|
||||
"osmnode.cpp"
|
||||
"osmobject.cpp"
|
||||
"osmrelation.cpp"
|
||||
"osmway.cpp"
|
||||
"util.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries(osmparser PUBLIC
|
||||
tinyxml2
|
||||
)
|
|
@ -1,6 +1,6 @@
|
|||
#include <osmimember.hpp>
|
||||
#include "osmimember.hpp"
|
||||
|
||||
#include <osmobject.hpp>
|
||||
#include "osmobject.hpp"
|
||||
#include <tinyxml2.h>
|
||||
|
||||
namespace xml = tinyxml2;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <util.hpp>
|
||||
#include <osmtag.hpp>
|
||||
#include "util.hpp"
|
||||
#include "osmtag.hpp"
|
||||
|
||||
namespace osmp
|
||||
{
|
||||
|
@ -22,12 +22,12 @@ namespace osmp
|
|||
IMember(const IMember& other) = delete;
|
||||
virtual ~IMember() {}
|
||||
|
||||
[[nodiscard]] IMember::Type GetType() const;
|
||||
IMember::Type GetType() 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;
|
||||
const TagList& GetTags() const;
|
||||
size_t GetTagsSize() const;
|
||||
const Tag& GetTag(size_t index) const;
|
||||
std::string GetTag(const std::string& key) const;
|
||||
|
||||
protected:
|
||||
IMember(const tinyxml2::XMLElement* element, Object* parent, IMember::Type type);
|
|
@ -1,4 +1,4 @@
|
|||
#include <osmnode.hpp>
|
||||
#include "osmnode.hpp"
|
||||
|
||||
#include <tinyxml2.h>
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#include <util.hpp>
|
||||
#include <osmimember.hpp>
|
||||
#include <osmtag.hpp>
|
||||
#include "util.hpp"
|
||||
#include "osmimember.hpp"
|
||||
#include "osmtag.hpp"
|
||||
|
||||
namespace osmp
|
||||
{
|
|
@ -1,13 +1,13 @@
|
|||
#include <osmobject.hpp>
|
||||
#include "osmobject.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
|
||||
#include <osmnode.hpp>
|
||||
#include <osmway.hpp>
|
||||
#include <osmrelation.hpp>
|
||||
#include "osmnode.hpp"
|
||||
#include "osmway.hpp"
|
||||
#include "osmrelation.hpp"
|
||||
|
||||
namespace xml = tinyxml2;
|
||||
|
||||
|
|
40
src/osmobject.hpp
Normal file
40
src/osmobject.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "util.hpp"
|
||||
|
||||
namespace osmp
|
||||
{
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
explicit Object(const std::string& file);
|
||||
~Object();
|
||||
|
||||
Nodes GetNodes() const;
|
||||
size_t GetNodesSize() const;
|
||||
Node GetNode(uint64_t id) const;
|
||||
|
||||
Ways GetWays() const;
|
||||
size_t GetWaysSize() const;
|
||||
Way GetWay(uint64_t id) const;
|
||||
|
||||
Relations GetRelations() const;
|
||||
size_t GetRelationsSize() const;
|
||||
Relation GetRelation(uint64_t id) const;
|
||||
|
||||
public:
|
||||
const std::string version;
|
||||
const std::string generator;
|
||||
|
||||
Bounds bounds;
|
||||
|
||||
private:
|
||||
std::map<uint64_t, Node> nodes;
|
||||
std::map<uint64_t, Way> ways;
|
||||
std::map<uint64_t, Relation> relations;
|
||||
};
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
#include "..\include\osmrelation.hpp"
|
||||
#include <osmrelation.hpp>
|
||||
#include "osmrelation.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include <osmobject.hpp>
|
||||
#include <osmnode.hpp>
|
||||
#include <osmway.hpp>
|
||||
|
||||
#include "osmobject.hpp"
|
||||
#include "osmnode.hpp"
|
||||
#include "osmway.hpp"
|
||||
|
||||
namespace xml = tinyxml2;
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <util.hpp>
|
||||
#include <osmtag.hpp>
|
||||
#include <osmimember.hpp>
|
||||
#include "util.hpp"
|
||||
#include "osmtag.hpp"
|
||||
#include "osmimember.hpp"
|
||||
|
||||
namespace osmp
|
||||
{
|
|
@ -1,10 +1,11 @@
|
|||
#include <osmway.hpp>
|
||||
#include "osmway.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include <osmobject.hpp>
|
||||
#include <osmtag.hpp>
|
||||
|
||||
#include "osmobject.hpp"
|
||||
#include "osmtag.hpp"
|
||||
|
||||
namespace xml = tinyxml2;
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <util.hpp>
|
||||
#include <osmtag.hpp>
|
||||
#include <osmimember.hpp>
|
||||
#include "util.hpp"
|
||||
#include "osmtag.hpp"
|
||||
#include "osmimember.hpp"
|
||||
|
||||
namespace osmp
|
||||
{
|
||||
|
@ -19,9 +19,9 @@ namespace osmp
|
|||
|
||||
friend Way CreateWay(const tinyxml2::XMLElement* way_elem, Object* parent);
|
||||
|
||||
[[nodiscard]] const Nodes& GetNodes() const;
|
||||
[[nodiscard]] size_t GetNodesSize() const;
|
||||
[[nodiscard]] Node GetNode(size_t index) const;
|
||||
const Nodes& GetNodes() const;
|
||||
size_t GetNodesSize() const;
|
||||
Node GetNode(size_t index) const;
|
||||
|
||||
protected:
|
||||
IWay(const tinyxml2::XMLElement* way_elem, Object* parent);
|
|
@ -1,4 +1,4 @@
|
|||
#include <util.hpp>
|
||||
#include "util.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <tinyxml2.h>
|
||||
|
|
1
vendor/tinyxml2
vendored
Submodule
1
vendor/tinyxml2
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit e45d9d16d430a3f5d3eee9fe40d5e194e1e5e63a
|
Loading…
Reference in a new issue