diff --git a/.gitignore b/.gitignore index 45e3cc4..8b91261 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ build/*.hpp install *.po~ src/version.hpp +compile_commands.json diff --git a/src/dlg_bulkdl_ex.cpp b/src/dlg_bulkdl_ex.cpp index 9fa6ca4..e60fbf1 100644 --- a/src/dlg_bulkdl_ex.cpp +++ b/src/dlg_bulkdl_ex.cpp @@ -32,8 +32,8 @@ bool dlg_bulkdl::show_ex() { // Populate the map selector m_choice_map->clear(); - florb::node section = florb::settings::get_instance()["tileservers"]; - for(florb::node::iterator it=section.begin(); it!=section.end(); ++it) { + YAML::Node section = florb::settings::get_instance()["tileservers"]; + for(YAML::Node::iterator it=section.begin(); it!=section.end(); ++it) { m_choice_map->add((*it).as().name().c_str()); } m_choice_map->value(0); diff --git a/src/dlg_search_ex.cpp b/src/dlg_search_ex.cpp index 1d5d9e7..6e00773 100644 --- a/src/dlg_search_ex.cpp +++ b/src/dlg_search_ex.cpp @@ -153,7 +153,7 @@ void dlg_search::process_download_ex() break; tinyxml2::XMLDocument doc; - if (doc.Parse(std::string(dtmp.buf().begin(), dtmp.buf().end()).c_str()) != tinyxml2::XML_NO_ERROR) + if (doc.Parse(std::string(dtmp.buf().begin(), dtmp.buf().end()).c_str()) != tinyxml2::XML_SUCCESS) break; tinyxml2::XMLElement* root = doc.RootElement(); diff --git a/src/dlg_settings_ex.cpp b/src/dlg_settings_ex.cpp index a1bf6e0..5dca6ce 100644 --- a/src/dlg_settings_ex.cpp +++ b/src/dlg_settings_ex.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include "settings.hpp" #include "utils.hpp" #include "unit.hpp" diff --git a/src/dlg_tileserver_ex.cpp b/src/dlg_tileserver_ex.cpp index d49f4da..003c3e5 100644 --- a/src/dlg_tileserver_ex.cpp +++ b/src/dlg_tileserver_ex.cpp @@ -81,8 +81,8 @@ bool dlg_tileserver::handle_ok_ex(bool add) // Make sure there is no other tile server with the same name if (add) { - florb::node section = florb::settings::get_instance()["tileservers"]; - for(florb::node::iterator it=section.begin(); it!=section.end(); ++it) + YAML::Node section = florb::settings::get_instance()["tileservers"]; + for(YAML::Node::iterator it=section.begin(); it!=section.end(); ++it) { if ((*it).as().name() == std::string(m_input_name->value())) { diff --git a/src/dlg_ui_ex.cpp b/src/dlg_ui_ex.cpp index 3f99b60..ff2967b 100644 --- a/src/dlg_ui_ex.cpp +++ b/src/dlg_ui_ex.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -222,8 +222,8 @@ void dlg_ui::update_choice_map_ex(void) m_choice_overlay->add(_("None")); // Get the configured tileservers from the florb::settings and populate the widgets - florb::node section = florb::settings::get_instance()["tileservers"]; - for(florb::node::iterator it=section.begin(); it!=section.end(); ++it) { + YAML::Node section = florb::settings::get_instance()["tileservers"]; + for(YAML::Node::iterator it=section.begin(); it!=section.end(); ++it) { m_choice_basemap->add((*it).as().name().c_str()); m_choice_overlay->add((*it).as().name().c_str()); } diff --git a/src/gfx.cpp b/src/gfx.cpp index df55180..d8e714e 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -147,7 +147,7 @@ namespace florb m_init = true; }; - image::image(int type, const unsigned char *buffer, int bufsize) : + image::image(int type, void const * const buffer, int bufsize) : m_type(type), m_init(false), m_buf(NULL) @@ -156,19 +156,18 @@ namespace florb { case PNG: { - m_buf = new Fl_PNG_Image(NULL, buffer, bufsize); + m_buf = new Fl_PNG_Image(NULL, static_cast(buffer), bufsize); m_init = true; break; } case JPG: { - m_buf = new Fl_JPEG_Image(NULL, buffer); + m_buf = new Fl_JPEG_Image(NULL, static_cast(buffer)); m_init = true; break; } default: - m_buf = NULL; - m_init = false; + break; } }; diff --git a/src/gfx.hpp b/src/gfx.hpp index 9b6085b..aae20c6 100644 --- a/src/gfx.hpp +++ b/src/gfx.hpp @@ -74,7 +74,7 @@ namespace florb class image { public: - image(int type, const unsigned char *buffer, int bufsize); + image(int type, void const * const buffer, int bufsize); ~image(); image_storage buf(void) { return m_buf; }; diff --git a/src/gpsdclient.cpp b/src/gpsdclient.cpp index 1b00439..3dd542e 100644 --- a/src/gpsdclient.cpp +++ b/src/gpsdclient.cpp @@ -181,7 +181,11 @@ void florb::gpsdclient::worker(void) } // Read data +#if GPSD_API_MAJOR_VERSION >= 7 + if (gps_read(&m_gpsdata, NULL, 0) == -1) { +#else if (gps_read(&m_gpsdata) == -1) { +#endif // Error break; } diff --git a/src/settings.cpp b/src/settings.cpp index 8a01d07..1a8e679 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2,322 +2,19 @@ #include #include "settings.hpp" -namespace YAML { - template<> - struct convert { - static Node encode(const florb::cfg_tileserver& rhs) { - Node node; - node["name"] = rhs.name(); - node["url"] = rhs.url(); - node["zmin"] = rhs.zmin(); - node["zmax"] = rhs.zmax(); - node["parallel"] = rhs.parallel(); - - node["type"] = "PNG"; - if (rhs.type() == florb::image::PNG) - node["type"] = "PNG"; - else if (rhs.type() == florb::image::JPG) - node["type"] = "JPG"; - - return node; - } - - static bool decode(const Node& node, florb::cfg_tileserver& rhs) - { - if((!node.IsMap()) || (node.size() == 0)) - return true; - - if (node["name"]) - rhs.name(node["name"].as()); - - if (node["url"]) - rhs.url(node["url"].as()); - - if (node["zmin"]) - rhs.zmin(node["zmin"].as()); - - if (node["zmax"]) - rhs.zmax(node["zmax"].as()); - - if (node["parallel"]) - rhs.parallel(node["parallel"].as()); - - if (node["type"]) - { - rhs.type(florb::image::PNG); - std::string imgtype = node["type"].as(); - if (imgtype.compare("PNG") == 0) - rhs.type(florb::image::PNG); - else if (imgtype.compare("JPG") == 0) - rhs.type(florb::image::JPG); - } - - return true; - } - }; - - template<> - struct convert { - static Node encode(const florb::cfg_cache& rhs) { - Node node; - node["location"] = rhs.location(); - return node; - } - - static bool decode(const Node& node, florb::cfg_cache& rhs) - { - if((!node.IsMap()) || (node.size() == 0)) - return true; - - if (node["location"]) - rhs.location(node["location"].as()); - - return true; - } - }; - - template<> - struct convert { - static Node encode(const florb::cfg_units& rhs) { - Node node; - - switch (rhs.system_length()) - { - case (florb::cfg_units::system::IMPERIAL): - node["system_length"] = "imperial"; - break; - case (florb::cfg_units::system::NAUTICAL): - node["system_length"] = "nautical"; - break; - default: - node["system_length"] = "metric"; - break; - } - - return node; - } - - static bool decode(const Node& node, florb::cfg_units& rhs) - { - if((!node.IsMap()) || (node.size() == 0)) - return true; - - if (node["system_length"]) - { - std::string sm(node["system_length"].as()); - if (sm == "imperial") - rhs.system_length(florb::cfg_units::system::IMPERIAL); - else if (sm == "nautical") - rhs.system_length(florb::cfg_units::system::NAUTICAL); - else - rhs.system_length(florb::cfg_units::system::METRIC); - } - - return true; - } - }; - - template<> - struct convert { - static Node encode(const florb::cfg_gpsd& rhs) { - Node node; - node["enabled"] = rhs.enabled(); - node["host"] = rhs.host(); - node["port"] = rhs.port(); - return node; - } - - static bool decode(const Node& node, florb::cfg_gpsd& rhs) - { - if((!node.IsMap()) || (node.size() == 0)) - return true; - - if (node["enabled"]) - rhs.enabled(node["enabled"].as()); - - if (node["host"]) - rhs.host(node["host"].as()); - - if (node["port"]) - rhs.port(node["port"].as()); - - return true; - } - }; - - template<> - struct convert { - static Node encode(const florb::cfg_ui& rhs) { - Node node; - node["markercolor"] = rhs.markercolor().rgb(); - node["markercolorselected"] = rhs.markercolorselected().rgb(); - node["trackcolor"] = rhs.trackcolor().rgb(); - node["selectioncolor"] = rhs.selectioncolor().rgb(); - node["gpscursorcolor"] = rhs.gpscursorcolor().rgb(); - node["tracklinewidth"] = rhs.tracklinewidth(); - return node; - } - - static bool decode(const Node& node, florb::cfg_ui& rhs) - { - // Use defaults - if((!node.IsMap()) || (node.size() == 0)) - { - return true; - } - - if (node["markercolor"]) - rhs.markercolor(florb::color(node["markercolor"].as())); - - if (node["markercolorselected"]) - rhs.markercolorselected(florb::color(node["markercolorselected"].as())); - - if (node["trackcolor"]) - rhs.trackcolor(florb::color(node["trackcolor"].as())); - - if (node["selectioncolor"]) - rhs.selectioncolor(florb::color(node["selectioncolor"].as())); - - if (node["gpscursorcolor"]) - rhs.gpscursorcolor(florb::color(node["gpscursorcolor"].as())); - - if (node["tracklinewidth"]) - rhs.tracklinewidth(node["tracklinewidth"].as()); - - return true; - } - }; - - template<> - struct convert { - static Node encode(const florb::cfg_viewport& rhs) { - Node node; - node["lon"] = rhs.lon(); - node["lat"] = rhs.lat(); - node["z"] = rhs.z(); - return node; - } - - static bool decode(const Node& node, florb::cfg_viewport& rhs) - { - if((!node.IsMap()) || (node.size() == 0)) - { - return true; - } - - - if (node["lat"]) - rhs.lat(node["lat"].as()); - - if (node["lon"]) - rhs.lon(node["lon"].as()); - - if (node["z"]) - rhs.z(node["z"].as()); - - return true; - } - }; -} - -class florb::yaml_node -{ - public: - yaml_node(YAML::Node n) : m_node(n) {}; - yaml_node(const std::string& path) - { - // Touch cfgfile in case it doesn't exist - florb::utils::touch(path); - m_node = YAML::LoadFile(path); - } - ~yaml_node() {}; - - YAML::Node& get() { return m_node; }; - private: - YAML::Node m_node; -}; - -class florb::yaml_iterator -{ - public: - yaml_iterator(YAML::iterator i) : m_iter(i) {}; - ~yaml_iterator() {}; - - YAML::iterator& get() { return m_iter; }; - private: - YAML::iterator m_iter; -}; - -florb::node::iterator::iterator(const node& n, int be) -{ - if (be <= 0) - m_ref = new yaml_iterator(n.m_ref->get().begin()); - else - m_ref = new yaml_iterator(n.m_ref->get().end()); -} - -florb::node::iterator::~iterator() -{ - delete m_ref; -} - -bool florb::node::iterator::operator==(iterator const& rhs) const -{ - return (m_ref->get() == rhs.m_ref->get()); -} - -bool florb::node::iterator::operator!=(iterator const& rhs) const -{ - return !(m_ref->get() == rhs.m_ref->get()); -} - -florb::node::iterator& florb::node::iterator::operator++() -{ - (m_ref->get())++; - return *this; -} - -florb::node::iterator florb::node::iterator::operator++(int) -{ - florb::node::iterator tmp (*this); - ++(*this); - return tmp; -} - -// Bidirectional iterators are not supported by YAML-Cpp -#if 0 -iterator& florb::node::iterator::operator--() -{ - (m_ref.get())--; - return *this; -} - -iterator florb::node::iterator::operator--(int) -{ - iterator tmp (*this); - --(*this); - return tmp; -} -#endif - -florb::node florb::node::iterator::operator* () const -{ - florb::yaml_node *tmp = new florb::yaml_node(*(m_ref->get())); - return florb::node(tmp); -} - florb::settings::settings() { m_cfgfile = florb::utils::appdir() + florb::utils::pathsep() + "config"; florb::utils::mkdir(florb::utils::appdir()); - m_rootnode = florb::node(m_cfgfile); + m_rootnode = YAML::LoadFile(m_cfgfile); defaults(m_cfgfile); } florb::settings::~settings() { - m_rootnode.serialize(m_cfgfile); + std::ofstream fout(m_cfgfile.c_str(), std::fstream::in|std::fstream::out|std::fstream::trunc); + fout << m_rootnode; } florb::settings& florb::settings::get_instance() @@ -330,7 +27,7 @@ void florb::settings::defaults(const std::string& path) { // Tileserver default configuration florb::cfg_tileserver cfgtileserver; - if((!m_rootnode["tileservers"]) || (!m_rootnode["tileservers"].is_sequence())) + if((!m_rootnode["tileservers"]) || (!m_rootnode["tileservers"].IsSequence())) { std::vector v; v.push_back(cfgtileserver); @@ -359,115 +56,3 @@ void florb::settings::defaults(const std::string& path) m_rootnode["units"] = cfgunits; } -florb::node::node(const std::string& path) -{ - m_ref = new florb::yaml_node(path); -} - -florb::node::node(const node& n) -{ - m_ref = new florb::yaml_node(n.m_ref->get()); -} - -florb::node::node() -{ - m_ref = new florb::yaml_node(YAML::Node()); -} - -florb::node::~node() -{ - if (m_ref) - delete m_ref; -} - -bool florb::node::is_sequence() -{ - return m_ref->get().IsSequence(); -} - -florb::node florb::node::operator[] (const int idx) -{ - return florb::node(new florb::yaml_node(m_ref->get()[idx])); -} - -florb::node florb::node::operator[] (const std::string &name) -{ - return florb::node(new florb::yaml_node(m_ref->get()[name])); -} - -florb::node& florb::node::operator= (const node& n) -{ - if (m_ref) - delete m_ref; - - m_ref = new florb::yaml_node(n.m_ref->get()); - - return *this; -} - -template florb::node& florb::node::operator= (const T& rhs) -{ - m_ref->get() = rhs; - return *this; -} - -florb::node::operator bool() const -{ - return m_ref->get(); -} - -template T florb::node::as() const -{ - return m_ref->get().as(); -} - -template void florb::node::push_back(const T& rhs) -{ - m_ref->get().push_back(rhs); -} - -void florb::node::push_back(const node& rhs) -{ - m_ref->get().push_back(rhs.m_ref->get()); -} - -void florb::node::serialize(const std::string& path) -{ - std::ofstream fout(path.c_str(), std::fstream::in|std::fstream::out|std::fstream::trunc); - fout << m_ref->get(); -} - -size_t florb::node::size() -{ - return m_ref->get().size(); -} - -// This is necessary so YAML::Node template internals remain hidden from the -// header file -template int florb::node::as() const; -template std::string florb::node::as() const; -template florb::cfg_tileserver florb::node::as() const; -template std::vector< florb::cfg_tileserver > florb::node::as< std::vector >() const; -template bool florb::node::as() const; -template florb::cfg_cache florb::node::as() const; -template florb::cfg_gpsd florb::node::as() const; -template florb::cfg_ui florb::node::as() const; -template florb::cfg_viewport florb::node::as() const; -template florb::cfg_units florb::node::as() const; - -template void florb::node::push_back(const int& rhs); -template void florb::node::push_back(const std::string& rhs); -template void florb::node::push_back(const florb::cfg_tileserver& rhs); - -template florb::node& florb::node::operator= (const int& rhs); -template florb::node& florb::node::operator=< std::vector > (const std::vector& rhs); -template florb::node& florb::node::operator= (const std::string& rhs); -template florb::node& florb::node::operator=< std::vector > (const std::vector& rhs); -template florb::node& florb::node::operator= (const florb::cfg_tileserver& rhs); -template florb::node& florb::node::operator= (const bool& rhs); -template florb::node& florb::node::operator= (const florb::cfg_gpsd& rhs); -template florb::node& florb::node::operator= (const florb::cfg_ui& rhs); -template florb::node& florb::node::operator= (const florb::cfg_cache& rhs); -template florb::node& florb::node::operator= (const florb::cfg_viewport& rhs); -template florb::node& florb::node::operator= (const florb::cfg_units& rhs); - diff --git a/src/settings.hpp b/src/settings.hpp index 952ce26..71a865a 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -2,17 +2,10 @@ #define SETTINGS_HPP #include -#include +#include #include "gfx.hpp" #include "utils.hpp" -// The YAML namespace defines an enumerator "None". This clashes with a -// definition of "None" in X.h which is included by FLTK. So if there is any -// module including FLTK and YAML headers, things get nasty. Thus this clumsy -// attempt at hiding the YAML-cpp internals. It could have been so easy... -// On a positive note it is now relatively easy to swap out YAML-cpp for some -// other backend. - namespace florb { // Tileserver configuration class @@ -160,7 +153,6 @@ namespace florb class cfg_units { public: - enum system { METRIC, @@ -174,7 +166,6 @@ namespace florb cfg_units() : m_sl(system::METRIC) {}; - system system_length() const { return m_sl; } void system_length(system sl) { m_sl = sl; } @@ -182,77 +173,243 @@ namespace florb system m_sl; }; - // Forward declaration of YAML-cpp node container and iterator container - class yaml_node; - class yaml_iterator; - - // A configuration node - class node - { - public: - class iterator : public std::iterator - { - public: - iterator(const node &n, int be); - ~iterator(); - bool operator==(iterator const& rhs) const; - bool operator!=(iterator const& rhs) const; - iterator& operator++(); - iterator operator++(int); -#if 0 - iterator& operator--(); - iterator operator--(int); -#endif - node operator* () const; - private: - yaml_iterator *m_ref; - }; - iterator begin() { return iterator(*this, -1); } - iterator end() { return iterator(*this, 1); } - - node(); - node(yaml_node *in) : m_ref(in) {}; - node(const std::string& path); - node(const node& n); - ~node(); - - bool is_sequence(); - - node operator[] (const int idx); - node operator[] (const std::string &name); - node& operator= (const node& n); - template node& operator= (const T& rhs); - - explicit operator bool() const; - - size_t size(); - template T as() const; - template void push_back(const T& rhs); - void push_back(const node& rhs); - void serialize(const std::string& path); - private: - yaml_node *m_ref; - }; - // Settings singleton class settings { public: ~settings(); static settings& get_instance(); - node& root() { return m_rootnode; }; - - node operator[] (const int idx) { return m_rootnode[idx]; }; - node operator[] (const std::string &name) { return m_rootnode[name]; }; + YAML::Node& root() { return m_rootnode; }; + YAML::Node operator[] (const int idx) { return m_rootnode[idx]; }; + YAML::Node operator[] (const std::string &name) { return m_rootnode[name]; }; private: settings(); settings(const settings& s); void defaults(const std::string& path); - node m_rootnode; + YAML::Node m_rootnode; std::string m_cfgfile; }; }; +namespace YAML { + template<> + struct convert { + static Node encode(const florb::cfg_tileserver& rhs) { + Node node; + node["name"] = rhs.name(); + node["url"] = rhs.url(); + node["zmin"] = rhs.zmin(); + node["zmax"] = rhs.zmax(); + node["parallel"] = rhs.parallel(); + + node["type"] = "PNG"; + if (rhs.type() == florb::image::PNG) + node["type"] = "PNG"; + else if (rhs.type() == florb::image::JPG) + node["type"] = "JPG"; + + return node; + } + + static bool decode(const Node& node, florb::cfg_tileserver& rhs) + { + if((!node.IsMap()) || (node.size() == 0)) + return true; + + if (node["name"]) + rhs.name(node["name"].as()); + + if (node["url"]) + rhs.url(node["url"].as()); + + if (node["zmin"]) + rhs.zmin(node["zmin"].as()); + + if (node["zmax"]) + rhs.zmax(node["zmax"].as()); + + if (node["parallel"]) + rhs.parallel(node["parallel"].as()); + + if (node["type"]) + { + rhs.type(florb::image::PNG); + std::string imgtype = node["type"].as(); + if (imgtype.compare("PNG") == 0) + rhs.type(florb::image::PNG); + else if (imgtype.compare("JPG") == 0) + rhs.type(florb::image::JPG); + } + + return true; + } + }; + + template<> + struct convert { + static Node encode(const florb::cfg_cache& rhs) { + Node node; + node["location"] = rhs.location(); + return node; + } + + static bool decode(const Node& node, florb::cfg_cache& rhs) + { + if((!node.IsMap()) || (node.size() == 0)) + return true; + + if (node["location"]) + rhs.location(node["location"].as()); + + return true; + } + }; + + template<> + struct convert { + static Node encode(const florb::cfg_units& rhs) { + Node node; + + switch (rhs.system_length()) + { + case (florb::cfg_units::system::IMPERIAL): + node["system_length"] = "imperial"; + break; + case (florb::cfg_units::system::NAUTICAL): + node["system_length"] = "nautical"; + break; + default: + node["system_length"] = "metric"; + break; + } + + return node; + } + + static bool decode(const Node& node, florb::cfg_units& rhs) + { + if((!node.IsMap()) || (node.size() == 0)) + return true; + + if (node["system_length"]) + { + std::string sm(node["system_length"].as()); + if (sm == "imperial") + rhs.system_length(florb::cfg_units::system::IMPERIAL); + else if (sm == "nautical") + rhs.system_length(florb::cfg_units::system::NAUTICAL); + else + rhs.system_length(florb::cfg_units::system::METRIC); + } + + return true; + } + }; + + template<> + struct convert { + static Node encode(const florb::cfg_gpsd& rhs) { + Node node; + node["enabled"] = rhs.enabled(); + node["host"] = rhs.host(); + node["port"] = rhs.port(); + return node; + } + + static bool decode(const Node& node, florb::cfg_gpsd& rhs) + { + if((!node.IsMap()) || (node.size() == 0)) + return true; + + if (node["enabled"]) + rhs.enabled(node["enabled"].as()); + + if (node["host"]) + rhs.host(node["host"].as()); + + if (node["port"]) + rhs.port(node["port"].as()); + + return true; + } + }; + + template<> + struct convert { + static Node encode(const florb::cfg_ui& rhs) { + Node node; + node["markercolor"] = rhs.markercolor().rgb(); + node["markercolorselected"] = rhs.markercolorselected().rgb(); + node["trackcolor"] = rhs.trackcolor().rgb(); + node["selectioncolor"] = rhs.selectioncolor().rgb(); + node["gpscursorcolor"] = rhs.gpscursorcolor().rgb(); + node["tracklinewidth"] = rhs.tracklinewidth(); + return node; + } + + static bool decode(const Node& node, florb::cfg_ui& rhs) + { + // Use defaults + if((!node.IsMap()) || (node.size() == 0)) + { + return true; + } + + if (node["markercolor"]) + rhs.markercolor(florb::color(node["markercolor"].as())); + + if (node["markercolorselected"]) + rhs.markercolorselected(florb::color(node["markercolorselected"].as())); + + if (node["trackcolor"]) + rhs.trackcolor(florb::color(node["trackcolor"].as())); + + if (node["selectioncolor"]) + rhs.selectioncolor(florb::color(node["selectioncolor"].as())); + + if (node["gpscursorcolor"]) + rhs.gpscursorcolor(florb::color(node["gpscursorcolor"].as())); + + if (node["tracklinewidth"]) + rhs.tracklinewidth(node["tracklinewidth"].as()); + + return true; + } + }; + + template<> + struct convert { + static Node encode(const florb::cfg_viewport& rhs) { + Node node; + node["lon"] = rhs.lon(); + node["lat"] = rhs.lat(); + node["z"] = rhs.z(); + return node; + } + + static bool decode(const Node& node, florb::cfg_viewport& rhs) + { + if((!node.IsMap()) || (node.size() == 0)) + { + return true; + } + + + if (node["lat"]) + rhs.lat(node["lat"].as()); + + if (node["lon"]) + rhs.lon(node["lon"].as()); + + if (node["z"]) + rhs.z(node["z"].as()); + + return true; + } + }; +} + + #endif // SETTINGS_HPP diff --git a/src/tracklayer.cpp b/src/tracklayer.cpp index 994ccf6..06fd920 100644 --- a/src/tracklayer.cpp +++ b/src/tracklayer.cpp @@ -285,7 +285,7 @@ void florb::tracklayer::load_track(const std::string &path) { // Load the XML tinyxml2::XMLDocument doc; - if (doc.LoadFile(path.c_str()) != tinyxml2::XML_NO_ERROR) + if (doc.LoadFile(path.c_str()) != tinyxml2::XML_SUCCESS) throw std::runtime_error(_("Failed to open GPX file")); // Clear existing track and selection @@ -411,7 +411,7 @@ void florb::tracklayer::save_track(const std::string &path) setlocale(LC_ALL, oldlc); // Throw in case of error - if (xmlerr != tinyxml2::XML_NO_ERROR) + if (xmlerr != tinyxml2::XML_SUCCESS) throw std::runtime_error(_("Failed to save GPX data")); } diff --git a/src/utils.cpp b/src/utils.cpp index 1efb7ad..aa5f9cc 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -117,7 +117,7 @@ double florb::utils::dist(const florb::point2d &p1, const florb::point2d double ret = (6378.388 * acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1))); - return (isnan(ret) > 0) ? 0.0 : ret; + return (std::isnan(ret) > 0) ? 0.0 : ret; } double florb::utils::dist_merc(const florb::point2d &p1, const florb::point2d &p2)