geostat/cache.h

99 wiersze
2.3 KiB
C
Czysty Zwykły widok Historia

2019-09-08 16:42:10 +00:00
#pragma once
#include <string>
#include <set>
#include <map>
2020-01-25 15:12:29 +00:00
#include <vector>
2019-09-08 16:42:10 +00:00
#include <iostream>
#include <ctime>
2019-09-08 16:42:10 +00:00
// enum Service {
// gc,
// ocpl,
// ocde,
// ocna,
// ocro,
// ocuk,
// ocnl,
// gcsu
// };
2019-09-08 16:42:10 +00:00
// enum Type {
// traditional,
// multi,
// quiz, // also known as "Mystery"
// moving, // a geocache with changing coordinates
// virt,
// webcam,
// other, // also dubbed "unknown type"; allows OC users to create special caches which don't fit into the scheme of well-known types
// event, // a peculiar type of geocache which is NOT a geocache at all, but it is stored as a geocache in OC database. Just keep in mind, that in case of Event Caches, some fields may have a little different meaning than you would tell by their name
// own, // a moving geocache which is carried by the owner
// podcast //a geocache with attached MP3 file(s). The MP3 data is not accessible via OKAPI. This type is only in use at Opencaching.US
// };
2020-03-06 09:55:57 +00:00
enum Status {
ok, // available
disabled, // temporarily disabled
archived, // archived
unknown
};
2019-11-10 19:59:21 +00:00
const int Earth_radius = 6378;
const double Pi = 3.14159265358979323846264338327950288;
2019-09-08 16:42:10 +00:00
class Position {
public:
float lat = 0;
float lon = 0;
Position() = default;
Position(float y, float x) : lat(y), lon(x) {}
2019-09-08 16:42:10 +00:00
};
class Cache {
public:
std::string code;
Position pos;
std::string name;
2020-03-06 09:55:57 +00:00
Status status;
2019-09-08 16:42:10 +00:00
std::string size;
float diff = 0;
float terr = 0;
2020-01-25 15:12:29 +00:00
int fav = 0;
int founds = 0;
bool recommended = 0; // was the cache recommended by that user?
2019-09-08 16:42:10 +00:00
std::string type;
2019-09-12 11:58:54 +00:00
std::string region;
std::string origin;
std::string owner;
std::string owner_uuid;
std::time_t date_t;
std::time_t date_hidden_t;
std::tm date_tm;
std::tm date_hidden_tm;
std::string year;
std::string mon;
std::string day;
std::string hour;
2019-11-17 18:42:32 +00:00
std::string day_of_week;
std::string date;
std::string date_hidden;
void set_date(const std::tm& t);
void set_date_hidden(const std::tm& t);
2019-09-08 16:42:10 +00:00
static Position home;
void show() const;
std::string link() const;
std::string link_name() const;
std::string safe_name() const;
2019-09-08 16:42:10 +00:00
float distance() const;
};
typedef std::vector<Cache> Caches;
typedef std::vector<const Cache*> pCaches;
typedef std::multimap<std::time_t, const Cache*> Date_Caches;
2019-11-10 19:59:21 +00:00
float cache_distance(const Cache& a, const Cache& b);