~ubuntu-branches/ubuntu/wily/proj/wily

« back to all changes in this revision

Viewing changes to src/PJ_geos.c

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine, Jerome Villeneuve Larouche, Francesco Paolo Lovergine
  • Date: 2013-11-25 15:11:25 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20131125151125-mvcw144wvgep1hev
Tags: 4.8.0-1
[ Jerome Villeneuve Larouche ]
* New upstream release
* Modified libproj-dev.install to remove nad_list.h and projects.h
* Modified proj-bin.install to remove nad2nad
* Modified proj-bin.manpages to remove nad2nad man
* Added symbols for libproj0

[ Francesco Paolo Lovergine ]
* Properly merged with current git master and sid version 4.7.0-2.
* Removed proj transitional package and obsolete conflicts/replaces against
  series 4.6 and older.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
** libproj -- library of cartographic projections
3
3
**
4
4
** Copyright (c) 2004   Gerald I. Evenden
 
5
** Copyright (c) 2012   Martin Raspaud
5
6
*/
6
7
static const char
7
 
LIBPROJ_ID[] = "$Id: PJ_geos.c 1504 2009-01-06 02:11:57Z warmerdam $";
 
8
LIBPROJ_ID[] = "$Id: PJ_geos.c 2176 2012-02-27 07:56:32Z warmerdam $";
8
9
/*
9
10
** See also (section 4.4.3.2):
10
11
**   http://www.eumetsat.int/en/area4/msg/news/us_doc/cgms_03_26.pdf
35
36
        double  radius_p_inv2; \
36
37
        double  radius_g; \
37
38
        double  radius_g_1; \
38
 
        double  C;
 
39
        double  C; \
 
40
        char *  sweep_axis; \
 
41
        int     flip_axis;
39
42
#define PJ_LIB__
40
43
#include        <projects.h>
41
44
 
54
57
        if (((P->radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.) F_ERROR;
55
58
/* Calculation based on view angles from satellite.*/
56
59
        tmp = P->radius_g - Vx;
57
 
        xy.x = P->radius_g_1 * atan(Vy / tmp);
58
 
        xy.y = P->radius_g_1 * atan(Vz / hypot(Vy, tmp));
 
60
        if(P->flip_axis)
 
61
          {
 
62
            xy.x = P->radius_g_1 * atan(Vy / hypot(Vz, tmp));
 
63
            xy.y = P->radius_g_1 * atan(Vz / tmp);
 
64
          }
 
65
        else
 
66
          {
 
67
            xy.x = P->radius_g_1 * atan(Vy / tmp);
 
68
            xy.y = P->radius_g_1 * atan(Vz / hypot(Vy, tmp));
 
69
          }
59
70
        return (xy);
60
71
}
61
72
FORWARD(e_forward); /* ellipsoid */
74
85
                F_ERROR;
75
86
/* Calculation based on view angles from satellite. */
76
87
        tmp = P->radius_g - Vx;
77
 
        xy.x = P->radius_g_1 * atan (Vy / tmp);
78
 
        xy.y = P->radius_g_1 * atan (Vz / hypot (Vy, tmp));
 
88
        if(P->flip_axis)
 
89
          {
 
90
            xy.x = P->radius_g_1 * atan (Vy / hypot (Vz, tmp));
 
91
            xy.y = P->radius_g_1 * atan (Vz / tmp);
 
92
          }
 
93
        else
 
94
          {
 
95
            xy.x = P->radius_g_1 * atan (Vy / tmp);
 
96
            xy.y = P->radius_g_1 * atan (Vz / hypot (Vy, tmp));
 
97
          }
79
98
        return (xy);
80
99
}
81
100
INVERSE(s_inverse); /* spheroid */
82
 
        double Vx, Vy, Vz, a, b, c, det, k;
 
101
        double Vx, Vy, Vz, a, b, det, k;
83
102
 
84
103
/* Setting three components of vector from satellite to position.*/
85
104
        Vx = -1.0;
86
 
        Vy = tan (xy.x / (P->radius_g - 1.0));
87
 
        Vz = tan (xy.y / (P->radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
 
105
        if(P->flip_axis)
 
106
          {
 
107
            Vz = tan (xy.y / (P->radius_g - 1.0));
 
108
            Vy = tan (xy.x / (P->radius_g - 1.0)) * sqrt (1.0 + Vz * Vz);
 
109
          }
 
110
        else
 
111
          {
 
112
            Vy = tan (xy.x / (P->radius_g - 1.0));
 
113
            Vz = tan (xy.y / (P->radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
 
114
          }
88
115
/* Calculation of terms in cubic equation and determinant.*/
89
116
        a   = Vy * Vy + Vz * Vz + Vx * Vx;
90
117
        b   = 2 * P->radius_g * Vx;
100
127
        return (lp);
101
128
}
102
129
INVERSE(e_inverse); /* ellipsoid */
103
 
        double Vx, Vy, Vz, a, b, c, det, k;
 
130
        double Vx, Vy, Vz, a, b, det, k;
104
131
 
105
132
/* Setting three components of vector from satellite to position.*/
106
133
        Vx = -1.0;
107
 
        Vy = tan (xy.x / P->radius_g_1);
108
 
        Vz = tan (xy.y / P->radius_g_1) * hypot(1.0, Vy);
 
134
        if(P->flip_axis)
 
135
          {
 
136
            Vz = tan (xy.y / P->radius_g_1);
 
137
            Vy = tan (xy.x / P->radius_g_1) * hypot(1.0, Vz);
 
138
          }
 
139
        else
 
140
          {
 
141
            Vy = tan (xy.x / P->radius_g_1);
 
142
            Vz = tan (xy.y / P->radius_g_1) * hypot(1.0, Vy);
 
143
          }
109
144
/* Calculation of terms in cubic equation and determinant.*/
110
145
        a = Vz / P->radius_p;
111
146
        a   = Vy * Vy + a * a + Vx * Vx;
124
159
}
125
160
FREEUP; if (P) free(P); }
126
161
ENTRY0(geos)
127
 
        if ((P->h = pj_param(P->params, "dh").f) <= 0.) E_ERROR(-30);
 
162
        if ((P->h = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
128
163
        if (P->phi0) E_ERROR(-46);
129
 
        P->radius_g = 1. + (P->radius_g_1 = P->h / P->a);
 
164
        P->sweep_axis = pj_param(P->ctx, P->params, "ssweep").s;
 
165
        if (P->sweep_axis == NULL)
 
166
          P->flip_axis = 0;
 
167
        else
 
168
          {
 
169
            if (P->sweep_axis[1] != '\0' ||
 
170
                (P->sweep_axis[0] != 'x' &&
 
171
                 P->sweep_axis[0] != 'y'))
 
172
              E_ERROR(-49);
 
173
            if (P->sweep_axis[0] == 'y')
 
174
              P->flip_axis = 1;
 
175
            else
 
176
              P->flip_axis = 0;
 
177
          }
 
178
        P->radius_g_1 = P->h / P->a;
 
179
        P->radius_g = 1. + P->radius_g_1;
130
180
        P->C  = P->radius_g * P->radius_g - 1.0;
131
181
        if (P->es) {
132
182
                P->radius_p      = sqrt (P->one_es);