PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwprint_normalize_latlon()

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

Definition at line 34 of file lwprint.c.

35 {
36  /* First remove all the truly excessive trips around the world via up or down. */
37  while (*lat > 270)
38  {
39  *lat -= 360;
40  }
41  while (*lat < -270)
42  {
43  *lat += 360;
44  }
45 
46  /* Now see if latitude is past the top or bottom of the world.
47  * Past 90 or -90 puts us on the other side of the earth,
48  * so wrap latitude and add 180 to longitude to reflect that. */
49  if (*lat > 90)
50  {
51  *lat = 180 - *lat;
52  *lon += 180;
53  }
54  if (*lat < -90)
55  {
56  *lat = -180 - *lat;
57  *lon += 180;
58  }
59  /* Now make sure lon is in the normal range. Wrapping longitude
60  * has no effect on latitude. */
61  while (*lon > 180)
62  {
63  *lon -= 360;
64  }
65  while (*lon < -180)
66  {
67  *lon += 360;
68  }
69 }

Referenced by lwdoubles_to_latlon().

Here is the caller graph for this function: