Use reference instead of pointer in class Heat constructor, add an assert

sql-rework
Tomasz Golinski 2020-01-25 11:44:21 +01:00
rodzic a5abf529bb
commit 3234258bca
3 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -379,7 +379,7 @@ int main(int argc, char** argv) {
std::cout << "Map " << heat_map << " not found.\n";
std::exit(EXIT_FAILURE);
}
Heat hmap(&fcc, chosen_map);
Heat hmap(fcc, chosen_map);
hmap.generate(heat_file, heat_stamp_size, (heat_exp == 1 ? "exp" : "soft"));
if (show_html)
std::cout << "<img class=\"heatmap\" src=\"" << heat_file << "\" alt=\"heat map\">\n";

Wyświetl plik

@ -8,8 +8,11 @@
#include <set>
#include <vector>
#include <string>
#include <assert.h>
Heat::Heat(Caches& cc, const Map* m) : points(cc), mp(m) {
assert(mp);
Heat::Heat(Caches* cc, const Map* m) : points(cc), mp(m) {
#ifdef graphicsmagick
Magick::InitializeMagick(nullptr);
#endif
@ -20,7 +23,7 @@ void Heat::generate(std::string filename, int size, std::string theme) {
heatmap_stamp_t* stamp = heatmap_stamp_gen(size);
std::vector<unsigned char> image(mp->size_x * mp->size_y * 4);
for (auto el : *points) {
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';

4
heat.h
Wyświetl plik

@ -8,11 +8,11 @@
class Heat {
private:
Caches* points;
const Caches& points;
const Map* mp;
public:
Heat(Caches* cc, const Map* m);
Heat(Caches& cc, const Map* m);
void generate(std::string filename, int size, std::string theme = "soft");
};