GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
|
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "index.h"
#include <float.h>
#include <math.h>
#include <grass/gis.h>
Go to the source code of this file.
Macros | |
#define | BIG_NUM (FLT_MAX/4.0) |
#define | Undefined(x, t) ((x)->boundary[0] > (x)->boundary[t->ndims_alloc]) |
#define | UnitSphereVolume UnitSphereVolumes[NUMDIMS] |
Functions | |
struct RTree_Rect * | RTreeAllocRect (struct RTree *t) |
Create a new rectangle for a given tree. More... | |
void | RTreeFreeRect (struct RTree_Rect *r) |
Delete a rectangle. More... | |
RectReal * | RTreeAllocBoundary (struct RTree *t) |
Allocate the boundary array of a rectangle for a given tree. More... | |
void | RTreeFreeBoundary (struct RTree_Rect *r) |
Delete the boundary of a rectangle. More... | |
void | RTreeInitRect (struct RTree_Rect *r, struct RTree *t) |
Initialize a rectangle to have all 0 coordinates. More... | |
void | RTreeSetRect1D (struct RTree_Rect *r, struct RTree *t, double x_min, double x_max) |
Set one dimensional coordinates of a rectangle for a given tree. More... | |
void | RTreeSetRect2D (struct RTree_Rect *r, struct RTree *t, double x_min, double x_max, double y_min, double y_max) |
Set two dimensional coordinates of a rectangle for a given tree. More... | |
void | RTreeSetRect3D (struct RTree_Rect *r, struct RTree *t, double x_min, double x_max, double y_min, double y_max, double z_min, double z_max) |
Set three dimensional coordinates of a rectangle for a given tree. More... | |
void | RTreeSetRect4D (struct RTree_Rect *r, struct RTree *t, double x_min, double x_max, double y_min, double y_max, double z_min, double z_max, double t_min, double t_max) |
Set 4 dimensional coordinates of a rectangle for a given tree. More... | |
void | RTreeNullRect (struct RTree_Rect *r, struct RTree *t) |
void | RTreePrintRect (struct RTree_Rect *R, int depth, struct RTree *t) |
RectReal | RTreeRectVolume (struct RTree_Rect *R, struct RTree *t) |
RectReal | RTreeRectSphericalVolume (struct RTree_Rect *r, struct RTree *t) |
RectReal | RTreeRectSurfaceArea (struct RTree_Rect *r, struct RTree *t) |
RectReal | RTreeRectMargin (struct RTree_Rect *r, struct RTree *t) |
void | RTreeCombineRect (struct RTree_Rect *r1, struct RTree_Rect *r2, struct RTree_Rect *r3, struct RTree *t) |
int | RTreeExpandRect (struct RTree_Rect *r1, struct RTree_Rect *r2, struct RTree *t) |
int | RTreeCompareRect (struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t) |
int | RTreeOverlap (struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t) |
int | RTreeContained (struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t) |
int | RTreeContains (struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t) |
Variables | |
const double | UnitSphereVolumes [] |
Definition at line 31 of file rect.c.
Referenced by RTreeCombineRect(), RTreeExpandRect(), RTreeRectSphericalVolume(), RTreeRectSurfaceArea(), and RTreeRectVolume().
#define UnitSphereVolume UnitSphereVolumes[NUMDIMS] |
Definition at line 396 of file rect.c.
Referenced by RTreeRectVolume().
Allocate the boundary array of a rectangle for a given tree.
This method allocated the boundary coordinates array in provided rectangle. It does not release previously allocated memory.
r | The pointer to rectangle to initialize the boundary coordinates. This is usually a rectangle that was created on the stack or self allocated. |
t | The pointer to a RTree struct |
Definition at line 83 of file rect.c.
References assert, RTree_Rect::boundary, malloc(), and RTree::rectsize.
Referenced by RTreeAllocNode(), RTreeAllocRect(), and RTreeCreateTree().
struct RTree_Rect* RTreeAllocRect | ( | struct RTree * | t | ) |
Create a new rectangle for a given tree.
This method allocates a new rectangle and initializes the internal boundary coordinates based on the tree dimension.
Hence a call to RTreeNewBoundary() is not necessary.
t | The pointer to a RTree struct |
Definition at line 44 of file rect.c.
References assert, RTree_Rect::boundary, malloc(), r, and RTreeAllocBoundary().
void RTreeCombineRect | ( | struct RTree_Rect * | r1, |
struct RTree_Rect * | r2, | ||
struct RTree_Rect * | r3, | ||
struct RTree * | t | ||
) |
Definition at line 504 of file rect.c.
References RTree_Rect::boundary, MAX, MIN, RTree::ndims, RTree::ndims_alloc, RTree::nsides_alloc, and Undefined.
int RTreeCompareRect | ( | struct RTree_Rect * | r, |
struct RTree_Rect * | s, | ||
struct RTree * | t | ||
) |
int RTreeContained | ( | struct RTree_Rect * | r, |
struct RTree_Rect * | s, | ||
struct RTree * | t | ||
) |
int RTreeContains | ( | struct RTree_Rect * | r, |
struct RTree_Rect * | s, | ||
struct RTree * | t | ||
) |
int RTreeExpandRect | ( | struct RTree_Rect * | r1, |
struct RTree_Rect * | r2, | ||
struct RTree * | t | ||
) |
Definition at line 541 of file rect.c.
References RTree_Rect::boundary, RTree::ndims, RTree::ndims_alloc, and Undefined.
Referenced by RTreeNodeCover().
void RTreeFreeBoundary | ( | struct RTree_Rect * | r | ) |
Delete the boundary of a rectangle.
This method deletes (free) the memory of the boundary of a rectangle and sets the boundary pointer to NULL.
r | The pointer to the rectangle to delete the boundary from. |
Definition at line 100 of file rect.c.
References assert, RTree_Rect::boundary, free(), and NULL.
Referenced by RTreeDestroyTree(), RTreeFreeListBranch(), RTreeFreeNode(), and RTreeFreeRect().
void RTreeFreeRect | ( | struct RTree_Rect * | r | ) |
Delete a rectangle.
This method deletes (free) the allocated memory of a rectangle.
r | The pointer to the rectangle to be deleted |
Definition at line 65 of file rect.c.
References assert, free(), and RTreeFreeBoundary().
void RTreeInitRect | ( | struct RTree_Rect * | r, |
struct RTree * | t | ||
) |
Initialize a rectangle to have all 0 coordinates.
Definition at line 111 of file rect.c.
References RTree_Rect::boundary, and RTree::ndims_alloc.
Referenced by RTreeSetRect1D(), RTreeSetRect2D(), RTreeSetRect3D(), and RTreeSetRect4D().
void RTreeNullRect | ( | struct RTree_Rect * | r, |
struct RTree * | t | ||
) |
Definition at line 226 of file rect.c.
References RTree_Rect::boundary, RTree::ndims_alloc, RTree::nsides_alloc, and r.
Referenced by RTreeInitPVars().
int RTreeOverlap | ( | struct RTree_Rect * | r, |
struct RTree_Rect * | s, | ||
struct RTree * | t | ||
) |
void RTreePrintRect | ( | struct RTree_Rect * | R, |
int | depth, | ||
struct RTree * | t | ||
) |
Definition at line 306 of file rect.c.
Referenced by RTreePrintNode().
RectReal RTreeRectMargin | ( | struct RTree_Rect * | r, |
struct RTree * | t | ||
) |
Definition at line 486 of file rect.c.
References RTree_Rect::boundary, RTree::ndims, and RTree::ndims_alloc.
RectReal RTreeRectSphericalVolume | ( | struct RTree_Rect * | r, |
struct RTree * | t | ||
) |
Definition at line 434 of file rect.c.
References RTree_Rect::boundary, RTree::ndims, RTree::ndims_alloc, Undefined, and UnitSphereVolumes.
RectReal RTreeRectSurfaceArea | ( | struct RTree_Rect * | r, |
struct RTree * | t | ||
) |
Definition at line 458 of file rect.c.
References RTree_Rect::boundary, RTree::ndims, RTree::ndims_alloc, and Undefined.
RectReal RTreeRectVolume | ( | struct RTree_Rect * | R, |
struct RTree * | t | ||
) |
Definition at line 324 of file rect.c.
References assert, RTree_Rect::boundary, M_PI, RTree::ndims, RTree::ndims_alloc, r, sphere_volume(), Undefined, and UnitSphereVolume.
void RTreeSetRect1D | ( | struct RTree_Rect * | r, |
struct RTree * | t, | ||
double | x_min, | ||
double | x_max | ||
) |
Set one dimensional coordinates of a rectangle for a given tree.
All coordinates of the rectangle will be initialized to 0 before the x coordinates are set.
r | The pointer to the rectangle |
t | The pointer to the RTree |
x_min | The lower x coordinate |
x_max | The higher x coordinate |
Definition at line 130 of file rect.c.
References RTree_Rect::boundary, RTree::ndims_alloc, and RTreeInitRect().
void RTreeSetRect2D | ( | struct RTree_Rect * | r, |
struct RTree * | t, | ||
double | x_min, | ||
double | x_max, | ||
double | y_min, | ||
double | y_max | ||
) |
Set two dimensional coordinates of a rectangle for a given tree.
All coordinates of the rectangle will be initialized to 0 before the x and y coordinates are set.
r | The pointer to the rectangle |
t | The pointer to the RTree |
x_min | The lower x coordinate |
x_max | The higher x coordinate |
y_min | The lower y coordinate |
y_max | The higher y coordinate |
Definition at line 151 of file rect.c.
References RTree_Rect::boundary, RTree::ndims_alloc, and RTreeInitRect().
void RTreeSetRect3D | ( | struct RTree_Rect * | r, |
struct RTree * | t, | ||
double | x_min, | ||
double | x_max, | ||
double | y_min, | ||
double | y_max, | ||
double | z_min, | ||
double | z_max | ||
) |
Set three dimensional coordinates of a rectangle for a given tree.
All coordinates of the rectangle will be initialized to 0 before the x,y and z coordinates are set.
r | The pointer to the rectangle |
t | The pointer to the RTree |
x_min | The lower x coordinate |
x_max | The higher x coordinate |
y_min | The lower y coordinate |
y_max | The higher y coordinate |
z_min | The lower z coordinate |
z_max | The higher z coordinate |
Definition at line 176 of file rect.c.
References RTree_Rect::boundary, RTree::ndims_alloc, and RTreeInitRect().
void RTreeSetRect4D | ( | struct RTree_Rect * | r, |
struct RTree * | t, | ||
double | x_min, | ||
double | x_max, | ||
double | y_min, | ||
double | y_max, | ||
double | z_min, | ||
double | z_max, | ||
double | t_min, | ||
double | t_max | ||
) |
Set 4 dimensional coordinates of a rectangle for a given tree.
All coordinates of the rectangle will be initialized to 0 before the x,y,z and t coordinates are set.
r | The pointer to the rectangle |
t | The pointer to the RTree |
x_min | The lower x coordinate |
x_max | The higher x coordinate |
y_min | The lower y coordinate |
y_max | The higher y coordinate |
z_min | The lower z coordinate |
z_max | The higher z coordinate |
t_min | The lower t coordinate |
t_max | The higher t coordinate |
Definition at line 206 of file rect.c.
References assert, RTree_Rect::boundary, RTree::ndims, RTree::ndims_alloc, and RTreeInitRect().
const double UnitSphereVolumes[] |
Definition at line 369 of file rect.c.
Referenced by RTreeRectSphericalVolume().