use boost program_options in osrm-prepare/routed

This commit is contained in:
Emil Tin
2013-08-19 22:41:46 +02:00
parent b80cda66a9
commit 613e38d7f8
24 changed files with 296 additions and 269 deletions
+3 -68
View File
@@ -19,76 +19,11 @@ or see http://www.gnu.org/licenses/agpl.txt.
*/
#include "OSRM.h"
#include <boost/foreach.hpp>
OSRM::OSRM(const char * server_ini_path) {
if( !testDataFile(server_ini_path) ){
std::string error_message = std::string(server_ini_path) + " not found";
throw OSRMException(error_message.c_str());
}
IniFile serverConfig(server_ini_path);
boost::filesystem::path base_path =
boost::filesystem::absolute(server_ini_path).parent_path();
if ( !serverConfig.Holds("hsgrData")) {
throw OSRMException("no ram index file name in server ini");
}
if ( !serverConfig.Holds("ramIndex") ) {
throw OSRMException("no mem index file name in server ini");
}
if ( !serverConfig.Holds("fileIndex") ) {
throw OSRMException("no nodes file name in server ini");
}
if ( !serverConfig.Holds("nodesData") ) {
throw OSRMException("no nodes file name in server ini");
}
if ( !serverConfig.Holds("edgesData") ) {
throw OSRMException("no edges file name in server ini");
}
boost::filesystem::path hsgr_path = boost::filesystem::absolute(
serverConfig.GetParameter("hsgrData"),
base_path
);
boost::filesystem::path ram_index_path = boost::filesystem::absolute(
serverConfig.GetParameter("ramIndex"),
base_path
);
boost::filesystem::path file_index_path = boost::filesystem::absolute(
serverConfig.GetParameter("fileIndex"),
base_path
);
boost::filesystem::path node_data_path = boost::filesystem::absolute(
serverConfig.GetParameter("nodesData"),
base_path
);
boost::filesystem::path edge_data_path = boost::filesystem::absolute(
serverConfig.GetParameter("edgesData"),
base_path
);
boost::filesystem::path name_data_path = boost::filesystem::absolute(
serverConfig.GetParameter("namesData"),
base_path
);
boost::filesystem::path timestamp_path = boost::filesystem::absolute(
serverConfig.GetParameter("timestamp"),
base_path
);
objects = new QueryObjectsStorage(
hsgr_path.string(),
ram_index_path.string(),
file_index_path.string(),
node_data_path.string(),
edge_data_path.string(),
name_data_path.string(),
timestamp_path.string()
);
OSRM::OSRM(boost::unordered_map<const std::string,boost::filesystem::path>& paths) {
objects = new QueryObjectsStorage( paths );
RegisterPlugin(new HelloWorldPlugin());
RegisterPlugin(new LocatePlugin(objects));
RegisterPlugin(new NearestPlugin(objects));
+2 -2
View File
@@ -30,9 +30,9 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "../Plugins/TimestampPlugin.h"
#include "../Plugins/ViaRoutePlugin.h"
#include "../Server/DataStructures/RouteParameters.h"
#include "../Util/IniFile.h"
#include "../Util/InputFileUtil.h"
#include "../Util/OSRMException.h"
#include "../Util/ProgramOptions.h"
#include "../Util/SimpleLogger.h"
#include "../Server/BasicDatastructures.h"
@@ -47,7 +47,7 @@ class OSRM : boost::noncopyable {
typedef boost::unordered_map<std::string, BasePlugin *> PluginMap;
QueryObjectsStorage * objects;
public:
OSRM(const char * server_ini_path);
OSRM(boost::unordered_map<const std::string,boost::filesystem::path>& paths);
~OSRM();
void RunQuery(RouteParameters & route_parameters, http::Reply & reply);
private: