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

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

Definition at line 27 of file lwgeodetic.c.

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

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

Here is the caller graph for this function: