diff --git a/src/imagewriter.cpp b/src/imagewriter.cpp index 24d75d1..2f8a0bf 100644 --- a/src/imagewriter.cpp +++ b/src/imagewriter.cpp @@ -40,6 +40,8 @@ #include #include +using namespace std; + #define DEFAULT_JPEG_QUALITY 90 @@ -65,9 +67,21 @@ ImageWriter::ImageWriter(const std::string &filename, ImageType imagetype, default: #ifdef HAVE_LIBPNG case IMAGETYPE_PNG: - m_png_ptr = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + m_png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); m_info_ptr = png_create_info_struct(m_png_ptr); + // write metadata + m_text_ptr[0].key = strdup("Title"); + m_text_ptr[0].text = strdup("SPLAT!"); + m_text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; + m_text_ptr[1].key = strdup("projection"); + m_text_ptr[1].text = strdup("EPSG:4326"); + m_text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; + m_text_ptr[2].key = strdup("bounds"); + bounds_str = ("[["+to_string(m_south)+","+to_string(m_west)+"],["+to_string(m_north)+","+to_string(m_east)+"]]").c_str(); + sprintf(bounds, "%s", bounds_str.c_str()); + m_text_ptr[2].text = bounds; + m_text_ptr[2].compression = PNG_TEXT_COMPRESSION_NONE; + png_set_text(m_png_ptr, m_info_ptr, m_text_ptr, PNG_NTEXT); png_init_io(m_png_ptr, m_fp); png_set_IHDR(m_png_ptr, m_info_ptr, m_width, m_height, 8, /* 8 bits per color or 24 bits per pixel for RGB */ diff --git a/src/imagewriter.h b/src/imagewriter.h index e86018f..7f20790 100644 --- a/src/imagewriter.h +++ b/src/imagewriter.h @@ -115,8 +115,12 @@ class ImageWriter { unsigned char *m_imgline_alpha = NULL; #ifdef HAVE_LIBPNG + #define PNG_NTEXT 4 png_structp m_png_ptr = NULL; png_infop m_info_ptr = NULL; + png_text m_text_ptr[PNG_NTEXT] = {0}; + std::string bounds_str; + char bounds[80]; #endif #ifdef HAVE_LIBGDAL GDALDriver *poDriver; diff --git a/src/json.cpp b/src/json.cpp index 621f180..e855a58 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -18,6 +18,8 @@ #include #include +using namespace std; + Json::Json(const ElevationMap &em, const SplatRun &sr) : path(sr.arraysize, sr.ppd), em(em), sr(sr) {} @@ -28,18 +30,18 @@ Json::Json(const ElevationMap &em, const SplatRun &sr) /* read in argv[] as an associative array. * You can now access the list e.g. by args["o"] which will not fail if the argument is not set * - * std::map::iterator i; + * map::iterator i; * for (i=args.begin(); i != args.end(); i++) { - * std::cout << i->first << ": " << i->second << std::endl; + * cout << i->first << ": " << i->second << endl; * } */ - //typedef std::map arg_t; + //typedef map arg_t; /* arg_t args; - std::string curr_arg = ""; + string curr_arg = ""; int curr_arg_i = 0; for(int i=0; i::iterator i; + map::iterator i; int pos = 0; int len = args.size(); for (i=args.begin(); i != args.end(); i++, pos++) { @@ -121,7 +123,7 @@ void Json::WriteJSON(arg_t args, Site tx_site, Lrp lrp, std::string mapfile) { reportfile.close(); - std::cout << "\nJSON file written to: " << report_name; + cout << "\nJSON file written to: " << report_name; fflush(stdout); }