GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
interpf.h File Reference
#include <grass/config.h>
#include <stdio.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/vector.h>
#include <grass/bitmap.h>
#include <grass/dataquad.h>
#include <grass/qtree.h>
#include <grass/dbmi.h>
Include dependency graph for interpf.h:

Go to the source code of this file.

Data Structures

struct  fcell_triple
 
struct  interp_params
 

Typedefs

typedef int grid_calc_fn(struct interp_params *, struct quaddata *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double)
 
typedef int matrix_create_fn(struct interp_params *, struct triple *, int, double **, int *)
 
typedef int check_points_fn(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple)
 
typedef int secpar_fn(struct interp_params *, int, int, int, struct BM *, double *, double *, double *, double *, double *, double *, int, int)
 
typedef double interp_fn(double, double)
 
typedef int interpder_fn(double, double, double *, double *)
 
typedef int wr_temp_fn(struct interp_params *, int, int, off_t)
 

Functions

double IL_dist_square (double *, double *, int)
 
double IL_crst (double, double)
 
int IL_crstg (double, double, double *, double *)
 
void IL_init_params_2d (struct interp_params *, FILE *, int, int, double, int, int, char *, int, int, DCELL *, DCELL *, DCELL *, DCELL *, DCELL *, DCELL *, double, int, int, int, int, double, char *, char *, char *, char *, char *, char *, double, double, double, int, double, double, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, struct TimeStamp *, int, const char *)
 
void IL_init_func_2d (struct interp_params *, grid_calc_fn *, matrix_create_fn *, check_points_fn *, secpar_fn *, interp_fn *, interpder_fn *, wr_temp_fn *)
 
int IL_input_data_2d (struct interp_params *, struct tree_info *, double *, double *, double *, double *, double *, double *, int *)
 
struct BMIL_create_bitmask (struct interp_params *)
 
int translate_quad (struct multtree *, double, double, double, int)
 
int IL_grid_calc_2d (struct interp_params *, struct quaddata *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double)
 
int IL_matrix_create (struct interp_params *, struct triple *, int, double **, int *)
 
int IL_matrix_create_alloc (struct interp_params *, struct triple *, int, double **, int *, double *)
 Creates system of linear equations from interpolated points. More...
 
int min1 (int, int)
 
int max1 (int, int)
 
double amax1 (double, double)
 
double amin1 (double, double)
 
int IL_interp_segments_new_2d (struct interp_params *, struct tree_info *, struct multtree *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, int, int, double)
 
int IL_output_2d (struct interp_params *, struct Cell_head *, double, double, double, double, double, double, double, double, double, double, double, char *, double, int, int, int)
 
int IL_check_at_points_2d (struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple)
 
int IL_resample_output_2d (struct interp_params *, double, double, double, double, double, double, double, double, double, double, double, char *, double *, struct Cell_head *, struct Cell_head *, char *, int)
 
int IL_resample_interp_segments_2d (struct interp_params *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double *, int, int, int, int, int, double, double, double, double, int)
 
int IL_secpar_loop_2d (struct interp_params *, int, int, int, struct BM *, double *, double *, double *, double *, double *, double *, int, int)
 
double smallest_segment (struct multtree *, int)
 
int IL_interp_segments_2d (struct interp_params *, struct tree_info *, struct multtree *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, int, off_t, double)
 
int IL_interp_segments_2d_parallel (struct interp_params *, struct tree_info *, struct multtree *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, int, off_t, double, int)
 
int IL_vector_input_data_2d (struct interp_params *, struct Map_info *, int, char *, char *, struct tree_info *, double *, double *, double *, double *, double *, double *, int *, double *)
 
int process_point (double, double, double, double, struct tree_info *, double, double *, double *, double *, double *, double *, double *, int *, int *, int *)
 
int IL_write_temp_2d (struct interp_params *, int, int, off_t)
 

Variables

struct line_pntsPnts
 
struct line_catsCats2
 
dbDriverdriver2
 
dbString sql2
 
struct Map_info Map2
 
struct field_infoff
 
int count
 

Typedef Documentation

◆ check_points_fn

typedef int check_points_fn(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple)

Definition at line 53 of file interpf.h.

◆ grid_calc_fn

typedef int grid_calc_fn(struct interp_params *, struct quaddata *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double)

Definition at line 44 of file interpf.h.

◆ interp_fn

typedef double interp_fn(double, double)

Definition at line 62 of file interpf.h.

◆ interpder_fn

typedef int interpder_fn(double, double, double *, double *)

Definition at line 64 of file interpf.h.

◆ matrix_create_fn

typedef int matrix_create_fn(struct interp_params *, struct triple *, int, double **, int *)

Definition at line 50 of file interpf.h.

◆ secpar_fn

typedef int secpar_fn(struct interp_params *, int, int, int, struct BM *, double *, double *, double *, double *, double *, double *, int, int)

Definition at line 57 of file interpf.h.

◆ wr_temp_fn

typedef int wr_temp_fn(struct interp_params *, int, int, off_t)

Definition at line 66 of file interpf.h.

Function Documentation

◆ amax1()

double amax1 ( double  ,
double   
)

Definition at line 54 of file minmax.c.

Referenced by IL_secpar_loop_2d().

◆ amin1()

double amin1 ( double  ,
double   
)

Definition at line 67 of file minmax.c.

Referenced by IL_secpar_loop_2d().

◆ IL_check_at_points_2d()

int IL_check_at_points_2d ( struct interp_params params,
struct quaddata data,
double *  b,
double *  ertot,
double  zmin,
double  dnorm,
struct triple  skip_point 
)

Checks if interpolating function interp() evaluates correct z-values at given points. If smoothing is used calculate the maximum error caused by smoothing.

ertot is a RMS deviation of the interpolated surface.

Todo:
Alternative description: ...calculate the maximum and RMS deviation caused by smoothing.
Parameters
datacurrent region
bsolution of linear equations
ertottotal error
zminmin z-value

Definition at line 53 of file point2d.c.

◆ IL_create_bitmask()

struct BM* IL_create_bitmask ( struct interp_params params)

Creates a bitmap mask from given raster map

Creates a bitmap mask from maskmap raster file and/or current MASK if present and returns a pointer to the bitmask. If no mask is in force returns NULL.

Definition at line 40 of file input2d.c.

References _, BM_create(), BM_set(), G_fatal_error(), G_find_raster2(), G_message(), interp_params::maskmap, interp_params::nsizc, interp_params::nsizr, NULL, Rast_allocate_c_buf(), Rast_close(), Rast_get_c_row(), Rast_is_c_null_value, Rast_maskfd(), and Rast_open_old().

◆ IL_crst()

double IL_crst ( double  r,
double  fi 
)

Radial basis function

Radial basis function - completely regularized spline with tension (d=2)

Parameters
rdistance squared
fitension

Definition at line 48 of file func2d.c.

◆ IL_crstg()

int IL_crstg ( double  r,
double  fi,
double *  gd1,
double *  gd2 
)

Function for calculating derivatives (d=2)

Derivatives of radial basis function - regularized spline with tension(d=2)

Parameters
rdistance squared
fitension
gd1G1(r)
gd2G2(r)

Definition at line 106 of file func2d.c.

References r, and x.

◆ IL_dist_square()

double IL_dist_square ( double *  ,
double *  ,
int   
)

Definition at line 19 of file rst/interp_float/distance.c.

◆ IL_grid_calc_2d()

int IL_grid_calc_2d ( struct interp_params params,
struct quaddata data,
struct BM bitmask,
double  zmin,
double  zmax,
double *  zminac,
double *  zmaxac,
double *  gmin,
double *  gmax,
double *  c1min,
double *  c1max,
double *  c2min,
double *  c2max,
double *  ertot,
double *  b,
off_t  offset1,
double  dnorm 
)

Calculates grid values for a given segment

Calculates grid for the given segment represented by data (contains n_rows, n_cols, ew_res,ns_res, and all points inside + overlap) using solutions of system of linear equations and interpolating functions interp() and interpder(). Also calls secpar() to compute slope, aspect and curvatures if required.

ertot can be also called RMS deviation of the interpolated surface

Parameters
datagiven segment
bitmaskbitmask
zmaxmin and max input z-values
zmaxacmin and max interp. z-values
gmaxmin and max interp. slope val.
c1maxmin and max interp. curv. val.
c2maxmin and max interp. curv. val.
ertottotal interpolating func. error
bsolutions of linear equations
offset1offset for temp file writing

Definition at line 65 of file interp2d.c.

◆ IL_init_func_2d()

void IL_init_func_2d ( struct interp_params params,
grid_calc_fn grid_f,
matrix_create_fn matr_f,
check_points_fn point_f,
secpar_fn secp_f,
interp_fn interp_f,
interpder_fn interpder_f,
wr_temp_fn temp_f 
)

Initializes functions used by the library

Parameters
grid_fcalculates grid for given segment
matr_fcreates matrix for a given segment
point_fchecks interpolation function at points
secp_fcalculates aspect, slope, curvature
interp_fradial basis function
interpder_fderivatives of radial basis function
temp_fwrites temp files

Definition at line 109 of file init2d.c.

References interp_params::check_points, interp_params::grid_calc, interp_params::interp, interp_params::interpder, interp_params::matrix_create, interp_params::secpar, and interp_params::wr_temp.

◆ IL_init_params_2d()

void IL_init_params_2d ( struct interp_params params,
FILE *  inp,
int  elatt,
int  smatt,
double  zm,
int  k1,
int  k2,
char *  msk,
int  rows,
int  cols,
DCELL ar1,
DCELL ar2,
DCELL ar3,
DCELL ar4,
DCELL ar5,
DCELL ar6,
double  tension,
int  k3,
int  sc1,
int  sc2,
int  sc3,
double  sm,
char *  f1,
char *  f2,
char *  f3,
char *  f4,
char *  f5,
char *  f6,
double  dm,
double  x_or,
double  y_or,
int  der,
double  tet,
double  scl,
FILE *  t1,
FILE *  t2,
FILE *  t3,
FILE *  t4,
FILE *  t5,
FILE *  t6,
FILE *  dev,
struct TimeStamp ts,
int  c,
const char *  wheresql 
)

Initializes parameters used by the library

Parameters
inpinput stream
elattwhich fp att in sites file? 1 = first
smattwhich fp att in sites file to use for smoothing? (if zero use sm) 1 = first
zmmultiplier for z-values
k1min number of points per segment for interpolation
k2max number of points per segment
mskname of mask
colsnumber of rows and columns
ar6arrays for interpolated values (ar1-ar6)
tensiontension
k3max number of points for interpolation
sc3multipliers for interpolation values
smsmoothing
f6output files (f1-f6)
dmmin distance between points
x_orx of origin
y_ory of origin
der1 if compute partial derivatives
tetanisotropy angle (0 is East, counter-clockwise)
sclanisotropy scaling factor
t6temp files for writing interp. values (t1-t6)
devpointer to deviations file
ccross validation
wheresqlSQL WHERE statement

Definition at line 31 of file init2d.c.

◆ IL_input_data_2d()

int IL_input_data_2d ( struct interp_params ,
struct tree_info ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
int *   
)

◆ IL_interp_segments_2d()

int IL_interp_segments_2d ( struct interp_params params,
struct tree_info info,
struct multtree tree,
struct BM bitmask,
double  zmin,
double  zmax,
double *  zminac,
double *  zmaxac,
double *  gmin,
double *  gmax,
double *  c1min,
double *  c1max,
double *  c2min,
double *  c2max,
double *  ertot,
int  totsegm,
off_t  offset1,
double  dnorm 
)

Interpolate recursively a tree of segments

