1 #include "config/gps_config.hpp"
2 #include "util/util.hpp"
3 #include "util/debug.hpp"
8 SPDLOG_INFO(
"GPS format: GDAL trajectory");
9 SPDLOG_INFO(
"File name: {} ",
file);
10 SPDLOG_INFO(
"ID name: {} ",
id);
11 SPDLOG_INFO(
"Timestamp name: {} ",
timestamp);
12 }
else if (format==1) {
13 SPDLOG_INFO(
"GPS format: CSV trajectory");
14 SPDLOG_INFO(
"File name: {} ",
file);
15 SPDLOG_INFO(
"ID name: {} ",
id);
16 SPDLOG_INFO(
"Geom name: {} ",
geom);
17 SPDLOG_INFO(
"Timestamp name: {} ",
timestamp);
19 SPDLOG_INFO(
"GPS format: CSV point");
20 SPDLOG_INFO(
"File name: {} ",
file);
21 SPDLOG_INFO(
"ID name: {} ",
id);
22 SPDLOG_INFO(
"x name: {} ",
x);
23 SPDLOG_INFO(
"y name: {} ",
y);
24 SPDLOG_INFO(
"Timestamp name: {} ",
timestamp);
29 const boost::property_tree::ptree &xml_data){
31 config.
file = xml_data.get<std::string>(
"config.input.gps.file");
32 config.
id = xml_data.get(
"config.input.gps.id",
"id");
33 config.
geom = xml_data.get(
"config.input.gps.geom",
"geom");
34 config.
timestamp = xml_data.get(
"config.input.gps.timestamp",
36 config.
x = xml_data.get(
"config.input.gps.x",
"x");
37 config.
y = xml_data.get(
"config.input.gps.y",
"y");
38 config.
gps_point = !(!xml_data.get_child_optional(
39 "config.input.gps.gps_point"));
44 const cxxopts::ParseResult &arg_data){
46 config.
file = arg_data[
"gps"].as<std::string>();
47 config.
id = arg_data[
"gps_id"].as<std::string>();
48 config.
geom = arg_data[
"gps_geom"].as<std::string>();
49 config.
timestamp = arg_data[
"gps_timestamp"].as<std::string>();
50 config.
x = arg_data[
"gps_x"].as<std::string>();
51 config.
y = arg_data[
"gps_y"].as<std::string>();
52 if (arg_data.count(
"gps_point")>0)
58 std::string fn_extension = file.substr(
59 file.find_last_of(
".") + 1);
60 if (fn_extension ==
"csv" || fn_extension ==
"txt") {
66 }
else if (fn_extension ==
"gpkg" || fn_extension ==
"shp") {
69 SPDLOG_CRITICAL(
"GPS file extension {} unknown",fn_extension);
77 SPDLOG_CRITICAL(
"GPS file {} not found",file);
80 if (get_gps_format()<0) {
81 SPDLOG_CRITICAL(
"Unknown GPS format");
std::string x
x field/column name
std::string y
y field/column name
bool validate() const
Validate the GPS configuration for file existence, parameter validation.
std::string id
id field/column name
bool gps_point
gps point stored or not
std::string geom
geometry field/column name
GPS configuration class for reading data from a file.
void print() const
Print members of the GPS configuration.
std::string timestamp
timestamp field/column name
bool file_exists(const char *filename)
Check if file exist or not.
int get_gps_format() const
Find the GPS format.
static GPSConfig load_from_xml(const boost::property_tree::ptree &xml_data)
Load GPSConfig from XML data.
static GPSConfig load_from_arg(const cxxopts::ParseResult &arg_data)
Load GPSConfig from argument parsed data.