Skip to content

Commit f446a19

Browse files
authored
r.volume: fix -p flag behavior (OSGeo#6068)
1 parent 99185cc commit f446a19

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

raster/r.volume/main.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ int main(int argc, char *argv[])
135135

136136
flag.print = G_define_flag();
137137
flag.print->key = 'p';
138-
flag.print->answer = 1;
139138
flag.print->description = _("Print report");
140139

140+
// Uncomment for GRASS v9
141+
// G_option_required(flag.print, opt.centroids, NULL);
142+
141143
if (G_parser(argc, argv))
142144
exit(EXIT_FAILURE);
143145

@@ -192,12 +194,9 @@ int main(int argc, char *argv[])
192194
}
193195
format = CSV;
194196
}
195-
196-
print = flag.print->answer || flag.report->answer;
197-
if (format != PLAIN && !print) {
198-
G_fatal_error(
199-
_("The -p flag is required when using the format option."));
200-
}
197+
// print = flag.print->answer;
198+
// currently prints always, change for GRASS v9
199+
print = 1;
201200

202201
/*
203202
* see if raster mask or a separate "clumpmap" raster map is to be used

raster/r.volume/r.volume.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ option.
2424

2525
To print the volume report, use the **-p** flag along with the **format** option
2626
to specify the desired output format. The volume report is printed even without
27-
this flag to maintain backward compatibility; however, this behavior may change
27+
this flag to maintain backward compatibility; however, this behavior will change
2828
in the future.
2929

30-
The default separator set to **:** for backward compatibility. However,
30+
The default separator is set to **:** for backward compatibility. However,
3131
if **format=csv** is specified, the default separator will be a **comma**.
3232

3333
### CENTROIDS
@@ -82,7 +82,7 @@ r.lake elevation=elev_lid792_1m water_level=113.7 lake=mylake coordinates=638684
8282
# Lake volume 648.875328 cubic meters
8383

8484
# compute water volume
85-
r.volume input=elev_lid792_1m clump=mylake
85+
r.volume input=elev_lid792_1m clump=mylake -p
8686
#
8787
# Category Average Data # Cells Centroid Total
8888
# Number in clump Total in clump Easting Northing Volume
@@ -106,7 +106,7 @@ dataset):
106106
g.region raster=elevation -p
107107

108108
# compute volume
109-
r.volume input=elevation clump=geology_30m
109+
r.volume input=elevation clump=geology_30m -p
110110
#
111111
# Volume report on data from <elevation> using clumps on <geology_30m> raster map
112112
#

0 commit comments

Comments
 (0)