PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void lwprint_normalize_latlon ( double *  lat,
double *  lon 
)
static

Definition at line 15 of file lwprint.c.

Referenced by lwdoubles_to_latlon().

16 {
17  /* First remove all the truly excessive trips around the world via up or down. */
18  while (*lat > 270)
19  {
20  *lat -= 360;
21  }
22  while (*lat < -270)
23  {
24  *lat += 360;
25  }
26 
27  /* Now see if latitude is past the top or bottom of the world.
28  * Past 90 or -90 puts us on the other side of the earth,
29  * so wrap latitude and add 180 to longitude to reflect that. */
30  if (*lat > 90)
31  {
32  *lat = 180 - *lat;
33  *lon += 180;
34  }
35  if (*lat < -90)
36  {
37  *lat = -180 - *lat;
38  *lon += 180;
39  }
40  /* Now make sure lon is in the normal range. Wrapping longitude
41  * has no effect on latitude. */
42  while (*lon > 180)
43  {
44  *lon -= 360;
45  }
46  while (*lon < -180)
47  {
48  *lon += 360;
49  }
50 }

Here is the caller graph for this function: