GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73587
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
short_way.c
Go to the documentation of this file.
1 /*!
2  * \file lib/gis/short_way.c
3  *
4  * \brief GIS Library - Shortest path functions.
5  *
6  * (C) 2001-2009 by the GRASS Development Team
7  *
8  * This program is free software under the GNU General Public License
9  * (>=v2). Read the file COPYING that comes with GRASS for details.
10  *
11  * \author Original author CERL
12  */
13 
14 #include <grass/gis.h>
15 
16 /*!
17  * \brief Shortest way between two eastings.
18  *
19  * For lat-lon projection (<tt>PROJECTION_LL</tt>), <i>east1</i>,
20  * <i>east2</i> are changed so that they are no more than 180 degrees
21  * apart. Their true locations are not changed. For all other
22  * projections, this function does nothing.
23  *
24  * \param[in,out] east1 east (x) coordinate of first point
25  * \param[in,out] east2 east (x) coordinate of second point
26  */
27 
28 void G_shortest_way(double *east1, double *east2)
29 {
30  if (G_projection() == PROJECTION_LL) {
31  if (*east1 > *east2)
32  while ((*east1 - *east2) > 180)
33  *east2 += 360;
34  else if (*east2 > *east1)
35  while ((*east2 - *east1) > 180)
36  *east1 += 360;
37  }
38 }
#define PROJECTION_LL
Projection code - Latitude-Longitude.
Definition: gis.h:99
int G_projection(void)
Query cartographic projection.
Definition: proj1.c:32
void G_shortest_way(double *east1, double *east2)
Shortest way between two eastings.
Definition: short_way.c:28