GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
gis/window_map.c
Go to the documentation of this file.
1 /*!
2  \file lib/gis/window_map.c
3 
4  \brief GIS Library - Window mapping functions.
5 
6  (C) 2001-2009, 2011 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 #include "G.h"
17 
18 /*!
19  \brief Adjust east longitude.
20 
21  This routine returns an equivalent <i>east</i> that is at least as
22  large as the <i>west</i> coordinate.
23 
24  <b>Note:</b> This routine should be used only with
25  latitude-longitude coordinates.
26 
27  \param east east coordinate
28  \param west west coordinate
29 
30  \return east coordinate
31  */
32 double G_adjust_east_longitude(double east, double west)
33 {
34  double shift;
35 
36  shift = 0;
37  while (east + shift < west)
38  shift += 360.0;
39 
40  return east + shift;
41 }
42 
43 /*!
44  \brief Returns east not smaller than west.
45 
46  If the region projection is <tt>PROJECTION_LL</tt>, then this
47  routine returns an equivalent <i>east</i> that is not smaller than
48  the coordinate for the western edge of the region and, if possible,
49  smaller than the coordinate for the eastern edge of the region.
50  Otherwise no adjustment is made and the original <i>east</i> is
51  returned.
52 
53  \param east east coordinate
54  \param window pointer to Cell_head
55 
56  \return east coordinate
57  */
58 double G_adjust_easting(double east, const struct Cell_head *window)
59 {
60  double shift;
61 
62  shift = 0;
63  if (window->proj == PROJECTION_LL) {
64  while (east + shift >= window->east)
65  shift -= 360.0;
66  while (east + shift < window->west)
67  shift += 360.0;
68  }
69 
70  return east + shift;
71 }
72 
73 /*!
74  \brief Initialize window (region).
75  */
76 void G__init_window(void)
77 {
79  return;
80 
82 
84 }
int G_is_initialized(int *)
Definition: counter.c:60
void G_initialize_done(int *)
Definition: counter.c:77
void G_get_window(struct Cell_head *)
Get the current region.
Definition: get_window.c:47
double G_adjust_east_longitude(double east, double west)
Adjust east longitude.
void G__init_window(void)
Initialize window (region).
double G_adjust_easting(double east, const struct Cell_head *window)
Returns east not smaller than west.
#define PROJECTION_LL
Projection code - Latitude-Longitude.
Definition: gis.h:130
2D/3D raster map header (used also for region)
Definition: gis.h:440
double east
Extent coordinates (east)
Definition: gis.h:490
int proj
Projection code.
Definition: gis.h:472
Definition: G.h:5
int window_set
Definition: G.h:7
struct Cell_head window
Definition: G.h:6