kopia lustrzana https://gitlab.com/tomaszg/geostat
Move around some consts, comment out code unused for now
rodzic
03b8952fac
commit
3f109a7047
|
@ -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];
|
||||
|
|
5
cache.h
5
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;
|
||||
};
|
||||
|
|
3
common.h
3
common.h
|
@ -12,6 +12,9 @@
|
|||
|
||||
class Cache;
|
||||
|
||||
const uint Earth_radius = 6378;
|
||||
const uint Moon_dist = 384400;
|
||||
|
||||
typedef std::vector<Cache> Caches;
|
||||
typedef std::vector<const Cache*> pCaches;
|
||||
typedef std::multimap<std::time_t, const Cache*> Date_Caches;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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";
|
||||
|
|
7
okapi.h
7
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();
|
||||
|
|
Ładowanie…
Reference in New Issue