Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-proj4 / src / pj_pr_list.c @ 7098

History | View | Annotate | Download (2.41 KB)

1
/* print projection's list of parameters */
2
#ifndef lint
3
static const char SCCSID[]="@(#)pj_pr_list.c        4.6   94/03/19 GIE REL";
4
#endif
5
#include <projects.h>
6
#include <stdio.h>
7
#include <string.h>
8
#define LINE_LEN 72
9
        static int
10
pr_list(PJ *P, int not_used) {
11
        paralist *t;
12
        int l, n = 1, flag = 0;
13

    
14
        (void)putchar('#');
15
        for (t = P->params; t; t = t->next)
16
                if ((!not_used && t->used) || (not_used && !t->used)) {
17
                        l = strlen(t->param) + 1;
18
                        if (n + l > LINE_LEN) {
19
                                (void)fputs("\n#", stdout);
20
                                n = 2;
21
                        }
22
                        (void)putchar(' ');
23
                        if (*(t->param) != '+')
24
                                (void)putchar('+');
25
                        (void)fputs(t->param, stdout);
26
                        n += l;
27
                } else
28
                        flag = 1;
29
        if (n > 1)
30
                (void)putchar('\n');
31
        return flag;
32
}
33
        void /* print link list of projection parameters */
34
pj_pr_list(PJ *P) {
35
        char const *s;
36

    
37
        (void)putchar('#');
38
        for (s = P->descr; *s ; ++s) {
39
                (void)putchar(*s);
40
                if (*s == '\n')
41
                        (void)putchar('#');
42
        }
43
        (void)putchar('\n');
44
        if (pr_list(P, 0)) {
45
                (void)fputs("#--- following specified but NOT used\n", stdout);
46
                (void)pr_list(P, 1);
47
        }
48
}
49

    
50
/************************************************************************/
51
/*                             pj_get_def()                             */
52
/*                                                                      */
53
/*      Returns the PROJ.4 command string that would produce this       */
54
/*      definition expanded as much as possible.  For instance,         */
55
/*      +init= calls and +datum= defintions would be expanded.          */
56
/************************************************************************/
57

    
58
char *pj_get_def( PJ *P, int options )
59

    
60
{
61
    paralist *t;
62
    int l;
63
    char *definition;
64
    int  def_max = 10;
65

    
66
    definition = (char *) pj_malloc(def_max);
67
    definition[0] = '\0';
68

    
69
    for (t = P->params; t; t = t->next)
70
    {
71
        /* skip unused parameters ... mostly appended defaults and stuff */
72
        if (!t->used)
73
            continue;
74

    
75
        /* grow the resulting string if needed */
76
        l = strlen(t->param) + 1;
77
        if( strlen(definition) + l + 5 > def_max )
78
        {
79
            char *def2;
80

    
81
            def_max = def_max * 2 + l + 5;
82
            def2 = (char *) pj_malloc(def_max);
83
            strcpy( def2, definition );
84
            pj_dalloc( definition );
85
            definition = def2;
86
        }
87

    
88
        /* append this parameter */
89
        strcat( definition, " +" );
90
        strcat( definition, t->param );
91
    }
92

    
93
    return definition;
94
}