GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
raster/window.c File Reference

Raster Library - Window functions. More...

#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "R.h"
Include dependency graph for raster/window.c:

Go to the source code of this file.

Functions

void Rast_get_window (struct Cell_head *window)
 Read the current window. More...
 
void Rast_get_input_window (struct Cell_head *window)
 Read the current input window. More...
 
void Rast_get_output_window (struct Cell_head *window)
 Read the current output window. More...
 
int Rast_window_rows (void)
 Number of rows in active window. More...
 
int Rast_window_cols (void)
 Number of columns in active window. More...
 
int Rast_input_window_rows (void)
 Number of rows in active input window. More...
 
int Rast_input_window_cols (void)
 Number of columns in active input window. More...
 
int Rast_output_window_rows (void)
 Number of rows in active output window. More...
 
int Rast_output_window_cols (void)
 Number of columns in active output window. More...
 
double Rast_northing_to_row (double north, const struct Cell_head *window)
 Northing to row. More...
 
double Rast_easting_to_col (double east, const struct Cell_head *window)
 Easting to column. More...
 
double Rast_row_to_northing (double row, const struct Cell_head *window)
 Row to northing. More...
 
double Rast_col_to_easting (double col, const struct Cell_head *window)
 Column to easting. More...
 

Detailed Description

Raster Library - Window functions.

(C) 2001-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL

Definition in file raster/window.c.

Function Documentation

double Rast_col_to_easting ( double  col,
const struct Cell_head window 
)

Column to easting.

Converts a col relative to a window to an easting.

Note: col is a double:

  • col+0.0 will return the easting for the western edge of the column.
  • col+0.5 will return the easting for the center of the column.
  • col+1.0 will return the easting for the eastern edge of the column.
Parameters
colcolumn number
[in]windowpointer to Cell_head
Returns
east coordinate

Definition at line 264 of file raster/window.c.

References Cell_head::ew_res, and Cell_head::west.

Referenced by P_Read_Raster_Region_Map(), and P_Regular_Points().

double Rast_easting_to_col ( double  east,
const struct Cell_head window 
)

Easting to column.

Converts east relative to a window to a column.

Note: The result is a double. Casting it to an int will give the column number.

Parameters
easteast coordinate
windowpointer to Cell_head
Returns
column number

Definition at line 221 of file raster/window.c.

References Cell_head::ew_res, G_adjust_easting(), and Cell_head::west.

Referenced by Rast_get_sample_bilinear(), Rast_get_sample_cubic(), and Rast_get_sample_nearest().

void Rast_get_input_window ( struct Cell_head window)

Read the current input window.

Parameters
windowpointer to Cell_head

Definition at line 43 of file raster/window.c.

References Rast__init_window(), and R__::rd_window.

void Rast_get_output_window ( struct Cell_head window)

Read the current output window.

Parameters
windowpointer to Cell_head

Definition at line 56 of file raster/window.c.

References Rast__init_window(), and R__::wr_window.

void Rast_get_window ( struct Cell_head window)

Read the current window.

Parameters
windowpointer to Cell_head

Definition at line 26 of file raster/window.c.

References _, G_fatal_error(), Rast__init_window(), R__::split_window, and R__::wr_window.

int Rast_input_window_cols ( void  )

Number of columns in active input window.

This routine returns the number of columns in the active input window.

Returns
number of columns

Definition at line 152 of file raster/window.c.

References Cell_head::cols, Rast__init_window(), and R__::rd_window.

Referenced by Rast_allocate_c_input_buf(), Rast_allocate_d_input_buf(), Rast_allocate_f_input_buf(), Rast_allocate_input_buf(), Rast_allocate_null_input_buf(), and Rast_zero_input_buf().

int Rast_input_window_rows ( void  )

Number of rows in active input window.

This routine returns the number of rows in the active input window.

Returns
number of rows

Definition at line 138 of file raster/window.c.

References Rast__init_window(), R__::rd_window, and Cell_head::rows.

double Rast_northing_to_row ( double  north,
const struct Cell_head window 
)

Northing to row.

Converts a northing relative to a window to a row.

Note: The result is a double. Casting it to an integer will give the row number.

Parameters
northnorthing value
windowpointer to Cell_head
Returns
row number

Definition at line 201 of file raster/window.c.

References Cell_head::north, and Cell_head::ns_res.

Referenced by Rast_get_sample_bilinear(), Rast_get_sample_cubic(), and Rast_get_sample_nearest().

int Rast_output_window_cols ( void  )

Number of columns in active output window.

This routine returns the number of columns in the active output window.

Returns
number of columns

Definition at line 180 of file raster/window.c.

References Cell_head::cols, Rast__init_window(), and R__::wr_window.

Referenced by Rast_allocate_c_output_buf(), Rast_allocate_d_output_buf(), Rast_allocate_f_output_buf(), Rast_allocate_null_output_buf(), Rast_allocate_output_buf(), and Rast_zero_output_buf().

int Rast_output_window_rows ( void  )

Number of rows in active output window.

This routine returns the number of rows in the active output window.

Returns
number of rows

Definition at line 166 of file raster/window.c.

References Rast__init_window(), Cell_head::rows, and R__::wr_window.

double Rast_row_to_northing ( double  row,
const struct Cell_head window 
)

Row to northing.

Converts a row relative to a window to a northing.

Note: row is a double:

  • row+0.0 will return the northing for the northern edge of the row.
  • row+0.5 will return the northing for the center of the row.
  • row+1.0 will return the northing for the southern edge of the row.
Parameters
rowrow number
[in]windowpointer to Cell_head
Returns
north coordinate

Definition at line 244 of file raster/window.c.

References Cell_head::north, and Cell_head::ns_res.

Referenced by P_Read_Raster_Region_Map(), and P_Regular_Points().

int Rast_window_cols ( void  )

Number of columns in active window.

These routines return the number of rows and columns (respectively) in the active module region. Before raster maps can be read or written, it is necessary to known how many rows and columns are in the active region. For example:

int nrows, cols;
int row, col;
nrows = Rast_window_rows();
ncols = Rast_window_cols();
for (row = 0; row < nrows; row++) {
// read row ...
for (col = 0; col < ncols; col++) {
// process col ...
}
}
Returns
number of columns

Definition at line 120 of file raster/window.c.

References _, Cell_head::cols, G_fatal_error(), Rast__init_window(), R__::split_window, and R__::wr_window.

Referenced by create_raster(), P_Aux_to_Raster(), Rast_allocate_buf(), Rast_allocate_c_buf(), Rast_allocate_d_buf(), Rast_allocate_f_buf(), Rast_allocate_null_buf(), Rast_get_row_colors(), Rast_get_sample_bilinear(), Rast_get_sample_cubic(), Rast_get_sample_nearest(), Rast_map_to_img_str(), and Rast_zero_buf().

int Rast_window_rows ( void  )

Number of rows in active window.

This routine returns the number of rows in the active module window. Before raster files can be read or written, it is necessary to known how many rows are in the active window. For example:

int nrows, cols;
int row, col;
nrows = Rast_window_rows();
ncols = Rast_window_cols();
for (row = 0; row < nrows; row++) {
// read row ...
for (col = 0; col < ncols; col++) {
// process col ...
}
}
Returns
number of rows

Definition at line 85 of file raster/window.c.

References _, G_fatal_error(), Rast__init_window(), Cell_head::rows, R__::split_window, and R__::wr_window.

Referenced by create_raster(), I_compute_scatts(), P_Aux_to_Raster(), Rast_get_sample_bilinear(), Rast_get_sample_cubic(), Rast_get_sample_nearest(), and Rast_map_to_img_str().