Move around some consts, comment out code unused for now

master
Tomasz Golinski 2023-08-30 15:53:47 +02:00
rodzic 03b8952fac
commit 3f109a7047
6 zmienionych plików z 28 dodań i 28 usunięć

Wyświetl plik

@ -34,9 +34,9 @@ std::string Cache::safe_name() const {
return tmp; return tmp;
} }
float Cache::distance() const { // 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))); // 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) { void Cache::set_date(const std::tm& t) {
char tmp[20]; char tmp[20];

Wyświetl plik

@ -37,9 +37,6 @@ enum Status {
unknown unknown
}; };
const uint Earth_radius = 6378;
const uint Moon_dist = 384400;
class Cache { class Cache {
public: public:
std::string code; std::string code;
@ -87,5 +84,5 @@ public:
std::string link() const; std::string link() const;
std::string link_name() const; std::string link_name() const;
std::string safe_name() const; std::string safe_name() const;
float distance() const; // float distance() const;
}; };

Wyświetl plik

@ -12,6 +12,9 @@
class Cache; class Cache;
const uint Earth_radius = 6378;
const uint Moon_dist = 384400;
typedef std::vector<Cache> Caches; typedef std::vector<Cache> Caches;
typedef std::vector<const Cache*> pCaches; typedef std::vector<const Cache*> pCaches;
typedef std::multimap<std::time_t, const Cache*> Date_Caches; typedef std::multimap<std::time_t, const Cache*> Date_Caches;

Wyświetl plik

@ -24,7 +24,7 @@ void show_usage() {
std::cout << " * Output:\n"; std::cout << " * Output:\n";
std::cout << "\t-N\t\tcompute stats only for unfound caches (works only with SQLite)\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-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-C\t\tprint calendar related stats\n";
std::cout << "\t-H file\t\trender a heat map to a file\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"; 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) { int main(int argc, char** argv) {
User user; User user;
bool show_minmax = 0; bool show_minmax = 0;
bool show_dist = 0; // bool show_dist = 0;
bool show_list = 0; bool show_list = 0;
bool show_dt = 0; bool show_dt = 0;
bool show_owners = 0; bool show_owners = 0;
@ -112,9 +112,9 @@ int main(int argc, char** argv) {
case 'M': case 'M':
show_minmax = 1; show_minmax = 1;
break; break;
case 'D': // case 'D':
show_dist = 1; // show_dist = 1;
break; // break;
case 'C': case 'C':
show_calendar = 1; show_calendar = 1;
break; break;
@ -221,15 +221,15 @@ int main(int argc, char** argv) {
W->show(); W->show();
} }
if (show_dist) { // 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 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(); }); // 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"; // std::cout << "Nearest cache: " << near->distance() << " km\n";
near->show(); // near->show();
std::cout << "Furthest cache: " << far->distance() << " km\n"; // std::cout << "Furthest cache: " << far->distance() << " km\n";
far->show(); // far->show();
} // }
if (show_owners) { if (show_owners) {
show_histogram(user.cc, &Cache::owner, "Cache owners"); show_histogram(user.cc, &Cache::owner, "Cache owners");

Wyświetl plik

@ -11,13 +11,6 @@
using json = nlohmann::json; 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) { 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) if (url.find(".pl/") != std::string::npos)
service = "OC.pl"; service = "OC.pl";

Wyświetl plik

@ -28,6 +28,13 @@ private:
const static int MAX_LOGS = 1000; const static int MAX_LOGS = 1000;
const static int MAX_CACHES = 500; 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: public:
Okapi(const std::string& server_url, const std::string& consumer_key); Okapi(const std::string& server_url, const std::string& consumer_key);
~Okapi(); ~Okapi();