sql-rework
Tomasz Golinski 2019-09-10 14:03:01 +02:00
rodzic 8d22d2a85c
commit 3218af8d99
5 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ Position Cache::home;
static float degtorad(float x) {
return x * M_PI / 180;
}
void Cache::show() const {
std::cout << "Cache:\t" << code << ' ' << name << '\n';
std::cout << '\t' << pos.lat << " " << pos.lon << "\t\t D/T: " << diff << '/' << terr << '\n';
@ -15,7 +16,7 @@ void Cache::show() 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)));
};
}
bool CacheCmpNS(const Cache& lhs, const Cache& rhs) {
return lhs.pos.lat < rhs.pos.lat;

Wyświetl plik

@ -157,7 +157,6 @@ int main(int argc, char** argv) {
near->show();
std::cout << "Furthest cache: " << far->distance() << " km\n";
far->show();
std::cout << "Dist:\t" << far->distance() << " km\n";
}
if (show_list) {

Wyświetl plik

@ -23,7 +23,7 @@ void Heat::generate(std::string filename, int size, std::string theme) {
for (auto el : *points) {
if (mp->contains(Position(el.pos.lat, el.pos.lon))) {
heatmap_add_point_with_stamp(hm, mp->coordinate_x(Position(el.pos.lat, el.pos.lon)), mp->coordinate_y(Position(el.pos.lat, el.pos.lon)), stamp);
// std::cout << mp->coordinate_x(Position(el.pos.lon, el.pos.lat)) << '\t' << mp->coordinate_y(Position(el.pos.lon, el.pos.lat)) << '\n';
// std::cout << mp->coordinate_x(Position(el.pos.lon, el.pos.lat)) << '\t' << mp->coordinate_y(Position(el.pos.lon, el.pos.lat)) << '\n';
}
}

4
maps.h
Wyświetl plik

@ -11,8 +11,8 @@ public:
const std::string map_file;
Map(int sx, int sy, float lat_mi, float lat_ma, float lon_mi, float lon_ma, std::string file) : size_x(sx), size_y(sy), lat_max(lat_ma), lat_min(lat_mi), lon_max(lon_ma), lon_min(lon_mi), map_file(file) {};
Map(int sx, int sy, float lat_mi, float lat_ma, float lon_mi, float lon_ma, std::string file) : size_x(sx), size_y(sy), lat_max(lat_ma), lat_min(lat_mi), lon_max(lon_ma), lon_min(lon_mi), map_file(file){};
bool contains(Position pos) const {
return (pos.lon >= lon_min && pos.lon <= lon_max && pos.lat >= lat_min && pos.lat <= lat_max);
}

Wyświetl plik

@ -15,6 +15,7 @@ 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";
// Callback for cURL easy interface used to save received output to std::string object
size_t Okapi::write_cb(char* ptr, size_t size, size_t nmemb, void* userdata) {
std::string* str = reinterpret_cast<std::string*>(userdata);
str->append(ptr, nmemb);