GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71817
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
region.c File Reference
#include <stdio.h>
#include <math.h>
#include <grass/raster.h>
#include "raster3d_intern.h"
Include dependency graph for region.c:

Go to the source code of this file.

Functions

void Rast3d_extract2d_region (RASTER3D_Region *region3d, struct Cell_head *region2d)
 Returns in region2d the 2d portion of region3d. More...
 
void Rast3d_region_to_cell_head (RASTER3D_Region *region3d, struct Cell_head *region2d)
 Returns in region2d the 2d portion of region3d. More...
 
void Rast3d_incorporate2d_region (struct Cell_head *region2d, RASTER3D_Region *region3d)
 Replaces the 2d portion of region3d with the values stored in region2d. More...
 
void Rast3d_region_from_to_cell_head (struct Cell_head *region2d, RASTER3D_Region *region3d)
 Replaces the 2d portion of region3d with the values stored in region2d. More...
 
void Rast3d_adjust_region (RASTER3D_Region *region)
 Computes an adjusts the resolutions in the region structure from the region boundaries and number of cells per dimension. More...
 
void Rast3d_adjust_region_res (RASTER3D_Region *region)
 Computes an adjusts the number of cells per dimension in the region structure from the region boundaries and resolutions. More...
 
void Rast3d_region_copy (RASTER3D_Region *regionDest, RASTER3D_Region *regionSrc)
 Copies the values of regionSrc into regionDst. More...
 
int Rast3d_read_region_map (const char *name, const char *mapset, RASTER3D_Region *region)
 
int Rast3d_is_valid_location (RASTER3D_Region *region, double north, double east, double top)
 Returns 1 if region-coordinates (north, east, top) are inside the region of map. Returns 0 otherwise. More...
 
void Rast3d_location2coord (RASTER3D_Region *region, double north, double east, double top, int *x, int *y, int *z)
 Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z). More...
 
void Rast3d_location2coord_double (RASTER3D_Region *region, double north, double east, double top, double *x, double *y, double *z)
 Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z). More...
 
void Rast3d_location2coord2 (RASTER3D_Region *region, double north, double east, double top, int *x, int *y, int *z)
 Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z). This function calls Rast3d_fatal_error in case location is not in window. More...
 
void Rast3d_coord2location (RASTER3D_Region *region, double x, double y, double z, double *north, double *east, double *top)
 Converts cell-coordinates (x, y, z) into region-coordinates (north, east, top). More...
 

Function Documentation

void Rast3d_adjust_region ( RASTER3D_Region region)

Computes an adjusts the resolutions in the region structure from the region boundaries and number of cells per dimension.

Parameters
region
Returns
void

Definition at line 151 of file region.c.

References RASTER3D_Region::bottom, RASTER3D_Region::depths, G_adjust_Cell_head3(), Rast3d_fatal_error(), Rast3d_region_from_to_cell_head(), Rast3d_region_to_cell_head(), RASTER3D_Region::tb_res, and RASTER3D_Region::top.

Referenced by Rast3d_fill_header(), Rast3d_open_cell_new(), Rast3d_open_cell_old(), Rast3d_set_window(), and Rast3d_set_window_map().

void Rast3d_adjust_region_res ( RASTER3D_Region region)

Computes an adjusts the number of cells per dimension in the region structure from the region boundaries and resolutions.

Parameters
region
Returns
void

Definition at line 177 of file region.c.

References RASTER3D_Region::bottom, RASTER3D_Region::depths, G_adjust_Cell_head3(), Rast3d_fatal_error(), Rast3d_region_from_to_cell_head(), Rast3d_region_to_cell_head(), RASTER3D_Region::tb_res, and RASTER3D_Region::top.

void Rast3d_coord2location ( RASTER3D_Region region,
double  x,
double  y,
double  z,
double *  north,
double *  east,
double *  top 
)

Converts cell-coordinates (x, y, z) into region-coordinates (north, east, top).

  • Note: x, y and z is a double:
  • x+0.0 will return the easting for the western edge of the column.
  • x+0.5 will return the easting for the center of the column.
  • x+1.0 will return the easting for the eastern edge of the column.
  • y+0.0 will return the northing for the northern edge of the row.
  • y+0.5 will return the northing for the center of the row.
  • y+1.0 will return the northing for the southern edge of the row.
  • z+0.0 will return the top for the lower edge of the depth.
  • z+0.5 will return the top for the center of the depth.
  • z+1.0 will return the top for the upper edge of the column.
Parameters
region
x
y
z
north
east
top
Returns
void

Definition at line 392 of file region.c.

References COORD_TO_LOCATION, and G_debug().

Referenced by Rast3d_nearest_neighbor().

void Rast3d_incorporate2d_region ( struct Cell_head region2d,
RASTER3D_Region region3d 
)
int Rast3d_is_valid_location ( RASTER3D_Region region,
double  north,
double  east,
double  top 
)

Returns 1 if region-coordinates (north, east, top) are inside the region of map. Returns 0 otherwise.

Parameters
region
north
east
top
Returns
int

Definition at line 263 of file region.c.

References RASTER3D_Region::bottom, Cell_head::bottom, RASTER3D_Region::south, RASTER3D_Region::top, and RASTER3D_Region::west.

Referenced by Rast3d_location2coord2().

void Rast3d_location2coord ( RASTER3D_Region region,
double  north,
double  east,
double  top,
int x,
int y,
int z 
)

Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z).

Parameters
region
north
east
top
x
y
z
Returns
void

Definition at line 290 of file region.c.

References int, and LOCATION_TO_COORD.

Referenced by Rast3d_get_region_value(), Rast3d_get_window_value(), and Rast3d_nearest_neighbor().

void Rast3d_location2coord2 ( RASTER3D_Region region,
double  north,
double  east,
double  top,
int x,
int y,
int z 
)

Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z). This function calls Rast3d_fatal_error in case location is not in window.

Parameters
region
north
east
top
x
y
z
Returns
void

Definition at line 347 of file region.c.

References int, LOCATION_TO_COORD, Rast3d_fatal_error(), and Rast3d_is_valid_location().

Referenced by Rast3d_get_volume_a().

void Rast3d_location2coord_double ( RASTER3D_Region region,
double  north,
double  east,
double  top,
double *  x,
double *  y,
double *  z 
)

Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z).

Note: The results are double numbers. Casting them to int will give the column, row and depth number.

Parameters
region
north
east
top
x
y
z
Returns
void

Definition at line 321 of file region.c.

References G_debug(), and LOCATION_TO_COORD.

int Rast3d_read_region_map ( const char *  name,
const char *  mapset,
RASTER3D_Region region 
)