1 #include "config/result_config.hpp"
2 #include "util/util.hpp"
3 #include "util/debug.hpp"
30 SPDLOG_INFO(
"ResultConfig");
31 SPDLOG_INFO(
"File: {}",
file);
32 SPDLOG_INFO(
"Fields: {}",ss.str());
36 const boost::property_tree::ptree &xml_data) {
38 config.
file = xml_data.get<std::string>(
"config.output.file");
39 if (xml_data.get_child_optional(
"config.output.fields")) {
44 if (xml_data.get_child_optional(
"config.output.fields.opath")) {
47 if (xml_data.get_child_optional(
"config.output.fields.cpath")) {
50 if (xml_data.get_child_optional(
"config.output.fields.tpath")) {
53 if (xml_data.get_child_optional(
"config.output.fields.mgeom")) {
56 if (xml_data.get_child_optional(
"config.output.fields.pgeom")) {
59 if (xml_data.get_child_optional(
"config.output.fields.offset")) {
62 if (xml_data.get_child_optional(
"config.output.fields.error")) {
65 if (xml_data.get_child_optional(
"config.output.fields.spdist")) {
68 if (xml_data.get_child_optional(
"config.output.fields.ep")) {
71 if (xml_data.get_child_optional(
"config.output.fields.tp")) {
74 if (xml_data.get_child_optional(
"config.output.fields.length")) {
77 if (xml_data.get_child_optional(
"config.output.fields.all")) {
95 const cxxopts::ParseResult &arg_data) {
97 config.
file = arg_data[
"output"].as<std::string>();
98 if (arg_data.count(
"output_fields") > 0) {
101 std::string fields = arg_data[
"output_fields"].as<std::string>();
102 std::set<std::string> dict = string2set(fields);
103 if (dict.find(
"opath") != dict.end()) {
106 if (dict.find(
"cpath") != dict.end()) {
109 if (dict.find(
"mgeom") != dict.end()) {
112 if (dict.find(
"tpath") != dict.end()) {
115 if (dict.find(
"pgeom") != dict.end()) {
118 if (dict.find(
"offset") != dict.end()) {
121 if (dict.find(
"error") != dict.end()) {
124 if (dict.find(
"spdist") != dict.end()) {
127 if (dict.find(
"ep") != dict.end()) {
130 if (dict.find(
"tp") != dict.end()) {
133 if (dict.find(
"length") != dict.end()) {
136 if (dict.find(
"all") != dict.end()) {
154 const std::string &s) {
156 std::set<std::string> result;
157 std::stringstream ss(s);
158 std::string intermediate;
159 while (getline(ss, intermediate, delim)) {
160 result.insert(intermediate);
167 SPDLOG_WARN(
"Overwrite existing result file {}",file);
171 SPDLOG_CRITICAL(
"Output folder {} not exists",output_folder);
static ResultConfig load_from_xml(const boost::property_tree::ptree &xml_data)
Load result configuration data from xml file.
bool write_tpath
if true, tpath (the path traversed between each two consecutive observations) will be exported
bool write_ep
if true, ep (emission proability of each point) will be exported
bool validate() const
Check the validation of the configuration.
bool write_spdist
if true, spdist (the distance traversed between each two consecutive points) will be exported
bool write_tp
if true, tp (transition probability) will be exported
OutputConfig output_config
Output fields to export.
bool write_length
if true, length (length of each matched edge) will be exported
std::string file
Output file to write the result.
bool folder_exist(const std::string &folder_name)
Check if folder exists or not.
bool write_mgeom
if true, mgeom (the geometry of the matched path) will be exported
static std::set< std::string > string2set(const std::string &s)
Parse a string separated by , into a set of strings.
std::string get_file_directory(const std::string &fn)
Get folder path from file path.
bool write_cpath
if true, cpath (a list of edge ID representing the matched path) will be exported
bool write_opath
if true, opath (edge id matched for each point) will be exported
Result Configuration class, defining output file and output fields.
bool write_error
if true, gps error (distance from GPS point to the matched point) will be exported
void print() const
Print the configuration information.
static ResultConfig load_from_arg(const cxxopts::ParseResult &arg_data)
Load result configuration from argument data.
bool write_pgeom
if true, pgeom (a linestring connecting the matched point) will be exported
bool file_exists(const char *filename)
Check if file exist or not.
bool write_offset
if true, offset (distance to the start point of a matched edge) will be exported