00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <string.h>
00018 #include <unistd.h>
00019 #include <stdlib.h>
00020 #include <grass/gis.h>
00021 #include <grass/glocale.h>
00022
00023 int G_ask_ellipse_name( char *spheriod)
00024 {
00025 char buff[1024],answer[50];
00026 double aa,e2;
00027 char *sph, *Tmp_file;
00028 FILE *Tmp_fd = NULL;
00029 int i;
00030
00031 Tmp_file = G_tempfile ();
00032 if (NULL == (Tmp_fd = fopen (Tmp_file, "w"))) {
00033 G_fatal_error(_("Cannot open temp file")) ;
00034 }
00035 fprintf(Tmp_fd,"sphere\n");
00036 for (i=0; (sph = G_ellipsoid_name(i)); i++) {
00037 fprintf(Tmp_fd,"%s\n",sph);
00038 }
00039
00040 fclose(Tmp_fd);
00041
00042 for(;;) {
00043 do {
00044 fprintf(stderr,_("\nPlease specify ellipsoid name\n"));
00045 fprintf(stderr,_("Enter 'list' for the list of available ellipsoids\n"));
00046 fprintf (stderr, _("Hit RETURN to cancel request\n"));
00047 fprintf(stderr,">");
00048 } while(!G_gets(answer));
00049 G_strip(answer);
00050 if(strlen(answer)==0) return -1;
00051 if (strcmp(answer,"list") == 0) {
00052 if (isatty(1)) {
00053 sprintf(buff,"$GRASS_PAGER %s",Tmp_file);
00054 }
00055 else
00056 sprintf(buff,"cat %s",Tmp_file);
00057 system(buff);
00058 }
00059 else {
00060 if (strcmp(answer,"sphere") == 0) break;
00061 if (G_get_ellipsoid_by_name(answer,&aa,&e2) == 0) {
00062 fprintf(stderr,_("\ninvalid ellipsoid\n"));
00063 }
00064 else break;
00065 }
00066 }
00067 sprintf(spheriod,"%s",answer);
00068 remove ( Tmp_file );
00069 if (strcmp(spheriod,"sphere") == 0) {
00070 return 2;
00071 }
00072 return 1;
00073 }