int main(int argc, char **argv) { struct Option *grp, *val, *fmt, *xfm_pts; struct Flag *sum, *rev_flag, *dump_flag; struct GModule *module; char *desc; G_gisinit(argv[0]); /* Get Args */ module = G_define_module(); G_add_keyword(_("miscellaneous")); G_add_keyword(_("transformation")); G_add_keyword("GCP"); module->description = _("Computes a coordinate transformation based on the control points."); grp = G_define_standard_option(G_OPT_I_GROUP); val = G_define_option(); val->key = "order"; val->type = TYPE_INTEGER; val->required = YES; val->options = "1-3"; val->description = _("Rectification polynomial order"); fmt = G_define_option(); fmt->key = "format"; fmt->type = TYPE_STRING; fmt->required = NO; fmt->multiple = YES; fmt->options = "idx,src,dst,fwd,rev,fxy,rxy,fd,rd"; desc = NULL; G_asprintf(&desc, "idx;%s;src;%s;dst;%s;fwd;%s;rev;%s;fxy;%s;rxy;%s;fd;%s;rd;%s", _("point index"), _("source coordinates"), _("destination coordinates"), _("forward coordinates (destination)"), _("reverse coordinates (source)"), _("forward coordinates difference (destination)"), _("reverse coordinates difference (source)"), _("forward error (destination)"), _("reverse error (source)")); fmt->descriptions = desc; fmt->answer = "fd,rd"; fmt->description = _("Output format"); sum = G_define_flag(); sum->key = 's'; sum->description = _("Display summary information"); xfm_pts = G_define_standard_option(G_OPT_F_INPUT); xfm_pts->required = NO; xfm_pts->label = _("File containing coordinates to transform (\"-\" to read from stdin)"); xfm_pts->description = _("Local x,y coordinates to target east,north"); rev_flag = G_define_flag(); rev_flag->key = 'r'; rev_flag->label = _("Reverse transform of coords file or coeff. dump"); rev_flag->description = _("Target east,north coordinates to local x,y"); dump_flag = G_define_flag(); dump_flag->key = 'x'; dump_flag->description = _("Display transform matrix coefficients"); if (G_parser(argc, argv)) exit(EXIT_FAILURE); name = grp->answer; order = atoi(val->answer); summary = !!sum->answer; columns = fmt->answers; forward = !rev_flag->answer; coord_file = xfm_pts->answer; I_get_control_points(name, &points); parse_format(); compute_transformation(); I_put_control_points(name, &points); analyze(); if(dump_flag->answer) dump_cooefs(); if(coord_file) do_pt_xforms(); return 0; }
int main(int argc, char *argv[]) { char name[GNAME_MAX], mapset[GMAPSET_MAX], xmapset[GMAPSET_MAX]; struct Cell_head cellhd; struct GModule *module; struct Option *grp; /* must run in a term window */ G_putenv("GRASS_UI_TERM", "1"); G_gisinit(argv[0]); module = G_define_module(); G_add_keyword(_("imagery")); G_add_keyword(_("geometry")); module->description = _("Mark ground control points on image to be rectified."); grp = G_define_option(); grp->key = "group"; grp->type = TYPE_STRING; grp->required = YES; grp->gisprompt = "old,group,group"; grp->description = _("Name of imagery group to be registered"); if (G_parser(argc, argv)) exit(EXIT_FAILURE); Rast_suppress_masking(); /* need to do this for target location */ interrupt_char = G_intr_char(); tempfile1 = G_tempfile(); tempfile2 = G_tempfile(); cell_list = G_tempfile(); vect_list = G_tempfile(); group_list = G_tempfile(); digit_points = G_tempfile(); digit_results = G_tempfile(); if (R_open_driver() != 0) G_fatal_error(_("No graphics device selected")); /* parse group name */ /* only enforce local-mapset-only due to I_get_group_ref() not liking "@mapset" */ if (G_name_is_fully_qualified(grp->answer, group.name, xmapset)) { if (0 != strcmp(G_mapset(), xmapset)) G_fatal_error(_("[%s] Only local groups may be used"), grp->answer); } else { strncpy(group.name, grp->answer, GNAME_MAX - 1); group.name[GNAME_MAX - 1] = '\0'; /* strncpy() doesn't null terminate on overflow */ } if (!I_get_group_ref(group.name, &group.ref)) G_fatal_error(_("Group [%s] contains no maps, run i.group"), group.name); if (group.ref.nfiles <= 0) G_fatal_error(_("Group [%s] contains no maps, run i.group"), group.name); /* write group files to group list file */ prepare_group_list(); /* get target info and environment */ get_target(); find_target_files(); /* read group control points, if any */ G_suppress_warnings(1); if (!I_get_control_points(group.name, &group.points)) group.points.count = 0; G_suppress_warnings(0); /* determine transformation equation */ Compute_equation(); signal(SIGINT, SIG_IGN); /* signal (SIGQUIT, SIG_IGN); */ Init_graphics(); display_title(VIEW_MAP1); select_target_env(); display_title(VIEW_MAP2); select_current_env(); Begin_curses(); G_set_error_routine(error); /* #ifdef SIGTSTP signal (SIGTSTP, SIG_IGN); #endif */ /* ask user for group file to be displayed */ do { if (!choose_groupfile(name, mapset)) quit(0); /* display this file in "map1" */ } while (!G_find_raster2(name, mapset)); Rast_get_cellhd(name, mapset, &cellhd); G_adjust_window_to_box(&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows, VIEW_MAP1->ncols); Configure_view(VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res); drawcell(VIEW_MAP1); display_points(1); Curses_clear_window(PROMPT_WINDOW); /* determine initial input method. */ setup_digitizer(); if (use_digitizer) { from_digitizer = 1; from_keyboard = 0; from_flag = 1; } /* go do the work */ driver(); quit(0); }