PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ longitude_radians_normalize()

double longitude_radians_normalize ( double  lon)

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

Definition at line 41 of file lwgeodetic.c.

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

42 {
43  if ( lon == -1.0 * M_PI )
44  return M_PI;
45  if ( lon == -2.0 * M_PI )
46  return 0.0;
47 
48  if ( lon > 2.0 * M_PI )
49  lon = remainder(lon, 2.0 * M_PI);
50 
51  if ( lon < -2.0 * M_PI )
52  lon = remainder(lon, -2.0 * M_PI);
53 
54  if ( lon > M_PI )
55  lon = -2.0 * M_PI + lon;
56 
57  if ( lon < -1.0 * M_PI )
58  lon = 2.0 * M_PI + lon;
59 
60  if ( lon == -2.0 * M_PI )
61  lon *= -1.0;
62 
63  return lon;
64 }
Here is the caller graph for this function: