Skip to content

Commit

Permalink
Merge pull request #12 from OPTITOOL/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
Venator2013 authored Jul 22, 2024
2 parents 002c5a2 + 91becff commit 0c95c3c
Show file tree
Hide file tree
Showing 42 changed files with 5,291 additions and 4,177 deletions.
3 changes: 0 additions & 3 deletions .devcontainer/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"dependencies": [
"boost-log",
"boost-program-options",
"boost-filesystem",
"icu",
"boost-timer",
"shapelib",
"libosmium",
{
"name": "gdal",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"MIMode": "gdb",
"args": [
//"--bb=-25.0 32.9 31.4 71.7",
"--countries=ALB AND AUT BEL BGR BIH BLR CHE CYP CZE DEU DNK ESP EST FIN FRA FRO GBR GIB GRC GRL HRV HUN IMN IRL ISL ITA KOS LIE LTU LUX LVA MCO MDA MKD MLT MNE NCY NLD NOR POL PRT ROU SJM SMR SRB SVK SVN SWE VAT",
"/here-europe",
"--countries=ALB AUT BEL BGR BIH BLR CHE CYP CZE DEU DNK ESP EST FIN FRA GBR GRC HRV HUN IRL ISL ITA LTU LUX LVA MDA MKD MLT MNE NLD NOR POL PRT ROU SRB SVK SVN SWE ",
"${workspaceFolder}/here-data",
"build/europa.osm.pbf"
]
},
Expand Down
20 changes: 19 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.associations": {
"*.FTL": "csv",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
Expand Down Expand Up @@ -55,7 +56,24 @@
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"strstream": "cpp",
"bit": "cpp",
"charconv": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"source_location": "cpp",
"format": "cpp",
"numbers": "cpp",
"ranges": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"stdfloat": "cpp",
"stop_token": "cpp",
"typeindex": "cpp",
"variant": "cpp"
},
"C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools",
"cmake.configureSettings": {
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ ENDIF()
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)

find_package(Boost REQUIRED COMPONENTS system filesystem log program_options)
find_package(Boost REQUIRED COMPONENTS system log program_options)
find_package(GDAL REQUIRED)
find_package(geos REQUIRED)
find_path(OSMIUM_INCLUDE_DIRS "osmium/version.hpp")
find_package(shapelib CONFIG REQUIRED)
find_package(ICU COMPONENTS uc data io i18n tu)

# Find includes in corresponding build directories
Expand All @@ -50,6 +49,5 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${ICU_LIBRARY}
PRIVATE GEOS::geos
PRIVATE ${OSMIUM_INCLUDE_DIRS}
PRIVATE GDAL::GDAL
PRIVATE shapelib::shp
PRIVATE expat bz2
)
7 changes: 4 additions & 3 deletions comm2osm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
#include <iostream>
#include <memory>
#include <ogrsf_frmts.h>
#include <set>
#include <vector>

#include "plugins/base_plugin.hpp"
#include "plugins/dummy/dummy_plugin.hpp"
#include "plugins/navteq/navteq_plugin.hpp"

boost::filesystem::path input_path, output_file;
std::filesystem::path input_path, output_file;
std::vector<double> boundingBox;
std::vector<std::string> countries;
std::set<std::string> countries;
static bool debug = false;

void check_args_and_setup(int argc, char *argv[]) {
Expand Down Expand Up @@ -99,7 +100,7 @@ int main(int argc, char *argv[]) {

std::vector<std::unique_ptr<base_plugin>> plugins;

boost::filesystem::path executable_path(argv[0]);
std::filesystem::path executable_path(argv[0]);

// plugins.emplace_back(std::make_unique<dummy_plugin>());
plugins.emplace_back(std::make_unique<navteq_plugin>(executable_path));
Expand Down
29 changes: 15 additions & 14 deletions plugins/base_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@

#include <assert.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <filesystem>
#include <set>

#include <osmium/io/error.hpp>

class base_plugin {
public:
std::string name;
boost::filesystem::path input_path;
boost::filesystem::path output_path;
boost::filesystem::path executable_path;
std::filesystem::path input_path;
std::filesystem::path output_path;
std::filesystem::path executable_path;

base_plugin() { this->name = ""; };
base_plugin(const std::string &name) { this->name = name; };
base_plugin(const std::string &name,
const boost::filesystem::path &executable_path) {
const std::filesystem::path &executable_path) {
this->name = name;
this->executable_path = executable_path.parent_path();
}
Expand All @@ -42,14 +43,14 @@ class base_plugin {
* \param inputh_path_rhs input path to set
* \param output_path_rhs output path to set (may be ommited)
* */
void plugin_setup(const boost::filesystem::path &input_path_rhs,
const boost::filesystem::path &output_path_rhs =
boost::filesystem::path()) {
void plugin_setup(
const std::filesystem::path &input_path_rhs,
const std::filesystem::path &output_path_rhs = std::filesystem::path()) {
input_path = input_path_rhs;
if (!boost::filesystem::is_directory(input_path))
if (!std::filesystem::is_directory(input_path))
throw(osmium::io_error("input_path '" + input_path.string() +
"' is not valid."));
if (boost::filesystem::is_directory(output_path_rhs.parent_path()))
if (std::filesystem::is_directory(output_path_rhs.parent_path()))
output_path = output_path_rhs;
}

Expand All @@ -74,9 +75,9 @@ class base_plugin {
*
* \return returns true if input is existing and valid
* */
virtual bool check_input(const boost::filesystem::path &input_path,
const boost::filesystem::path &output_path =
boost::filesystem::path("")) = 0;
virtual bool check_input(
const std::filesystem::path &input_path,
const std::filesystem::path &output_path = std::filesystem::path("")) = 0;

/**
* \brief Converts input to OSM files
Expand All @@ -92,7 +93,7 @@ class base_plugin {
virtual void setBoundingBox(double minX, double minY, double maxX,
double maxY) = 0;

virtual void setCountries(const std::vector<std::string> &_countries) = 0;
virtual void setCountries(const std::set<std::string> &_countries) = 0;

virtual void setDebug(bool debug) = 0;
};
Expand Down
3 changes: 1 addition & 2 deletions plugins/dummy/dummy_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ dummy_plugin::dummy_plugin() : base_plugin::base_plugin("Dummy Plugin") {}

dummy_plugin::~dummy_plugin() {}

bool dummy_plugin::check_input(boost::filesystem::path,
boost::filesystem::path) {
bool dummy_plugin::check_input(std::filesystem::path, std::filesystem::path) {
return true;
}

Expand Down
5 changes: 2 additions & 3 deletions plugins/dummy/dummy_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ class dummy_plugin : public base_plugin {
dummy_plugin();
virtual ~dummy_plugin();

bool
check_input(boost::filesystem::path input_path,
boost::filesystem::path output_path = boost::filesystem::path());
bool check_input(std::filesystem::path input_path,
std::filesystem::path output_path = std::filesystem::path());
void execute();
};

Expand Down
Loading

0 comments on commit 0c95c3c

Please sign in to comment.