#include "heat.h" #include "cache.h" #include #include #include #include #include #include Heat::Heat(Caches* cc, const Map* m) : points(cc), mp(m) { #ifdef graphicsmagick Magick::InitializeMagick(nullptr); #endif } void Heat::generate(std::string filename, int size, std::string theme) { heatmap_t* hm = heatmap_new(mp->size_x, mp->size_y); heatmap_stamp_t* stamp = heatmap_stamp_gen(size); std::vector image(mp->size_x * mp->size_y * 4); for (auto el : *points) { if (mp->contains(Position(el.pos.lat, el.pos.lon)) && el.type != "Moving" && el.type != "Own") { 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'; } } if (theme == "soft") heatmap_render_to(hm, heatmap_cs_Spectral_soft, &image[0]); else if (theme == "exp") heatmap_render_to(hm, heatmap_cs_Spectral_mixed_exp, &image[0]); else throw 0; heatmap_free(hm); Magick::Image contour(mp->map_file); Magick::Image heatmap(mp->size_x, mp->size_y, "RGBA", Magick::CharPixel, &image[0]); contour.composite(heatmap, 0, 0, Magick::OverCompositeOp); contour.write(filename); // heatmap.write("geostat_heat.png"); }