File: creat_trans.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (134 lines) | stat: -rw-r--r-- 2,781 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
****************************************************************************
*
* MODULE:       v.transform
* AUTHOR(S):    See other files as well...
*               Eric G. Miller <egm2@jps.net>
* PURPOSE:      To transform a vector layer's coordinates via a set of tie
*               points.
* COPYRIGHT:    (C) 2002 by the GRASS Development Team
*
*               This program is free software under the GNU General Public
*   	    	License (>=v2). Read the file COPYING that comes with GRASS
*   	    	for details.
*
*****************************************************************************/

/*
*  create_transform_conversion () - main driver routine to prepare
*    the transformation equation.
*
*  yes_no_quest(s)  -  ask the user a yes, no question.
*     returns:   1 for yes, 0 for no
*  Written by the GRASS Team, 02/16/90, -mh.
*/

#include <stdio.h>
#include <stdlib.h>
#include "glocale.h"
#include "gis.h"
#include "Vect.h"
#include "trans.h"
#include "local_proto.h"

int 
create_transform_conversion (struct file_info *Coord, int quiet)
{
	if ( Coord->name[0] != '\0')
		create_transform_from_file( Coord, quiet) ;
	else
		create_transform_from_user () ;

	return 0;
}

int 
create_transform_from_user (void)
{
	int  status ;
	int  n_points;
	int  ok ;

init_transform_arrays() ;

n_points = 0 ;
ok = 0 ;
while (! ok)
 {
	/*  go to Vask page to enter the coordinates  */
	if ((n_points =  ask_transform_coor (n_points)) < 0)
		exit(-1) ;

	system("clear") ;

	status =  setup_transform( n_points) ;


	if (status != ALL_OK )
	{
		G_message ( _(" Number of points that have been entered: %d\n"), n_points );
		print_transform_error(status) ;
		continue ;
	}

	print_transform_resids( n_points) ;
	ok = yes_no_quest ("\n\n\nIf satisfied with the residuals, enter 'y', else 'n' and <Return>:  ");

 }		/*  while (!ok)   */


 return(0) ;

}			/*  create_transform_conversion()  */

int 
yes_no_quest (char *s)
{
    char buff[200];
    while (1)
    {
	G_message ( _("%s"),s);
	if (NULL == fgets(buff,200,stdin))
		exit(-1) ;
	switch (*buff)
	{
	    case 'Y': case 'y':
		return(1);
	    case 'N': case 'n':
		return(0);
	    default:
		G_message ( _("Please answer yes or no"));
	}
    }
}


int 
create_transform_from_file (struct file_info *Coord, int quiet)
{
	int  status ;
	int  n_points;

	init_transform_arrays() ;

	n_points = 0 ;
/*  Get the coordinates from the file.  */
	if ((n_points =  get_coor_from_file (Coord->fp) ) < 0)
		exit(-1) ;

	status =  setup_transform( n_points) ;

	if (status != ALL_OK )
	{
		G_message ( _("Number of points that have been entered: %d\n"), n_points );
		print_transform_error(status) ;
		exit(-1) ;
	}

	if (!quiet)
		print_transform_resids( n_points) ;

 return(0) ;

}			/*  create_transform_from_file()  */