PostGIS  2.1.10dev-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 83 of file lwgeodetic.c.

Referenced by gbox_centroid(), and ptarray_force_geodetic().

84 {
85  if ( lon > 360.0 )
86  lon = remainder(lon, 360.0);
87 
88  if ( lon < -360.0 )
89  lon = remainder(lon, -360.0);
90 
91  if ( lon > 180.0 )
92  lon = -360.0 + lon;
93 
94  if ( lon < -180.0 )
95  lon = 360 + lon;
96 
97  if ( lon == -180.0 )
98  return 180.0;
99 
100  if ( lon == -360.0 )
101  return 0.0;
102 
103  return lon;
104 }

Here is the caller graph for this function: