PostGIS  2.3.7dev-r@@SVN_REVISION@@
double longitude_degrees_normalize ( double  lon)

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

Parameters
lonlongitude in degrees

Definition at line 97 of file lwgeodetic.c.

Referenced by gbox_centroid(), and ptarray_force_geodetic().

98 {
99  if ( lon > 360.0 )
100  lon = remainder(lon, 360.0);
101 
102  if ( lon < -360.0 )
103  lon = remainder(lon, -360.0);
104 
105  if ( lon > 180.0 )
106  lon = -360.0 + lon;
107 
108  if ( lon < -180.0 )
109  lon = 360 + lon;
110 
111  if ( lon == -180.0 )
112  return 180.0;
113 
114  if ( lon == -360.0 )
115  return 0.0;
116 
117  return lon;
118 }

Here is the caller graph for this function: