GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
output2d.c
Go to the documentation of this file.
1 
2 /*-
3  * Written by H. Mitasova, I. Kosinovsky, D. Gerdes Summer 1992
4  * Copyright 1992, H. Mitasova
5  * I. Kosinovsky, and D.Gerdes
6  *
7  * modified by McCauley in August 1995
8  * modified by Mitasova in August 1995
9  * modified by Mitasova in August 1999 (fix for elev color)
10  * modified by Brown in September 1999 (fix for Timestamps)
11  * Modified by Mitasova in Nov. 1999 (write given tension into hist)
12  * Last modified: 2006-12-13
13  *
14  */
15 
16 #include <stdio.h>
17 #include <math.h>
18 #include <grass/gis.h>
19 #include <grass/bitmap.h>
20 #include <grass/linkm.h>
21 
22 #include <grass/glocale.h>
23 #include <grass/interpf.h>
24 
25 
26 #define MULT 100000
27 
28 
29 int IL_output_2d(struct interp_params *params, struct Cell_head *cellhd, /* current region */
30  double zmin, double zmax, /* min,max input z-values */
31  double zminac, double zmaxac, double c1min, double c1max, /* min,max interpolated values */
32  double c2min, double c2max, double gmin, double gmax, double ertot, /* total interplating func. error */
33  char *input, /* input file name */
34  double dnorm, int dtens, int vect, int n_points)
35 
36 /*
37  * Creates output files as well as history files and color tables for
38  * them.
39  */
40 {
41  FCELL *cell1;
42  int cf1 = 0, cf2 = 0, cf3 = 0, cf4 = 0, cf5 = 0, cf6 = 0;
43  int nrows, ncols;
44  int i, ii;
45  double zstep;
46  FCELL data1, data2;
47  struct Colors colors;
48  struct History hist, hist1, hist2, hist3, hist4, hist5;
49  char *type;
50  char *mapset = NULL;
51  int cond1, cond2;
52  FCELL dat1, dat2;
53 
54  cond2 = ((params->pcurv != NULL) || (params->tcurv != NULL)
55  || (params->mcurv != NULL));
56  cond1 = ((params->slope != NULL) || (params->aspect != NULL) || cond2);
57 
58  cell1 = G_allocate_f_raster_buf();
59 
60  /*
61  * G_set_embedded_null_value_mode(1);
62  */
63  if (params->elev != NULL) {
64  cf1 = G_open_fp_cell_new(params->elev);
65  if (cf1 < 0) {
66  fprintf(stderr, "unable to create raster map %s\n", params->elev);
67  return -1;
68  }
69  }
70 
71  if (params->slope != NULL) {
72  cf2 = G_open_fp_cell_new(params->slope);
73  if (cf2 < 0) {
74  fprintf(stderr, "unable to create raster map %s\n",
75  params->slope);
76  return -1;
77  }
78  }
79 
80  if (params->aspect != NULL) {
81  cf3 = G_open_fp_cell_new(params->aspect);
82  if (cf3 < 0) {
83  fprintf(stderr, "unable to create raster map %s\n",
84  params->aspect);
85  return -1;
86  }
87  }
88 
89  if (params->pcurv != NULL) {
90  cf4 = G_open_fp_cell_new(params->pcurv);
91  if (cf4 < 0) {
92  fprintf(stderr, "unable to create raster map %s\n",
93  params->pcurv);
94  return -1;
95  }
96  }
97 
98  if (params->tcurv != NULL) {
99  cf5 = G_open_fp_cell_new(params->tcurv);
100  if (cf5 < 0) {
101  fprintf(stderr, "unable to create raster map %s\n",
102  params->tcurv);
103  return -1;
104  }
105  }
106 
107  if (params->mcurv != NULL) {
108  cf6 = G_open_fp_cell_new(params->mcurv);
109  if (cf6 < 0) {
110  fprintf(stderr, "unable to create raster map %s\n",
111  params->mcurv);
112  return -1;
113  }
114  }
115 
116  nrows = cellhd->rows;
117  if (nrows != params->nsizr) {
118  fprintf(stderr, "first change your rows number to nsizr! %d %d\n",
119  nrows, params->nsizr);
120  return -1;
121  }
122 
123  ncols = cellhd->cols;
124  if (ncols != params->nsizc) {
125  G_warning(_("First change your cols number to nsizc %d %d"),
126  ncols, params->nsizc);
127  return -1;
128  }
129 
130  if (G_set_window(cellhd) < 0)
131  return -1;
132 
133  if (nrows != G_window_rows()) {
134  fprintf(stderr, "OOPS: rows changed from %d to %d\n", nrows,
135  G_window_rows());
136  return -1;
137  }
138 
139  if (ncols != G_window_cols()) {
140  fprintf(stderr, "OOPS: cols changed from %d to %d\n", ncols,
141  G_window_cols());
142  return -1;
143  }
144 
145  if (params->elev != NULL) {
146  fseek(params->Tmp_fd_z, 0L, 0); /* seek to the beginning */
147  for (i = 0; i < params->nsizr; i++) {
148  /* seek to the right row */
149  if (fseek(params->Tmp_fd_z, (long)
150  ((params->nsizr - 1 -
151  i) * params->nsizc * sizeof(FCELL)), 0)
152  == -1) {
153  fprintf(stderr, "cannot fseek to the right spot\n");
154  return -1;
155  }
156  ii = fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_z);
157  /*
158  * for(j=0;j<params->nsizc;j++) fprintf(stderr,"%f ",cell1[j]);
159  * fprintf(stderr,"\n");
160  */
161  G_put_f_raster_row(cf1, cell1);
162 
163  }
164  }
165 
166  if (params->slope != NULL) {
167  fseek(params->Tmp_fd_dx, 0L, 0); /* seek to the beginning */
168  for (i = 0; i < params->nsizr; i++) {
169  /* seek to the right row */
170  if (fseek(params->Tmp_fd_dx, (long)
171  ((params->nsizr - 1 -
172  i) * params->nsizc * sizeof(FCELL)), 0)
173  == -1) {
174  fprintf(stderr, "cannot fseek to the right spot\n");
175  return -1;
176  }
177  fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dx);
178  G_put_f_raster_row(cf2, cell1);
179  }
180  }
181 
182  if (params->aspect != NULL) {
183  fseek(params->Tmp_fd_dy, 0L, 0); /* seek to the beginning */
184  for (i = 0; i < params->nsizr; i++) {
185  /* seek to the right row */
186  if (fseek(params->Tmp_fd_dy, (long)
187  ((params->nsizr - 1 -
188  i) * params->nsizc * sizeof(FCELL)), 0)
189  == -1) {
190  fprintf(stderr, "cannot fseek to the right spot\n");
191  return -1;
192  }
193  fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dy);
194  G_put_f_raster_row(cf3, cell1);
195  }
196  }
197 
198  if (params->pcurv != NULL) {
199  fseek(params->Tmp_fd_xx, 0L, 0); /* seek to the beginning */
200  for (i = 0; i < params->nsizr; i++) {
201  /* seek to the right row */
202  if (fseek(params->Tmp_fd_xx, (long)
203  ((params->nsizr - 1 -
204  i) * params->nsizc * sizeof(FCELL)), 0)
205  == -1) {
206  fprintf(stderr, "cannot fseek to the right spot\n");
207  return -1;
208  }
209  fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xx);
210  G_put_f_raster_row(cf4, cell1);
211  }
212  }
213 
214  if (params->tcurv != NULL) {
215  fseek(params->Tmp_fd_yy, 0L, 0); /* seek to the beginning */
216  for (i = 0; i < params->nsizr; i++) {
217  /* seek to the right row */
218  if (fseek(params->Tmp_fd_yy, (long)
219  ((params->nsizr - 1 -
220  i) * params->nsizc * sizeof(FCELL)), 0)
221  == -1) {
222  fprintf(stderr, "cannot fseek to the right spot\n");
223  return -1;
224  }
225  fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_yy);
226  G_put_f_raster_row(cf5, cell1);
227  }
228  }
229 
230  if (params->mcurv != NULL) {
231  fseek(params->Tmp_fd_xy, 0L, 0); /* seek to the beginning */
232  for (i = 0; i < params->nsizr; i++) {
233  /* seek to the right row */
234  if (fseek(params->Tmp_fd_xy, (long)
235  ((params->nsizr - 1 -
236  i) * params->nsizc * sizeof(FCELL)), 0)
237  == -1) {
238  fprintf(stderr, "cannot fseek to the right spot\n");
239  return -1;
240  }
241  fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xy);
242  G_put_f_raster_row(cf6, cell1);
243  }
244  }
245 
246  if (cf1)
247  G_close_cell(cf1);
248  if (cf2)
249  G_close_cell(cf2);
250  if (cf3)
251  G_close_cell(cf3);
252  if (cf4)
253  G_close_cell(cf4);
254  if (cf5)
255  G_close_cell(cf5);
256  if (cf6)
257  G_close_cell(cf6);
258 
259 
260  /* colortable for elevations */
261  G_init_colors(&colors);
262  zstep = (FCELL) (zmaxac - zminac) / 5.;
263  for (i = 1; i <= 5; i++) {
264  data1 = (FCELL) (zminac + (i - 1) * zstep);
265  data2 = (FCELL) (zminac + i * zstep);
266  switch (i) {
267  case 1:
268  G_add_f_raster_color_rule(&data1, 0, 191, 191,
269  &data2, 0, 255, 0, &colors);
270  break;
271  case 2:
272  G_add_f_raster_color_rule(&data1, 0, 255, 0,
273  &data2, 255, 255, 0, &colors);
274  break;
275  case 3:
276  G_add_f_raster_color_rule(&data1, 255, 255, 0,
277  &data2, 255, 127, 0, &colors);
278  break;
279  case 4:
280  G_add_f_raster_color_rule(&data1, 255, 127, 0,
281  &data2, 191, 127, 63, &colors);
282  break;
283  case 5:
284  G_add_f_raster_color_rule(&data1, 191, 127, 63,
285  &data2, 20, 20, 20, &colors);
286  break;
287  }
288  }
289 
290  if (params->elev != NULL) {
291  mapset = G_find_file("cell", params->elev, "");
292  if (mapset == NULL) {
293  fprintf(stderr, "file [%s] not found\n", params->elev);
294  return -1;
295  }
296  G_write_colors(params->elev, mapset, &colors);
297  G_quantize_fp_map_range(params->elev, mapset,
298  (DCELL) zminac - 0.5, (DCELL) zmaxac + 0.5,
299  (CELL) (zminac - 0.5), (CELL) (zmaxac + 0.5));
300  }
301 
302  /* colortable for slopes */
303  if (cond1) {
304  if (!params->deriv) {
305  /*
306  * smin = (CELL) ((int)(gmin*scig)); smax = (CELL) gmax; fprintf
307  * (stderr, "min %d max %d \n", smin,smax); G_make_rainbow_colors
308  * (&colors,smin,smax);
309  */
310  G_init_colors(&colors);
311  G_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
312  G_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
313  G_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
314  G_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
315  G_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
316  G_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
317  G_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
318  }
319  else {
320  G_init_colors(&colors);
321  dat1 = (FCELL) - 5.0; /* replace by min dx, amin1 (c1min,
322  * c2min); */
323  dat2 = (FCELL) - 0.1;
324  G_add_f_raster_color_rule(&dat1, 127, 0, 255,
325  &dat2, 0, 0, 255, &colors);
326  dat1 = dat2;
327  dat2 = (FCELL) - 0.01;
328  G_add_f_raster_color_rule(&dat1, 0, 0, 255,
329  &dat2, 0, 127, 255, &colors);
330  dat1 = dat2;
331  dat2 = (FCELL) - 0.001;
332  G_add_f_raster_color_rule(&dat1, 0, 127, 255,
333  &dat2, 0, 255, 255, &colors);
334  dat1 = dat2;
335  dat2 = (FCELL) 0.0;
336  G_add_f_raster_color_rule(&dat1, 0, 255, 255,
337  &dat2, 200, 255, 200, &colors);
338  dat1 = dat2;
339  dat2 = (FCELL) 0.001;
340  G_add_f_raster_color_rule(&dat1, 200, 255, 200,
341  &dat2, 255, 255, 0, &colors);
342  dat1 = dat2;
343  dat2 = (FCELL) 0.01;
344  G_add_f_raster_color_rule(&dat1, 255, 255, 0,
345  &dat2, 255, 127, 0, &colors);
346  dat1 = dat2;
347  dat2 = (FCELL) 0.1;
348  G_add_f_raster_color_rule(&dat1, 255, 127, 0,
349  &dat2, 255, 0, 0, &colors);
350  dat1 = dat2;
351  dat2 = (FCELL) 5.0; /* replace by max dx, amax1 (c1max,
352  * c2max); */
353  G_add_f_raster_color_rule(&dat1, 255, 0, 0,
354  &dat2, 255, 0, 200, &colors);
355  }
356 
357  if (params->slope != NULL) {
358  mapset = G_find_file("cell", params->slope, "");
359  if (mapset == NULL) {
360  fprintf(stderr, "file [%s] not found\n", params->slope);
361  return -1;
362  }
363  G_write_colors(params->slope, mapset, &colors);
364  G_quantize_fp_map_range(params->slope, mapset, 0., 90., 0, 90);
365 
366  type = "raster";
367  G_short_history(params->slope, type, &hist1);
368  if (params->elev != NULL)
369  sprintf(hist1.edhist[0], "The elevation map is %s",
370  params->elev);
371  if (vect)
372  sprintf(hist1.datsrc_1, "vector map %s", input);
373  else
374  sprintf(hist1.datsrc_1, "site file %s", input);
375  hist1.edlinecnt = 1;
376 
377  G_command_history(&hist1);
378  G_write_history(params->slope, &hist1);
379  if (params->ts)
380  G_write_raster_timestamp(params->slope, params->ts);
381 
382  }
383 
384  /* colortable for aspect */
385  if (!params->deriv) {
386  G_init_colors(&colors);
387  G_add_color_rule(0, 255, 255, 255, 0, 255, 255, 255, &colors);
388  G_add_color_rule(1, 255, 255, 0, 90, 0, 255, 0, &colors);
389  G_add_color_rule(90, 0, 255, 0, 180, 0, 255, 255, &colors);
390  G_add_color_rule(180, 0, 255, 255, 270, 255, 0, 0, &colors);
391  G_add_color_rule(270, 255, 0, 0, 360, 255, 255, 0, &colors);
392  }
393  else {
394  G_init_colors(&colors);
395  dat1 = (FCELL) - 5.0; /* replace by min dy, amin1 (c1min,
396  * c2min); */
397  dat2 = (FCELL) - 0.1;
398  G_add_f_raster_color_rule(&dat1, 127, 0, 255,
399  &dat2, 0, 0, 255, &colors);
400  dat1 = dat2;
401  dat2 = (FCELL) - 0.01;
402  G_add_f_raster_color_rule(&dat1, 0, 0, 255,
403  &dat2, 0, 127, 255, &colors);
404  dat1 = dat2;
405  dat2 = (FCELL) - 0.001;
406  G_add_f_raster_color_rule(&dat1, 0, 127, 255,
407  &dat2, 0, 255, 255, &colors);
408  dat1 = dat2;
409  dat2 = (FCELL) 0.0;
410  G_add_f_raster_color_rule(&dat1, 0, 255, 255,
411  &dat2, 200, 255, 200, &colors);
412  dat1 = dat2;
413  dat2 = (FCELL) 0.001;
414  G_add_f_raster_color_rule(&dat1, 200, 255, 200,
415  &dat2, 255, 255, 0, &colors);
416  dat1 = dat2;
417  dat2 = (FCELL) 0.01;
418  G_add_f_raster_color_rule(&dat1, 255, 255, 0,
419  &dat2, 255, 127, 0, &colors);
420  dat1 = dat2;
421  dat2 = (FCELL) 0.1;
422  G_add_f_raster_color_rule(&dat1, 255, 127, 0,
423  &dat2, 255, 0, 0, &colors);
424  dat1 = dat2;
425  dat2 = (FCELL) 5.0; /* replace by max dy, amax1 (c1max,
426  * c2max); */
427  G_add_f_raster_color_rule(&dat1, 255, 0, 0,
428  &dat2, 255, 0, 200, &colors);
429  }
430 
431  if (params->aspect != NULL) {
432  mapset = G_find_file("cell", params->aspect, "");
433  if (mapset == NULL) {
434  fprintf(stderr, "file [%s] not found\n", params->aspect);
435  return -1;
436  }
437  G_write_colors(params->aspect, mapset, &colors);
438  G_quantize_fp_map_range(params->aspect, mapset, 0., 360., 0, 360);
439 
440  type = "raster";
441  G_short_history(params->aspect, type, &hist2);
442  if (params->elev != NULL)
443  sprintf(hist2.edhist[0], "The elevation map is %s",
444  params->elev);
445  if (vect)
446  sprintf(hist2.datsrc_1, "vector map %s", input);
447  else
448  sprintf(hist2.datsrc_1, "site file %s", input);
449  hist2.edlinecnt = 1;
450 
451  G_command_history(&hist2);
452  G_write_history(params->aspect, &hist2);
453  if (params->ts)
454  G_write_raster_timestamp(params->aspect, params->ts);
455  }
456 
457  /* colortable for curvatures */
458  if (cond2) {
459  G_init_colors(&colors);
460  dat1 = (FCELL) amin1(c1min, c2min); /* for derivatives use min
461  * dxx,dyy,dxy */
462  dat2 = (FCELL) - 0.01;
463  G_add_f_raster_color_rule(&dat1, 127, 0, 255,
464  &dat2, 0, 0, 255, &colors);
465  dat1 = dat2;
466  dat2 = (FCELL) - 0.001;
467  G_add_f_raster_color_rule(&dat1, 0, 0, 255,
468  &dat2, 0, 127, 255, &colors);
469  dat1 = dat2;
470  dat2 = (FCELL) - 0.00001;
471  G_add_f_raster_color_rule(&dat1, 0, 127, 255,
472  &dat2, 0, 255, 255, &colors);
473  dat1 = dat2;
474  dat2 = (FCELL) 0.0;
475  G_add_f_raster_color_rule(&dat1, 0, 255, 255,
476  &dat2, 200, 255, 200, &colors);
477  dat1 = dat2;
478  dat2 = (FCELL) 0.00001;
479  G_add_f_raster_color_rule(&dat1, 200, 255, 200,
480  &dat2, 255, 255, 0, &colors);
481  dat1 = dat2;
482  dat2 = (FCELL) 0.001;
483  G_add_f_raster_color_rule(&dat1, 255, 255, 0,
484  &dat2, 255, 127, 0, &colors);
485  dat1 = dat2;
486  dat2 = (FCELL) 0.01;
487  G_add_f_raster_color_rule(&dat1, 255, 127, 0,
488  &dat2, 255, 0, 0, &colors);
489  dat1 = dat2;
490  dat2 = (FCELL) amax1(c1max, c2max); /* for derivatives use max
491  * dxx,dyy,dxy */
492  G_add_f_raster_color_rule(&dat1, 255, 0, 0,
493  &dat2, 255, 0, 200, &colors);
494 
495  if (params->pcurv != NULL) {
496  mapset = G_find_file("cell", params->pcurv, "");
497  if (mapset == NULL) {
498  fprintf(stderr, "file [%s] not found\n", params->pcurv);
499  return -1;
500  }
501  G_write_colors(params->pcurv, mapset, &colors);
502  G_quantize_fp_map_range(params->pcurv, mapset, dat1, dat2,
503  (CELL) (dat1 * MULT),
504  (CELL) (dat2 * MULT));
505 
506  type = "raster";
507  G_short_history(params->pcurv, type, &hist3);
508  if (params->elev != NULL)
509  sprintf(hist3.edhist[0], "The elevation map is %s",
510  params->elev);
511  if (vect)
512  sprintf(hist3.datsrc_1, "vector map %s", input);
513  else
514  sprintf(hist3.datsrc_1, "site file %s", input);
515  hist3.edlinecnt = 1;
516 
517  G_command_history(&hist3);
518  G_write_history(params->pcurv, &hist3);
519  if (params->ts)
520  G_write_raster_timestamp(params->pcurv, params->ts);
521  }
522 
523  if (params->tcurv != NULL) {
524  mapset = G_find_file("cell", params->tcurv, "");
525  if (mapset == NULL) {
526  fprintf(stderr, "file [%s] not found\n", params->tcurv);
527  return -1;
528  }
529  G_write_colors(params->tcurv, mapset, &colors);
530  G_quantize_fp_map_range(params->tcurv, mapset, dat1, dat2,
531  (CELL) (dat1 * MULT),
532  (CELL) (dat2 * MULT));
533 
534  type = "raster";
535  G_short_history(params->tcurv, type, &hist4);
536  if (params->elev != NULL)
537  sprintf(hist4.edhist[0], "The elevation map is %s",
538  params->elev);
539  if (vect)
540  sprintf(hist4.datsrc_1, "vector map %s", input);
541  else
542  sprintf(hist4.datsrc_1, "site file %s", input);
543  hist4.edlinecnt = 1;
544 
545  G_command_history(&hist4);
546  G_write_history(params->tcurv, &hist4);
547  if (params->ts)
548  G_write_raster_timestamp(params->tcurv, params->ts);
549  }
550 
551  if (params->mcurv != NULL) {
552  mapset = G_find_file("cell", params->mcurv, "");
553  if (mapset == NULL) {
554  fprintf(stderr, "file [%s] not found\n", params->mcurv);
555  return -1;
556  }
557  G_write_colors(params->mcurv, mapset, &colors);
558  G_quantize_fp_map_range(params->mcurv, mapset, dat1, dat2,
559  (CELL) (dat1 * MULT),
560  (CELL) (dat2 * MULT));
561 
562  type = "raster";
563  G_short_history(params->mcurv, type, &hist5);
564  if (params->elev != NULL)
565  sprintf(hist5.edhist[0], "The elevation map is %s",
566  params->elev);
567  if (vect)
568  sprintf(hist5.datsrc_1, "vector map %s", input);
569  else
570  sprintf(hist5.datsrc_1, "site file %s", input);
571  hist5.edlinecnt = 1;
572 
573  G_command_history(&hist5);
574  G_write_history(params->mcurv, &hist5);
575  if (params->ts)
576  G_write_raster_timestamp(params->mcurv, params->ts);
577  }
578  }
579  }
580 
581  if (params->elev != NULL) {
582  mapset = G_find_file("cell", params->elev, "");
583  if (mapset == NULL) {
584  fprintf(stderr, "file [%s] not found\n", params->elev);
585  return -1;
586  }
587  type = "raster";
588  G_short_history(params->elev, type, &hist);
589 
590  params->dmin = sqrt(params->dmin);
591 
592  /*
593  * sprintf (hist.edhist[0], "tension=%f, smoothing=%f", params->fi *
594  * dnorm / 1000., params->rsm);
595  */
596 
597  if (dtens) {
598  if (params->rsm == -1)
599  sprintf(hist.edhist[0], "giventension=%f, smoothing att=%d",
600  params->fi * 1000. / dnorm, params->smatt);
601  else
602  sprintf(hist.edhist[0], "giventension=%f, smoothing=%f",
603  params->fi * 1000. / dnorm, params->rsm);
604  }
605  else {
606  if (params->rsm == -1)
607  sprintf(hist.edhist[0], "tension=%f, smoothing att=%d",
608  params->fi * 1000. / dnorm, params->smatt);
609  else
610  sprintf(hist.edhist[0], "tension=%f, smoothing=%f",
611  params->fi, params->rsm);
612  }
613 
614  sprintf(hist.edhist[1], "dnorm=%f, dmin=%f, zmult=%f",
615  dnorm, params->dmin, params->zmult);
616  /*
617  * sprintf(hist.edhist[2], "segmax=%d, npmin=%d, errtotal=%f",
618  * params->kmax,params->kmin,ertot);
619  */
620  /*
621  * sprintf (hist.edhist[2], "segmax=%d, npmin=%d, errtotal =%f",
622  * params->kmax, params->kmin, sqrt (ertot) / n_points);
623  */
624 
625  sprintf(hist.edhist[2], "segmax=%d, npmin=%d, rmsdevi=%f",
626  params->kmax, params->kmin, sqrt(ertot / n_points));
627 
628  sprintf(hist.edhist[3], "zmin_data=%f, zmax_data=%f", zmin, zmax);
629  sprintf(hist.edhist[4], "zmin_int=%f, zmax_int=%f", zminac, zmaxac);
630 
631  if ((params->theta) && (params->scalex)) {
632  sprintf(hist.edhist[5], "theta=%f, scalex=%f", params->theta,
633  params->scalex);
634  hist.edlinecnt = 6;
635  }
636  else
637  hist.edlinecnt = 5;
638 
639  if (vect)
640  sprintf(hist.datsrc_1, "vector map %s", input);
641  else
642  sprintf(hist.datsrc_1, "site file %s", input);
643 
644  G_command_history(&hist);
645  G_write_history(params->elev, &hist);
646  if (params->ts)
647  G_write_raster_timestamp(params->elev, params->ts);
648  }
649 
650  /*
651  * if (title) G_put_cell_title (output, title);
652  */
653  return 1;
654 }
int G_write_colors(const char *name, const char *mapset, struct Colors *colors)
write map layer color table
Definition: color_write.c:74
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
int G_short_history(const char *name, const char *type, struct History *hist)
initialize history structure
Definition: history.c:202
int G_open_fp_cell_new(const char *name)
Opens new fcell file in a database.
Definition: opencell.c:546
double rsm
Definition: interpf.h:52
int G_close_cell(int fd)
close a raster map
Definition: closecell.c:71
double scalex
Definition: interpf.h:58
FCELL * G_allocate_f_raster_buf(void)
Allocates memory for a raster map of type FCELL.
Definition: alloc_cell.c:111
char * mcurv
Definition: interpf.h:53
FILE * Tmp_fd_xy
Definition: interpf.h:60
int G_set_window(struct Cell_head *window)
Establishes &#39;window&#39; as the current working window.
Definition: set_window.c:49
FILE * Tmp_fd_yy
Definition: interpf.h:60
double theta
Definition: interpf.h:57
double amax1(double, double)
Definition: minmax.c:54
char * elev
Definition: interpf.h:53
char * pcurv
Definition: interpf.h:53
FILE * Tmp_fd_xx
Definition: interpf.h:60
#define MULT
Definition: output2d.c:26
int G_write_history(const char *name, struct History *hist)
write raster history file
Definition: history.c:153
int G_write_raster_timestamp(const char *name, const struct TimeStamp *ts)
Returns: 1 on success. -1 error - can&#39;t create timestamp file -2 error - invalid datetime in ts...
Definition: timestamp.c:459
int G_command_history(struct History *hist)
Save command line to raster history structure.
Definition: history.c:254
FILE * Tmp_fd_dx
Definition: interpf.h:60
int G_add_f_raster_color_rule(const FCELL *cat1, int r1, int g1, int b1, const FCELL *cat2, int r2, int g2, int b2, struct Colors *colors)
Adds the floating-point rule (FCELL version)
Definition: color_rule.c:65
char * aspect
Definition: interpf.h:53
int IL_output_2d(struct interp_params *, struct Cell_head *, double, double, double, double, double, double, double, double, double, double, double, char *, double, int, int, int)
Definition: output2d.c:29
int G_window_cols(void)
Number of columns in active window.
Definition: window_map.c:306
double fi
Definition: interpf.h:49
double amin1(double, double)
Definition: minmax.c:67
char * tcurv
Definition: interpf.h:53
return NULL
Definition: dbfopen.c:1394
FILE * Tmp_fd_dy
Definition: interpf.h:60
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
double dmin
Definition: interpf.h:54
FILE * Tmp_fd_z
Definition: interpf.h:60
int G_add_color_rule(CELL cat1, int r1, int g1, int b1, CELL cat2, int r2, int g2, int b2, struct Colors *colors)
Set colors rules.
Definition: color_rule.c:165
double zmult
Definition: interpf.h:40
char * G_find_file(const char *element, char *name, const char *mapset)
searches for a file from the mapset search list or in a specified mapset. returns the mapset name whe...
Definition: find_file.c:159
struct TimeStamp * ts
Definition: interpf.h:59
int G_quantize_fp_map_range(const char *name, const char *mapset, DCELL d_min, DCELL d_max, CELL min, CELL max)
Writes the f_quant file for the raster map name with one rule. The rule is generated using the floati...
Definition: quant_rw.c:159
G_init_colors(colors)
int G_window_rows(void)
Number of rows in active window.
Definition: window_map.c:273
char * slope
Definition: interpf.h:53
int G_put_f_raster_row(int fd, const FCELL *buf)
Definition: gis/put_row.c:233