GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
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 * SPDX-FileCopyrightText: 2001-2009 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Original author CERL
10 */
11
12#include <grass/gis.h>
13
14/*!
15 * \brief Shortest way between two eastings.
16 *
17 * For lat-lon projection (<tt>PROJECTION_LL</tt>), <i>east1</i>,
18 * <i>east2</i> are changed so that they are no more than 180 degrees
19 * apart. Their true locations are not changed. For all other
20 * projections, this function does nothing.
21 *
22 * \param[in,out] east1 east (x) coordinate of first point
23 * \param[in,out] east2 east (x) coordinate of second point
24 */
25void G_shortest_way(double *east1, double *east2)
26{
27 if (G_projection() == PROJECTION_LL) {
28 if (*east1 > *east2)
29 while ((*east1 - *east2) > 180)
30 *east2 += 360;
31 else if (*east2 > *east1)
32 while ((*east2 - *east1) > 180)
33 *east1 += 360;
34 }
35}
int G_projection(void)
Query cartographic projection.
Definition proj1.c:30
#define PROJECTION_LL
Projection code - Latitude-Longitude.
Definition gis.h:126
void G_shortest_way(double *east1, double *east2)
Shortest way between two eastings.
Definition short_way.c:25