PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ longitude_radians_normalize()

double longitude_radians_normalize ( double  lon)

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

Definition at line 50 of file lwgeodetic.c.

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

51 {
52  if ( lon == -1.0 * M_PI )
53  return M_PI;
54  if ( lon == -2.0 * M_PI )
55  return 0.0;
56 
57  if ( lon > 2.0 * M_PI )
58  lon = remainder(lon, 2.0 * M_PI);
59 
60  if ( lon < -2.0 * M_PI )
61  lon = remainder(lon, -2.0 * M_PI);
62 
63  if ( lon > M_PI )
64  lon = -2.0 * M_PI + lon;
65 
66  if ( lon < -1.0 * M_PI )
67  lon = 2.0 * M_PI + lon;
68 
69  if ( lon == -2.0 * M_PI )
70  lon *= -1.0;
71 
72  return lon;
73 }
Here is the caller graph for this function: