58 struct Cell_head *cellhd,
59 double zmin,
double zmax,
60 double zminac,
double zmaxac,
double c1min,
62 double c2min,
double c2max,
double gmin UNUSED,
67 int dtens,
int vect,
int n_points)
70 int cf1 = -1, cf2 = -1, cf3 = -1, cf4 = -1, cf5 = -1, cf6 = -1;
78 const char *mapset =
NULL;
87 Rast_set_window(cellhd);
89 cell1 = Rast_allocate_f_buf();
95 cf1 = Rast_open_new(params->
elev, FCELL_TYPE);
98 cf2 = Rast_open_new(params->
slope, FCELL_TYPE);
101 cf3 = Rast_open_new(params->
aspect, FCELL_TYPE);
104 cf4 = Rast_open_new(params->
pcurv, FCELL_TYPE);
107 cf5 = Rast_open_new(params->
tcurv, FCELL_TYPE);
110 cf6 = Rast_open_new(params->
mcurv, FCELL_TYPE);
112 nrows = cellhd->rows;
113 if (nrows != params->
nsizr) {
114 G_warning(_(
"First change your rows number to nsizr! %d %d"), nrows,
119 ncols = cellhd->cols;
120 if (ncols != params->
nsizc) {
121 G_warning(_(
"First change your cols number to nsizc %d %d"), ncols,
128 for (i = 0; i < params->
nsizr; i++) {
131 (off_t)(params->
nsizr - 1 - i) * params->
nsizc *
134 if (fread(cell1,
sizeof(FCELL), params->
nsizc, params->
Tmp_fd_z) !=
135 (
size_t)params->
nsizc)
136 G_fatal_error(_(
"RST library temporary file reading error: %s"),
138 Rast_put_f_row(cf1, cell1);
144 for (i = 0; i < params->
nsizr; i++) {
147 (off_t)(params->
nsizr - 1 - i) * params->
nsizc *
150 if (fread(cell1,
sizeof(FCELL), params->
nsizc, params->
Tmp_fd_dx) !=
151 (
size_t)params->
nsizc)
152 G_fatal_error(_(
"RST library temporary file reading error: %s"),
154 Rast_put_f_row(cf2, cell1);
160 for (i = 0; i < params->
nsizr; i++) {
163 (off_t)(params->
nsizr - 1 - i) * params->
nsizc *
166 if (fread(cell1,
sizeof(FCELL), params->
nsizc, params->
Tmp_fd_dy) !=
167 (
size_t)params->
nsizc)
168 G_fatal_error(_(
"RST library temporary file reading error: %s"),
170 Rast_put_f_row(cf3, cell1);
176 for (i = 0; i < params->
nsizr; i++) {
179 (off_t)(params->
nsizr - 1 - i) * params->
nsizc *
182 if (fread(cell1,
sizeof(FCELL), params->
nsizc, params->
Tmp_fd_xx) !=
183 (
size_t)params->
nsizc)
184 G_fatal_error(_(
"RST library temporary file reading error: %s"),
186 Rast_put_f_row(cf4, cell1);
192 for (i = 0; i < params->
nsizr; i++) {
195 (off_t)(params->
nsizr - 1 - i) * params->
nsizc *
198 if (fread(cell1,
sizeof(FCELL), params->
nsizc, params->
Tmp_fd_yy) !=
199 (
size_t)params->
nsizc)
200 G_fatal_error(_(
"RST library temporary file reading error: %s"),
202 Rast_put_f_row(cf5, cell1);
208 for (i = 0; i < params->
nsizr; i++) {
211 (off_t)(params->
nsizr - 1 - i) * params->
nsizc *
214 if (fread(cell1,
sizeof(FCELL), params->
nsizc, params->
Tmp_fd_xy) !=
215 (
size_t)params->
nsizc)
216 G_fatal_error(_(
"RST library temporary file reading error: %s"),
218 Rast_put_f_row(cf6, cell1);
236 Rast_init_colors(&colors);
237 zstep = (FCELL)(zmaxac - zminac) / 5.;
238 for (i = 1; i <= 5; i++) {
239 data1 = (FCELL)(zminac + (i - 1) * zstep);
240 data2 = (FCELL)(zminac + i * zstep);
243 Rast_add_f_color_rule(&data1, 0, 191, 191, &data2, 0, 255, 0,
247 Rast_add_f_color_rule(&data1, 0, 255, 0, &data2, 255, 255, 0,
251 Rast_add_f_color_rule(&data1, 255, 255, 0, &data2, 255, 127, 0,
255 Rast_add_f_color_rule(&data1, 255, 127, 0, &data2, 191, 127, 63,
259 Rast_add_f_color_rule(&data1, 191, 127, 63, &data2, 200, 200, 200,
267 if (mapset ==
NULL) {
271 Rast_write_colors(params->
elev, mapset, &colors);
272 Rast_quantize_fp_map_range(params->
elev, mapset, (DCELL)zminac - 0.5,
273 (DCELL)zmaxac + 0.5, (CELL)(zminac - 0.5),
274 (CELL)(zmaxac + 0.5));
279 if (!params->
deriv) {
285 Rast_init_colors(&colors);
288 Rast_add_c_color_rule(&val1, 255, 255, 255, &val2, 255, 255, 0,
292 Rast_add_c_color_rule(&val1, 255, 255, 0, &val2, 0, 255, 0,
296 Rast_add_c_color_rule(&val1, 0, 255, 0, &val2, 0, 255, 255,
300 Rast_add_c_color_rule(&val1, 0, 255, 255, &val2, 0, 0, 255,
304 Rast_add_c_color_rule(&val1, 0, 0, 255, &val2, 255, 0, 255,
308 Rast_add_c_color_rule(&val1, 255, 0, 255, &val2, 255, 0, 0,
312 Rast_add_c_color_rule(&val1, 255, 0, 0, &val2, 0, 0, 0, &colors);
315 Rast_init_colors(&colors);
319 Rast_add_f_color_rule(&dat1, 127, 0, 255, &dat2, 0, 0, 255,
323 Rast_add_f_color_rule(&dat1, 0, 0, 255, &dat2, 0, 127, 255,
326 dat2 = (FCELL)-0.001;
327 Rast_add_f_color_rule(&dat1, 0, 127, 255, &dat2, 0, 255, 255,
331 Rast_add_f_color_rule(&dat1, 0, 255, 255, &dat2, 200, 255, 200,
335 Rast_add_f_color_rule(&dat1, 200, 255, 200, &dat2, 255, 255, 0,
339 Rast_add_f_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
343 Rast_add_f_color_rule(&dat1, 255, 127, 0, &dat2, 255, 0, 0,
348 Rast_add_f_color_rule(&dat1, 255, 0, 0, &dat2, 255, 0, 200,
354 if (mapset ==
NULL) {
358 Rast_write_colors(params->
slope, mapset, &colors);
359 Rast_quantize_fp_map_range(params->
slope, mapset, 0., 90., 0, 90);
361 do_history(params->
slope, vect, input, params);
365 if (!params->
deriv) {
366 Rast_init_colors(&colors);
369 Rast_add_c_color_rule(&val1, 255, 255, 255, &val2, 255, 255, 255,
373 Rast_add_c_color_rule(&val1, 255, 255, 0, &val2, 0, 255, 0,
377 Rast_add_c_color_rule(&val1, 0, 255, 0, &val2, 0, 255, 255,
381 Rast_add_c_color_rule(&val1, 0, 255, 255, &val2, 255, 0, 0,
385 Rast_add_c_color_rule(&val1, 255, 0, 0, &val2, 255, 255, 0,
389 Rast_init_colors(&colors);
393 Rast_add_f_color_rule(&dat1, 127, 0, 255, &dat2, 0, 0, 255,
397 Rast_add_f_color_rule(&dat1, 0, 0, 255, &dat2, 0, 127, 255,
400 dat2 = (FCELL)-0.001;
401 Rast_add_f_color_rule(&dat1, 0, 127, 255, &dat2, 0, 255, 255,
405 Rast_add_f_color_rule(&dat1, 0, 255, 255, &dat2, 200, 255, 200,
409 Rast_add_f_color_rule(&dat1, 200, 255, 200, &dat2, 255, 255, 0,
413 Rast_add_f_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
417 Rast_add_f_color_rule(&dat1, 255, 127, 0, &dat2, 255, 0, 0,
422 Rast_add_f_color_rule(&dat1, 255, 0, 0, &dat2, 255, 0, 200,
428 if (mapset ==
NULL) {
432 Rast_write_colors(params->
aspect, mapset, &colors);
433 Rast_quantize_fp_map_range(params->
aspect, mapset, 0., 360., 0,
436 do_history(params->
aspect, vect, input, params);
441 Rast_init_colors(&colors);
442 dat1 = (FCELL)
amin1(c1min, c2min);
445 Rast_add_f_color_rule(&dat1, 127, 0, 255, &dat2, 0, 0, 255,
448 dat2 = (FCELL)-0.001;
449 Rast_add_f_color_rule(&dat1, 0, 0, 255, &dat2, 0, 127, 255,
452 dat2 = (FCELL)-0.00001;
453 Rast_add_f_color_rule(&dat1, 0, 127, 255, &dat2, 0, 255, 255,
457 Rast_add_f_color_rule(&dat1, 0, 255, 255, &dat2, 200, 255, 200,
460 dat2 = (FCELL)0.00001;
461 Rast_add_f_color_rule(&dat1, 200, 255, 200, &dat2, 255, 255, 0,
465 Rast_add_f_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
469 Rast_add_f_color_rule(&dat1, 255, 127, 0, &dat2, 255, 0, 0,
472 dat2 = (FCELL)
amax1(c1max, c2max);
474 Rast_add_f_color_rule(&dat1, 255, 0, 0, &dat2, 255, 0, 200,
479 if (mapset ==
NULL) {
483 Rast_write_colors(params->
pcurv, mapset, &colors);
484 Rast_quantize_fp_map_range(params->
pcurv, mapset, dat1, dat2,
486 (CELL)(dat2 *
MULT));
488 do_history(params->
pcurv, vect, input, params);
493 if (mapset ==
NULL) {
497 Rast_write_colors(params->
tcurv, mapset, &colors);
498 Rast_quantize_fp_map_range(params->
tcurv, mapset, dat1, dat2,
500 (CELL)(dat2 *
MULT));
502 do_history(params->
tcurv, vect, input, params);
507 if (mapset ==
NULL) {
511 Rast_write_colors(params->
mcurv, mapset, &colors);
512 Rast_quantize_fp_map_range(params->
mcurv, mapset, dat1, dat2,
514 (CELL)(dat2 *
MULT));
516 do_history(params->
mcurv, vect, input, params);
523 if (mapset ==
NULL) {
528 Rast_short_history(params->
elev, type, &hist);
538 if (params->
rsm == -1)
539 Rast_append_format_history(
540 &hist,
"giventension=%f, smoothing att=%d",
541 params->
fi * 1000. / dnorm, params->
smatt);
543 Rast_append_format_history(
544 &hist,
"giventension=%f, smoothing=%f",
545 params->
fi * 1000. / dnorm, params->
rsm);
548 if (params->
rsm == -1)
549 Rast_append_format_history(
550 &hist,
"tension=%f, smoothing att=%d",
551 params->
fi * 1000. / dnorm, params->
smatt);
553 Rast_append_format_history(&hist,
"tension=%f, smoothing=%f",
554 params->
fi, params->
rsm);
557 Rast_append_format_history(&hist,
"dnorm=%f, dmin=%f, zmult=%f", dnorm,
568 Rast_append_format_history(&hist,
"segmax=%d, npmin=%d, rmsdevi=%f",
570 sqrt(ertot / n_points));
572 Rast_append_format_history(&hist,
"zmin_data=%f, zmax_data=%f", zmin,
574 Rast_append_format_history(&hist,
"zmin_int=%f, zmax_int=%f", zminac,
578 Rast_append_format_history(&hist,
"theta=%f, scalex=%f",
581 Rast_format_history(&hist, HIST_DATSRC_1,
"%s %s",
582 vect ?
"vector map" :
"site file", input);
584 Rast_command_history(&hist);
585 Rast_write_history(params->
elev, &hist);
589 Rast_free_history(&hist);