18 #include <grass/gis.h>
19 #include <grass/bitmap.h>
20 #include <grass/linkm.h>
22 #include <grass/glocale.h>
23 #include <grass/interpf.h>
30 double zmin,
double zmax,
31 double zminac,
double zmaxac,
double c1min,
double c1max,
32 double c2min,
double c2max,
double gmin,
double gmax,
double ertot,
34 double dnorm,
int dtens,
int vect,
int n_points)
42 int cf1 = 0, cf2 = 0, cf3 = 0, cf4 = 0, cf5 = 0, cf6 = 0;
48 struct History hist, hist1, hist2, hist3, hist4, hist5;
66 fprintf(stderr,
"unable to create raster map %s\n", params->
elev);
74 fprintf(stderr,
"unable to create raster map %s\n",
83 fprintf(stderr,
"unable to create raster map %s\n",
92 fprintf(stderr,
"unable to create raster map %s\n",
101 fprintf(stderr,
"unable to create raster map %s\n",
110 fprintf(stderr,
"unable to create raster map %s\n",
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);
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);
134 fprintf(stderr,
"OOPS: rows changed from %d to %d\n", nrows,
140 fprintf(stderr,
"OOPS: cols changed from %d to %d\n", ncols,
147 for (i = 0; i < params->
nsizr; i++) {
150 ((params->
nsizr - 1 -
151 i) * params->
nsizc *
sizeof(FCELL)), 0)
153 fprintf(stderr,
"cannot fseek to the right spot\n");
156 ii = fread(cell1,
sizeof(FCELL), params->
nsizc, params->
Tmp_fd_z);
168 for (i = 0; i < params->
nsizr; i++) {
171 ((params->
nsizr - 1 -
172 i) * params->
nsizc *
sizeof(FCELL)), 0)
174 fprintf(stderr,
"cannot fseek to the right spot\n");
184 for (i = 0; i < params->
nsizr; i++) {
187 ((params->
nsizr - 1 -
188 i) * params->
nsizc *
sizeof(FCELL)), 0)
190 fprintf(stderr,
"cannot fseek to the right spot\n");
200 for (i = 0; i < params->
nsizr; i++) {
203 ((params->
nsizr - 1 -
204 i) * params->
nsizc *
sizeof(FCELL)), 0)
206 fprintf(stderr,
"cannot fseek to the right spot\n");
216 for (i = 0; i < params->
nsizr; i++) {
219 ((params->
nsizr - 1 -
220 i) * params->
nsizc *
sizeof(FCELL)), 0)
222 fprintf(stderr,
"cannot fseek to the right spot\n");
232 for (i = 0; i < params->
nsizr; i++) {
235 ((params->
nsizr - 1 -
236 i) * params->
nsizc *
sizeof(FCELL)), 0)
238 fprintf(stderr,
"cannot fseek to the right spot\n");
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);
269 &data2, 0, 255, 0, &colors);
273 &data2, 255, 255, 0, &colors);
277 &data2, 255, 127, 0, &colors);
281 &data2, 191, 127, 63, &colors);
285 &data2, 20, 20, 20, &colors);
292 if (mapset ==
NULL) {
293 fprintf(stderr,
"file [%s] not found\n", params->
elev);
298 (DCELL) zminac - 0.5, (DCELL) zmaxac + 0.5,
299 (CELL) (zminac - 0.5), (CELL) (zmaxac + 0.5));
304 if (!params->
deriv) {
321 dat1 = (FCELL) - 5.0;
323 dat2 = (FCELL) - 0.1;
325 &dat2, 0, 0, 255, &colors);
327 dat2 = (FCELL) - 0.01;
329 &dat2, 0, 127, 255, &colors);
331 dat2 = (FCELL) - 0.001;
333 &dat2, 0, 255, 255, &colors);
337 &dat2, 200, 255, 200, &colors);
339 dat2 = (FCELL) 0.001;
341 &dat2, 255, 255, 0, &colors);
345 &dat2, 255, 127, 0, &colors);
349 &dat2, 255, 0, 0, &colors);
354 &dat2, 255, 0, 200, &colors);
359 if (mapset ==
NULL) {
360 fprintf(stderr,
"file [%s] not found\n", params->
slope);
369 sprintf(hist1.edhist[0],
"The elevation map is %s",
372 sprintf(hist1.datsrc_1,
"vector map %s", input);
374 sprintf(hist1.datsrc_1,
"site file %s", input);
385 if (!params->
deriv) {
395 dat1 = (FCELL) - 5.0;
397 dat2 = (FCELL) - 0.1;
399 &dat2, 0, 0, 255, &colors);
401 dat2 = (FCELL) - 0.01;
403 &dat2, 0, 127, 255, &colors);
405 dat2 = (FCELL) - 0.001;
407 &dat2, 0, 255, 255, &colors);
411 &dat2, 200, 255, 200, &colors);
413 dat2 = (FCELL) 0.001;
415 &dat2, 255, 255, 0, &colors);
419 &dat2, 255, 127, 0, &colors);
423 &dat2, 255, 0, 0, &colors);
428 &dat2, 255, 0, 200, &colors);
433 if (mapset ==
NULL) {
434 fprintf(stderr,
"file [%s] not found\n", params->
aspect);
443 sprintf(hist2.edhist[0],
"The elevation map is %s",
446 sprintf(hist2.datsrc_1,
"vector map %s", input);
448 sprintf(hist2.datsrc_1,
"site file %s", input);
460 dat1 = (FCELL)
amin1(c1min, c2min);
462 dat2 = (FCELL) - 0.01;
464 &dat2, 0, 0, 255, &colors);
466 dat2 = (FCELL) - 0.001;
468 &dat2, 0, 127, 255, &colors);
470 dat2 = (FCELL) - 0.00001;
472 &dat2, 0, 255, 255, &colors);
476 &dat2, 200, 255, 200, &colors);
478 dat2 = (FCELL) 0.00001;
480 &dat2, 255, 255, 0, &colors);
482 dat2 = (FCELL) 0.001;
484 &dat2, 255, 127, 0, &colors);
488 &dat2, 255, 0, 0, &colors);
490 dat2 = (FCELL)
amax1(c1max, c2max);
493 &dat2, 255, 0, 200, &colors);
497 if (mapset ==
NULL) {
498 fprintf(stderr,
"file [%s] not found\n", params->
pcurv);
503 (CELL) (dat1 *
MULT),
504 (CELL) (dat2 * MULT));
509 sprintf(hist3.edhist[0],
"The elevation map is %s",
512 sprintf(hist3.datsrc_1,
"vector map %s", input);
514 sprintf(hist3.datsrc_1,
"site file %s", input);
525 if (mapset ==
NULL) {
526 fprintf(stderr,
"file [%s] not found\n", params->
tcurv);
531 (CELL) (dat1 *
MULT),
532 (CELL) (dat2 * MULT));
537 sprintf(hist4.edhist[0],
"The elevation map is %s",
540 sprintf(hist4.datsrc_1,
"vector map %s", input);
542 sprintf(hist4.datsrc_1,
"site file %s", input);
553 if (mapset ==
NULL) {
554 fprintf(stderr,
"file [%s] not found\n", params->
mcurv);
559 (CELL) (dat1 *
MULT),
560 (CELL) (dat2 * MULT));
565 sprintf(hist5.edhist[0],
"The elevation map is %s",
568 sprintf(hist5.datsrc_1,
"vector map %s", input);
570 sprintf(hist5.datsrc_1,
"site file %s", input);
583 if (mapset ==
NULL) {
584 fprintf(stderr,
"file [%s] not found\n", params->
elev);
598 if (params->
rsm == -1)
599 sprintf(hist.edhist[0],
"giventension=%f, smoothing att=%d",
600 params->
fi * 1000. / dnorm, params->
smatt);
602 sprintf(hist.edhist[0],
"giventension=%f, smoothing=%f",
603 params->
fi * 1000. / dnorm, params->
rsm);
606 if (params->
rsm == -1)
607 sprintf(hist.edhist[0],
"tension=%f, smoothing att=%d",
608 params->
fi * 1000. / dnorm, params->
smatt);
610 sprintf(hist.edhist[0],
"tension=%f, smoothing=%f",
611 params->
fi, params->
rsm);
614 sprintf(hist.edhist[1],
"dnorm=%f, dmin=%f, zmult=%f",
625 sprintf(hist.edhist[2],
"segmax=%d, npmin=%d, rmsdevi=%f",
626 params->
kmax, params->
kmin, sqrt(ertot / n_points));
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);
632 sprintf(hist.edhist[5],
"theta=%f, scalex=%f", params->
theta,
640 sprintf(hist.datsrc_1,
"vector map %s", input);
642 sprintf(hist.datsrc_1,
"site file %s", input);
int G_write_colors(const char *name, const char *mapset, struct Colors *colors)
write map layer color table
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
int G_short_history(const char *name, const char *type, struct History *hist)
initialize history structure
int G_open_fp_cell_new(const char *name)
Opens new fcell file in a database.
int G_close_cell(int fd)
close a raster map
FCELL * G_allocate_f_raster_buf(void)
Allocates memory for a raster map of type FCELL.
int G_set_window(struct Cell_head *window)
Establishes 'window' as the current working window.
double amax1(double, double)
int G_write_history(const char *name, struct History *hist)
write raster history file
int G_write_raster_timestamp(const char *name, const struct TimeStamp *ts)
Returns: 1 on success. -1 error - can't create timestamp file -2 error - invalid datetime in ts...
int G_command_history(struct History *hist)
Save command line to raster history structure.
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)
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)
int G_window_cols(void)
Number of columns in active window.
double amin1(double, double)
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
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.
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...
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...
int G_window_rows(void)
Number of rows in active window.
int G_put_f_raster_row(int fd, const FCELL *buf)