50
51
module = G_define_module();
51
52
module->description =
52
53
_("Calculates contrast weighted edge density index on a raster map");
53
module->keywords = _("raster, landscape structure analysis, patch index");
54
G_add_keyword(_("raster"));
55
G_add_keyword(_("landscape structure analysis"));
56
G_add_keyword(_("patch index"));
55
58
/* define options */
57
raster = G_define_standard_option(G_OPT_R_MAP);
60
raster = G_define_standard_option(G_OPT_R_INPUT);
59
62
conf = G_define_standard_option(G_OPT_F_INPUT);
61
64
conf->description = _("Configuration file");
62
65
conf->required = YES;
335
338
c2.t = CELL_TYPE;
337
340
/*the first time buf_sup is all null */
338
G_set_c_null_value(buf_null + ad->x, ad->cl);
341
Rast_set_c_null_value(buf_null + ad->x, ad->cl);
339
342
buf_sup = buf_null;
341
344
for (j = 0; j < ad->rl; j++) { /* for each row */
358
G_set_c_null_value(&prevCell, 1);
359
G_set_c_null_value(&corrCell, 1);
361
Rast_set_c_null_value(&prevCell, 1);
362
Rast_set_c_null_value(&corrCell, 1);
360
363
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
361
364
corrCell = buf_corr[i + ad->x];
362
365
if (masked && mask_corr[i] == 0) {
363
G_set_c_null_value(&corrCell, 1);
366
/* total sample area */
366
Rast_set_c_null_value(&corrCell, 1);
370
if (!(G_is_null_value(&corrCell, CELL_TYPE))) {
369
if (!(Rast_is_null_value(&corrCell, CELL_TYPE))) {
370
/* total sample area */
371
373
supCell = buf_sup[i + ad->x];
372
374
if (masked && (mask_sup[i] == 0)) {
373
G_set_c_null_value(&supCell, 1);
375
Rast_set_c_null_value(&supCell, 1);
376
378
/* calculate how many edges the cell has */
377
if (((!G_is_null_value(&prevCell, CELL_TYPE))) &&
379
if (((!Rast_is_null_value(&prevCell, CELL_TYPE))) &&
378
380
(corrCell != prevCell)) {
483
485
c2.t = DCELL_TYPE;
485
487
/*the first time buf_sup is all null */
486
G_set_d_null_value(buf_null + ad->x, ad->cl);
488
Rast_set_d_null_value(buf_null + ad->x, ad->cl);
487
489
buf_sup = buf_null;
489
491
for (j = 0; j < ad->rl; j++) { /* for each row */
502
504
return RLI_ERRORE;
505
G_set_d_null_value(&prevCell, 1);
506
G_set_d_null_value(&corrCell, 1);
507
Rast_set_d_null_value(&prevCell, 1);
508
Rast_set_d_null_value(&corrCell, 1);
507
509
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
508
510
corrCell = buf_corr[i + ad->x];
509
511
if (masked && mask_corr[i] == 0) {
510
G_set_d_null_value(&corrCell, 1);
512
Rast_set_d_null_value(&corrCell, 1);
515
if (!(Rast_is_null_value(&corrCell, DCELL_TYPE))) {
513
516
/* total sample area */
517
if (!(G_is_null_value(&corrCell, DCELL_TYPE))) {
518
519
supCell = buf_sup[i + ad->x];
519
520
if (masked && (mask_sup[i] == 0)) {
520
G_set_d_null_value(&supCell, 1);
521
Rast_set_d_null_value(&supCell, 1);
523
524
/* calculate how many edges the cell has */
524
if (((!G_is_null_value(&prevCell, DCELL_TYPE))) &&
525
if (((!Rast_is_null_value(&prevCell, DCELL_TYPE))) &&
525
526
(corrCell != prevCell)) {
623
624
/* allocate and inizialize buffers */
624
buf_null = G_allocate_f_raster_buf();
625
buf_null = Rast_allocate_f_buf();
625
626
if (buf_null == NULL) {
626
627
G_fatal_error("malloc buf_sup failed");
627
628
return RLI_ERRORE;
629
630
/*the first time buf_sup is all null */
630
G_set_f_null_value(buf_null + ad->x, ad->cl);
631
Rast_set_f_null_value(buf_null + ad->x, ad->cl);
631
632
buf_sup = buf_null;
633
634
c1.t = FCELL_TYPE;
650
651
return RLI_ERRORE;
653
G_set_f_null_value(&prevCell, 1);
654
G_set_f_null_value(&corrCell, 1);
654
Rast_set_f_null_value(&prevCell, 1);
655
Rast_set_f_null_value(&corrCell, 1);
655
656
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
656
657
corrCell = buf_corr[i + ad->x];
657
658
if (masked && mask_corr[i] == 0) {
658
G_set_f_null_value(&corrCell, 1);
659
Rast_set_f_null_value(&corrCell, 1);
662
if (!(Rast_is_null_value(&corrCell, FCELL_TYPE))) {
661
663
/* total sample area */
665
if (!(G_is_null_value(&corrCell, FCELL_TYPE))) {
666
666
supCell = buf_sup[i + ad->x];
667
667
if (masked && (mask_sup[i] == 0)) {
668
G_set_f_null_value(&supCell, 1);
668
Rast_set_f_null_value(&supCell, 1);
671
671
/* calculate how many edges the cell has */
672
if (((!G_is_null_value(&prevCell, FCELL_TYPE))) &&
672
if (((!Rast_is_null_value(&prevCell, FCELL_TYPE))) &&
673
673
(corrCell != prevCell)) {
750
if ((G_is_null_value(&ce1.val.c, CELL_TYPE)) ||
751
(G_is_null_value(&ce2.val.c, CELL_TYPE)))
750
if ((Rast_is_null_value(&ce1.val.c, CELL_TYPE)) ||
751
(Rast_is_null_value(&ce2.val.c, CELL_TYPE)))
757
if ((G_is_null_value(&ce1.val.dc, DCELL_TYPE)) ||
758
(G_is_null_value(&ce2.val.dc, DCELL_TYPE)))
757
if ((Rast_is_null_value(&ce1.val.dc, DCELL_TYPE)) ||
758
(Rast_is_null_value(&ce2.val.dc, DCELL_TYPE)))
764
if ((G_is_null_value(&ce1.val.fc, FCELL_TYPE)) ||
765
(G_is_null_value(&ce2.val.fc, FCELL_TYPE)))
764
if ((Rast_is_null_value(&ce1.val.fc, FCELL_TYPE)) ||
765
(Rast_is_null_value(&ce2.val.fc, FCELL_TYPE)))
837
if ((G_is_null_value(&(c1.val.c), CELL_TYPE)) ||
838
(G_is_null_value(&(c2.val.c), CELL_TYPE)))
837
if ((Rast_is_null_value(&(c1.val.c), CELL_TYPE)) ||
838
(Rast_is_null_value(&(c2.val.c), CELL_TYPE)))
839
839
return RLI_ERRORE;
844
if ((G_is_null_value(&(c1.val.dc), DCELL_TYPE)) ||
845
(G_is_null_value(&(c2.val.dc), DCELL_TYPE)))
844
if ((Rast_is_null_value(&(c1.val.dc), DCELL_TYPE)) ||
845
(Rast_is_null_value(&(c2.val.dc), DCELL_TYPE)))
846
846
return RLI_ERRORE;
851
if ((G_is_null_value(&(c1.val.fc), FCELL_TYPE)) ||
852
(G_is_null_value(&(c2.val.fc), FCELL_TYPE)))
851
if ((Rast_is_null_value(&(c1.val.fc), FCELL_TYPE)) ||
852
(Rast_is_null_value(&(c2.val.fc), FCELL_TYPE)))
853
853
return RLI_ERRORE;