PostGIS  2.2.7dev-r@@SVN_REVISION@@
double longitude_radians_normalize ( double  lon)

Convert a longitude to the range of -PI,PI.

Definition at line 26 of file lwgeodetic.c.

Referenced by geographic_point_init(), lwgeom_project_spheroid(), and point_deg2rad().

27 {
28  if ( lon == -1.0 * M_PI )
29  return M_PI;
30  if ( lon == -2.0 * M_PI )
31  return 0.0;
32 
33  if ( lon > 2.0 * M_PI )
34  lon = remainder(lon, 2.0 * M_PI);
35 
36  if ( lon < -2.0 * M_PI )
37  lon = remainder(lon, -2.0 * M_PI);
38 
39  if ( lon > M_PI )
40  lon = -2.0 * M_PI + lon;
41 
42  if ( lon < -1.0 * M_PI )
43  lon = 2.0 * M_PI + lon;
44 
45  if ( lon == -2.0 * M_PI )
46  lon *= -1.0;
47 
48  return lon;
49 }

Here is the caller graph for this function: