您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ G_fatal_error函数代码示例

51自学网 2021-06-01 21:02:33
  C++
这篇教程C++ G_fatal_error函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中G_fatal_error函数的典型用法代码示例。如果您正苦于以下问题:C++ G_fatal_error函数的具体用法?C++ G_fatal_error怎么用?C++ G_fatal_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了G_fatal_error函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

//.........这里部分代码省略.........    method_opt = G_define_option();    method_opt->key = "method";    method_opt->type = TYPE_STRING;    method_opt->required = YES;    method_opt->multiple = NO;    method_opt->options = "weak,strong";    desc = NULL;    G_asprintf(&desc,	       "weak;%s;strong;%s",	       _("Weakly connected components"),	       _("Strongly connected components"));    method_opt->descriptions = desc;    method_opt->description = _("Type of components");    add_f = G_define_flag();    add_f->key = 'a';    add_f->description = _("Add points on nodes");    /* options and flags parser */    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    /* TODO: make an option for this */    mask_type = GV_LINE | GV_BOUNDARY;    Points = Vect_new_line_struct();    Cats = Vect_new_cats_struct();    Vect_check_input_output_name(map_in->answer, map_out->answer,				 G_FATAL_EXIT);    Vect_set_open_level(2);    if (1 > Vect_open_old(&In, map_in->answer, ""))	G_fatal_error(_("Unable to open vector map <%s>"), map_in->answer);    with_z = Vect_is_3d(&In);    if (0 > Vect_open_new(&Out, map_out->answer, with_z)) {	Vect_close(&In);	G_fatal_error(_("Unable to create vector map <%s>"), map_out->answer);    }    /* parse filter option and select appropriate lines */    afield = Vect_get_field_number(&In, afield_opt->answer);    nfield = Vect_get_field_number(&In, nfield_opt->answer);    if (0 != Vect_net_build_graph(&In, mask_type, afield, nfield, afcol->answer,                                  abcol->answer, ncol->answer, 0, 2))        G_fatal_error(_("Unable to build graph for vector map <%s>"), Vect_get_full_name(&In));    graph = Vect_net_get_graph(&In);    nnodes = Vect_get_num_nodes(&In);    component = (int *)G_calloc(nnodes + 1, sizeof(int));    covered = (char *)G_calloc(nnodes + 1, sizeof(char));    if (!component || !covered) {	G_fatal_error(_("Out of memory"));	exit(EXIT_FAILURE);    }    /* Create table */    Fi = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE);    Vect_map_add_dblink(&Out, 1, NULL, Fi->table, GV_KEY_COLUMN, Fi->database,			Fi->driver);    db_init_string(&sql);    driver = db_start_driver_open_database(Fi->driver, Fi->database);    if (driver == NULL)	G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
开发者ID:rkrug,项目名称:grass-ci,代码行数:67,


示例2: main

