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);