Recursively processes each segment in a tree by:

  • finding points from neighbouring segments so that the total number of points is between KMIN and KMAX2 by calling tree function MT_get_region().
  • creating and solving the system of linear equations using these points and interp() by calling matrix_create() and G_ludcmp().
  • checking the interpolating function values at points by calling check_points().
  • computing grid for this segment using points and interp() by calling grid_calc().
Todo:
Isn't this in fact the updated version of the function (IL_interp_segments_new_2d)? The function IL_interp_segments_new_2d has the following, better behavior: The difference between this function and IL_interp_segments_2d() is making sure that additional points are taken from all directions, i.e. it finds equal number of points from neighboring segments in each of 8 neighborhoods.
Parameters
infoinfo for the quad tree
treecurrent leaf of the quad tree
bitmaskbitmask
zmaxmin and max input z-values
zmaxacmin and max interp. z-values
gmaxmin and max inperp. slope val.
c1maxmin and max interp. curv. val.
c2maxmin and max interp. curv. val.
ertottotal interplating func. error
totsegmtotal number of segments
offset1offset for temp file writing

Definition at line 47 of file segmen2d.c.

◆ IL_interp_segments_2d_parallel()

int IL_interp_segments_2d_parallel ( struct interp_params params,
struct tree_info info,
struct multtree tree,
struct BM bitmask,
double  zmin,
double  zmax,
double *  zminac,
double *  zmaxac,
double *  gmin,
double *  gmax,
double *  c1min,
double *  c1max,
double *  c2min,
double *  c2max,
double *  ertot,
int  totsegm,
off_t  offset1,
double  dnorm,
int  threads 
)

See documentation for IL_interp_segments_2d. This is a parallel processing implementation.

Parameters
infoinfo for the quad tree
treecurrent leaf of the quad tree
bitmaskbitmask
zmaxmin and max input z-values
zmaxacmin and max interp. z-values
gmaxmin and max inperp. slope val.
c1maxmin and max interp. curv. val.
c2maxmin and max interp. curv. val.
ertottotal interplating func. error
totsegmtotal number of segments
offset1offset for temp file writing

Definition at line 38 of file segmen2d_parallel.c.

References b, and NULL.

◆ IL_interp_segments_new_2d()

int IL_interp_segments_new_2d ( struct interp_params ,
struct tree_info ,
struct multtree ,
struct BM ,
double  ,
double  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
int  ,
int  ,
double   
)

◆ IL_matrix_create()

int IL_matrix_create ( struct interp_params params,
struct triple points,
int  n_points,
double **  matrix,
int *  indx 
)
Author
Lubos Mitas (original program and various modifications)
H. Mitasova, I. Kosinovsky, D. Gerdes, D. McCauley (GRASS4.1 version of the program and GRASS4.2 modifications)
L. Mitas, H. Mitasova, I. Kosinovsky, D.Gerdes, D. McCauley (1993, 1995)
modified by McCauley in August 1995
modified by Mitasova in August 1995, Nov. 1996

Definition at line 39 of file matrix.c.

◆ IL_matrix_create_alloc()

int IL_matrix_create_alloc ( struct interp_params params,
struct triple points,
int  n_points,
double **  matrix,
int *  indx,
double *  A 
)

Creates system of linear equations from interpolated points.

Creates system of linear equations represented by matrix using given points and interpolating function interp()

Parameters
paramsstruct interp_params *
pointspoints for interpolation as struct triple
n_pointsnumber of points
[out]matrixthe matrix
indx
Returns
-1 on failure, 1 on success

Definition at line 72 of file matrix.c.

◆ IL_output_2d()

int IL_output_2d ( struct interp_params params,
struct Cell_head cellhd,
double  zmin,
double  zmax,
double  zminac,
double  zmaxac,
double  c1min,
double  c1max,
double  c2min,
double  c2max,
double  gmin,
double  gmax,
double  ertot,
char *  input,
double  dnorm,
int  dtens,
int  vect,
int  n_points 
)

