PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwprint_normalize_latlon()

static void lwprint_normalize_latlon ( double *  lat,
double *  lon 
)
static

Definition at line 14 of file lwprint.c.

Referenced by lwdoubles_to_latlon().

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