|
@@ -40,9 +40,10 @@ int main(int argc, char *argv[])
|
|
struct GModule *module;
|
|
struct GModule *module;
|
|
struct Option *raster, *title_opt, *history_opt;
|
|
struct Option *raster, *title_opt, *history_opt;
|
|
struct Option *datasrc1_opt, *datasrc2_opt, *datadesc_opt;
|
|
struct Option *datasrc1_opt, *datasrc2_opt, *datadesc_opt;
|
|
|
|
+ struct Option *bandref_opt;
|
|
struct Option *map_opt, *units_opt, *vdatum_opt;
|
|
struct Option *map_opt, *units_opt, *vdatum_opt;
|
|
struct Option *load_opt, *save_opt;
|
|
struct Option *load_opt, *save_opt;
|
|
- struct Flag *stats_flag, *null_flag, *del_flag;
|
|
|
|
|
|
+ struct Flag *stats_flag, *null_flag, *del_flag, *bandref_rm_flag;
|
|
int is_reclass; /* Is raster reclass? */
|
|
int is_reclass; /* Is raster reclass? */
|
|
const char *infile;
|
|
const char *infile;
|
|
struct History hist;
|
|
struct History hist;
|
|
@@ -63,6 +64,7 @@ int main(int argc, char *argv[])
|
|
title_opt->key_desc = "phrase";
|
|
title_opt->key_desc = "phrase";
|
|
title_opt->type = TYPE_STRING;
|
|
title_opt->type = TYPE_STRING;
|
|
title_opt->required = NO;
|
|
title_opt->required = NO;
|
|
|
|
+ title_opt->guisection = _("Metadata");
|
|
title_opt->description = _("Title for resultant raster map");
|
|
title_opt->description = _("Title for resultant raster map");
|
|
|
|
|
|
history_opt = G_define_option();
|
|
history_opt = G_define_option();
|
|
@@ -70,6 +72,7 @@ int main(int argc, char *argv[])
|
|
history_opt->key_desc = "phrase";
|
|
history_opt->key_desc = "phrase";
|
|
history_opt->type = TYPE_STRING;
|
|
history_opt->type = TYPE_STRING;
|
|
history_opt->required = NO;
|
|
history_opt->required = NO;
|
|
|
|
+ history_opt->guisection = _("Metadata");
|
|
history_opt->description =
|
|
history_opt->description =
|
|
_("Text to append to the next line of the map's metadata file");
|
|
_("Text to append to the next line of the map's metadata file");
|
|
|
|
|
|
@@ -77,12 +80,14 @@ int main(int argc, char *argv[])
|
|
units_opt->key = "units";
|
|
units_opt->key = "units";
|
|
units_opt->type = TYPE_STRING;
|
|
units_opt->type = TYPE_STRING;
|
|
units_opt->required = NO;
|
|
units_opt->required = NO;
|
|
|
|
+ units_opt->guisection = _("Metadata");
|
|
units_opt->description = _("Text to use for map data units");
|
|
units_opt->description = _("Text to use for map data units");
|
|
|
|
|
|
vdatum_opt = G_define_option();
|
|
vdatum_opt = G_define_option();
|
|
vdatum_opt->key = "vdatum";
|
|
vdatum_opt->key = "vdatum";
|
|
vdatum_opt->type = TYPE_STRING;
|
|
vdatum_opt->type = TYPE_STRING;
|
|
vdatum_opt->required = NO;
|
|
vdatum_opt->required = NO;
|
|
|
|
+ vdatum_opt->guisection = _("Metadata");
|
|
vdatum_opt->description = _("Text to use for map vertical datum");
|
|
vdatum_opt->description = _("Text to use for map vertical datum");
|
|
|
|
|
|
datasrc1_opt = G_define_option();
|
|
datasrc1_opt = G_define_option();
|
|
@@ -90,6 +95,7 @@ int main(int argc, char *argv[])
|
|
datasrc1_opt->key_desc = "phrase";
|
|
datasrc1_opt->key_desc = "phrase";
|
|
datasrc1_opt->type = TYPE_STRING;
|
|
datasrc1_opt->type = TYPE_STRING;
|
|
datasrc1_opt->required = NO;
|
|
datasrc1_opt->required = NO;
|
|
|
|
+ datasrc1_opt->guisection = _("Metadata");
|
|
datasrc1_opt->description = _("Text to use for data source, line 1");
|
|
datasrc1_opt->description = _("Text to use for data source, line 1");
|
|
|
|
|
|
datasrc2_opt = G_define_option();
|
|
datasrc2_opt = G_define_option();
|
|
@@ -97,6 +103,7 @@ int main(int argc, char *argv[])
|
|
datasrc2_opt->key_desc = "phrase";
|
|
datasrc2_opt->key_desc = "phrase";
|
|
datasrc2_opt->type = TYPE_STRING;
|
|
datasrc2_opt->type = TYPE_STRING;
|
|
datasrc2_opt->required = NO;
|
|
datasrc2_opt->required = NO;
|
|
|
|
+ datasrc2_opt->guisection = _("Metadata");
|
|
datasrc2_opt->description = _("Text to use for data source, line 2");
|
|
datasrc2_opt->description = _("Text to use for data source, line 2");
|
|
|
|
|
|
datadesc_opt = G_define_option();
|
|
datadesc_opt = G_define_option();
|
|
@@ -104,6 +111,7 @@ int main(int argc, char *argv[])
|
|
datadesc_opt->key_desc = "phrase";
|
|
datadesc_opt->key_desc = "phrase";
|
|
datadesc_opt->type = TYPE_STRING;
|
|
datadesc_opt->type = TYPE_STRING;
|
|
datadesc_opt->required = NO;
|
|
datadesc_opt->required = NO;
|
|
|
|
+ datadesc_opt->guisection = _("Metadata");
|
|
datadesc_opt->description =
|
|
datadesc_opt->description =
|
|
_("Text to use for data description or keyword(s)");
|
|
_("Text to use for data description or keyword(s)");
|
|
|
|
|
|
@@ -112,28 +120,48 @@ int main(int argc, char *argv[])
|
|
map_opt->type = TYPE_STRING;
|
|
map_opt->type = TYPE_STRING;
|
|
map_opt->required = NO;
|
|
map_opt->required = NO;
|
|
map_opt->gisprompt = "old,cell,raster";
|
|
map_opt->gisprompt = "old,cell,raster";
|
|
|
|
+ map_opt->guisection = _("Import / Export");
|
|
map_opt->description = _("Raster map from which to copy category table");
|
|
map_opt->description = _("Raster map from which to copy category table");
|
|
|
|
|
|
load_opt = G_define_standard_option(G_OPT_F_INPUT);
|
|
load_opt = G_define_standard_option(G_OPT_F_INPUT);
|
|
load_opt->key = "loadhistory";
|
|
load_opt->key = "loadhistory";
|
|
load_opt->required = NO;
|
|
load_opt->required = NO;
|
|
|
|
+ load_opt->guisection = _("Import / Export");
|
|
load_opt->description = _("Text file from which to load history");
|
|
load_opt->description = _("Text file from which to load history");
|
|
|
|
|
|
save_opt = G_define_standard_option(G_OPT_F_OUTPUT);
|
|
save_opt = G_define_standard_option(G_OPT_F_OUTPUT);
|
|
save_opt->key = "savehistory";
|
|
save_opt->key = "savehistory";
|
|
save_opt->required = NO;
|
|
save_opt->required = NO;
|
|
|
|
+ save_opt->guisection = _("Import / Export");
|
|
save_opt->description = _("Text file in which to save history");
|
|
save_opt->description = _("Text file in which to save history");
|
|
|
|
|
|
|
|
+ bandref_opt = G_define_option();
|
|
|
|
+ bandref_opt->key = "bandref";
|
|
|
|
+ bandref_opt->key_desc = "phrase";
|
|
|
|
+ bandref_opt->type = TYPE_STRING;
|
|
|
|
+ bandref_opt->required = NO;
|
|
|
|
+ bandref_opt->guisection = _("Band reference");
|
|
|
|
+ bandref_opt->description =
|
|
|
|
+ _("Band reference in form shortcut_name e.g. S2_8A");
|
|
|
|
+
|
|
|
|
+ bandref_rm_flag = G_define_flag();
|
|
|
|
+ bandref_rm_flag->key = 'b';
|
|
|
|
+ bandref_rm_flag->guisection = _("Band reference");
|
|
|
|
+ bandref_rm_flag->description = _("Delete the band reference");
|
|
|
|
+
|
|
stats_flag = G_define_flag();
|
|
stats_flag = G_define_flag();
|
|
stats_flag->key = 's';
|
|
stats_flag->key = 's';
|
|
|
|
+ stats_flag->guisection = _("Maintenance");
|
|
stats_flag->description = _("Update statistics (histogram, range)");
|
|
stats_flag->description = _("Update statistics (histogram, range)");
|
|
|
|
|
|
null_flag = G_define_flag();
|
|
null_flag = G_define_flag();
|
|
null_flag->key = 'n';
|
|
null_flag->key = 'n';
|
|
|
|
+ null_flag->guisection = _("Maintenance");
|
|
null_flag->description = _("Create/reset the null file");
|
|
null_flag->description = _("Create/reset the null file");
|
|
|
|
|
|
del_flag = G_define_flag();
|
|
del_flag = G_define_flag();
|
|
del_flag->key = 'd';
|
|
del_flag->key = 'd';
|
|
|
|
+ del_flag->guisection = _("Maintenance");
|
|
del_flag->description = _("Delete the null file");
|
|
del_flag->description = _("Delete the null file");
|
|
|
|
|
|
/* Parse command-line options */
|
|
/* Parse command-line options */
|
|
@@ -146,6 +174,10 @@ int main(int argc, char *argv[])
|
|
if (!mapset || strcmp(mapset, G_mapset()) != 0)
|
|
if (!mapset || strcmp(mapset, G_mapset()) != 0)
|
|
G_fatal_error(_("Raster map <%s> not found in current mapset"), infile);
|
|
G_fatal_error(_("Raster map <%s> not found in current mapset"), infile);
|
|
|
|
|
|
|
|
+ if (bandref_rm_flag->answer && bandref_opt->answer)
|
|
|
|
+ G_fatal_error(_("Band reference removal and setting band "
|
|
|
|
+ "reference values simultaneously doesn't make sense"));
|
|
|
|
+
|
|
Rast_get_cellhd(raster->answer, "", &cellhd);
|
|
Rast_get_cellhd(raster->answer, "", &cellhd);
|
|
is_reclass = (Rast_is_reclass(raster->answer, "", rname, rmapset) > 0);
|
|
is_reclass = (Rast_is_reclass(raster->answer, "", rname, rmapset) > 0);
|
|
|
|
|
|
@@ -252,10 +284,21 @@ int main(int argc, char *argv[])
|
|
Rast_free_cats(&cats);
|
|
Rast_free_cats(&cats);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (bandref_opt->answer) {
|
|
|
|
+ if (Rast_legal_bandref(bandref_opt->answer) < 0)
|
|
|
|
+ G_fatal_error(_("Provided band reference is not valid. "
|
|
|
|
+ "See documentation for valid examples"));
|
|
|
|
+
|
|
|
|
+ Rast_write_bandref(infile, bandref_opt->answer);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (bandref_rm_flag->answer)
|
|
|
|
+ G_remove_misc("cell_misc", "bandref", infile);
|
|
|
|
|
|
if (title_opt->answer || history_opt->answer || units_opt->answer
|
|
if (title_opt->answer || history_opt->answer || units_opt->answer
|
|
|| vdatum_opt->answer || datasrc1_opt->answer || datasrc2_opt->answer
|
|
|| vdatum_opt->answer || datasrc1_opt->answer || datasrc2_opt->answer
|
|
- || datadesc_opt->answer || map_opt->answer)
|
|
|
|
|
|
+ || datadesc_opt->answer || map_opt->answer
|
|
|
|
+ || bandref_opt->answer || bandref_rm_flag->answer)
|
|
exit(EXIT_SUCCESS);
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
|
|