本文整理汇总了C++中G_define_flag函数的典型用法代码示例。如果您正苦于以下问题:C++ G_define_flag函数的具体用法?C++ G_define_flag怎么用?C++ G_define_flag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_define_flag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
int parse(int argc, char *argv[], struct parms *parms)
{
struct Option *group, *subgroup, *sigfile, *output;
struct Option *blocksize;
struct Flag *ml;
group = G_define_standard_option(G_OPT_I_GROUP);
subgroup = G_define_standard_option(G_OPT_I_SUBGROUP);
sigfile = G_define_option();
sigfile->key = "signaturefile";
sigfile->label = _("Name of file containing signatures");
sigfile->description = _("Generated by i.gensigset");
sigfile->key_desc = "name";
sigfile->required = YES;
sigfile->type = TYPE_STRING;
output = G_define_standard_option(G_OPT_R_OUTPUT);
blocksize = G_define_option();
blocksize->key = "blocksize";
blocksize->description = _("Size of submatrix to process at one time");
blocksize->required = NO;
blocksize->type = TYPE_INTEGER;
blocksize->answer = "128";
ml = G_define_flag();
ml->key = 'm';
ml->description =
_("Use maximum likelihood estimation (instead of smap)");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
parms->ml = ml->answer;
parms->output_map = output->answer;
parms->group = group->answer;
parms->subgroup = subgroup->answer;
parms->sigfile = sigfile->answer;
/* check all the inputs */
if (!I_find_group(parms->group))
G_fatal_error(_("Group <%s> not found"), parms->group);
if (!I_find_subgroup(parms->group, parms->subgroup))
G_fatal_error(_("Subgroup <%s> not found"), parms->subgroup);
if (sscanf(blocksize->answer, "%d", &parms->blocksize) != 1
|| parms->blocksize <= 8)
parms->blocksize = 8;
return 0;
}
示例2: parse_command_line
static void parse_command_line(int argc, char **argv)
{
struct Option *driver, *database;
struct Flag *p, *s;
struct GModule *module;
const char *drv, *db;
/* Initialize the GIS calls */
G_gisinit(argv[0]);
driver = G_define_standard_option(G_OPT_DB_DRIVER);
driver->options = db_list_drivers();
if ((drv = db_get_default_driver_name()))
driver->answer = (char *) drv;
database = G_define_standard_option(G_OPT_DB_DATABASE);
if ((db = db_get_default_database_name()))
database->answer = (char *) db;
p = G_define_flag();
p->key = 'p';
p->description = _("Print tables and exit");
s = G_define_flag();
s->key = 's';
s->description = _("System tables instead of user tables");
/* Set description */
module = G_define_module();
G_add_keyword(_("database"));
G_add_keyword(_("attribute table"));
module->description = _("Lists all tables for a given database.");
if (G_parser(argc, argv))
exit(EXIT_SUCCESS);
parms.driver = driver->answer;
parms.database = database->answer;
parms.s = s->answer;
}
示例3: parse_args
void parse_args(struct opts *opt)
{
opt->reverse = G_define_flag();
opt->reverse->key = 'r';
opt->reverse->description =
_("Reverse transformation; 3D vector features to 2D");
opt->table = G_define_flag();
opt->table->key = 't';
opt->table->description = _("Do not copy table");
opt->input = G_define_standard_option(G_OPT_V_INPUT);
opt->field = G_define_standard_option(G_OPT_V_FIELD_ALL);
opt->field->guisection = _("Selection");
opt->type = G_define_standard_option(G_OPT_V_TYPE);
opt->type->options = "point,line,boundary,centroid";
opt->type->answer = "point,line,boundary,centroid";
opt->type->guisection = _("Selection");
opt->output = G_define_standard_option(G_OPT_V_OUTPUT);
opt->column = G_define_standard_option(G_OPT_DB_COLUMN);
opt->column->label = _("Name of attribute column used for height");
opt->column->description =
_("Can be used for reverse transformation, to store height of points");
opt->column->guisection = _("Height");
opt->height = G_define_option();
opt->height->key = "height";
opt->height->type = TYPE_DOUBLE;
opt->height->required = NO;
opt->height->multiple = NO;
opt->height->description = _("Fixed height for 3D vector features");
opt->height->guisection = _("Height");
return;
}
示例4: main
int main(int argc, char *argv[])
{
struct GModule *module;
struct
{
struct Option *map;
struct Option *line;
struct Option *null_str;
} parms;
struct Flag *coord;
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("raster"));
G_add_keyword(_("transect"));
module->description =
_("Outputs raster map layer values lying along "
"user defined transect line(s).");
parms.map = G_define_standard_option(G_OPT_R_MAP);
parms.map->description = _("Raster map to be queried");
parms.line = G_define_option();
parms.line->key = "line";
parms.line->key_desc = "east,north,azimuth,distance";
parms.line->type = TYPE_STRING;
parms.line->description = _("Transect definition");
parms.line->required = YES;
parms.line->multiple = YES;
parms.null_str = G_define_standard_option(G_OPT_M_NULL_VALUE);
parms.null_str->answer = "*";
coord = G_define_flag();
coord->key = 'g';
coord->description =
_("Output easting and northing in first two columns of four column output");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
return profile(coord->answer,
parms.map->answer,
parms.null_str->answer,
parms.line->answers) != 0;
}
示例5: parse_toplevel
void parse_toplevel(struct context *ctx, const char *cmd)
{
char **tokens;
if (G_strcasecmp(cmd, "module") == 0) {
ctx->state = S_MODULE;
ctx->module = G_define_module();
return;
}
if (G_strcasecmp(cmd, "flag") == 0) {
ctx->state = S_FLAG;
ctx->flag = G_define_flag();
if (!ctx->first_flag)
ctx->first_flag = ctx->flag;
return;
}
if (G_strncasecmp(cmd, "option", strlen("option")) == 0) {
ctx->state = S_OPTION;
tokens = G_tokenize(cmd, " ");
if (G_number_of_tokens(tokens) > 1) {
/* standard option */
ctx->option = define_standard_option(tokens[1]);
}
else {
ctx->option = G_define_option();
}
if (!ctx->first_option)
ctx->first_option = ctx->option;
G_free_tokens(tokens);
return;
}
if (G_strcasecmp(cmd, "rules") == 0) {
ctx->state = S_RULES;
return;
}
fprintf(stderr, _("Unknown command \"%s\" at line %d\n"), cmd, ctx->line);
}
示例6: main
int main(int argc, char *argv[])
{
int i, type, stat;
int day, yr, Out_proj;
int out_zone = 0;
int overwrite; /* overwrite output map */
const char *mapset;
const char *omap_name, *map_name, *iset_name, *iloc_name;
struct pj_info info_in;
struct pj_info info_out;
const char *gbase;
char date[40], mon[4];
struct GModule *module;
struct Option *omapopt, *mapopt, *isetopt, *ilocopt, *ibaseopt, *smax;
struct Key_Value *in_proj_keys, *in_unit_keys;
struct Key_Value *out_proj_keys, *out_unit_keys;
struct line_pnts *Points, *Points2;
struct line_cats *Cats;
struct Map_info Map;
struct Map_info Out_Map;
struct bound_box src_box, tgt_box;
int nowrap = 0, recommend_nowrap = 0;
double lmax;
struct
{
struct Flag *list; /* list files in source location */
struct Flag *transformz; /* treat z as ellipsoidal height */
struct Flag *wrap; /* latlon output: wrap to 0,360 */
struct Flag *no_topol; /* do not build topology */
} flag;
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("vector"));
G_add_keyword(_("projection"));
G_add_keyword(_("transformation"));
G_add_keyword(_("import"));
module->description = _("Re-projects a vector map from one location to the current location.");
/* set up the options and flags for the command line parser */
ilocopt = G_define_standard_option(G_OPT_M_LOCATION);
ilocopt->required = YES;
ilocopt->label = _("Location containing input vector map");
ilocopt->guisection = _("Source");
isetopt = G_define_standard_option(G_OPT_M_MAPSET);
isetopt->label = _("Mapset containing input vector map");
isetopt->description = _("Default: name of current mapset");
isetopt->guisection = _("Source");
mapopt = G_define_standard_option(G_OPT_V_INPUT);
mapopt->required = NO;
mapopt->label = _("Name of input vector map to re-project");
mapopt->description = NULL;
mapopt->guisection = _("Source");
ibaseopt = G_define_standard_option(G_OPT_M_DBASE);
ibaseopt->label = _("Path to GRASS database of input location");
smax = G_define_option();
smax->key = "smax";
smax->type = TYPE_DOUBLE;
smax->required = NO;
smax->answer = "10000";
smax->label = _("Maximum segment length in meters in output vector map");
smax->description = _("Increases accuracy of reprojected shapes, disable with smax=0");
smax->guisection = _("Target");
omapopt = G_define_standard_option(G_OPT_V_OUTPUT);
omapopt->required = NO;
omapopt->description = _("Name for output vector map (default: input)");
omapopt->guisection = _("Target");
flag.list = G_define_flag();
flag.list->key = 'l';
flag.list->description = _("List vector maps in input mapset and exit");
flag.transformz = G_define_flag();
flag.transformz->key = 'z';
flag.transformz->description = _("3D vector maps only");
flag.transformz->label =
_("Assume z coordinate is ellipsoidal height and "
"transform if possible");
flag.transformz->guisection = _("Target");
flag.wrap = G_define_flag();
flag.wrap->key = 'w';
flag.wrap->description = _("Latlon output only, default is -180,180");
flag.wrap->label =
_("Disable wrapping to -180,180 for latlon output");
flag.transformz->guisection = _("Target");
flag.no_topol = G_define_flag();
flag.no_topol->key = 'b';
flag.no_topol->label = _("Do not build vector topology");
flag.no_topol->description = _("Recommended for massive point projection");
/* The parser checks if the map already exists in current mapset,
//.........这里部分代码省略.........
示例7: main
int main(int argc, char *argv[])
{
struct Map_info In, Out;
static struct line_pnts *Points;
struct line_cats *Cats;
struct GModule *module; /* GRASS module for parsing arguments */
struct Option *map_in, *map_out;
struct Option *cat_opt, *field_opt, *where_opt, *abcol, *afcol;
struct Option *iter_opt, *error_opt;
struct Flag *geo_f, *add_f;
int chcat, with_z;
int layer, mask_type;
struct varray *varray;
dglGraph_s *graph;
int i, geo, nnodes, nlines, j, max_cat;
char buf[2000], *covered;
/* initialize GIS environment */
G_gisinit(argv[0]); /* reads grass env, stores program name to G_program_name() */
/* initialize module */
module = G_define_module();
module->keywords = _("vector, network, centrality measures");
module->description =
_("Computes degree, centrality, betweeness, closeness and eigenvector "
"centrality measures in the network.");
/* Define the different options as defined in gis.h */
map_in = G_define_standard_option(G_OPT_V_INPUT);
field_opt = G_define_standard_option(G_OPT_V_FIELD);
map_out = G_define_standard_option(G_OPT_V_OUTPUT);
cat_opt = G_define_standard_option(G_OPT_V_CATS);
cat_opt->guisection = _("Selection");
where_opt = G_define_standard_option(G_OPT_WHERE);
where_opt->guisection = _("Selection");
afcol = G_define_standard_option(G_OPT_COLUMN);
afcol->key = "afcolumn";
afcol->required = NO;
afcol->description =
_("Name of arc forward/both direction(s) cost column");
afcol->guisection = _("Cost");
abcol = G_define_standard_option(G_OPT_COLUMN);
abcol->key = "abcolumn";
abcol->required = NO;
abcol->description = _("Name of arc backward direction cost column");
abcol->guisection = _("Cost");
deg_opt = G_define_standard_option(G_OPT_COLUMN);
deg_opt->key = "degree";
deg_opt->required = NO;
deg_opt->description = _("Name of degree centrality column");
deg_opt->guisection = _("Columns");
close_opt = G_define_standard_option(G_OPT_COLUMN);
close_opt->key = "closeness";
close_opt->required = NO;
close_opt->description = _("Name of closeness centrality column");
close_opt->guisection = _("Columns");
betw_opt = G_define_standard_option(G_OPT_COLUMN);
betw_opt->key = "betweenness";
betw_opt->required = NO;
betw_opt->description = _("Name of betweenness centrality column");
betw_opt->guisection = _("Columns");
eigen_opt = G_define_standard_option(G_OPT_COLUMN);
eigen_opt->key = "eigenvector";
eigen_opt->required = NO;
eigen_opt->description = _("Name of eigenvector centrality column");
eigen_opt->guisection = _("Columns");
iter_opt = G_define_option();
iter_opt->key = "iterations";
iter_opt->answer = "1000";
iter_opt->type = TYPE_INTEGER;
iter_opt->required = NO;
iter_opt->description =
_("Maximum number of iterations to compute eigenvector centrality");
error_opt = G_define_option();
error_opt->key = "error";
error_opt->answer = "0.1";
error_opt->type = TYPE_DOUBLE;
error_opt->required = NO;
error_opt->description =
_("Cummulative error tolerance for eigenvector centrality");
geo_f = G_define_flag();
geo_f->key = 'g';
geo_f->description =
_("Use geodesic calculation for longitude-latitude locations");
add_f = G_define_flag();
add_f->key = 'a';
add_f->description = _("Add points on nodes");
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
opt6 = G_define_option();
opt6->key = "unknown_color";
opt6->type = TYPE_STRING;
opt6->required = NO;
opt6->answer = "red";
opt6->gisprompt = "old_color,color,color_none";
opt6->description = _("Color for showing unknown information");
opt6->guisection = _("Colors");
opt9 = G_define_option();
opt9->key = "skip";
opt9->type = TYPE_INTEGER;
opt9->required = NO;
opt9->answer = "1";
opt9->description = _("Draw arrow every Nth grid cell");
opt7 = G_define_option();
opt7->key = "magnitude_map";
opt7->type = TYPE_STRING;
opt7->required = NO;
opt7->multiple = NO;
opt7->gisprompt = "old,cell,raster";
opt7->description =
_("Raster map containing values used for arrow length");
opt8 = G_define_option();
opt8->key = "scale";
opt8->type = TYPE_DOUBLE;
opt8->required = NO;
opt8->answer = "1.0";
opt8->description = _("Scale factor for arrows (magnitude map)");
align = G_define_flag();
align->key = 'a';
align->description = _("Align grids with raster cells");
/* Check command line */
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
layer_name = opt1->answer;
arrow_color = D_translate_color(opt3->answer);
x_color = D_translate_color(opt5->answer);
unknown_color = D_translate_color(opt6->answer);
if (strcmp("none", opt4->answer) == 0)
grid_color = -1;
else
grid_color = D_translate_color(opt4->answer);
if (strcmp("grass", opt2->answer) == 0)
map_type = 1;
else if (strcmp("agnps", opt2->answer) == 0)
map_type = 2;
else if (strcmp("answers", opt2->answer) == 0)
map_type = 3;
else if (strcmp("compass", opt2->answer) == 0)
map_type = 4;
scale = atof(opt8->answer);
示例9: set_params
/* ************************************************************************* */
void set_params()
{
param.input = G_define_standard_option(G_OPT_R3_INPUTS);
param.input->required = NO;
param.input->description =
_("3D raster map(s) to be converted to VTK-ASCII data format");
param.output = G_define_standard_option(G_OPT_F_OUTPUT);
param.output->required = NO;
param.output->description = _("Name for VTK-ASCII output file");
param.null_val = G_define_option();
param.null_val->key = "null";
param.null_val->type = TYPE_DOUBLE;
param.null_val->required = NO;
param.null_val->description =
_("Float value to represent no data cell/points");
param.null_val->answer = "-99999.99";
param.point = G_define_flag();
param.point->key = 'p';
param.point->description =
_("Create VTK pointdata instead of VTK celldata (celldata is default)");
param.top = G_define_option();
param.top->key = "top";
param.top->type = TYPE_STRING;
param.top->required = NO;
param.top->gisprompt = "old,cell,raster";
param.top->multiple = NO;
param.top->guisection = "Surface options";
param.top->description = _("Top surface 2D raster map");
param.bottom = G_define_option();
param.bottom->key = "bottom";
param.bottom->type = TYPE_STRING;
param.bottom->required = NO;
param.bottom->gisprompt = "old,cell,raster";
param.bottom->multiple = NO;
param.bottom->guisection = "Surface options";
param.bottom->description = _("Bottom surface 2D raster map");
param.structgrid = G_define_flag();
param.structgrid->key = 's';
param.structgrid->guisection = "Surface options";
param.structgrid->description =
_("Create 3D elevation output with a top and a bottom surface, both raster maps are required.");
param.rgbmaps = G_define_option();
param.rgbmaps->key = "rgbmaps";
param.rgbmaps->type = TYPE_STRING;
param.rgbmaps->required = NO;
param.rgbmaps->gisprompt = "old,grid3,3d-raster";
param.rgbmaps->multiple = YES;
param.rgbmaps->guisection = "Advanced options";
param.rgbmaps->description =
_("Three (R,G,B) 3D raster maps to create RGB values [redmap,greenmap,bluemap]");
param.vectormaps = G_define_option();
param.vectormaps->key = "vectormaps";
param.vectormaps->type = TYPE_STRING;
param.vectormaps->required = NO;
param.vectormaps->gisprompt = "old,grid3,3d-raster";
param.vectormaps->multiple = YES;
param.vectormaps->guisection = "Advanced options";
param.vectormaps->description =
_("Three (x,y,z) 3D raster maps to create vector values [xmap,ymap,zmap]");
param.elevscale = G_define_option();
param.elevscale->key = "elevscale";
param.elevscale->type = TYPE_DOUBLE;
param.elevscale->required = NO;
param.elevscale->description = _("Scale factor for elevation");
param.elevscale->guisection = "Advanced options";
param.elevscale->answer = "1.0";
param.decimals = G_define_option();
param.decimals->key = "dp";
param.decimals->type = TYPE_INTEGER;
param.decimals->required = NO;
param.decimals->multiple = NO;
param.decimals->answer = "12";
param.decimals->options = "0-20";
param.decimals->guisection = "Advanced options";
param.decimals->description =
_("Number of significant digits (floating point only)");
param.mask = G_define_flag();
param.mask->key = 'm';
param.mask->guisection = "Advanced options";
param.mask->description = _("Use 3D raster mask (if exists) with input maps");
param.origin = G_define_flag();
param.origin->key = 'o';
param.origin->guisection = "Advanced options";
param.origin->description = _("Scale factor affects the origin");
param.coorcorr = G_define_flag();
//.........这里部分代码省略.........
示例10: main
int main(int argc, char *argv[])
{
struct GModule *module;
struct Option *start_opt, *select_opt, *stop_opt, *output_opt,
*width_opt, *height_opt, *bgcolor_opt, *res_opt;
struct Flag *list_flag, *selected_flag, *select_flag, *release_flag,
*cmd_flag, *truecolor_flag, *update_flag, *x_flag, *sfile_flag;
int nopts, ret;
const char *mon;
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("display"));
G_add_keyword(_("graphics"));
G_add_keyword(_("monitors"));
module->description = _("Controls graphics display monitors from the command line.");
start_opt = G_define_option();
start_opt->key = "start";
start_opt->type = TYPE_STRING;
start_opt->description = _("Name of monitor to start");
start_opt->options = "wx0,wx1,wx2,wx3,wx4,wx5,wx6,wx7,png,ps,html,cairo";
start_opt->guisection = _("Manage");
stop_opt = G_define_option();
stop_opt->key = "stop";
stop_opt->type = TYPE_STRING;
stop_opt->description = _("Name of monitor to stop");
stop_opt->options = "wx0,wx1,wx2,wx3,wx4,wx5,wx6,wx7,png,ps,html,cairo";
stop_opt->guisection = _("Manage");
select_opt = G_define_option();
select_opt->key = "select";
select_opt->type = TYPE_STRING;
select_opt->description = _("Name of monitor to select");
select_opt->options = "wx0,wx1,wx2,wx3,wx4,wx5,wx6,wx7,png,ps,html,cairo";
select_opt->guisection = _("Manage");
width_opt = G_define_option();
width_opt->key = "width";
width_opt->label = _("Width for display monitor if not set by GRASS_RENDER_WIDTH");
width_opt->description = _("Default value: 720");
width_opt->type = TYPE_INTEGER;
width_opt->key_desc = "value";
width_opt->guisection = _("Settings");
height_opt = G_define_option();
height_opt->key = "height";
height_opt->label = _("Height for display monitor if not set by GRASS_RENDER_HEIGHT");
height_opt->description = _("Default value: 480");
height_opt->type = TYPE_INTEGER;
height_opt->key_desc = "value";
height_opt->guisection = _("Settings");
res_opt = G_define_option();
res_opt->key = "resolution";
res_opt->label = _("Dimensions of display monitor versus current size");
res_opt->description = _("Example: resolution=2 enlarge display monitor twice to 1280x960");
res_opt->type = TYPE_INTEGER;
res_opt->key_desc = "value";
res_opt->guisection = _("Settings");
bgcolor_opt = G_define_standard_option(G_OPT_CN);
bgcolor_opt->key = "bgcolor";
bgcolor_opt->label = _("Background color");
bgcolor_opt->answer = DEFAULT_BG_COLOR;
bgcolor_opt->guisection = _("Settings");
output_opt = G_define_standard_option(G_OPT_F_OUTPUT);
output_opt->required = NO;
output_opt->label = _("Name for output file (when starting new monitor)");
output_opt->description = _("Ignored for 'wx' monitors");
output_opt->guisection = _("Settings");
list_flag = G_define_flag();
list_flag->key = 'l';
list_flag->description = _("List running monitors and exit");
list_flag->guisection = _("Print");
selected_flag = G_define_flag();
selected_flag->key = 'p';
selected_flag->description = _("Print name of currently selected monitor and exit");
selected_flag->guisection = _("Print");
cmd_flag = G_define_flag();
cmd_flag->key = 'c';
cmd_flag->description = _("Print commands for currently selected monitor and exit");
cmd_flag->guisection = _("Print");
sfile_flag = G_define_flag();
sfile_flag->key = 'g';
sfile_flag->description =
_("Print path to support files of currently selected monitor and exit");
select_flag = G_define_flag();
select_flag->key = 's';
select_flag->description = _("Do not automatically select when starting");
select_flag->guisection = _("Manage");
//.........这里部分代码省略.........
示例11: main
int main(int argc, char *argv[])
{
const char *input, *source, *output;
char *title;
struct Cell_head cellhd;
GDALDatasetH hDS;
GDALRasterBandH hBand;
struct GModule *module;
struct {
struct Option *input, *source, *output, *band, *title;
} parm;
struct {
struct Flag *o, *f, *e, *r, *h, *v;
} flag;
int min_band, max_band, band;
struct band_info info;
int flip;
struct Ref reference;
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("raster"));
G_add_keyword(_("import"));
G_add_keyword(_("input"));
G_add_keyword(_("external"));
module->description =
_("Links GDAL supported raster data as a pseudo GRASS raster map.");
parm.input = G_define_standard_option(G_OPT_F_INPUT);
parm.input->description = _("Name of raster file to be linked");
parm.input->required = NO;
parm.input->guisection = _("Input");
parm.source = G_define_option();
parm.source->key = "source";
parm.source->description = _("Name of non-file GDAL data source");
parm.source->required = NO;
parm.source->type = TYPE_STRING;
parm.source->key_desc = "name";
parm.source->guisection = _("Input");
parm.output = G_define_standard_option(G_OPT_R_OUTPUT);
parm.band = G_define_option();
parm.band->key = "band";
parm.band->type = TYPE_INTEGER;
parm.band->required = NO;
parm.band->description = _("Band to select (default: all)");
parm.band->guisection = _("Input");
parm.title = G_define_option();
parm.title->key = "title";
parm.title->key_desc = "phrase";
parm.title->type = TYPE_STRING;
parm.title->required = NO;
parm.title->description = _("Title for resultant raster map");
parm.title->guisection = _("Metadata");
flag.f = G_define_flag();
flag.f->key = 'f';
flag.f->description = _("List supported formats and exit");
flag.f->guisection = _("Print");
flag.f->suppress_required = YES;
flag.o = G_define_flag();
flag.o->key = 'o';
flag.o->description =
_("Override projection (use location's projection)");
flag.e = G_define_flag();
flag.e->key = 'e';
flag.e->description = _("Extend location extents based on new dataset");
flag.r = G_define_flag();
flag.r->key = 'r';
flag.r->description = _("Require exact range");
flag.h = G_define_flag();
flag.h->key = 'h';
flag.h->description = _("Flip horizontally");
flag.v = G_define_flag();
flag.v->key = 'v';
flag.v->description = _("Flip vertically");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
GDALAllRegister();
if (flag.f->answer) {
list_formats();
exit(EXIT_SUCCESS);
}
input = parm.input->answer;
source = parm.source->answer;
output = parm.output->answer;
//.........这里部分代码省略.........
示例12: main
int main(int argc, char **argv)
{
struct Flag *printattributes, *topo_flag, *shell_flag;
struct Option *map_opt, *field_opt, *coords_opt, *maxdistance;
struct Cell_head window;
struct GModule *module;
char buf[2000];
int i, level, ret;
int *field;
double xval, yval, xres, yres, maxd, x;
double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
char nsres[30], ewres[30];
char ch;
/* Initialize the GIS calls */
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("vector"));
G_add_keyword(_("position"));
G_add_keyword(_("querying"));
module->description = _("Queries a vector map at given locations.");
map_opt = G_define_standard_option(G_OPT_V_MAPS);
field_opt = G_define_standard_option(G_OPT_V_FIELD_ALL);
coords_opt = G_define_standard_option(G_OPT_M_EN);
coords_opt->label = _("Coordinates for query");
coords_opt->description = _("If not given read from standard input");
maxdistance = G_define_option();
maxdistance->type = TYPE_DOUBLE;
maxdistance->key = "distance";
maxdistance->answer = "0";
maxdistance->multiple = NO;
maxdistance->description = _("Query threshold distance");
topo_flag = G_define_flag();
topo_flag->key = 'd';
topo_flag->description = _("Print topological information (debugging)");
topo_flag->guisection = _("Print");
printattributes = G_define_flag();
printattributes->key = 'a';
printattributes->description = _("Print attribute information");
printattributes->guisection = _("Print");
shell_flag = G_define_flag();
shell_flag->key = 'g';
shell_flag->description = _("Print the stats in shell script style");
shell_flag->guisection = _("Print");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
if (map_opt->answers && map_opt->answers[0])
vect = map_opt->answers;
maxd = atof(maxdistance->answer);
/*
* fprintf(stdout, maxdistance->answer);
* fprintf(stdout, "Maxd is %f", maxd);
* fprintf(stdout, xcoord->answer);
* fprintf(stdout, "xval is %f", xval);
* fprintf(stdout, ycoord->answer);
* fprintf(stdout, "yval is %f", yval);
*/
if (maxd == 0.0) {
G_get_window(&window);
x = window.proj;
G_format_resolution(window.ew_res, ewres, x);
G_format_resolution(window.ns_res, nsres, x);
EW_DIST1 =
G_distance(window.east, window.north, window.west, window.north);
/* EW Dist at South Edge */
EW_DIST2 =
G_distance(window.east, window.south, window.west, window.south);
/* NS Dist at East edge */
NS_DIST1 =
G_distance(window.east, window.north, window.east, window.south);
/* NS Dist at West edge */
NS_DIST2 =
G_distance(window.west, window.north, window.west, window.south);
xres = ((EW_DIST1 + EW_DIST2) / 2) / window.cols;
yres = ((NS_DIST1 + NS_DIST2) / 2) / window.rows;
if (xres > yres)
maxd = xres;
else
maxd = yres;
}
/* Look at maps given on command line */
if (vect) {
for (i = 0; vect[i]; i++)
;
nvects = i;
//.........这里部分代码省略.........
示例13: main
int main(int argc, char **argv)
{
static DCELL *count, *sum, *mean, *sumu, *sum2, *sum3, *sum4, *min, *max;
DCELL *result;
struct GModule *module;
struct {
struct Option *method, *basemap, *covermap, *output;
} opt;
struct {
struct Flag *c, *r;
} flag;
char methods[2048];
const char *basemap, *covermap, *output;
int usecats;
int reclass;
int base_fd, cover_fd;
struct Categories cats;
CELL *base_buf;
DCELL *cover_buf;
struct Range range;
CELL mincat, ncats;
int method;
int rows, cols;
int row, col, i;
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("raster"));
G_add_keyword(_("statistics"));
module->description =
_("Calculates category or object oriented statistics (accumulator-based statistics).");
opt.basemap = G_define_standard_option(G_OPT_R_BASE);
opt.covermap = G_define_standard_option(G_OPT_R_COVER);
opt.method = G_define_option();
opt.method->key = "method";
opt.method->type = TYPE_STRING;
opt.method->required = YES;
opt.method->description = _("Method of object-based statistic");
for (i = 0; menu[i].name; i++) {
if (i)
strcat(methods, ",");
else
*(methods) = 0;
strcat(methods, menu[i].name);
}
opt.method->options = G_store(methods);
for (i = 0; menu[i].name; i++) {
if (i)
strcat(methods, ";");
else
*(methods) = 0;
strcat(methods, menu[i].name);
strcat(methods, ";");
strcat(methods, menu[i].text);
}
opt.method->descriptions = G_store(methods);
opt.output = G_define_standard_option(G_OPT_R_OUTPUT);
opt.output->description = _("Resultant raster map");
opt.output->required = YES;
flag.c = G_define_flag();
flag.c->key = 'c';
flag.c->description =
_("Cover values extracted from the category labels of the cover map");
flag.r = G_define_flag();
flag.r->key = 'r';
flag.r->description =
_("Create reclass map with statistics as category labels");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
basemap = opt.basemap->answer;
covermap = opt.covermap->answer;
output = opt.output->answer;
usecats = flag.c->answer;
reclass = flag.r->answer;
for (i = 0; menu[i].name; i++)
if (strcmp(menu[i].name, opt.method->answer) == 0)
break;
if (!menu[i].name) {
G_warning(_("<%s=%s> unknown %s"), opt.method->key, opt.method->answer,
opt.method->key);
G_usage();
exit(EXIT_FAILURE);
}
method = menu[i].val;
base_fd = Rast_open_old(basemap, "");
//.........这里部分代码省略.........
示例14: main
int main(int argc, char **argv)
{
struct GModule *module;
struct Option *bg_color_opt, *fg_color_opt, *coords, *n_arrow, *fsize,
*width_opt, *rotation_opt, *lbl_opt;
struct Flag *no_text, *rotate_text, *rads;
double east, north;
double rotation;
double fontsize, line_width;
int rot_with_text;
/* Initialize the GIS calls */
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("display"));
G_add_keyword(_("cartography"));
module->description =
_("Displays a north arrow on the graphics monitor.");
n_arrow = G_define_option();
n_arrow->key = "style";
n_arrow->description = _("North arrow style");
n_arrow->options =
"1a,1b,2,3,4,5,6,7a,7b,8a,8b,9,fancy_compass,basic_compass,arrow1,arrow2,arrow3,star";
G_asprintf((char **)&(n_arrow->descriptions),
"1a;%s;" "1b;%s;" "2;%s;" "3;%s;" "4;%s;" "5;%s;" "6;%s;"
"7a;%s;" "7b;%s;" "8a;%s;" "8b;%s;" "9;%s;" "fancy_compass;%s;"
"basic_compass;%s;" "arrow1;%s;" "arrow2;%s;" "arrow3;%s;"
"star;%s;",
_("Two color arrowhead"),
_("Two color arrowhead with circle"),
_("Narrow with blending N"), _("Long with small arrowhead"),
_("Inverted narrow inside a circle"),
_("Triangle and N inside a circle"),
_("Arrowhead and N inside a circle"),
_("Tall half convex arrowhead"),
_("Tall half concave arrowhead"), _("Thin arrow in a circle"),
_("Fat arrow in a circle"), _("One color arrowhead"),
_("Fancy compass"), _("Basic compass"), _("Simple arrow"),
_("Thin arrow"), _("Fat arrow"), _("4-point star"));
n_arrow->answer = "1a";
n_arrow->guisection = _("Style");
n_arrow->gisprompt = "old,northarrow,northarrow";
coords = G_define_option();
coords->key = "at";
coords->key_desc = "x,y";
coords->type = TYPE_DOUBLE;
coords->answer = "85.0,15.0";
coords->options = "0-100";
coords->label =
_("Screen coordinates of the rectangle's top-left corner");
coords->description = _("(0,0) is lower-left of the display frame");
rotation_opt = G_define_option();
rotation_opt->key = "rotation";
rotation_opt->type = TYPE_DOUBLE;
rotation_opt->required = NO;
rotation_opt->answer = "0";
rotation_opt->description =
_("Rotation angle in degrees (counter-clockwise)");
lbl_opt = G_define_option();
lbl_opt->key = "label";
lbl_opt->required = NO;
lbl_opt->answer = "N";
lbl_opt->description =
_("Displayed letter on the top of arrow");
lbl_opt->guisection = _("Text");
fg_color_opt = G_define_standard_option(G_OPT_C);
fg_color_opt->label = _("Line color");
fg_color_opt->guisection = _("Colors");
bg_color_opt = G_define_standard_option(G_OPT_CN);
bg_color_opt->key = "fill_color";
bg_color_opt->label = _("Fill color");
bg_color_opt->answer = _("black");
bg_color_opt->guisection = _("Colors");
width_opt = G_define_option();
width_opt->key = "width";
width_opt->type = TYPE_DOUBLE;
width_opt->answer = "0";
width_opt->description = _("Line width");
fsize = G_define_option();
fsize->key = "fontsize";
fsize->type = TYPE_DOUBLE;
fsize->required = NO;
fsize->answer = "14";
fsize->options = "1-360";
fsize->description = _("Font size");
fsize->guisection = _("Text");
no_text = G_define_flag();
no_text->key = 't';
no_text->description = _("Draw the symbol without text");
no_text->guisection = _("Text");
//.........这里部分代码省略.........
示例15: main
int main(int argc, char *argv[])
{
struct Option *type, *rc_file;
struct Flag *update, *nolaunch;
struct GModule *module;
const char *gui_type_env;
char progname[GPATH_MAX];
char *desc;
G_gisinit(argv[0]);
module = G_define_module();
G_add_keyword(_("general"));
G_add_keyword(_("gui"));
G_add_keyword(_("user interface"));
module->label =
_("Launches a GRASS graphical user interface (GUI) session.");
module->description = _("And updates default user interface settings.");
type = G_define_option();
type->key = "ui";
type->type = TYPE_STRING;
type->label = _("User interface");
type->description = _("Default value: GRASS_GUI if defined otherwise wxpython");
desc = NULL;
G_asprintf(&desc,
"wxpython;%s;text;%s",
_("wxPython based GUI (wxGUI)"),
_("command line interface only"));
type->descriptions = desc;
type->options = "wxpython,text";
type->guisection = _("Type");
rc_file = G_define_standard_option(G_OPT_F_INPUT);
rc_file->key = "workspace";
rc_file->required = NO;
rc_file->key_desc = "name.gxw";
rc_file->description = _("Name of workspace file to load on start-up (valid only for wxGUI)");
update = G_define_flag();
update->key = 'd';
update->description = _("Update default user interface settings");
update->guisection = _("Default");
nolaunch = G_define_flag();
nolaunch->key = 'n';
nolaunch->description =
_("Do not launch GUI after updating the default user interface settings");
nolaunch->guisection = _("Default");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
if (type->answer && strcmp(type->answer, "text") == 0 &&
!nolaunch->answer)
nolaunch->answer = TRUE;
if (nolaunch->answer && !update->answer)
update->answer = TRUE;
gui_type_env = G__getenv("GUI");
if (!type->answer) {
if (gui_type_env && strcmp(gui_type_env, "text")) {
type->answer = G_store(gui_type_env);
}
else {
type->answer = "wxpython";
}
}
if (((gui_type_env && update->answer) &&
strcmp(gui_type_env, type->answer) != 0) || !gui_type_env) {
G_setenv("GUI", type->answer);
G_message(_("<%s> is now the default GUI"), type->answer);
}
else {
if(update->answer)
if(gui_type_env) {
G_debug(1, "No change: old gui_type_env=[%s], new type->ans=[%s]",
gui_type_env, type->answer);
}
}
if(nolaunch->answer)
exit(EXIT_SUCCESS);
G_message(_("Launching <%s> GUI in the background, please wait..."), type->answer);
if (strcmp(type->answer, "wxpython") == 0) {
sprintf(progname, "%s/gui/wxpython/wxgui.py", G_gisbase());
if (rc_file->answer) {
G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
"--workspace", rc_file->answer, SF_BACKGROUND, NULL);
}
else {
G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
SF_BACKGROUND, NULL);
//.........这里部分代码省略.........