diff --git a/cache.cpp b/cache.cpp index de708d8..91cb307 100644 --- a/cache.cpp +++ b/cache.cpp @@ -34,9 +34,9 @@ std::string Cache::safe_name() const { return tmp; } -float Cache::distance() const { - return 2 * Earth_radius * asin(sqrt(pow(sin(degtorad((pos.lat - home.lat) / 2)), 2) + cos(degtorad(pos.lat)) * cos(degtorad(home.lat)) * pow(sin(degtorad((pos.lon - home.lon) / 2)), 2))); -} +// float Cache::distance() const { +// return 2 * Earth_radius * asin(sqrt(pow(sin(degtorad((pos.lat - home.lat) / 2)), 2) + cos(degtorad(pos.lat)) * cos(degtorad(home.lat)) * pow(sin(degtorad((pos.lon - home.lon) / 2)), 2))); +// } void Cache::set_date(const std::tm& t) { char tmp[20]; diff --git a/cache.h b/cache.h index a57849e..b656d9e 100644 --- a/cache.h +++ b/cache.h @@ -37,9 +37,6 @@ enum Status { unknown }; -const uint Earth_radius = 6378; -const uint Moon_dist = 384400; - class Cache { public: std::string code; @@ -87,5 +84,5 @@ public: std::string link() const; std::string link_name() const; std::string safe_name() const; - float distance() const; + // float distance() const; }; diff --git a/common.h b/common.h index f32e741..a861e75 100644 --- a/common.h +++ b/common.h @@ -12,6 +12,9 @@ class Cache; +const uint Earth_radius = 6378; +const uint Moon_dist = 384400; + typedef std::vector Caches; typedef std::vector pCaches; typedef std::multimap Date_Caches; diff --git a/geostat_cli.cpp b/geostat_cli.cpp index 5d7fd74..3de6420 100644 --- a/geostat_cli.cpp +++ b/geostat_cli.cpp @@ -24,7 +24,7 @@ void show_usage() { std::cout << " * Output:\n"; std::cout << "\t-N\t\tcompute stats only for unfound caches (works only with SQLite)\n"; std::cout << "\t-M\t\tprint geographically extreme caches\n"; - std::cout << "\t-D\t\tprint furthest and closest caches\n"; + // std::cout << "\t-D\t\tprint furthest and closest caches\n"; std::cout << "\t-C\t\tprint calendar related stats\n"; std::cout << "\t-H file\t\trender a heat map to a file\n"; std::cout << "\t-s n\t\tstamp size for a heat map (default = 15)\n"; @@ -43,7 +43,7 @@ void show_usage() { int main(int argc, char** argv) { User user; bool show_minmax = 0; - bool show_dist = 0; + // bool show_dist = 0; bool show_list = 0; bool show_dt = 0; bool show_owners = 0; @@ -112,9 +112,9 @@ int main(int argc, char** argv) { case 'M': show_minmax = 1; break; - case 'D': - show_dist = 1; - break; + // case 'D': + // show_dist = 1; + // break; case 'C': show_calendar = 1; break; @@ -221,15 +221,15 @@ int main(int argc, char** argv) { W->show(); } - if (show_dist) { - auto far = *std::max_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); }); - auto near = *std::min_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); }); - - std::cout << "Nearest cache: " << near->distance() << " km\n"; - near->show(); - std::cout << "Furthest cache: " << far->distance() << " km\n"; - far->show(); - } + // if (show_dist) { + // auto far = *std::max_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); }); + // auto near = *std::min_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); }); + // + // std::cout << "Nearest cache: " << near->distance() << " km\n"; + // near->show(); + // std::cout << "Furthest cache: " << far->distance() << " km\n"; + // far->show(); + // } if (show_owners) { show_histogram(user.cc, &Cache::owner, "Cache owners"); diff --git a/okapi.cpp b/okapi.cpp index 21f89eb..c74797d 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -11,13 +11,6 @@ using json = nlohmann::json; -static const std::string OKAPI_logs = "services/logs/userlogs"; -static const std::string OKAPI_cache = "services/caches/geocache"; -static const std::string OKAPI_caches = "services/caches/geocaches"; -static const std::string OKAPI_username = "services/users/by_username"; -static const std::string OKAPI_user = "services/users/user"; -static const std::string OKAPI_changelog = "services/replicate/changelog"; - Okapi::Okapi(const std::string& server_url, const std::string& consumer_key) : url(server_url), key(consumer_key) { if (url.find(".pl/") != std::string::npos) service = "OC.pl"; diff --git a/okapi.h b/okapi.h index 05c1c55..e83031a 100644 --- a/okapi.h +++ b/okapi.h @@ -28,6 +28,13 @@ private: const static int MAX_LOGS = 1000; const static int MAX_CACHES = 500; + constexpr static auto OKAPI_logs = "services/logs/userlogs"; + constexpr static auto OKAPI_cache = "services/caches/geocache"; + constexpr static auto OKAPI_caches = "services/caches/geocaches"; + constexpr static auto OKAPI_username = "services/users/by_username"; + constexpr static auto OKAPI_user = "services/users/user"; + constexpr static auto OKAPI_changelog = "services/replicate/changelog"; + public: Okapi(const std::string& server_url, const std::string& consumer_key); ~Okapi();