int main(int argc, char *argv[]){    int out_fd;    CELL *result, *rp;    int nrows, ncols;    int row, col;    struct GModule *module;    struct Option *in_opt, *out_opt;    struct Option *method_opt, *size_opt;    char *mapset;    struct Map_info In;    double radius;    struct ilist *List;    struct Cell_head region;    BOUND_BOX box;    struct line_pnts *Points;    struct line_cats *Cats;    G_gisinit(argv[0]);    module = G_define_module();    module->keywords = _("vector, raster, aggregation");    module->description = "Makes each cell value a "	"function of the attribute values assigned to the vector points or centroids "	"around it, and stores new cell values in an output raster map layer.";    in_opt = G_define_standard_option(G_OPT_V_INPUT);    out_opt = G_define_standard_option(G_OPT_R_OUTPUT);    method_opt = G_define_option();    method_opt->key = "method";    method_opt->type = TYPE_STRING;    method_opt->required = YES;    method_opt->options = "count";    method_opt->answer = "count";    method_opt->description = "Neighborhood operation";    size_opt = G_define_option();    size_opt->key = "size";    size_opt->type = TYPE_DOUBLE;    size_opt->required = YES;    size_opt->description = "Neighborhood diameter in map units";    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    radius = atof(size_opt->answer) / 2;    /* open input vector */    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {	G_fatal_error(_("Vector map <%s> not found in the current mapset"),		      in_opt->answer);    }    Vect_set_open_level(2);    Vect_open_old(&In, in_opt->answer, mapset);    G_get_set_window(&region);    nrows = G_window_rows();    ncols = G_window_cols();    result = G_allocate_raster_buf(CELL_TYPE);    Points = Vect_new_line_struct();    Cats = Vect_new_cats_struct();    List = Vect_new_list();    /*open the new cellfile */    out_fd = G_open_raster_new(out_opt->answer, CELL_TYPE);    if (out_fd < 0)	G_fatal_error(_("Unable to create raster map <%s>"), out_opt->answer);    box.T = PORT_DOUBLE_MAX;    box.B = -PORT_DOUBLE_MAX;    for (row = 0; row < nrows; row++) {	double x, y;	G_percent(row, nrows, 1);	y = G_row_to_northing(row + 0.5, &region);	box.N = y + radius;	box.S = y - radius;	G_set_null_value(result, ncols, CELL_TYPE);	rp = result;	for (col = 0; col < ncols; col++) {	    int i, count;	    CELL value;	    x = G_col_to_easting(col + 0.5, &region);	    box.E = x + radius;	    box.W = x - radius;	    Vect_select_lines_by_box(&In, &box, GV_POINTS, List);	    G_debug(3, "  %d lines in box", List->n_values);	    count = 0;//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-grass,代码行数:101,


示例3: format_l

static off_t format_l(){    G_fatal_error(_("Requested format is not compiled in this version"));    return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:5,


示例4: main

int main(int argc, char **argv){    struct GModule *module;    struct Option *map_opt, *field_opt, *fs_opt, *vs_opt, *nv_opt, *col_opt,	*where_opt, *file_opt;    struct Flag *c_flag, *v_flag, *r_flag;    dbDriver *driver;    dbString sql, value_string;    dbCursor cursor;    dbTable *table;    dbColumn *column;    dbValue *value;    struct field_info *Fi;    int ncols, col, more;    struct Map_info Map;    char query[1024];    struct ilist *list_lines;    struct bound_box *min_box, *line_box;    int i, line, area, init_box, cat;    module = G_define_module();    G_add_keyword(_("vector"));    G_add_keyword(_("database"));    G_add_keyword(_("attribute table"));    module->description = _("Prints vector map attributes.");    map_opt = G_define_standard_option(G_OPT_V_MAP);    field_opt = G_define_standard_option(G_OPT_V_FIELD);    col_opt = G_define_standard_option(G_OPT_DB_COLUMNS);    where_opt = G_define_standard_option(G_OPT_DB_WHERE);    fs_opt = G_define_standard_option(G_OPT_F_SEP);    fs_opt->description = _("Output field separator");    fs_opt->guisection = _("Format");    vs_opt = G_define_standard_option(G_OPT_F_SEP);    vs_opt->key = "vs";    vs_opt->description = _("Output vertical record separator");    vs_opt->answer = NULL;    vs_opt->guisection = _("Format");    nv_opt = G_define_option();    nv_opt->key = "nv";    nv_opt->type = TYPE_STRING;    nv_opt->required = NO;    nv_opt->description = _("Null value indicator");    nv_opt->guisection = _("Format");    file_opt = G_define_standard_option(G_OPT_F_OUTPUT);     file_opt->key = "file";    file_opt->required = NO;     file_opt->description = 	_("Name for output file (if omitted or /"-/" output to stdout)");         r_flag = G_define_flag();    r_flag->key = 'r';    r_flag->description =	_("Print minimal region extent of selected vector features instead of attributes");    c_flag = G_define_flag();    c_flag->key = 'c';    c_flag->description = _("Do not include column names in output");    c_flag->guisection = _("Format");    v_flag = G_define_flag();    v_flag->key = 'v';    v_flag->description = _("Vertical output (instead of horizontal)");    v_flag->guisection = _("Format");    G_gisinit(argv[0]);    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    /* set input vector map name and mapset */    if (file_opt->answer && strcmp(file_opt->answer, "-") != 0) { 	if (NULL == freopen(file_opt->answer, "w", stdout)) { 	    G_fatal_error(_("Unable to open file <%s> for writing"), file_opt->answer); 	}     }         if (r_flag->answer) {	min_box = (struct bound_box *) G_malloc(sizeof(struct bound_box));	G_zero((void *)min_box, sizeof(struct bound_box));	line_box = (struct bound_box *) G_malloc(sizeof(struct bound_box));	list_lines = Vect_new_list();    }    else {      min_box = line_box = NULL;      list_lines = NULL;    }    db_init_string(&sql);    db_init_string(&value_string);    /* open input vector *///.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例5: cell_draw

static int cell_draw( char *name,                      char *mapset,                      struct Colors *colors,                      RASTER_MAP_TYPE data_type,                      char *format ){  int cellfile;  void *xarray;  int row;  int ncols, nrows;  static unsigned char *red, *grn, *blu, *set;  int i;  void *ptr;  int big_endian;  long one = 1;  FILE *fo;  int raster_size;  big_endian = !( *(( char * )( &one ) ) );  ncols = G_window_cols();  nrows = G_window_rows();  /* Make sure map is available */  if (( cellfile = G_open_cell_old( name, mapset ) ) == -1 )    G_fatal_error(( "Unable to open raster map <%s>" ), name );  /* Allocate space for cell buffer */  xarray = G_allocate_raster_buf( data_type );  red = G_malloc( ncols );  grn = G_malloc( ncols );  blu = G_malloc( ncols );  set = G_malloc( ncols );  /* some buggy C libraries require BOTH setmode() and fdopen(bin) */#ifdef WIN32  if ( _setmode( _fileno( stdout ), _O_BINARY ) == -1 )    G_fatal_error( "Cannot set stdout mode" );#endif  // Unfortunately this is not sufficient on Windows to switch stdout to binary mode  fo = fdopen( fileno( stdout ), "wb" );  raster_size = G_raster_size( data_type );  //fprintf( fo, "%d %d", data_type, raster_size );  //exit(0);  /* loop for array rows */  for ( row = 0; row < nrows; row++ )  {    G_get_raster_row( cellfile, xarray, row, data_type );    ptr = xarray;    G_lookup_raster_colors( xarray, red, grn, blu, set, ncols, colors,                            data_type );    for ( i = 0; i < ncols; i++ )    {      unsigned char alpha = 255;      //G_debug ( 0, "row = %d col = %d", row, i );      if ( G_is_null_value( ptr, data_type ) )      {        alpha = 0;      }      if ( strcmp( format, "color" ) == 0 )      {        // We need data suitable for QImage 32-bpp        // the data are stored in QImage as QRgb which is unsigned int.        // Because it depends on byte order of the platform we have to        // consider byte order (well, middle endian ignored)        if ( big_endian )        {          // I have never tested this          fprintf( fo, "%c%c%c%c", alpha, red[i], grn[i], blu[i] );        }        else        {          fprintf( fo, "%c%c%c%c", blu[i], grn[i], red[i], alpha );        }      }      else      {        if ( data_type == CELL_TYPE )        {          //G_debug ( 0, "valx = %d", *((CELL *) ptr));        }        if ( G_is_null_value( ptr, data_type ) )        {          if ( data_type == CELL_TYPE )          {            int nul = -2147483647;            fwrite( &nul , 4, 1, fo );          }          else if ( data_type == DCELL_TYPE )          {            double nul = 2.2250738585072014e-308;            fwrite( &nul , 8, 1, fo );          }          else if ( data_type == FCELL_TYPE )          {            double nul = 1.17549435e-38F;//.........这里部分代码省略.........
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:101,


示例6: main

//.........这里部分代码省略.........    s = method_opt->answer;    if (strcmp(s, "douglas") == 0)	method = DOUGLAS;    else if (strcmp(s, "lang") == 0)	method = LANG;    else if (strcmp(s, "reduction") == 0)	method = VERTEX_REDUCTION;    else if (strcmp(s, "reumann") == 0)	method = REUMANN;    else if (strcmp(s, "boyle") == 0)	method = BOYLE;    else if (strcmp(s, "distance_weighting") == 0)	method = DISTANCE_WEIGHTING;    else if (strcmp(s, "chaiken") == 0)	method = CHAIKEN;    else if (strcmp(s, "hermite") == 0)	method = HERMITE;    else if (strcmp(s, "snakes") == 0)	method = SNAKES;    else if (strcmp(s, "douglas_reduction") == 0)	method = DOUGLAS_REDUCTION;    else if (strcmp(s, "sliding_averaging") == 0)	method = SLIDING_AVERAGING;    else if (strcmp(s, "network") == 0)	method = NETWORK;    else if (strcmp(s, "displacement") == 0) {	method = DISPLACEMENT;	/* we can displace only the lines */	mask_type = GV_LINE;    }    else {	G_fatal_error(_("Unknown method"));	exit(EXIT_FAILURE);    }    /* simplification or smoothing? */    switch (method) {    case DOUGLAS:    case DOUGLAS_REDUCTION:    case LANG:    case VERTEX_REDUCTION:    case REUMANN:	simplification = 1;	break;    default:	simplification = 0;	break;    }    Points = Vect_new_line_struct();    Cats = Vect_new_cats_struct();    Vect_check_input_output_name(map_in->answer, map_out->answer,				 G_FATAL_EXIT);    Vect_set_open_level(2);    if (Vect_open_old2(&In, map_in->answer, "", field_opt->answer) < 1)	G_fatal_error(_("Unable to open vector map <%s>"), map_in->answer);    if (Vect_get_num_primitives(&In, mask_type) == 0) {	G_warning(_("No lines found in input map <%s>"), map_in->answer);
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:67,


示例7: main

int main(int argc, char *argv[]){    struct GModule *module;    int Out_proj;    int out_stat;    int old_zone, old_proj;    int i;    int stat;    char cmnd2[500];    char proj_out[20], proj_name[50], set_name[20];    char path[1024], buffa[1024], buffb[1024], answer[200], answer1[200];    char answer2[200], buff[1024];    char tmp_buff[20], *buf;    struct Key_Value *old_proj_keys, *out_proj_keys, *in_unit_keys;    double aa, e2;    double f;    FILE *FPROJ;    int exist = 0;    char spheroid[100];    int j, k, sph_check;    struct Cell_head cellhd;    char datum[100], dat_ellps[100], dat_params[100];    struct proj_parm *proj_parms;    G_gisinit(argv[0]);    module = G_define_module();    G_add_keyword(_("general"));    G_add_keyword(_("projection"));    module->description =	_("Interactively reset the location's projection settings.");    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    if (strcmp(G_mapset(), "PERMANENT") != 0)	G_fatal_error(_("You must be in the PERMANENT mapset to run g.setproj"));	/***         * no longer necessary, table is a static struct 	 * init_unit_table();        ***/    sprintf(set_name, "PERMANENT");    G_file_name(path, "", PROJECTION_FILE, set_name);    /* get the output projection parameters, if existing */    /* Check for ownership here */    stat = G__mapset_permissions(set_name);    if (stat == 0) {	G_fatal_error(_("PERMANENT: permission denied"));    }    G_get_default_window(&cellhd);    if (-1 == G_set_window(&cellhd))	G_fatal_error(_("Current region cannot be set"));    if (G_get_set_window(&cellhd) == -1)	G_fatal_error(_("Retrieving and setting region failed"));    Out_proj = cellhd.proj;    old_zone = cellhd.zone;    old_proj = cellhd.proj;    if (access(path, 0) == 0) {	exist = 1;	FPROJ = fopen(path, "r");	old_proj_keys = G_fread_key_value(FPROJ);	fclose(FPROJ);	buf = G_find_key_value("name", old_proj_keys);	fprintf(stderr,		"/nWARNING: A projection file already exists for this location/n(Filename '%s')/n",		path);	fprintf(stderr,		"/nThis file contains all the parameters for the location's projection:/n  %s/n",		buf);	fprintf(stderr,		"/n    Overriding this information implies that the old projection parameters/n"		"    were incorrect.  If you change the parameters, all existing data will/n"		"    be interpreted differently by the projection software./n%c%c%c",		7, 7, 7);	fprintf(stderr,		"    GRASS will not re-project your data automatically./n/n");	if (!G_yes	    (_("Would you still like to change some of the parameters?"),	     0)) {	    G_message(_("The projection information will not be updated"));	    leave(SP_NOCHANGE);	}    }    out_proj_keys = G_create_key_value();    if (exist) {	buf = G_find_key_value("zone", old_proj_keys);	if (buf != NULL)	    sscanf(buf, "%d", &zone);	if (zone != old_zone) {	    G_warning(_("Zone in default geographic region definition: %d/n"			" is different from zone in PROJ_INFO file: %d"),//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例8: main

int main( int argc, char **argv ){  struct GModule *module;  struct Option *info_opt, *rast_opt, *vect_opt, *coor_opt, *north_opt, *south_opt, *east_opt, *west_opt, *rows_opt, *cols_opt;  struct Cell_head window;  /* Initialize the GIS calls */  G_gisinit( argv[0] );  module = G_define_module();  module->description = ( "Get info about locations,mapsets,maps" );  info_opt = G_define_option();  info_opt->key = "info";  info_opt->type = TYPE_STRING;  info_opt->description = "info key";  info_opt->options = "proj,window,size,query,info,colors,stats";  rast_opt = G_define_standard_option( G_OPT_R_INPUT );  rast_opt->key = "rast";  rast_opt->required = NO;  vect_opt = G_define_standard_option( G_OPT_V_INPUT );  vect_opt->key = "vect";  vect_opt->required = NO;  coor_opt = G_define_option();  coor_opt->key = "coor";  coor_opt->type = TYPE_DOUBLE;  coor_opt->multiple = YES;  north_opt = G_define_option();  north_opt->key = "north";  north_opt->type = TYPE_STRING;  south_opt = G_define_option();  south_opt->key = "south";  south_opt->type = TYPE_STRING;  east_opt = G_define_option();  east_opt->key = "east";  east_opt->type = TYPE_STRING;  west_opt = G_define_option();  west_opt->key = "west";  west_opt->type = TYPE_STRING;  rows_opt = G_define_option();  rows_opt->key = "rows";  rows_opt->type = TYPE_INTEGER;  cols_opt = G_define_option();  cols_opt->key = "cols";  cols_opt->type = TYPE_INTEGER;  if ( G_parser( argc, argv ) )    exit( EXIT_FAILURE );  if ( strcmp( "proj", info_opt->answer ) == 0 )  {    G_get_window( &window );    /* code from g.proj */    if ( window.proj != PROJECTION_XY )    {      struct Key_Value *projinfo, *projunits;      char *wkt;      projinfo = G_get_projinfo();      projunits = G_get_projunits();      wkt = GPJ_grass_to_wkt( projinfo, projunits, 0, 0 );      fprintf( stdout, "%s", wkt );    }  }  else if ( strcmp( "window", info_opt->answer ) == 0 )  {    if ( rast_opt->answer )    {      G_get_cellhd( rast_opt->answer, "", &window );      fprintf( stdout, "%f,%f,%f,%f", window.west, window.south, window.east, window.north );    }    else if ( vect_opt->answer )    {      G_fatal_error( "Not yet supported" );    }  }  // raster width and height  else if ( strcmp( "size", info_opt->answer ) == 0 )  {    if ( rast_opt->answer )    {      G_get_cellhd( rast_opt->answer, "", &window );      fprintf( stdout, "%d,%d", window.cols, window.rows );    }    else if ( vect_opt->answer )    {      G_fatal_error( "Not yet supported" );    }  }  // raster information  else if ( strcmp( "info", info_opt->answer ) == 0 )//.........这里部分代码省略.........
开发者ID:sourcepole,项目名称:kadas-albireo,代码行数:101,


示例9: main

int main(int argc, char **argv){    struct band B[3];    int row;    int next_row;    int overlay;    struct Cell_head window;    struct GModule *module;    struct Flag *flag_n;    int i;    G_gisinit(argv[0]);    module = G_define_module();    G_add_keyword(_("display"));    G_add_keyword(_("graphics"));    G_add_keyword(_("raster"));    G_add_keyword("RGB");    module->description =	_("Displays three user-specified raster maps "	  "as red, green, and blue overlays in the active graphics frame.");    flag_n = G_define_flag();    flag_n->key = 'n';    flag_n->description = _("Make null cells opaque");    flag_n->guisection = _("Null cells");        for (i = 0; i < 3; i++) {	char buff[80];	sprintf(buff, _("Name of raster map to be used for <%s>"),		color_names[i]);	B[i].opt = G_define_standard_option(G_OPT_R_MAP);	B[i].opt->key = G_store(color_names[i]);	B[i].opt->description = G_store(buff);    }    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    /* Do screen initializing stuff */    D_open_driver();        overlay = !flag_n->answer;    D_setup(0);    D_set_overlay_mode(overlay);    for (i = 0; i < 3; i++) {	/* Get name of layer to be used */	char *name = B[i].opt->answer;	/* Make sure map is available */	B[i].file = Rast_open_old(name, "");	B[i].type = Rast_get_map_type(B[i].file);	/* Reading color lookup table */	if (Rast_read_colors(name, "", &B[i].colors) == -1)	    G_fatal_error(_("Color file for <%s> not available"), name);	B[i].array = Rast_allocate_buf(B[i].type);    }    /* read in current window */    G_get_window(&window);    D_raster_draw_begin();    next_row = 0;    for (row = 0; row < window.rows;) {	G_percent(row, window.rows, 5);	for (i = 0; i < 3; i++)	    Rast_get_row(B[i].file, B[i].array, row, B[i].type);	if (row == next_row)	    next_row = D_draw_raster_RGB(next_row,					 B[0].array, B[1].array, B[2].array,					 &B[0].colors, &B[1].colors,					 &B[2].colors, B[0].type, B[1].type,					 B[2].type);	else if (next_row > 0)	    row = next_row;	else	    break;    }    G_percent(window.rows, window.rows, 5);    D_raster_draw_end();        D_save_command(G_recreate_command());    D_close_driver();    /* Close the raster maps */    for (i = 0; i < 3; i++)	Rast_close(B[i].file);    exit(EXIT_SUCCESS);}
开发者ID:felipebetancur,项目名称:grass-ci,代码行数:100,


示例10: main

int main(int argc, char **argv){    MELEMENT *rowlist;    SHORT nrows, ncols;    SHORT datarows;    int npoints;    struct GModule *module;    struct History history;    struct    {	struct Option *input, *output, *npoints;    } parm;    struct    {	struct Flag *e;    } flag;    int n, fd, maskfd;    /* Initialize the GIS calls                                     */    G_gisinit(argv[0]);    module = G_define_module();    G_add_keyword(_("raster"));    G_add_keyword(_("surface"));    G_add_keyword(_("interpolation"));    G_add_keyword(_("IDW"));    module->description =	_("Surface interpolation utility for raster map.");    parm.input = G_define_standard_option(G_OPT_R_INPUT);    parm.output = G_define_standard_option(G_OPT_R_OUTPUT);    parm.npoints = G_define_option();    parm.npoints->key = "npoints";    parm.npoints->type = TYPE_INTEGER;    parm.npoints->required = NO;    parm.npoints->description = _("Number of interpolation points");    parm.npoints->answer = "12";    flag.e = G_define_flag();    flag.e->key = 'e';    flag.e->description = _("Output is the interpolation error");    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    if (sscanf(parm.npoints->answer, "%d", &n) != 1 || n <= 0)	G_fatal_error(_("Illegal value for '%s' (%s)"), parm.npoints->key,		      parm.npoints->answer);    npoints = n;    error_flag = flag.e->answer;    input = parm.input->answer;    output = parm.output->answer;    /*  Get database window parameters                              */    G_get_window(&window);    /*  find number of rows and columns in window                   */    nrows = Rast_window_rows();    ncols = Rast_window_cols();    /* create distance squared or latitude lookup tables */    /* initialize function pointers */    lookup_and_function_ptrs(nrows, ncols);    /*  allocate buffers for row i/o                                */    cell = Rast_allocate_c_buf();    if ((maskfd = Rast_maskfd()) >= 0 || error_flag) {	/* apply mask to output */	if (error_flag)		/* use input as mask when -e option chosen */	    maskfd = Rast_open_old(input, "");	mask = Rast_allocate_c_buf();    }    else	mask = NULL;    /*  Open input cell layer for reading                           */    fd = Rast_open_old(input, "");    /* Store input data in array-indexed doubly-linked lists and close input file */    rowlist = row_lists(nrows, ncols, &datarows, &n, fd, cell);    Rast_close(fd);    if (npoints > n)	npoints = n;    /* open cell layer for writing output              */    fd = Rast_open_c_new(output);    /* call the interpolation function                              */    interpolate(rowlist, nrows, ncols, datarows, npoints, fd, maskfd);    /* free allocated memory */    free_row_lists(rowlist, nrows);    G_free(rowlook);    G_free(collook);    if (ll)	free_dist_params();    Rast_close(fd);//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例11: main

int main(int argc, char **argv){    struct GModule *module;    struct Option *opt1, *opt2;    struct Flag *mapcoords;    int R, G, B, color = 0;    /* Initialize the GIS calls */    G_gisinit(argv[0]);    module = G_define_module();    G_add_keyword(_("display"));    G_add_keyword(_("cartography"));    module->description =	_("Program for generating and displaying simple graphics on the "	  "display monitor.");    opt1 = G_define_option();    opt1->key = "input";    opt1->type = TYPE_STRING;    opt1->required = NO;    opt1->description = _("Name of file containing graphics commands, "			  "if not given reads from standard input");    opt1->gisprompt = "old_file,file,input";    opt2 = G_define_option();    opt2->key = "color";    opt2->type = TYPE_STRING;    opt2->required = NO;    opt2->description = _("Color to draw with, either a standard GRASS color "			  "or R:G:B triplet");    opt2->answer = DEFAULT_FG_COLOR;    opt2->gisprompt = "old_color,color,color";    mapcoords = G_define_flag();    mapcoords->key = 'm';    mapcoords->description = _("Coordinates are given in map units");    /* Check command line */    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    /* default font scaling: 5% of active frame */    hsize = vsize = 5.;    if (opt1->answer != NULL) {	if ((infile = fopen(opt1->answer, "r")) == NULL)	    G_fatal_error(_("Graph file <%s> not found"), opt1->answer);    }    else	infile = stdin;    /* open graphics window */    if (D_open_driver() != 0)	G_fatal_error(_("No graphics device selected. "			"Use d.mon to select graphics device."));        /* Parse and select color */    if (opt2->answer != NULL) {	color = G_str_to_color(opt2->answer, &R, &G, &B);	if (color == 0)	    G_fatal_error(_("[%s]: No such color"), opt2->answer);	if (color == 1) {	    D_RGB_color(R, G, B);	    set_last_color(R, G, B, RGBA_COLOR_OPAQUE);	}	else			/* (color==2) is "none" */	    set_last_color(0, 0, 0, RGBA_COLOR_NONE);    }    if (mapcoords->answer) {	mapunits = TRUE;	D_setup(0);    }    else {	D_setup2(0, 0, 100, 0, 0, 100);	mapunits = FALSE;    }    /* Do the graphics */    set_graph_stuff();    set_text_size();    graphics(infile);    D_save_command(G_recreate_command());    D_close_driver();    exit(EXIT_SUCCESS);}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:91,


示例12: start_mon

int start_mon(const char *name, const char *output, int select,	      const char *width, const char *height, const char *bgcolor,	      int truecolor){    const char *curr_mon;    char *env_name, *env_value, *cmd_value;    char *tempfile, buf[1024];    int env_fd;        curr_mon = G__getenv("MONITOR");    if (curr_mon && strcmp(curr_mon, name) == 0 && check_mon(curr_mon))	G_fatal_error(_("Monitor <%s> already running"), name);        tempfile = G_tempfile();    env_name = env_value = NULL;    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", name);    G_asprintf(&env_value, "%s.env", tempfile);    G_setenv(env_name, env_value);    env_fd = creat(env_value, 0666);    if (env_fd < 0)	G_fatal_error(_("Unable to create file '%s'"), env_value);    if (width) {	sprintf(buf, "GRASS_WIDTH=%s/n", width);	write(env_fd, buf, strlen(buf));    }    if (height) {	sprintf(buf, "GRASS_HEIGHT=%s/n", height);	write(env_fd, buf, strlen(buf));    }    if (bgcolor) {	if (strcmp(bgcolor, "none") == 0)	    sprintf(buf, "GRASS_TRANSPARENT=TRUE/n");	else	    sprintf(buf, "GRASS_BACKGROUNDCOLOR=%s/n", bgcolor);	write(env_fd, buf, strlen(buf));    }    if (truecolor) {	sprintf(buf, "GRASS_TRUECOLOR=TRUE/n");	write(env_fd, buf, strlen(buf));    }    close(env_fd);    cmd_value = NULL;    G_asprintf(&env_name, "MONITOR_%s_CMDFILE", name);    G_asprintf(&cmd_value, "%s.cmd", tempfile);    G_setenv(env_name, cmd_value);    close(creat(cmd_value, 0666));    G_verbose_message(_("Staring monitor <%s> with env file '%s'"), name, env_value);        G_debug(1, "start: name=%s ", name);    G_debug(3, "       envfile = %s", env_value);    G_debug(3, "       cmdfile = %s", cmd_value);        if (select)	G_setenv("MONITOR", name);        if (strncmp(name, "wx", 2) == 0) /* use G_strncasecmp() instead */	start_wx(name, tempfile, env_value, cmd_value, 		 width, height);    else	start(name, output);        return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:66,


示例13: main

int main(int argc, char *argv[]){    char *terrainmap, *seedmap, *lakemap, *mapset;    int rows, cols, in_terran_fd, out_fd, lake_fd, row, col, pases, pass;    int lastcount, curcount, start_col = 0, start_row = 0;    double east, north, area = 0, volume = 0;    FCELL **in_terran, **out_water, water_level, max_depth = 0, min_depth = 0;    FCELL water_window[3][3];    struct Option *tmap_opt, *smap_opt, *wlvl_opt, *lake_opt, *sdxy_opt;    struct Flag *negative_flag, *overwrite_flag;    struct GModule *module;    struct Colors colr;    struct Cell_head window;    struct History history;    G_gisinit(argv[0]);        module = G_define_module();    module->keywords = _("raster, hydrology");    module->description = _("Fills lake at given point to given level.");    tmap_opt = G_define_option();    tmap_opt->key = "dem";    tmap_opt->key_desc = "name";    tmap_opt->description = _("Name of terrain raster map (DEM)");    tmap_opt->type = TYPE_STRING;    tmap_opt->gisprompt = "old,cell,raster";    tmap_opt->required = YES;    wlvl_opt = G_define_option();    wlvl_opt->key = "wl";    wlvl_opt->description = _("Water level");    wlvl_opt->type = TYPE_DOUBLE;    wlvl_opt->required = YES;    lake_opt = G_define_option();    lake_opt->key = "lake";    lake_opt->key_desc = "name";    lake_opt->description = _("Name for output raster map with lake");    lake_opt->type = TYPE_STRING;    lake_opt->gisprompt = "new,cell,raster";    lake_opt->required = NO;    sdxy_opt = G_define_option();    sdxy_opt->key = "xy";    sdxy_opt->description = _("Seed point coordinates");    sdxy_opt->type = TYPE_DOUBLE;    sdxy_opt->key_desc = "east,north";    sdxy_opt->required = NO;    sdxy_opt->multiple = NO;    smap_opt = G_define_option();    smap_opt->key = "seed";    smap_opt->key_desc = "name";    smap_opt->description =	_("Name of raster map with given starting point(s) (at least 1 cell > 0)");    smap_opt->type = TYPE_STRING;    smap_opt->gisprompt = "old,cell,raster";    smap_opt->required = NO;    negative_flag = G_define_flag();    negative_flag->key = 'n';    negative_flag->description =	_("Use negative depth values for lake raster map");    overwrite_flag = G_define_flag();    overwrite_flag->key = 'o';    overwrite_flag->description =	_("Overwrite seed map with result (lake) map");    if (G_parser(argc, argv))	/* Returns 0 if successful, non-zero otherwise */	exit(EXIT_FAILURE);    if (smap_opt->answer && sdxy_opt->answer)	G_fatal_error(_("Both seed map and coordinates cannot be specified"));    if (!smap_opt->answer && !sdxy_opt->answer)	G_fatal_error(_("Seed map or seed coordinates must be set!"));    if (sdxy_opt->answer && !lake_opt->answer)	G_fatal_error(_("Seed coordinates and output map lake= must be set!"));    if (lake_opt->answer && overwrite_flag->answer)	G_fatal_error(_("Both lake and overwrite cannot be specified"));    if (!lake_opt->answer && !overwrite_flag->answer)	G_fatal_error(_("Output lake map or overwrite flag must be set!"));    terrainmap = tmap_opt->answer;    seedmap = smap_opt->answer;    sscanf(wlvl_opt->answer, "%f", &water_level);    lakemap = lake_opt->answer;    /* If lakemap is set, write to it, else is set overwrite flag and we should write to seedmap. */    if (lakemap) {	lake_fd = G_open_raster_new(lakemap, 1);	if (lake_fd < 0)	    G_fatal_error(_("Unable to create raster map <%s>"), lakemap);    }//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-grass,代码行数:101,


示例14: describe

int describe(char *name, char *mapset, int compact, char *no_data_str,	     int range, int windowed, int nsteps, int as_int, int skip_nulls){    int fd;    struct Cell_stats statf;    CELL *buf, *b;    int nrows, ncols;    int row, col;    struct Cell_head window;    CELL negmin = 0, negmax = 0, zero = 0, posmin = 0, posmax = 0;    CELL null = 0;    RASTER_MAP_TYPE map_type;    struct Quant q;    struct FPRange r;    DCELL dmin, dmax;    int (*get_row) ();    if (windowed) {	get_row = G_get_c_raster_row;    }    else {	char msg[100];	if (G_get_cellhd(name, mapset, &window) < 0) {	    sprintf(msg, "can't get cell header for [%s] in [%s]", name,		    mapset);	    G_fatal_error(msg);	}	G_set_window(&window);	get_row = G_get_c_raster_row_nomask;    }    fd = G_open_cell_old(name, mapset);    if (fd < 0)	return 0;    map_type = G_get_raster_map_type(fd);    if (as_int)	map_type = CELL_TYPE;	/* read as int */    /* allocate the cell buffer */    buf = G_allocate_cell_buf();    if (map_type != CELL_TYPE && range)	/* this will make it report fp range */    {	range = 0;	nsteps = 1;    }    /* start the cell stats */    if (!range) {	G_init_cell_stats(&statf);    }    else {	zero = 0;	negmin = 0;	negmax = 0;	posmin = 0;	posmax = 0;	null = 0;	dmin = 0.0;	dmax = 0.0;    }    /* set up quantization rules */    if (map_type != CELL_TYPE) {	G_quant_init(&q);	G_read_fp_range(name, mapset, &r);	G_get_fp_range_min_max(&r, &dmin, &dmax);	G_quant_add_rule(&q, dmin, dmax, 1, nsteps);	G_set_quant_rules(fd, &q);    }    nrows = G_window_rows();    ncols = G_window_cols();    G_verbose_message("Reading [%s in %s] ...", name, mapset);    for (row = 0; row < nrows; row++) {	G_percent(row, nrows, 2);	if ((*get_row) (fd, b = buf, row) < 0)	    break;	if (range) {	    for (col = ncols; col-- > 0; b++) {		if (G_is_c_null_value(b))		    null = 1;		else if (*b == 0)		    zero = 1;		else if (*b < 0) {		    if (!negmin)			negmin = negmax = *b;		    else if (*b > negmax)			negmax = *b;		    else if (*b < negmin)			negmin = *b;		}		else {		    if (!posmin)			posmin = posmax = *b;		    else if (*b > posmax)			posmax = *b;//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-grass,代码行数:101,


示例15: write_line

int write_line(PAD_ENT_HDR adenhd, int type, int level){    int i, l;    double x, y, z, r, ang;    adSeekLayer(dwghandle, adenhd->entlayerobjhandle, Layer);    /* Transformation, go up through all levels of transformation */    /* not sure what is the right order of transformation */    for (l = level; l >= 0; l--) {	for (i = 0; i < Points->n_points; i++) {	    /* scale */	    x = Points->x[i] * Trans[l].xscale;	    y = Points->y[i] * Trans[l].yscale;	    z = Points->z[i] * Trans[l].zscale;	    /* rotate */	    r = sqrt(x * x + y * y);	    ang = atan2(y, x) + Trans[l].rotang;	    x = r * cos(ang);	    y = r * sin(ang);	    /* move */	    x += Trans[l].dx;	    y += Trans[l].dy;	    z += Trans[l].dz;	    Points->x[i] = x;	    Points->y[i] = y;	    Points->z[i] = z;	}    }    Vect_reset_cats(Cats);    Vect_cat_set(Cats, 1, cat);    Vect_write_line(&Map, type, Points, Cats);    /* Cat */    sprintf(buf, "insert into %s values ( %d", Fi->table, cat);    db_set_string(&sql, buf);    /* Entity name */    getEntTypeName(adenhd, buf2);    sprintf(buf, ", '%s'", buf2);    db_append_string(&sql, buf);    /* Color */    sprintf(buf, ", %d", adenhd->entcolor);    db_append_string(&sql, buf);    /* Weight */    sprintf(buf, ", %d", adenhd->lineweight);    db_append_string(&sql, buf);    /* Layer name */    if (!Layer->purgedflag && Layer->name != NULL) {	db_set_string(&str, Layer->name);	db_double_quote_string(&str);	sprintf(buf, ", '%s'", db_get_string(&str));    }    else {	sprintf(buf, ", ''");    }    db_append_string(&sql, buf);    /* Block name */    if (Block != NULL) {	db_set_string(&str, Block);	db_double_quote_string(&str);    }    else {	db_set_string(&str, "");    }    sprintf(buf, ", '%s'", db_get_string(&str));    db_append_string(&sql, buf);    /* Text */    if (Txt != NULL) {	db_set_string(&str, Txt);	db_double_quote_string(&str);    }    else {	db_set_string(&str, "");    }    sprintf(buf, ", '%s'", db_get_string(&str));    db_append_string(&sql, buf);    db_append_string(&sql, ")");    G_debug(3, db_get_string(&sql));    if (db_execute_immediate(driver, &sql) != DB_OK) {	db_close_database(driver);	db_shutdown_driver(driver);	G_fatal_error("Cannot insert new row: %s", db_get_string(&sql));    }    cat++;    return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:96,


示例16: main

int main(int argc, char *argv[]){    struct GModule *module;    struct Option *coord, *out_file, *min, *max, *mult;    struct Flag *flag;    int *int_buf;    struct Cell_head w;    struct History history;    int cellfile;    double east, north, pt[2], cur[2], row, col, fmult;    double fmin, fmax;    int binary;    G_gisinit(argv[0]);    module = G_define_module();    G_add_keyword(_("raster"));    G_add_keyword(_("buffer"));    G_add_keyword(_("geometry"));    G_add_keyword(_("circle"));    module->description =	_("Creates a raster map containing concentric "	  "rings around a given point.");    out_file = G_define_standard_option(G_OPT_R_OUTPUT);    coord = G_define_standard_option(G_OPT_M_COORDS);    coord->required = YES;    coord->description = _("The coordinate of the center (east,north)");    min = G_define_option();    min->key = "min";    min->type = TYPE_DOUBLE;    min->required = NO;    min->description = _("Minimum radius for ring/circle map (in meters)");    max = G_define_option();    max->key = "max";    max->type = TYPE_DOUBLE;    max->required = NO;    max->description = _("Maximum radius for ring/circle map (in meters)");    mult = G_define_option();    mult->key = "multiplier";    mult->type = TYPE_DOUBLE;    mult->required = NO;    mult->description = _("Data value multiplier");    flag = G_define_flag();    flag->key = 'b';    flag->description = _("Generate binary raster map");    if (G_parser(argc, argv))	exit(EXIT_FAILURE);    G_scan_easting(coord->answers[0], &east, G_projection());    G_scan_northing(coord->answers[1], &north, G_projection());    pt[0] = east;    pt[1] = north;    fmult = 1.0;    if (min->answer)	sscanf(min->answer, "%lf", &fmin);    else	fmin = 0;    if (max->answer)	sscanf(max->answer, "%lf", &fmax);    else	fmax = HUGE_VAL;    if (fmin > fmax)	G_fatal_error(_("Please specify a radius in which min < max"));    if (mult->answer)	if (1 != sscanf(mult->answer, "%lf", &fmult))	    fmult = 1.0;    /* nonsense test */    if (flag->answer && (!min->answer && !max->answer))	G_fatal_error(_("Please specify min and/or max radius when "			"using the binary flag"));    if (flag->answer)	binary = 1;		/* generate binary pattern only, useful for MASK */    else	binary = 0;    G_get_set_window(&w);    cellfile = Rast_open_c_new(out_file->answer);    int_buf = (int *)G_malloc(w.cols * sizeof(int));    {	int c;	for (row = 0; row < w.rows; row++) {	    G_percent(row, w.rows, 2);//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:101,


示例17: grad_check

/* data preparations, sigma, shear, etc. */int grad_check(void){    int k, l;    double zx, zy, zd2, zd4, sinsl;    double cc, cmul2;    double sheer;    double vsum = 0.;    double vmax = 0.;    double chsum = 0.;    double zmin = 1.e12;    double zmax = -1.e12;    double zd2min = 1.e12;    double zd2max = -1.e12;    double smin = 1.e12;    double smax = -1.e12;    double infmin = 1.e12;    double infmax = -1.e12;    double sigmax = -1.e12;    double cchezmax = -1.e12;    double rhow = 1000.;    double gacc = 9.81;    double hh = 1.;    double deltaw = 1.e12;    sisum = 0.;    infsum = 0.;    cmul2 = rhow * gacc;    for (k = 0; k < my; k++) {	for (l = 0; l < mx; l++) {	    if (zz[k][l] != UNDEF) {		zx = v1[k][l];		zy = v2[k][l];		zd2 = zx * zx + zy * zy;		sinsl = sqrt(zd2) / sqrt(zd2 + 1);	/* sin(terrain slope) */		/* Computing MIN */		zd2 = sqrt(zd2);		zd2min = amin1(zd2min, zd2);		/* Computing MAX */		zd2max = amax1(zd2max, zd2);		zd4 = sqrt(zd2);	/* ^.25 */		if (cchez[k][l] != 0.) {		    cchez[k][l] = 1. / cchez[k][l];	/* 1/n */		}		else {		    G_fatal_error(_("Zero value in Mannings n"));		}		if (zd2 == 0.) {		    v1[k][l] = 0.;		    v2[k][l] = 0.;		    slope[k][l] = 0.;		}		else {		    if (wdepth)			hh = pow(gama[k][l], 2. / 3.);		    /* hh = 1 if there is no water depth input */		    v1[k][l] = (double)hh *cchez[k][l] * zx / zd4;		    v2[k][l] = (double)hh *cchez[k][l] * zy / zd4;		    slope[k][l] =			sqrt(v1[k][l] * v1[k][l] + v2[k][l] * v2[k][l]);		}		if (wdepth) {		    sheer = (double)(cmul2 * gama[k][l] * sinsl);	/* shear stress */		    /* if critical shear stress >= shear then all zero */		    if ((sheer <= tau[k][l]) || (ct[k][l] == 0.)) {			si[k][l] = 0.;			sigma[k][l] = 0.;		    }		    else {			si[k][l] = (double)(dc[k][l] * (sheer - tau[k][l]));			sigma[k][l] = (double)(dc[k][l] / ct[k][l]) * (sheer - tau[k][l]) / (pow(sheer, 1.5));	/* rill erosion=1.5, sheet = 1.1 */		    }		}		sisum += si[k][l];		smin = amin1(smin, si[k][l]);		smax = amax1(smax, si[k][l]);		if (inf) {		    infsum += inf[k][l];		    infmin = amin1(infmin, inf[k][l]);		    infmax = amax1(infmax, inf[k][l]);		}		vmax = amax1(vmax, slope[k][l]);		vsum += slope[k][l];		chsum += cchez[k][l];		zmin = amin1(zmin, (double)zz[k][l]);		zmax = amax1(zmax, (double)zz[k][l]);	/* not clear were needed */		if (wdepth)		    sigmax = amax1(sigmax, sigma[k][l]);		cchezmax = amax1(cchezmax, cchez[k][l]);		/* saved sqrt(sinsl)*cchez to cchez array for output */		cchez[k][l] *= sqrt(sinsl);	    }			/* DEFined area */	}    }    if (inf != NULL && smax < infmax)	G_warning(_("Infiltration exceeds the rainfall rate everywhere! No overland flow."));    cc = (double)mx *my;//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例18: E_edit_fp_cats

int E_edit_fp_cats(const char *name, struct Categories *cats){    long incr;    long atnum;    long startcat;    long endcat;    char buff[NLINES][60];    char next[20];    char next_line[80];    char title[80];    char msg1[80];    char msg2[80];    int line, ncats;    size_t lab_len;    DCELL max_val[NLINES], min_val[NLINES];    DCELL dmin, dmax;    CELL tmp_cell;    struct Categories old_cats;    struct FPRange fp_range;    if (G_read_fp_range(name, G_mapset(), &fp_range) < 0)	G_fatal_error("can't read the floating point range for %s", name);    G_get_fp_range_min_max(&fp_range, &dmin, &dmax);    /* first save old cats */    G_copy_raster_cats(&old_cats, cats);    G_init_raster_cats(old_cats.title, cats);    G_free_raster_cats(cats);    ncats = old_cats.ncats;    V_clear();    if (!ncats)	sprintf(msg1, "There are no predefined fp ranges to label");    else	sprintf(msg1, "There are %d predefined fp ranges to label", ncats);    sprintf(msg2, "Enter the number of fp ranges you want to label");    V_line(1, msg1);    V_line(2, msg2);    V_ques(&ncats, 'l', 2, 48, 5);    V_line(16, next_line);    *next_line = 0;    V_intrpt_ok();    if (!V_call())	return -1;    *title = 0;    if (old_cats.title != NULL)	strcpy(title, old_cats.title);    startcat = 0;    sprintf(msg1, "The fp data in map %s ranges from %f to %f", name, dmin,	    dmax);    sprintf(msg2, "[%s] ENTER NEW CATEGORY NAMES FOR THESE CATEGORIES", name);    while (1) {	V_clear();	V_line(0, msg1);	V_line(1, msg2);	V_line(3, "TITLE: ");	V_line(4, "FP RANGE           NEW CATEGORY NAME");	V_ques(title, 's', 2, 8, 60);	endcat = startcat + NLINES <= ncats ? startcat + NLINES : ncats;	line = 6;	for (incr = startcat; incr < endcat; incr++) {	    atnum = incr - startcat;	    if (incr < old_cats.ncats) {		/* if editing existing range label */		lab_len = strlen(old_cats.labels[incr]);		if (lab_len > 58)		    lab_len = 58;		strncpy(buff[atnum], old_cats.labels[incr], lab_len);		buff[atnum][lab_len] = 0;		G_quant_get_ith_rule(&old_cats.q, incr, &min_val[atnum],				     &max_val[atnum], &tmp_cell, &tmp_cell);	    }	    else {		/* adding new range label */		strcpy(buff[atnum], "");		max_val[atnum] = min_val[atnum] = 0;	    }	    V_ques(&min_val[atnum], 'd', line, 1, 8);	    V_const("-", 's', line, 9, 1);	    V_ques(&max_val[atnum], 'd', line, 10, 8);	    V_ques(buff[atnum], 's', line, 19, 58);	    line++;	}	line += 2;	*next = 0;	if (endcat >= ncats)	    strcpy(next, "end");	else//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-grass,代码行数:101,


示例19: input_data

/* Read all input maps and input values into memory ************************ */int input_data(void){    int rows = my, cols = mx; /* my and mx are global variables */    double unitconv = 0.0000002;	/* mm/hr to m/s */    int if_rain = 0;    G_debug(1, "Running MAR 2011 version, started modifications on 20080211");    G_debug(1, "Reading input data");        /* Elevation and gradients are mandatory */    zz = read_float_raster_map(rows, cols, elevin, 1.0);    v1 = read_double_raster_map(rows, cols, dxin, 1.0);    v2 = read_double_raster_map(rows, cols, dyin, 1.0);    /* Update elevation map */    copy_matrix_undef_double_to_float_values(rows, cols, v1, zz);    copy_matrix_undef_double_to_float_values(rows, cols, v2, zz);    /* Manning surface roughnes: read map or use a single value */    if(manin != NULL) {    	cchez = read_float_raster_map(rows, cols, manin, 1.0);     } else if(manin_val >= 0.0) { /* If no value set its set to -999.99 */	cchez = create_float_matrix(rows, cols, manin_val);    }else{        G_fatal_error(_("Raster map <%s> not found, and manin_val undefined, choose one to be allowed to process"), manin);    }           /* Rain: read rain map or use a single value for all cells */    if (rain != NULL) {	si = read_double_raster_map(rows, cols, rain, unitconv);	if_rain = 1;    } else if(rain_val >= 0.0) { /* If no value set its set to -999.99 */	si = create_double_matrix(rows, cols, rain_val * unitconv);	if_rain = 1;    } else{	si = create_double_matrix(rows, cols, (double)UNDEF);	if_rain = 0;    }    /* Update elevation map */    copy_matrix_undef_double_to_float_values(rows, cols, si, zz);    /* Load infiltration and traps if rain is present */    if(if_rain == 1) {	/* Infiltration: read map or use a single value */        if (infil != NULL) {            inf = read_double_raster_map(rows, cols, infil, unitconv);        } else if(infil_val >= 0.0) { /* If no value set its set to -999.99 */	    inf = create_double_matrix(rows, cols, infil_val * unitconv);        } else{	    inf = create_double_matrix(rows, cols, (double)UNDEF);        }   	/* Traps */        if (traps != NULL)            trap = read_float_raster_map(rows, cols, traps, 1.0);	else	    trap = create_float_matrix(rows, cols, (double)UNDEF);    }    if (detin != NULL) {    	 dc = read_float_raster_map(rows, cols, detin, 1.0);         copy_matrix_undef_float_values(rows, cols, dc, zz);    }    if (tranin != NULL) {    	 ct = read_float_raster_map(rows, cols, tranin, 1.0);         copy_matrix_undef_float_values(rows, cols, ct, zz);    }    if (tauin != NULL) {    	 tau = read_float_raster_map(rows, cols, tauin, 1.0);         copy_matrix_undef_float_values(rows, cols, tau, zz);    }    if (wdepth != NULL) {        gama = read_double_raster_map(rows, cols, wdepth, 1.0);        copy_matrix_undef_double_to_float_values(rows, cols, gama, zz);    }        /* Array for gradient checking */    slope = create_double_matrix(rows, cols, 0.0);        /* Create the observation points and open the logfile */    create_observation_points();  return 1;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:89,


示例20: avl_add

int avl_add(avl_tree * root, const generic_cell k, const long n){    avl_node *p = NULL;    avl_node *node_temp = NULL;    avl_node *critical = NULL;    int d = 0;    int pos1 = 0, pos2 = 0;    int rotation = 0;    if ((root == NULL) || (*root == NULL)) {	G_fatal_error("/navl.c: avl_add: param NULL");	return AVL_ERR;    }    /* search position where insert the new node */    node_temp = avl_individua(*root, k, &p, &d);    if (node_temp != NULL) {	node_temp->counter = node_temp->counter + n;	return AVL_PRES;    }    node_temp = avl_make(k, n);    if (node_temp == NULL) {	G_fatal_error("/navl.c:  avl_add: create node error");	return AVL_ERR;    }    /* link the new node */    node_temp->father = p;    if (d == -1) {	p->left_child = node_temp;    }    else {	if (d == 1) {	    p->right_child = node_temp;	}	else {	    G_free(node_temp);	    G_fatal_error("avl.c: avl_add: new node position unknown");	    return AVL_ERR;	}    }    /* if it's necessary balance the tree */    critical = critical_node(node_temp, &pos1, &pos2, NULL);    if (critical == NULL)	return AVL_ADD;    rotation = (pos1 * 10) + pos2;    switch (rotation) {    case AVL_SS:	avl_rotation_ll(critical);	break;    case AVL_SD:	avl_rotation_lr(critical);	break;    case AVL_DS:	avl_rotation_rl(critical);	break;    case AVL_DD:	avl_rotation_rr(critical);	break;    default:	G_fatal_error("avl, avl_add: balancing error/n");	return AVL_ERR;    }    /* if after rotation the root is changed modufy the pointer to the root */    while ((*root)->father != NULL)	*root = (*root)->father;    return AVL_ADD;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:81,


示例21: main

int main( int argc, char **argv ){  char *mapset;  char *name;  struct GModule *module;  struct Option *map;  struct Option *win;  struct Option *format;  struct Cell_head window;  RASTER_MAP_TYPE raster_type;  /* Initialize the GIS calls */  G_gisinit( argv[0] );  module = G_define_module();  module->keywords = ( "display, raster" );  module->description = ( "Output raster map layers in a format suitable for display in QGIS" );  map = G_define_standard_option( G_OPT_R_MAP );  map->description = ( "Raster map to be displayed" );  format = G_define_option();  format->key = "format";  format->type = TYPE_STRING;  format->description = "format";  format->options = "color,value";  win = G_define_option();  win->key = "window";  win->type = TYPE_DOUBLE;  win->multiple = YES;  win->description = "xmin,ymin,xmax,ymax,ncols,nrows";  if ( G_parser( argc, argv ) )    exit( EXIT_FAILURE );  name = map->answer;  /* Make sure map is available */  mapset = G_find_cell2( name, "" );  if ( mapset == NULL )    G_fatal_error(( "Raster map <%s> not found" ), name );  /* It can happen that GRASS data set is 'corrupted' and zone differs in WIND and   * cellhd, and G_open_cell_old fails, so it is better to read window from map */  /* G_get_window( &window ); */  G_get_cellhd( name, mapset, &window );  window.west = atof( win->answers[0] );  window.south = atof( win->answers[1] );  window.east = atof( win->answers[2] );  window.north = atof( win->answers[3] );  window.cols = atoi( win->answers[4] );  window.rows = atoi( win->answers[5] );  G_adjust_Cell_head( &window, 1, 1 );  G_set_window( &window );  raster_type = G_raster_map_type( name, "" );  display( name, mapset, raster_type, format->answer );  exit( EXIT_SUCCESS );}
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:62,


示例22: dig_read_cidx_head

/* return: 0 OK, -1 error */int dig_read_cidx_head(GVFILE * fp, struct Plus_head *plus){    unsigned char buf[5];    int i, byte_order;    dig_rewind(fp);    /* bytes 1 - 5 */    if (0 >= dig__fread_port_C(buf, 5, fp))	return (-1);    plus->cidx_Version_Major = buf[0];    plus->cidx_Version_Minor = buf[1];    plus->cidx_Back_Major = buf[2];    plus->cidx_Back_Minor = buf[3];    byte_order = buf[4];    G_debug(3,	    "Cidx header: file version %d.%d , supported from GRASS version %d.%d",	    plus->cidx_Version_Major, plus->cidx_Version_Minor,	    plus->cidx_Back_Major, plus->cidx_Back_Minor);    G_debug(3, "  byte order %d", byte_order);    /* check version numbers */    if (plus->cidx_Version_Major > GV_CIDX_VER_MAJOR ||	plus->cidx_Version_Minor > GV_CIDX_VER_MINOR) {	/* The file was created by GRASS library with higher version than this one */	if (plus->cidx_Back_Major > GV_CIDX_VER_MAJOR ||	    plus->cidx_Back_Minor > GV_CIDX_VER_MINOR) {	    /* This version of GRASS lib is lower than the oldest which can read this format */	    G_debug(1, "Category index format version %d.%d",		    plus->cidx_Version_Major, plus->cidx_Version_Minor);	    G_fatal_error		("This version of GRASS (%d.%d) is too old to read this category index format."		 " Try to rebuild topology or upgrade GRASS to at least version %d.",		 GRASS_VERSION_MAJOR, GRASS_VERSION_MINOR, GRASS_VERSION_MAJOR + 1);	    return (-1);	}	G_warning	    ("Your GRASS version does not fully support category index format %d.%d of the vector."	     " Consider to rebuild topology or upgrade GRASS.",	     plus->cidx_Version_Major, plus->cidx_Version_Minor);    }    dig_init_portable(&(plus->cidx_port), byte_order);    dig_set_cur_port(&(plus->cidx_port));    /* bytes 6 - 9 : header size */    if (0 >= dig__fread_port_L(&(plus->cidx_head_size), 1, fp))	return (-1);    G_debug(3, "  header size %ld", plus->cidx_head_size);    /* Body of header - info about all fields */    /* Number of fields */    if (0 >= dig__fread_port_I(&(plus->n_cidx), 1, fp))	return (-1);    /* alloc space */    plus->a_cidx = plus->n_cidx;    plus->cidx =	(struct Cat_index *)G_malloc(plus->a_cidx * sizeof(struct Cat_index));    for (i = 0; i < plus->n_cidx; i++) {	int t;	struct Cat_index *ci;	ci = &(plus->cidx[i]);	ci->cat = NULL;	ci->a_cats = 0;	/* Field number */	if (0 >= dig__fread_port_I(&(ci->field), 1, fp))	    return (-1);	/* Number of categories */	if (0 >= dig__fread_port_I(&(ci->n_cats), 1, fp))	    return (-1);	/* Number of unique categories */	if (0 >= dig__fread_port_I(&(ci->n_ucats), 1, fp))	    return (-1);	/* Number of types */	if (0 >= dig__fread_port_I(&(ci->n_types), 1, fp))	    return (-1);	/* Types */	for (t = 0; t < ci->n_types; t++) {	    int rtype;	    /* type */	    if (0 >= dig__fread_port_I(&rtype, 1, fp))		return (-1);	    ci->type[t][0] = dig_type_from_store(rtype);	    /* number of items */	    if (0 >= dig__fread_port_I(&(ci->type[t][1]), 1, fp))//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-grass,代码行数:101,


示例23: dig_Rd_Plus_head

/*!  /brief Read Plus_head from file  /param fp pointer to gvfile structure  /param[in,out] ptr pointer to Plus_head structure  /return -1 error  /return  0 OK */int dig_Rd_Plus_head(struct gvfile * fp, struct Plus_head *ptr){    unsigned char buf[5];    int byte_order;    dig_rewind(fp);    /* bytes 1 - 5 */    if (0 >= dig__fread_port_C((char *)buf, 5, fp))	return (-1);    ptr->version.topo.major = buf[0];    ptr->version.topo.minor = buf[1];    ptr->version.topo.back_major = buf[2];    ptr->version.topo.back_minor = buf[3];    byte_order = buf[4];    G_debug(2,	    "Topo header: file version %d.%d , supported from GRASS version %d.%d",	    ptr->version.topo.major, ptr->version.topo.minor, ptr->version.topo.back_major,	    ptr->version.topo.back_minor);    G_debug(2, "  byte order %d", byte_order);    /* check version numbers */    if (ptr->version.topo.major > GV_TOPO_VER_MAJOR ||	ptr->version.topo.minor > GV_TOPO_VER_MINOR) {	/* The file was created by GRASS library with higher version than this one */	if (ptr->version.topo.back_major > GV_TOPO_VER_MAJOR ||	    ptr->version.topo.back_minor > GV_TOPO_VER_MINOR) {	    /* This version of GRASS lib is lower than the oldest which can read this format */	    G_debug(1, "Topology format version %d.%d",		    ptr->version.topo.major, ptr->version.topo.minor);	    G_fatal_error		(_("This version of GRASS (%d.%d) is too old to read this topology format."		 " Try to rebuild topology or upgrade GRASS to at least version %d."),		 GRASS_VERSION_MAJOR, GRASS_VERSION_MINOR, GRASS_VERSION_MAJOR + 1);	    return (-1);	}	G_warning(_("Your GRASS version does not fully support topology format %d.%d of the vector."		    " Consider to rebuild topology or upgrade GRASS."),		  ptr->version.topo.major, ptr->version.topo.minor);    }    if (ptr->version.topo.major < GV_TOPO_VER_MAJOR ||	(ptr->version.topo.major == GV_TOPO_VER_MAJOR &&	 ptr->version.topo.minor < GV_TOPO_VER_MINOR)) {	/* The file was created by GRASS library with lower version than this one */	/* This version of GRASS lib can not read this old format */	G_warning(_("Old topology format version %d.%d is not supported by this release."		    " Try to rebuild topology using v.build or v.build.all module."),		  ptr->version.topo.major, ptr->version.topo.minor);	return (-1);    }    /* init Port_info structure and set as default */    dig_init_portable(&(ptr->port), byte_order);    dig_set_cur_port(&(ptr->port));    /* bytes 6 - 9 : header size */    if (0 >= dig__fread_port_L(&(ptr->head_size), 1, fp))	return (-1);    G_debug(2, "  header size %ld", ptr->head_size);    /* determine required offset size from header size */    /* this is not safe in case new fields get added in later versions */    /* better: add a new field with off_t_size after byte_order? */    if (ptr->head_size >= 142 + 32) /* keep in sync with dig_Wr_Plus_head() */	ptr->off_t_size = 8;    else	ptr->off_t_size = 4;    if (sizeof(off_t) < ptr->off_t_size) {	G_warning(_("Vector exceeds supported file size limit"));	return (-1);    }    G_debug(2, "topo off_t size = %d", ptr->off_t_size);    /* byte 10 : dimension 2D or 3D */    if (0 >= dig__fread_port_C((char *)buf, 1, fp))	return (-1);    ptr->with_z = buf[0];    G_debug(2, "  with_z %d", ptr->with_z);    /* bytes 11 - 58 : bound box */    if (0 >= dig__fread_port_D(&(ptr->box.N), 1, fp))	return (-1);    if (0 >= dig__fread_port_D(&(ptr->box.S), 1, fp))	return (-1);//.........这里部分代码省略.........
开发者ID:GRASS-GIS,项目名称:grass-ci,代码行数:101,


示例24: G_check_input_output_name

/*! * /brief Check input and output file names. * * Check:  *  1) output is legal map name, *  2) if can find input map, and *  3) if input was found in current mapset, check if input != output. * * /param input input map name * /param output output map name * /param error error type: G_FATAL_EXIT, G_FATAL_PRINT, G_FATAL_RETURN * * /return 0 OK * /return 1 error */int G_check_input_output_name(const char *input, const char *output,			      int error){    const char *mapset;    if (output == NULL)	return 0;		/* don't die on undefined parameters */    if (G_legal_filename(output) == -1) {	if (error == G_FATAL_EXIT) {	    G_fatal_error(_("Output raster map name <%s> is not valid map name"),			  output);	}	else if (error == G_FATAL_PRINT) {	    G_warning(_("Output raster map name <%s> is not valid map name"),		      output);	    return 1;	}	else {			/* G_FATAL_RETURN */	    return 1;	}    }    mapset = G_find_raster2(input, "");    if (mapset == NULL) {	if (error == G_FATAL_EXIT) {	    G_fatal_error(_("Raster map <%s> not found"), input);	}	else if (error == G_FATAL_PRINT) {	    G_warning(_("Raster map <%s> not found"), input);	    return 1;	}	else {			/* G_FATAL_RETURN */	    return 1;	}    }    if (strcmp(mapset, G_mapset()) == 0) {	char nm[1000], ms[1000];	const char *in;	if (G_name_is_fully_qualified(input, nm, ms)) {	    in = nm;	}	else {	    in = input;	}	if (strcmp(in, output) == 0) {	    if (error == G_FATAL_EXIT) {		G_fatal_error(_("Output raster map <%s> is used as input"),			      output);	    }	    else if (error == G_FATAL_PRINT) {		G_warning(_("Output raster map <%s> is used as input"),			  output);		return 1;	    }	    else {		/* G_FATAL_RETURN */		return 1;	    }	}    }    return 0;}
开发者ID:caomw,项目名称:grass,代码行数:81,


示例25: draw_n_arrow

int draw_n_arrow(double east, double north, double fontsize,		 char *n_arrow_num, double line_width){    double x_pos, y_pos;    double t, b, l, r;    double tt, tb, tl, tr; /* text box*/    SYMBOL *Symb;    RGBA_Color *line_color, *fill_color;    int R, G, B;    double x0, y0;    char icon[64];    double symbol_size;    /* Establish text size */    if (fontsize > 0)	D_text_size(fontsize, fontsize);    D_setup_unity(0);    D_get_src(&t, &b, &l, &r);    x_pos = east * (r - l) / 100.;    y_pos = (100. - north) * (b - t) / 100.;    if (line_width > 0)	D_line_width(line_width);    if (fontsize > 0) {    	/* draw the "N" */    	D_get_text_box("N", &tt, &tb, &tl, &tr);    	D_use_color(fg_color);    	/* positions manually tuned */    	switch (n_arrow_num[0]) {    	case '1':    	    D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 45);    	    D_text("N");    	    break;    	case '3':    	    D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 60);    	    D_text("N");    	    break;    	case '4':    	    D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 45);    	    D_text("N");    	    break;    	case '7':    	    D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 70);    	    D_text("N");    	    break;    	case '9':	case 'f':    	    D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 55);    	    D_text("N");	    break;    	case 'b':    	    D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 48.5);    	    D_text("N");    	    break;    	case '2':    	case '5':    	case '6':    	case '8':    	    break;    	default:    	    G_fatal_error(_("Could not parse symbol"));    	}    }    /* display the north arrow symbol */    line_color = G_malloc(sizeof(RGBA_Color));    fill_color = G_malloc(sizeof(RGBA_Color));    if (D_color_number_to_RGB(fg_color, &R, &G, &B) == 0)    	/* fall back to black on failure */    	G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B);    line_color->r = (unsigned char)R;    line_color->g = (unsigned char)G;    line_color->b = (unsigned char)B;    line_color->a = RGBA_COLOR_OPAQUE;    if (D_color_number_to_RGB(bg_color, &R, &G, &B) == 0)    	/* fall back to black on failure */    	G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B);    fill_color->r = (unsigned char)R;    fill_color->g = (unsigned char)G;    fill_color->b = (unsigned char)B;    fill_color->a = RGBA_COLOR_OPAQUE;    if (n_arrow_num[0] == '2' || n_arrow_num[0] == '9')    	fill_color->a = RGBA_COLOR_TRANSPARENT;    /* sizes manually tuned */    switch (n_arrow_num[0]) {    case '1':    	symbol_size = 35.;    	break;    case '2':    	symbol_size = 19.;//.........这里部分代码省略.........
开发者ID:caomw,项目名称:grass,代码行数:101,



注:本文中的G_fatal_error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ G_free函数代码示例
C++ G_define_option函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。