output2d.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*!
  2. * \file output2d.c
  3. *
  4. * \author H. Mitasova, I. Kosinovsky, D. Gerdesm, Summer 1992 (original authors)
  5. * \author modified by McCauley in August 1995
  6. * \author modified by Mitasova in August 1995
  7. * \author modified by Mitasova in August 1999 (fix for elev color)
  8. * \author modified by Brown in September 1999 (fix for Timestamps)
  9. * \author modified by Mitasova in Nov. 1999 (write given tension into hist)
  10. *
  11. * \copyright
  12. * (C) 1992-2006 by Helena Mitasova and the GRASS Development Team
  13. *
  14. * \copyright
  15. * This program is free software under the
  16. * GNU General Public License (>=v2).
  17. * Read the file COPYING that comes with GRASS for details.
  18. */
  19. #include <stdio.h>
  20. #include <math.h>
  21. #include <grass/gis.h>
  22. #include <grass/raster.h>
  23. #include <grass/bitmap.h>
  24. #include <grass/linkm.h>
  25. #include <grass/interpf.h>
  26. #include <grass/glocale.h>
  27. #define MULT 100000
  28. static void do_history(const char *name, int vect, const char *input,
  29. const struct interp_params *params)
  30. {
  31. struct History hist;
  32. Rast_short_history(name, "raster", &hist);
  33. if (params->elev)
  34. Rast_append_format_history(&hist, "The elevation map is %s",
  35. params->elev);
  36. Rast_format_history(&hist, HIST_DATSRC_1, "%s %s",
  37. vect ? "vector map" : "site file",
  38. input);
  39. Rast_command_history(&hist);
  40. Rast_write_history(name, &hist);
  41. if (params->ts)
  42. G_write_raster_timestamp(name, params->ts);
  43. Rast_free_history(&hist);
  44. }
  45. /*!
  46. * Creates output files as well as history files and color tables for them.
  47. *
  48. * *ertot* can be also called *RMS deviation of the interpolated surface*.
  49. */
  50. int IL_output_2d(struct interp_params *params,
  51. struct Cell_head *cellhd, /*!< current region */
  52. double zmin, double zmax, /*!< min,max input z-values */
  53. double zminac, double zmaxac,
  54. double c1min, double c1max, /*!< min,max interpolated values */
  55. double c2min, double c2max,
  56. double gmin, double gmax,
  57. double ertot, /*!< total interpolating func. error */
  58. char *input, /*!< input file name */
  59. double dnorm, /*!< normalization factor */
  60. int dtens, int vect, int n_points
  61. )
  62. {
  63. FCELL *cell1;
  64. int cf1 = -1, cf2 = -1, cf3 = -1, cf4 = -1, cf5 = -1, cf6 = -1;
  65. int nrows, ncols;
  66. int i, ii;
  67. double zstep;
  68. FCELL data1, data2;
  69. struct Colors colors;
  70. struct History hist;
  71. char *type;
  72. const char *mapset = NULL;
  73. int cond1, cond2;
  74. FCELL dat1, dat2;
  75. CELL val1, val2;
  76. cond2 = ((params->pcurv != NULL) || (params->tcurv != NULL)
  77. || (params->mcurv != NULL));
  78. cond1 = ((params->slope != NULL) || (params->aspect != NULL) || cond2);
  79. Rast_set_window(cellhd);
  80. cell1 = Rast_allocate_f_buf();
  81. /*
  82. * G_set_embedded_null_value_mode(1);
  83. */
  84. if (params->elev)
  85. cf1 = Rast_open_new(params->elev, FCELL_TYPE);
  86. if (params->slope)
  87. cf2 = Rast_open_new(params->slope, FCELL_TYPE);
  88. if (params->aspect)
  89. cf3 = Rast_open_new(params->aspect, FCELL_TYPE);
  90. if (params->pcurv)
  91. cf4 = Rast_open_new(params->pcurv, FCELL_TYPE);
  92. if (params->tcurv)
  93. cf5 = Rast_open_new(params->tcurv, FCELL_TYPE);
  94. if (params->mcurv)
  95. cf6 = Rast_open_new(params->mcurv, FCELL_TYPE);
  96. nrows = cellhd->rows;
  97. if (nrows != params->nsizr) {
  98. G_warning(_("First change your rows number to nsizr! %d %d"),
  99. nrows, params->nsizr);
  100. return -1;
  101. }
  102. ncols = cellhd->cols;
  103. if (ncols != params->nsizc) {
  104. G_warning(_("First change your cols number to nsizc %d %d"),
  105. ncols, params->nsizc);
  106. return -1;
  107. }
  108. if (params->elev != NULL) {
  109. G_fseek(params->Tmp_fd_z, 0L, 0); /* seek to the beginning */
  110. for (i = 0; i < params->nsizr; i++) {
  111. /* seek to the right row */
  112. G_fseek(params->Tmp_fd_z, (off_t) (params->nsizr - 1 - i) *
  113. params->nsizc * sizeof(FCELL), 0);
  114. ii = fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_z);
  115. /*
  116. * for(j=0;j<params->nsizc;j++) fprintf(stderr,"%f ",cell1[j]);
  117. * fprintf(stderr,"\n");
  118. */
  119. Rast_put_f_row(cf1, cell1);
  120. }
  121. }
  122. if (params->slope != NULL) {
  123. G_fseek(params->Tmp_fd_dx, 0L, 0); /* seek to the beginning */
  124. for (i = 0; i < params->nsizr; i++) {
  125. /* seek to the right row */
  126. G_fseek(params->Tmp_fd_dx, (off_t) (params->nsizr - 1 - i) *
  127. params->nsizc * sizeof(FCELL), 0);
  128. fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dx);
  129. Rast_put_f_row(cf2, cell1);
  130. }
  131. }
  132. if (params->aspect != NULL) {
  133. G_fseek(params->Tmp_fd_dy, 0L, 0); /* seek to the beginning */
  134. for (i = 0; i < params->nsizr; i++) {
  135. /* seek to the right row */
  136. G_fseek(params->Tmp_fd_dy, (off_t) (params->nsizr - 1 - i) *
  137. params->nsizc * sizeof(FCELL), 0);
  138. fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dy);
  139. Rast_put_f_row(cf3, cell1);
  140. }
  141. }
  142. if (params->pcurv != NULL) {
  143. G_fseek(params->Tmp_fd_xx, 0L, 0); /* seek to the beginning */
  144. for (i = 0; i < params->nsizr; i++) {
  145. /* seek to the right row */
  146. G_fseek(params->Tmp_fd_xx, (off_t) (params->nsizr - 1 - i) *
  147. params->nsizc * sizeof(FCELL), 0);
  148. fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xx);
  149. Rast_put_f_row(cf4, cell1);
  150. }
  151. }
  152. if (params->tcurv != NULL) {
  153. G_fseek(params->Tmp_fd_yy, 0L, 0); /* seek to the beginning */
  154. for (i = 0; i < params->nsizr; i++) {
  155. /* seek to the right row */
  156. G_fseek(params->Tmp_fd_yy, (off_t) (params->nsizr - 1 - i) *
  157. params->nsizc * sizeof(FCELL), 0);
  158. fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_yy);
  159. Rast_put_f_row(cf5, cell1);
  160. }
  161. }
  162. if (params->mcurv != NULL) {
  163. G_fseek(params->Tmp_fd_xy, 0L, 0); /* seek to the beginning */
  164. for (i = 0; i < params->nsizr; i++) {
  165. /* seek to the right row */
  166. G_fseek(params->Tmp_fd_xy, (off_t) (params->nsizr - 1 - i) *
  167. params->nsizc * sizeof(FCELL), 0);
  168. fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xy);
  169. Rast_put_f_row(cf6, cell1);
  170. }
  171. }
  172. if (cf1 >= 0)
  173. Rast_close(cf1);
  174. if (cf2 >= 0)
  175. Rast_close(cf2);
  176. if (cf3 >= 0)
  177. Rast_close(cf3);
  178. if (cf4 >= 0)
  179. Rast_close(cf4);
  180. if (cf5 >= 0)
  181. Rast_close(cf5);
  182. if (cf6 >= 0)
  183. Rast_close(cf6);
  184. /* colortable for elevations */
  185. Rast_init_colors(&colors);
  186. zstep = (FCELL) (zmaxac - zminac) / 5.;
  187. for (i = 1; i <= 5; i++) {
  188. data1 = (FCELL) (zminac + (i - 1) * zstep);
  189. data2 = (FCELL) (zminac + i * zstep);
  190. switch (i) {
  191. case 1:
  192. Rast_add_f_color_rule(&data1, 0, 191, 191,
  193. &data2, 0, 255, 0, &colors);
  194. break;
  195. case 2:
  196. Rast_add_f_color_rule(&data1, 0, 255, 0,
  197. &data2, 255, 255, 0, &colors);
  198. break;
  199. case 3:
  200. Rast_add_f_color_rule(&data1, 255, 255, 0,
  201. &data2, 255, 127, 0, &colors);
  202. break;
  203. case 4:
  204. Rast_add_f_color_rule(&data1, 255, 127, 0,
  205. &data2, 191, 127, 63, &colors);
  206. break;
  207. case 5:
  208. Rast_add_f_color_rule(&data1, 191, 127, 63,
  209. &data2, 200, 200, 200, &colors);
  210. break;
  211. }
  212. }
  213. if (params->elev != NULL) {
  214. mapset = G_find_file("cell", params->elev, "");
  215. if (mapset == NULL) {
  216. G_warning(_("Raster map <%s> not found"), params->elev);
  217. return -1;
  218. }
  219. Rast_write_colors(params->elev, mapset, &colors);
  220. Rast_quantize_fp_map_range(params->elev, mapset,
  221. (DCELL) zminac - 0.5, (DCELL) zmaxac + 0.5,
  222. (CELL) (zminac - 0.5), (CELL) (zmaxac + 0.5));
  223. }
  224. /* colortable for slopes */
  225. if (cond1) {
  226. if (!params->deriv) {
  227. /*
  228. * smin = (CELL) ((int)(gmin*scig)); smax = (CELL) gmax; fprintf
  229. * (stderr, "min %d max %d \n", smin,smax); Rast_make_rainbow_colors
  230. * (&colors,smin,smax);
  231. */
  232. Rast_init_colors(&colors);
  233. val1 = 0;
  234. val2 = 2;
  235. Rast_add_c_color_rule(&val1, 255, 255, 255, &val2, 255, 255, 0, &colors);
  236. val1 = 2;
  237. val2 = 5;
  238. Rast_add_c_color_rule(&val1, 255, 255, 0, &val2, 0, 255, 0, &colors);
  239. val1 = 5;
  240. val2 = 10;
  241. Rast_add_c_color_rule(&val1, 0, 255, 0, &val2, 0, 255, 255, &colors);
  242. val1 = 10;
  243. val2 = 15;
  244. Rast_add_c_color_rule(&val1, 0, 255, 255, &val2, 0, 0, 255, &colors);
  245. val1 = 15;
  246. val2 = 30;
  247. Rast_add_c_color_rule(&val1, 0, 0, 255, &val2, 255, 0, 255, &colors);
  248. val1 = 30;
  249. val2 = 50;
  250. Rast_add_c_color_rule(&val1, 255, 0, 255, &val2, 255, 0, 0, &colors);
  251. val1 = 50;
  252. val2 = 90;
  253. Rast_add_c_color_rule(&val1, 255, 0, 0, &val2, 0, 0, 0, &colors);
  254. }
  255. else {
  256. Rast_init_colors(&colors);
  257. dat1 = (FCELL) - 5.0; /* replace by min dx, amin1 (c1min,
  258. * c2min); */
  259. dat2 = (FCELL) - 0.1;
  260. Rast_add_f_color_rule(&dat1, 127, 0, 255,
  261. &dat2, 0, 0, 255, &colors);
  262. dat1 = dat2;
  263. dat2 = (FCELL) - 0.01;
  264. Rast_add_f_color_rule(&dat1, 0, 0, 255,
  265. &dat2, 0, 127, 255, &colors);
  266. dat1 = dat2;
  267. dat2 = (FCELL) - 0.001;
  268. Rast_add_f_color_rule(&dat1, 0, 127, 255,
  269. &dat2, 0, 255, 255, &colors);
  270. dat1 = dat2;
  271. dat2 = (FCELL) 0.0;
  272. Rast_add_f_color_rule(&dat1, 0, 255, 255,
  273. &dat2, 200, 255, 200, &colors);
  274. dat1 = dat2;
  275. dat2 = (FCELL) 0.001;
  276. Rast_add_f_color_rule(&dat1, 200, 255, 200,
  277. &dat2, 255, 255, 0, &colors);
  278. dat1 = dat2;
  279. dat2 = (FCELL) 0.01;
  280. Rast_add_f_color_rule(&dat1, 255, 255, 0,
  281. &dat2, 255, 127, 0, &colors);
  282. dat1 = dat2;
  283. dat2 = (FCELL) 0.1;
  284. Rast_add_f_color_rule(&dat1, 255, 127, 0,
  285. &dat2, 255, 0, 0, &colors);
  286. dat1 = dat2;
  287. dat2 = (FCELL) 5.0; /* replace by max dx, amax1 (c1max,
  288. * c2max); */
  289. Rast_add_f_color_rule(&dat1, 255, 0, 0,
  290. &dat2, 255, 0, 200, &colors);
  291. }
  292. if (params->slope != NULL) {
  293. mapset = G_find_file("cell", params->slope, "");
  294. if (mapset == NULL) {
  295. G_warning(_("Raster map <%s> not found"), params->slope);
  296. return -1;
  297. }
  298. Rast_write_colors(params->slope, mapset, &colors);
  299. Rast_quantize_fp_map_range(params->slope, mapset, 0., 90., 0, 90);
  300. do_history(params->slope, vect, input, params);
  301. }
  302. /* colortable for aspect */
  303. if (!params->deriv) {
  304. Rast_init_colors(&colors);
  305. val1 = 0;
  306. val2 = 0;
  307. Rast_add_c_color_rule(&val1, 255, 255, 255, &val2, 255, 255, 255, &colors);
  308. val1 = 1;
  309. val2 = 90;
  310. Rast_add_c_color_rule(&val1, 255, 255, 0, &val2, 0, 255, 0, &colors);
  311. val1 = 90;
  312. val2 = 180;
  313. Rast_add_c_color_rule(&val1, 0, 255, 0, &val2, 0, 255, 255, &colors);
  314. val1 = 180;
  315. val2 = 270;
  316. Rast_add_c_color_rule(&val1, 0, 255, 255, &val2, 255, 0, 0, &colors);
  317. val1 = 270;
  318. val2 = 360;
  319. Rast_add_c_color_rule(&val1, 255, 0, 0, &val2, 255, 255, 0, &colors);
  320. }
  321. else {
  322. Rast_init_colors(&colors);
  323. dat1 = (FCELL) - 5.0; /* replace by min dy, amin1 (c1min,
  324. * c2min); */
  325. dat2 = (FCELL) - 0.1;
  326. Rast_add_f_color_rule(&dat1, 127, 0, 255,
  327. &dat2, 0, 0, 255, &colors);
  328. dat1 = dat2;
  329. dat2 = (FCELL) - 0.01;
  330. Rast_add_f_color_rule(&dat1, 0, 0, 255,
  331. &dat2, 0, 127, 255, &colors);
  332. dat1 = dat2;
  333. dat2 = (FCELL) - 0.001;
  334. Rast_add_f_color_rule(&dat1, 0, 127, 255,
  335. &dat2, 0, 255, 255, &colors);
  336. dat1 = dat2;
  337. dat2 = (FCELL) 0.0;
  338. Rast_add_f_color_rule(&dat1, 0, 255, 255,
  339. &dat2, 200, 255, 200, &colors);
  340. dat1 = dat2;
  341. dat2 = (FCELL) 0.001;
  342. Rast_add_f_color_rule(&dat1, 200, 255, 200,
  343. &dat2, 255, 255, 0, &colors);
  344. dat1 = dat2;
  345. dat2 = (FCELL) 0.01;
  346. Rast_add_f_color_rule(&dat1, 255, 255, 0,
  347. &dat2, 255, 127, 0, &colors);
  348. dat1 = dat2;
  349. dat2 = (FCELL) 0.1;
  350. Rast_add_f_color_rule(&dat1, 255, 127, 0,
  351. &dat2, 255, 0, 0, &colors);
  352. dat1 = dat2;
  353. dat2 = (FCELL) 5.0; /* replace by max dy, amax1 (c1max,
  354. * c2max); */
  355. Rast_add_f_color_rule(&dat1, 255, 0, 0,
  356. &dat2, 255, 0, 200, &colors);
  357. }
  358. if (params->aspect != NULL) {
  359. mapset = G_find_file("cell", params->aspect, "");
  360. if (mapset == NULL) {
  361. G_warning(_("Raster map <%s> not found"), params->aspect);
  362. return -1;
  363. }
  364. Rast_write_colors(params->aspect, mapset, &colors);
  365. Rast_quantize_fp_map_range(params->aspect, mapset, 0., 360., 0, 360);
  366. do_history(params->aspect, vect, input, params);
  367. }
  368. /* colortable for curvatures */
  369. if (cond2) {
  370. Rast_init_colors(&colors);
  371. dat1 = (FCELL) amin1(c1min, c2min); /* for derivatives use min
  372. * dxx,dyy,dxy */
  373. dat2 = (FCELL) - 0.01;
  374. Rast_add_f_color_rule(&dat1, 127, 0, 255,
  375. &dat2, 0, 0, 255, &colors);
  376. dat1 = dat2;
  377. dat2 = (FCELL) - 0.001;
  378. Rast_add_f_color_rule(&dat1, 0, 0, 255,
  379. &dat2, 0, 127, 255, &colors);
  380. dat1 = dat2;
  381. dat2 = (FCELL) - 0.00001;
  382. Rast_add_f_color_rule(&dat1, 0, 127, 255,
  383. &dat2, 0, 255, 255, &colors);
  384. dat1 = dat2;
  385. dat2 = (FCELL) 0.0;
  386. Rast_add_f_color_rule(&dat1, 0, 255, 255,
  387. &dat2, 200, 255, 200, &colors);
  388. dat1 = dat2;
  389. dat2 = (FCELL) 0.00001;
  390. Rast_add_f_color_rule(&dat1, 200, 255, 200,
  391. &dat2, 255, 255, 0, &colors);
  392. dat1 = dat2;
  393. dat2 = (FCELL) 0.001;
  394. Rast_add_f_color_rule(&dat1, 255, 255, 0,
  395. &dat2, 255, 127, 0, &colors);
  396. dat1 = dat2;
  397. dat2 = (FCELL) 0.01;
  398. Rast_add_f_color_rule(&dat1, 255, 127, 0,
  399. &dat2, 255, 0, 0, &colors);
  400. dat1 = dat2;
  401. dat2 = (FCELL) amax1(c1max, c2max); /* for derivatives use max
  402. * dxx,dyy,dxy */
  403. Rast_add_f_color_rule(&dat1, 255, 0, 0,
  404. &dat2, 255, 0, 200, &colors);
  405. if (params->pcurv != NULL) {
  406. mapset = G_find_file("cell", params->pcurv, "");
  407. if (mapset == NULL) {
  408. G_warning(_("Raster map <%s> not found"), params->pcurv);
  409. return -1;
  410. }
  411. Rast_write_colors(params->pcurv, mapset, &colors);
  412. Rast_quantize_fp_map_range(params->pcurv, mapset, dat1, dat2,
  413. (CELL) (dat1 * MULT),
  414. (CELL) (dat2 * MULT));
  415. do_history(params->pcurv, vect, input, params);
  416. }
  417. if (params->tcurv != NULL) {
  418. mapset = G_find_file("cell", params->tcurv, "");
  419. if (mapset == NULL) {
  420. G_warning(_("Raster map <%s> not found"), params->tcurv);
  421. return -1;
  422. }
  423. Rast_write_colors(params->tcurv, mapset, &colors);
  424. Rast_quantize_fp_map_range(params->tcurv, mapset, dat1, dat2,
  425. (CELL) (dat1 * MULT),
  426. (CELL) (dat2 * MULT));
  427. do_history(params->tcurv, vect, input, params);
  428. }
  429. if (params->mcurv != NULL) {
  430. mapset = G_find_file("cell", params->mcurv, "");
  431. if (mapset == NULL) {
  432. G_warning(_("Raster map <%s> not found"), params->mcurv);
  433. return -1;
  434. }
  435. Rast_write_colors(params->mcurv, mapset, &colors);
  436. Rast_quantize_fp_map_range(params->mcurv, mapset, dat1, dat2,
  437. (CELL) (dat1 * MULT),
  438. (CELL) (dat2 * MULT));
  439. do_history(params->mcurv, vect, input, params);
  440. }
  441. }
  442. }
  443. if (params->elev != NULL) {
  444. mapset = G_find_file("cell", params->elev, "");
  445. if (mapset == NULL) {
  446. G_warning(_("Raster map <%s> not found"), params->elev);
  447. return -1;
  448. }
  449. type = "raster";
  450. Rast_short_history(params->elev, type, &hist);
  451. params->dmin = sqrt(params->dmin);
  452. /*
  453. * sprintf (hist.edhist[0], "tension=%f, smoothing=%f", params->fi *
  454. * dnorm / 1000., params->rsm);
  455. */
  456. if (dtens) {
  457. if (params->rsm == -1)
  458. Rast_append_format_history(
  459. &hist, "giventension=%f, smoothing att=%d",
  460. params->fi * 1000. / dnorm, params->smatt);
  461. else
  462. Rast_append_format_history(
  463. &hist, "giventension=%f, smoothing=%f",
  464. params->fi * 1000. / dnorm, params->rsm);
  465. }
  466. else {
  467. if (params->rsm == -1)
  468. Rast_append_format_history(
  469. &hist, "tension=%f, smoothing att=%d",
  470. params->fi * 1000. / dnorm, params->smatt);
  471. else
  472. Rast_append_format_history(
  473. &hist, "tension=%f, smoothing=%f",
  474. params->fi, params->rsm);
  475. }
  476. Rast_append_format_history(
  477. &hist, "dnorm=%f, dmin=%f, zmult=%f",
  478. dnorm, params->dmin, params->zmult);
  479. /*
  480. * sprintf(hist.edhist[2], "segmax=%d, npmin=%d, errtotal=%f",
  481. * params->kmax,params->kmin,ertot);
  482. */
  483. /*
  484. * sprintf (hist.edhist[2], "segmax=%d, npmin=%d, errtotal =%f",
  485. * params->kmax, params->kmin, sqrt (ertot) / n_points);
  486. */
  487. Rast_append_format_history(
  488. &hist, "segmax=%d, npmin=%d, rmsdevi=%f",
  489. params->kmax, params->kmin, sqrt(ertot / n_points));
  490. Rast_append_format_history(
  491. &hist, "zmin_data=%f, zmax_data=%f", zmin, zmax);
  492. Rast_append_format_history(
  493. &hist, "zmin_int=%f, zmax_int=%f", zminac, zmaxac);
  494. if ((params->theta) && (params->scalex))
  495. Rast_append_format_history(
  496. &hist, "theta=%f, scalex=%f", params->theta,
  497. params->scalex);
  498. Rast_format_history(&hist, HIST_DATSRC_1, "%s %s",
  499. vect ? "vector map" : "site file",
  500. input);
  501. Rast_command_history(&hist);
  502. Rast_write_history(params->elev, &hist);
  503. if (params->ts)
  504. G_write_raster_timestamp(params->elev, params->ts);
  505. Rast_free_history(&hist);
  506. }
  507. /*
  508. * if (title) Rast_put_cell_title (output, title);
  509. */
  510. return 1;
  511. }