Add routed parameter to limit matching size
This commit is contained in:
parent
e5830b0116
commit
d8d46e0f3e
@ -33,15 +33,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
struct libosrm_config
|
struct libosrm_config
|
||||||
{
|
{
|
||||||
libosrm_config(const libosrm_config &) = delete;
|
libosrm_config(const libosrm_config &) = delete;
|
||||||
libosrm_config() : max_locations_distance_table(100), use_shared_memory(false) {}
|
libosrm_config()
|
||||||
|
: max_locations_distance_table(100), max_locations_map_matching(-1),
|
||||||
|
use_shared_memory(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
libosrm_config(const ServerPaths &paths, const bool flag, const int max)
|
libosrm_config(const ServerPaths &paths, const bool flag, const int max_table, const int max_matching)
|
||||||
: server_paths(paths), max_locations_distance_table(max), use_shared_memory(flag)
|
: server_paths(paths), max_locations_distance_table(max_table),
|
||||||
|
max_locations_map_matching(max_matching), use_shared_memory(flag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerPaths server_paths;
|
ServerPaths server_paths;
|
||||||
int max_locations_distance_table;
|
int max_locations_distance_table;
|
||||||
|
int max_locations_map_matching;
|
||||||
bool use_shared_memory;
|
bool use_shared_memory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,7 +82,8 @@ OSRM_impl::OSRM_impl(libosrm_config &lib_config)
|
|||||||
RegisterPlugin(new HelloWorldPlugin());
|
RegisterPlugin(new HelloWorldPlugin());
|
||||||
RegisterPlugin(new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
RegisterPlugin(new MapMatchingPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new MapMatchingPlugin<BaseDataFacade<QueryEdge::EdgeData>>(
|
||||||
|
query_data_facade, lib_config.max_locations_map_matching));
|
||||||
RegisterPlugin(new TimestampPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new TimestampPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
RegisterPlugin(new ViaRoutePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new ViaRoutePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,10 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
using TraceClassification = ClassifierT::ClassificationT;
|
using TraceClassification = ClassifierT::ClassificationT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapMatchingPlugin(DataFacadeT *facade)
|
MapMatchingPlugin(DataFacadeT *facade, const int max_locations_map_matching)
|
||||||
: descriptor_string("match")
|
: descriptor_string("match")
|
||||||
, facade(facade)
|
, facade(facade)
|
||||||
|
, max_locations_map_matching(max_locations_map_matching)
|
||||||
// the values where derived from fitting a laplace distribution
|
// the values where derived from fitting a laplace distribution
|
||||||
// to the values of manually classified traces
|
// to the values of manually classified traces
|
||||||
, classifier(LaplaceDistribution(0.0057154021891018675, 0.020294704891166186),
|
, classifier(LaplaceDistribution(0.0057154021891018675, 0.020294704891166186),
|
||||||
@ -225,6 +226,13 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
{
|
{
|
||||||
return 400;
|
return 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enforce maximum number of locations for performance reasons
|
||||||
|
if (max_locations_map_matching > 0 && static_cast<int>(input_coords.size()) > max_locations_map_matching)
|
||||||
|
{
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
|
||||||
bool found_candidates = getCandiates(input_coords, sub_trace_lengths, candidates_lists);
|
bool found_candidates = getCandiates(input_coords, sub_trace_lengths, candidates_lists);
|
||||||
if (!found_candidates)
|
if (!found_candidates)
|
||||||
{
|
{
|
||||||
@ -299,6 +307,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
private:
|
private:
|
||||||
std::string descriptor_string;
|
std::string descriptor_string;
|
||||||
DataFacadeT *facade;
|
DataFacadeT *facade;
|
||||||
|
int max_locations_map_matching;
|
||||||
ClassifierT classifier;
|
ClassifierT classifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,7 +77,8 @@ int main(int argc, const char *argv[])
|
|||||||
|
|
||||||
const unsigned init_result = GenerateServerProgramOptions(
|
const unsigned init_result = GenerateServerProgramOptions(
|
||||||
argc, argv, lib_config.server_paths, ip_address, ip_port, requested_thread_num,
|
argc, argv, lib_config.server_paths, ip_address, ip_port, requested_thread_num,
|
||||||
lib_config.use_shared_memory, trial_run, lib_config.max_locations_distance_table);
|
lib_config.use_shared_memory, trial_run, lib_config.max_locations_distance_table,
|
||||||
|
lib_config.max_locations_map_matching);
|
||||||
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
|
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -151,7 +151,8 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
|||||||
int &requested_num_threads,
|
int &requested_num_threads,
|
||||||
bool &use_shared_memory,
|
bool &use_shared_memory,
|
||||||
bool &trial,
|
bool &trial,
|
||||||
int &max_locations_distance_table)
|
int &max_locations_distance_table,
|
||||||
|
int &max_locations_map_matching)
|
||||||
{
|
{
|
||||||
// declare a group of options that will be allowed only on command line
|
// declare a group of options that will be allowed only on command line
|
||||||
boost::program_options::options_description generic_options("Options");
|
boost::program_options::options_description generic_options("Options");
|
||||||
@ -165,34 +166,35 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
|||||||
// declare a group of options that will be allowed both on command line
|
// declare a group of options that will be allowed both on command line
|
||||||
// as well as in a config file
|
// as well as in a config file
|
||||||
boost::program_options::options_description config_options("Configuration");
|
boost::program_options::options_description config_options("Configuration");
|
||||||
config_options.add_options()(
|
config_options.add_options()
|
||||||
"hsgrdata", boost::program_options::value<boost::filesystem::path>(&paths["hsgrdata"]),
|
("hsgrdata", boost::program_options::value<boost::filesystem::path>(&paths["hsgrdata"]),
|
||||||
".hsgr file")("nodesdata",
|
".hsgr file")
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["nodesdata"]),
|
("nodesdata", boost::program_options::value<boost::filesystem::path>(&paths["nodesdata"]),
|
||||||
".nodes file")(
|
".nodes file")
|
||||||
"edgesdata", boost::program_options::value<boost::filesystem::path>(&paths["edgesdata"]),
|
("edgesdata", boost::program_options::value<boost::filesystem::path>(&paths["edgesdata"]),
|
||||||
".edges file")("geometry",
|
".edges file")
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["geometries"]),
|
("geometry", boost::program_options::value<boost::filesystem::path>(&paths["geometries"]),
|
||||||
".geometry file")(
|
".geometry file")
|
||||||
"ramindex", boost::program_options::value<boost::filesystem::path>(&paths["ramindex"]),
|
("ramindex", boost::program_options::value<boost::filesystem::path>(&paths["ramindex"]),
|
||||||
".ramIndex file")(
|
".ramIndex file")
|
||||||
"fileindex", boost::program_options::value<boost::filesystem::path>(&paths["fileindex"]),
|
("fileindex", boost::program_options::value<boost::filesystem::path>(&paths["fileindex"]),
|
||||||
"File index file")(
|
"File index file")
|
||||||
"namesdata", boost::program_options::value<boost::filesystem::path>(&paths["namesdata"]),
|
("namesdata", boost::program_options::value<boost::filesystem::path>(&paths["namesdata"]),
|
||||||
".names file")("timestamp",
|
".names file")
|
||||||
boost::program_options::value<boost::filesystem::path>(&paths["timestamp"]),
|
("timestamp", boost::program_options::value<boost::filesystem::path>(&paths["timestamp"]),
|
||||||
".timestamp file")(
|
".timestamp file")
|
||||||
"ip,i", boost::program_options::value<std::string>(&ip_address)->default_value("0.0.0.0"),
|
("ip,i", boost::program_options::value<std::string>(&ip_address)->default_value("0.0.0.0"),
|
||||||
"IP address")("port,p", boost::program_options::value<int>(&ip_port)->default_value(5000),
|
"IP address")
|
||||||
"TCP/IP port")(
|
("port,p", boost::program_options::value<int>(&ip_port)->default_value(5000),
|
||||||
"threads,t", boost::program_options::value<int>(&requested_num_threads)->default_value(8),
|
"TCP/IP port")
|
||||||
"Number of threads to use")(
|
("threads,t", boost::program_options::value<int>(&requested_num_threads)->default_value(8),
|
||||||
"shared-memory,s",
|
"Number of threads to use")
|
||||||
boost::program_options::value<bool>(&use_shared_memory)->implicit_value(true),
|
("shared-memory,s", boost::program_options::value<bool>(&use_shared_memory)->implicit_value(true),
|
||||||
"Load data from shared memory")(
|
"Load data from shared memory")
|
||||||
"max-table-size,m",
|
("max-table-size,m", boost::program_options::value<int>(&max_locations_distance_table)->default_value(100),
|
||||||
boost::program_options::value<int>(&max_locations_distance_table)->default_value(100),
|
"Max. locations supported in distance table query")
|
||||||
"Max. locations supported in distance table query");
|
("max-matching-size,m", boost::program_options::value<int>(&max_locations_map_matching)->default_value(-1),
|
||||||
|
"Max. locations supported in map matching query");
|
||||||
|
|
||||||
// hidden options, will be allowed both on command line and in config
|
// hidden options, will be allowed both on command line and in config
|
||||||
// file, but will not be shown to the user
|
// file, but will not be shown to the user
|
||||||
@ -269,6 +271,10 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
|||||||
{
|
{
|
||||||
throw osrm::exception("Max location for distance table must be a positive number");
|
throw osrm::exception("Max location for distance table must be a positive number");
|
||||||
}
|
}
|
||||||
|
if (2 > max_locations_map_matching)
|
||||||
|
{
|
||||||
|
throw osrm::exception("Max location for map matching must be at least two");
|
||||||
|
}
|
||||||
|
|
||||||
SimpleLogger().Write() << visible_options;
|
SimpleLogger().Write() << visible_options;
|
||||||
return INIT_OK_DO_NOT_START_ENGINE;
|
return INIT_OK_DO_NOT_START_ENGINE;
|
||||||
|
Loading…
Reference in New Issue
Block a user