Creates output files as well as history files and color tables for them.

ertot can be also called RMS deviation of the interpolated surface.

Parameters
cellhdcurrent region
zmaxmin,max input z-values
c1maxmin,max interpolated values
ertottotal interpolating func. error
inputinput file name
dnormnormalization factor

Definition at line 59 of file output2d.c.

◆ IL_resample_interp_segments_2d()

int IL_resample_interp_segments_2d ( struct interp_params ,
struct BM ,
double  ,
double  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
off_t  ,
double *  ,
int  ,
int  ,
int  ,
int  ,
int  ,
double  ,
double  ,
double  ,
double  ,
int   
)

Definition at line 35 of file ressegm2d.c.

References l.

◆ IL_resample_output_2d()

int IL_resample_output_2d ( struct interp_params ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
double  ,
char *  ,
double *  ,
struct Cell_head ,
struct Cell_head ,
char *  ,
int   
)

Definition at line 45 of file resout2d.c.

◆ IL_secpar_loop_2d()

int IL_secpar_loop_2d ( struct interp_params params,
int  ngstc,
int  nszc,
int  k,
struct BM bitmask,
double *  gmin,
double *  gmax,
double *  c1min,
double *  c1max,
double *  c2min,
double *  c2max,
int  cond1,
int  cond2 
)

Compute slope aspect and curvatures

Computes slope, aspect and curvatures (depending on cond1, cond2) for derivative arrays adx,...,adxy between columns ngstc and nszc.

Parameters
ngstcstarting column
nszcending column
kcurrent row
c2maxmin,max interp. values
cond2determine if particular values need to be computed

Definition at line 39 of file secpar2d.c.

References interp_params::adx, interp_params::adxx, interp_params::adxy, interp_params::ady, interp_params::adyy, amax1(), amin1(), BM_get(), M_R2D, and NULL.

◆ IL_vector_input_data_2d()

int IL_vector_input_data_2d ( struct interp_params params,
struct Map_info Map,
int  field,
char *  zcol,
char *  scol,
struct tree_info info,
double *  xmin,
double *  xmax,
double *  ymin,
double *  ymax,
double *  zmin,
double *  zmax,
int *  n_points,
double *  dmax 
)

Insert into a quad tree

Inserts input data inside the region into a quad tree. Also translates data. Returns number of segments in the quad tree.

As z values may be used (in Map):

  • z coordinates in 3D file -> field = 0
  • categories -> field > 0, zcol = NULL
  • attributes -> field > 0, zcol != NULL
Parameters
paramsinterpolation parameters
Mapinput vector map
fieldcategory field number
zcolname of the column containing z values
scolname of the column containing smooth values
infoquadtree info
n_pointsnumber of points used for interpolation
dmaxmax distance between points

Definition at line 51 of file vinput2d.c.

◆ IL_write_temp_2d()

int IL_write_temp_2d ( struct interp_params params,
int  ngstc,
int  nszc,
off_t  offset2 
)

◆ max1()

int max1 ( int  ,
int   
)

Definition at line 32 of file minmax.c.

◆ min1()

int min1 ( int  ,
int   
)

Definition at line 18 of file minmax.c.

◆ process_point()

int process_point ( double  ,
double  ,
double  ,
double  ,
struct tree_info ,
double  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
int *  ,
int *  ,
int *   
)

Definition at line 306 of file vinput2d.c.

◆ smallest_segment()

double smallest_segment ( struct multtree ,
int   
)

Definition at line 346 of file segmen2d.c.

References multtree::data, multtree::leafs, NULL, and quaddata::xmax.

◆ translate_quad()

int translate_quad ( struct multtree ,
double  ,
double  ,
double  ,
int   
)

Variable Documentation

◆ Cats2

struct line_cats* Cats2

◆ count

◆ driver2

dbDriver* driver2

◆ ff

struct field_info* ff

◆ Map2

struct Map_info Map2

◆ Pnts

struct line_pnts* Pnts

◆ sql2

dbString sql2