blob: 112a91526938bdb4b1b1101d58772bd4c0b3509d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* reduce argument to range +/- PI */
#include <math.h>
#include "proj.h"
#include "proj_internal.h"
double adjlon (double lon) {
/* Let lon slightly overshoot, to avoid spurious sign switching at the date line */
if (fabs (lon) < M_PI + 1e-12)
return lon;
/* adjust to 0..2pi range */
lon += M_PI;
/* remove integral # of 'revolutions'*/
lon -= M_TWOPI * floor(lon / M_TWOPI);
/* adjust back to -pi..pi range */
lon -= M_PI;
return lon;
}
|