PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ longitude_degrees_normalize()

double longitude_degrees_normalize ( double  lon)

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

Parameters
lonlongitude in degrees

Definition at line 82 of file lwgeodetic.c.

Referenced by gbox_centroid(), and ptarray_force_geodetic().

83 {
84  if ( lon > 360.0 )
85  lon = remainder(lon, 360.0);
86 
87  if ( lon < -360.0 )
88  lon = remainder(lon, -360.0);
89 
90  if ( lon > 180.0 )
91  lon = -360.0 + lon;
92 
93  if ( lon < -180.0 )
94  lon = 360 + lon;
95 
96  if ( lon == -180.0 )
97  return 180.0;
98 
99  if ( lon == -360.0 )
100  return 0.0;
101 
102  return lon;
103 }
Here is the caller graph for this function: