1 /*
2 ** libproj -- library of cartographic projections
3 **
4 ** Copyright (c) 2004, 2006   Gerald I. Evenden
5 */
6 static const char
7 LIBPROJ_ID[] = "Id";
8 /*
9 ** Permission is hereby granted, free of charge, to any person obtaining
10 ** a copy of this software and associated documentation files (the
11 ** "Software"), to deal in the Software without restriction, including
12 ** without limitation the rights to use, copy, modify, merge, publish,
13 ** distribute, sublicense, and/or sell copies of the Software, and to
14 ** permit persons to whom the Software is furnished to do so, subject to
15 ** the following conditions:
16 **
17 ** The above copyright notice and this permission notice shall be
18 ** included in all copies or substantial portions of the Software.
19 **
20 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 */
28   static struct
29 BARANYI {
30   short ypa[11];
31   short xpa[20];
32   struct SEG {
33     union {
34       struct {double X, Y, R2; } arc;
35       struct {double A, B, dum; } lin;
36     } tipe;
37     double limit;
38   } seg[3];
39 } baranyi[] = {
40 {{00,100,205,315,430,550,675,805,940,1080,1080},
41  {00,100,200,300,400,500,600,700,800,900,
42   1000,1100,1200,1300,1400,1500,1600,1700,1800,1800},
43  {  {{{80.0,0.0,10000.0}},81.241411756},
44   {{{0.0,111.465034594,56264.9014095}},9999},
45   {{{0,0,0}},0} } },
46 
47 {{00,100,210,330,460,600,750,910,1080,1260,1260},
48  {00,100,200,300,400,500,600,700,800,900,
49   1000,1100,1200,1300,1400,1500,1600,1700,1800,1800},
50  {  {{{75.0,0.0,11025.00000000}},89.732937686},
51     {{{0.0,123.428571429,62214.612245111755}},9999},
52   {{{0,0,0}},0} } },
53 
54 {{00,120,240,360,490,620,750,860,970,1080,1080},
55  {00,120,240,350,460,570,680,780,880,980,
56   1080,1180,1280,1380,1480,1570,1660,1750,1840,1840},
57  {  {{{94.0,0.0,8100.0000000}},78.300539425},
58   {{{0.0,165.869652378,78766.3642715}},9999},
59   {{{0,0,0}},0} } },
60 
61 {{00,120,240,360,490,620,750,870,990,1110,1110},
62  {00,120,240,350,460,570,680,780,880,980,
63   1080,1180,1280,1380,1480,1570,1660,1750,1840,1840},
64  {  {{{84.0,0.0,10000.0}},94.323113828},
65   {{{0.0,315.227272727,181669.688016296}},9999},
66   {{{0,0,0}},0} } },
67 
68 {{00,100,205,315,440,580,705,815,920,1020,1020},
69  {00,105,210,315,420,525,625,725,825,925,
70   1025,1125,1225,1325,1425,1510,1595,1680,1765,1765},
71  {  {{{86.5,0.0,8100.0}},89.129742863},
72   {{{102.995921508,-0.140082858,0}},101.013708578},
73   {{{0.0,0.0,10404.000}},9999} } },
74 
75 {{00,100,205,315,435,565,705,850,1000,1155,1155},
76  {00,105,210,315,420,525,625,725,825,925,
77   1025,1125,1225,1325,1425,1515,1605,1695,1785,1785},
78  {  {{{83.5,0.0,9025.000000}},92.807743792},
79   {{{115.5,-0.218634245,0}},9999},
80   {{{0,0,0}},0} } },
81 
82 {{00,120,240,355,470,585,695,805,905,995,995},
83  {00,120,240,355,470,580,690,795,900,1000,
84   1100,1200,1300,1400,1500,1590,1680,1760,1840,1840},
85  {  {{{94.0,0.0,8100.0}},87.968257449},
86   {{{0.0,460.302631579,313378.98632277}},9999},
87   {{{0,0,0}},0} } },
88 };
89   static struct
90 VOXC {
91   double a1, a2;
92 } voxc[] = {
93   {0.975, 0.0025},
94   {0.95,  0.005}
95 };
96 #define PROJ_PARMS__ \
97   struct BARANYI *p; \
98   struct VOXC *vox; \
99   int vopt; \
100   int mode;
101 #define PROJ_LIB__
102 # include   <lib_proj.h>
103 PROJ_HEAD(brny_1, "Baranyi 1") "\n\tPCyl., Sph., NoInv.";
104 PROJ_HEAD(brny_2, "Baranyi 2") "\n\tPCyl., Sph., NoInv.";
105 PROJ_HEAD(brny_3, "Baranyi 3") "\n\tPCyl., Sph., NoInv.";
106 PROJ_HEAD(brny_4, "Baranyi 4") "\n\tPCyl., Sph., NoInv.";
107 PROJ_HEAD(brny_5, "Baranyi 5") "\n\tPCyl., Sph., NoInv.";
108 PROJ_HEAD(brny_6, "Baranyi 6") "\n\tPCyl., Sph., NoInv.";
109 PROJ_HEAD(brny_7, "Baranyi 7") "\n\tPCyl., Sph., NoInv.";
110   static double
xyp(double lp,short * pa)111 xyp(double lp, short *pa) {
112   int i;
113 
114   lp = fabs(lp) * RAD_TO_DEG * 0.1f;
115   i = (int)lp;
116   return ((pa[i] + (lp - i)*(pa[i+1]-pa[i]))*0.1);
117 }
118 FORWARD(s_forward); /* spheroid */
119   struct SEG *s;
120   double xl;
121 
122   xy.x = xyp(lp.lam, P->p->xpa);
123   if (P->vopt) { /* do Voxland's method? */
124     xy.y = lp.phi * RAD_TO_DEG;
125     xy.y = xy.y * (P->vox->a1 + P->vox->a2 * xy.y);
126   } else
127     xy.y = xyp(lp.phi, P->p->ypa);
128   for (s = P->p->seg; xy.y > s->limit; ++s) ;
129   if (s->tipe.arc.R2 > 0.) { /* for arc, R obviously non-zero */
130     double dy = xy.y + s->tipe.arc.Y;
131     xl = (s->tipe.arc.X + sqrt(fabs(s->tipe.arc.R2 - dy * dy)));
132   } else  /* for line, R==0 */
133     xl = (xy.y - s->tipe.lin.A) / s->tipe.lin.B;
134   xy.x *= DEG_TO_RAD * xl * 10. / P->p->xpa[19];
135   xy.y *= DEG_TO_RAD;
136   if (lp.phi < 0.) xy.y = - xy.y;
137   if (lp.lam < 0.) xy.x = - xy.x;
138   return (xy);
139 }
140   static PROJ *
141 setup(PROJ *P, int n) {
142   if (((P->mode = n--) <= 2) && (P->vopt = proj_param(P->params, "tvopt").i))
143     P->vox = voxc + n;
144   else
145     P->vopt = 0;
146   P->p = baranyi + n;
147   P->es = 0.;
148   P->fwd = s_forward;
149   return P;
150 }
151 FREEUP; if (P) free(P); }
152 ENTRY0(brny_1) ENDENTRY(setup(P, 1))
153 ENTRY0(brny_2) ENDENTRY(setup(P, 2))
154 ENTRY0(brny_3) ENDENTRY(setup(P, 3))
155 ENTRY0(brny_4) ENDENTRY(setup(P, 4))
156 ENTRY0(brny_5) ENDENTRY(setup(P, 5))
157 ENTRY0(brny_6) ENDENTRY(setup(P, 6))
158 ENTRY0(brny_7) ENDENTRY(setup(P, 7))
159 /*
160 ** Log: proj_baranyi.c
161 ** Revision 3.1  2006/01/11 01:38:18  gie
162 ** Initial
163 **
164 */
165