Skip to content

Commit 11b5a9f

Browse files
allixendersahrk
authored andcommitted
add cmath and/or _USE_MATH_DEFINES for MSVC in proj4 files
1 parent 7832a02 commit 11b5a9f

File tree

5 files changed

+57
-49
lines changed

5 files changed

+57
-49
lines changed

src/lib/proj4lib/include/proj4.h

+9-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PROJ4_H
88
#define PROJ4_H
99

10+
#define _USE_MATH_DEFINES
1011
#include <math.h>
1112
#include <stdlib.h>
1213
/*
@@ -21,13 +22,17 @@ extern long double usgs_hypot(long double, long double);
2122

2223
/* some useful constants */
2324

24-
#define FORTPI M_PI_4
25-
#define PI M_PI
26-
#define TWOPI 6.28318530717958647692528676655900576L
25+
#define FORTPI M_PI_4
26+
#define PI M_PI
27+
#define TWOPI 6.28318530717958647692528676655900576L
2728
#define RAD_TO_DEG M_180_PI
2829
#define DEG_TO_RAD M_PI_180
2930

30-
typedef union { long double f; int i; char *s; } PVALUE;
31+
typedef union {
32+
long double f;
33+
int i;
34+
char *s;
35+
} PVALUE;
3136

3237
/* procedure prototypes */
3338

@@ -49,4 +54,3 @@ long double pj_authlat(long double, long double *);
4954
*/
5055

5156
#endif
52-

src/lib/proj4lib/lib/adjlon.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/* reduce argument to range +/- PI */
22
#ifndef lint
3-
//static const char SCCSID[]="@(#)adjlon.c 4.3 93/06/12 GIE REL";
3+
// static const char SCCSID[]="@(#)adjlon.c 4.3 93/06/12 GIE
4+
// REL";
45
#endif
6+
#define _USE_MATH_DEFINES
57
#include <math.h>
68
/* note: PI adjusted high
79
** approx. true val: 3.14159265358979323844
810
*/
9-
#define SPI 3.14159265359
10-
#define TWOPI 6.2831853071795864769
11-
long double
12-
adjlon (long double lon) {
13-
while ( fabsl(lon) > SPI )
14-
lon += lon < 0. ? TWOPI : -TWOPI;
15-
return( lon );
11+
#define SPI 3.14159265359
12+
#define TWOPI 6.2831853071795864769
13+
long double adjlon(long double lon) {
14+
while (fabsl(lon) > SPI)
15+
lon += lon < 0. ? TWOPI : -TWOPI;
16+
return (lon);
1617
}

src/lib/proj4lib/lib/pj_phi2.cpp

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
/* determine latitude angle phi-2 */
22
#ifndef lint
3-
//static const char SCCSID[]="@(#)pj_phi2.c 4.3 93/06/12 GIE REL";
3+
// static const char SCCSID[]="@(#)pj_phi2.c 4.3 93/06/12 GIE
4+
// REL";
45
#endif
56
#include "proj4.h"
7+
#define _USE_MATH_DEFINES
8+
#include <math.h>
69

710
#define TOL 1.0e-10
811
#define N_ITER 15
912

10-
long double
11-
pj_phi2(long double ts, long double e) {
12-
long double eccnth, Phi, con, dphi;
13-
int i;
13+
long double pj_phi2(long double ts, long double e) {
14+
long double eccnth, Phi, con, dphi;
15+
int i;
1416

15-
eccnth = .5 * e;
16-
Phi = M_PI_2 - 2. * atan (ts);
17-
i = N_ITER;
18-
do {
19-
con = e * sin (Phi);
20-
dphi = M_PI_2 - 2. * atan (ts * pow((1. - con) /
21-
(1. + con), eccnth)) - Phi;
22-
Phi += dphi;
23-
} while ( fabsl(dphi) > TOL && --i);
24-
/*
25-
if (i <= 0)
26-
pj_errno = -18;
27-
*/
28-
return Phi;
17+
eccnth = .5 * e;
18+
Phi = M_PI_2 - 2. * atan(ts);
19+
i = N_ITER;
20+
do {
21+
con = e * sin(Phi);
22+
dphi = M_PI_2 - 2. * atan(ts * pow((1. - con) / (1. + con), eccnth)) - Phi;
23+
Phi += dphi;
24+
} while (fabsl(dphi) > TOL && --i);
25+
/*
26+
if (i <= 0)
27+
pj_errno = -18;
28+
*/
29+
return Phi;
2930
}

src/lib/proj4lib/lib/pj_qsfn.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/* determine small q */
22
#ifndef lint
3-
//static const char SCCSID[]="@(#)pj_qsfn.c 4.3 93/06/12 GIE REL";
3+
// static const char SCCSID[]="@(#)pj_qsfn.c 4.3 93/06/12 GIE
4+
// REL";
45
#endif
6+
#define _USE_MATH_DEFINES
57
#include <math.h>
68

7-
# define EPSILON 1.0e-7
8-
long double
9-
pj_qsfn(long double sinphi, long double e, long double one_es) {
10-
long double con;
9+
#define EPSILON 1.0e-7
10+
long double pj_qsfn(long double sinphi, long double e, long double one_es) {
11+
long double con;
1112

12-
if (e >= EPSILON) {
13-
con = e * sinphi;
14-
return (one_es * (sinphi / (1. - con * con) -
15-
(.5 / e) * log ((1. - con) / (1. + con))));
16-
} else
17-
return (sinphi + sinphi);
13+
if (e >= EPSILON) {
14+
con = e * sinphi;
15+
return (one_es * (sinphi / (1. - con * con) -
16+
(.5 / e) * log((1. - con) / (1. + con))));
17+
} else
18+
return (sinphi + sinphi);
1819
}

src/lib/proj4lib/lib/pj_tsfn.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/* determine small t */
22
#ifndef lint
3-
//static const char SCCSID[]="@(#)pj_tsfn.c 4.3 93/06/12 GIE REL";
3+
// static const char SCCSID[]="@(#)pj_tsfn.c 4.3 93/06/12 GIE
4+
// REL";
45
#endif
6+
#define _USE_MATH_DEFINES
57
#include <math.h>
6-
long double
7-
pj_tsfn(long double phi, long double sinphi, long double e) {
8-
sinphi *= e;
9-
return (tan (.5 * (M_PI_2 - phi)) /
10-
pow((1. - sinphi) / (1. + sinphi), .5 * e));
8+
long double pj_tsfn(long double phi, long double sinphi, long double e) {
9+
sinphi *= e;
10+
return (tan(.5 * (M_PI_2 - phi)) /
11+
pow((1. - sinphi) / (1. + sinphi), .5 * e));
1112
}

0 commit comments

Comments
 (0)