6 #include <grass/lidar.h>
89 Overlap->
N = General->
N;
96 Overlap->
S = General->
S;
102 General->
W = orig.
west;
104 Overlap->
W = General->
W;
110 General->
E = orig.
east;
111 Overlap->
E = General->
E;
121 int total_splines, edge_splines, n_windows;
122 int lastsplines, lastsplines_min, lastsplines_max;
123 double E_extension, N_extension, edgeE, edgeN;
129 E_extension = orig.
east - orig.
west;
139 total_splines = ceil(E_extension / pe);
140 edge_splines = edgeE / pe;
141 n_windows = E_extension / edgeE;
147 lastsplines = total_splines - edge_splines * n_windows;
148 while (lastsplines > lastsplines_max || lastsplines < lastsplines_min) {
153 edge_splines = edgeE / pe;
154 n_windows = E_extension / edgeE;
155 lastsplines = total_splines - edge_splines * n_windows;
161 total_splines = ceil(N_extension / pn);
162 edge_splines = edgeN / pn;
163 n_windows = N_extension / edgeN;
169 lastsplines = total_splines - edge_splines * n_windows;
170 while (lastsplines > lastsplines_max || lastsplines < lastsplines_min) {
175 edge_splines = edgeN / pn;
176 n_windows = N_extension / edgeN;
177 lastsplines = total_splines - edge_splines * n_windows;
213 return (2 * nsplines + 1);
216 return (4 * nsplines + 3);
224 int i, mean_count = 0;
234 for (i = 0; i < npoints; i++) {
236 (obs[i].coordX, obs[i].coordY, obs[i].coordZ, &mean_box)) {
244 mean /= (double)mean_count;
251 int type, npoints = 0;
252 double xmin = 0, xmax = 0, ymin = 0, ymax = 0;
272 if (points->
z !=
NULL)
302 *dist = sqrt(((xmax - xmin) * (ymax - ymin)) / npoints);
304 *dens = npoints / ((xmax - xmin) * (ymax - ymin));
314 int *num_points,
int dim_vect,
317 int line_num, pippo, npoints,
cat, type;
346 if (points->
z !=
NULL)
354 if (npoints >= pippo) {
359 sizeof(
struct Point));
364 obs[npoints - 1].
coordY = y;
365 obs[npoints - 1].
coordZ = z;
366 obs[npoints - 1].
lineID = line_num;
369 obs[npoints - 1].
cat =
cat;
375 *num_points = npoints;
382 int *num_points,
int dim_vect)
384 int col, row, startcol, endcol, startrow, endrow, nrows, ncols;
397 nrows = Original->
rows;
398 ncols = Original->
cols;
411 if (Elaboration->
west > Original->
west)
412 startcol = (Elaboration->
west - Original->
west) / Original->
ew_res - 1;
416 endcol = (Elaboration->
east - Original->
west) / Original->
ew_res + 1;
423 for (row = startrow; row < endrow; row++) {
424 for (col = startcol; col < endcol; col++) {
435 if (npoints >= pippo) {
440 sizeof(
struct Point));
445 obs[npoints - 1].
coordY = y;
446 obs[npoints - 1].
coordZ = z;
452 *num_points = npoints;
465 "Intermediate interpolated values");
476 G_debug(1,
_(
"<%s> created in database."), tab_name);
480 G_warning(
_(
"<%s> has not been created in database."), tab_name);
494 "Intermediate interpolated values");
513 G_debug(1,
_(
"<%s> created in database."), tab_name);
517 G_warning(
_(
"<%s> has not been created in database."), tab_name);
536 int ncols, col, nrows, row;
544 for (row = 0; row < nrows; row++) {
549 for (col = 0, ptr = raster; col < ncols;
564 int more, line_num, type,
count = 0;
583 sprintf(buf,
"select ID, X, Y, sum(Interp) from %s group by ID, X, Y",
#define DB_SQL_TYPE_INTEGER
#define DB_SQL_TYPE_DOUBLE_PRECISION
dbValue * db_get_column_value(dbColumn *)
Returns column value for given column structure.
dbColumn * db_get_table_column(dbTable *, int)
Returns column structure for given table and column number.
double db_get_value_double(dbValue *)
Get double precision value.
int db_sqltype_to_Ctype(int)
Get C data type based on given SQL data type.
int db_get_column_sqltype(dbColumn *)
Returns column sqltype for column.
void db_set_column_sqltype(dbColumn *, int)
Define column sqltype for column.
dbTable * db_get_cursor_table(dbCursor *)
Get table allocated by cursor.
int db_set_table_description(dbTable *, const char *)
Set the description of the table.
void db_zero_string(dbString *)
Zero string.
int db_set_table_name(dbTable *, const char *)
Set the name of the table.
int db_execute_immediate(dbDriver *, dbString *)
Execute SQL statements.
dbTable * db_alloc_table(int)
Allocate a table with a specific number of columns.
int db_get_value_int(dbValue *)
Get integer value.
void db_init_string(dbString *)
Initialize dbString.
int db_open_select_cursor(dbDriver *, dbString *, dbCursor *, int)
Open select cursor.
int db_set_column_name(dbColumn *, const char *)
Set column name.
int db_append_string(dbString *, const char *)
Append string to dbString.
int db_create_table(dbDriver *, dbTable *)
Create table.
int db_fetch(dbCursor *, int, int *)
Fetch data from open cursor.
void G_percent(long, long, int)
Print percent complete messages.
void G_warning(const char *,...) __attribute__((format(printf
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
#define G_incr_void_ptr(ptr, size)
int G_debug(int, const char *,...) __attribute__((format(printf
void G_get_window(struct Cell_head *)
Get the current region.
void * Rast_allocate_buf(RASTER_MAP_TYPE)
Allocate memory for a raster map of given type.
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
void Rast_set_d_value(void *, DCELL, RASTER_MAP_TYPE)
Places a DCELL raster value.
size_t Rast_cell_size(RASTER_MAP_TYPE)
Returns size of a raster cell in bytes.
void Rast_put_d_row(int, const DCELL *)
Writes the next row for dcell file (DCELL version)
int Rast_window_cols(void)
Number of columns in active window.
int Rast_window_rows(void)
Number of rows in active window.
#define Rast_is_d_null_value(dcellVal)
double Rast_row_to_northing(double, const struct Cell_head *)
Row to northing.
double Rast_col_to_easting(double, const struct Cell_head *)
Column to easting.
int Segment_get(SEGMENT *, void *, off_t, off_t)
Get value from segment file.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_read_next_line(const struct Map_info *, struct line_pnts *, struct line_cats *)
Read next vector feature.
int Vect_reset_cats(struct line_cats *)
Reset category structure to make sure cats structure is clean to be re-used.
int Vect_region_box(const struct Cell_head *, struct bound_box *)
Copy region window to bounding box.
int Vect_cat_set(struct line_cats *, int, int)
Add new field/cat to category structure if doesn't exist yet.
int Vect_cat_get(const struct line_cats *, int, int *)
Get first found category of given field.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_copy_xyz_to_pnts(struct line_pnts *, const double *, const double *, const double *, int)
Copy points from array to line_pnts structure.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_rewind(struct Map_info *)
Rewind vector map to cause reads to start at beginning.
int Vect_point_in_box(double, double, double, const struct bound_box *)
Tests if point is in 3D box.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
#define GV_POINT
Feature types used in memory on run time (may change)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
2D/3D raster map header (used also for region)
double ew_res
Resolution - east to west cell size for 2D data.
double north
Extent coordinates (north)
double east
Extent coordinates (east)
double ns_res
Resolution - north to south cell size for 2D data.
int rows
Number of rows for 2D data.
int cols
Number of columns for 2D data.
double south
Extent coordinates (south)
double west
Extent coordinates (west)
int * cat
Array of categories.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
double * z
Array of Z coordinates.
struct Point * P_Read_Vector_Region_Map(struct Map_info *Map, struct Cell_head *Elaboration, int *num_points, int dim_vect, int layer)
void P_Aux_to_Vector(struct Map_info *Map, struct Map_info *Out, dbDriver *driver, char *tab_name)
void P_Aux_to_Raster(double **matrix, int fd)
double P_Mean_Calc(struct Cell_head *Elaboration, struct Point *obs, int npoints)
struct Point * P_Read_Raster_Region_Map(SEGMENT *in_seg, struct Cell_head *Elaboration, struct Cell_head *Original, int *num_points, int dim_vect)
double P_estimate_splinestep(struct Map_info *Map, double *dens, double *dist)
int P_get_edge(int interpolator, struct Reg_dimens *dim, double pe, double pn)
void P_zero_dim(struct Reg_dimens *dim)
int P_get_BandWidth(int interpolator, int nsplines)
int P_Create_Aux2_Table(dbDriver *driver, char *tab_name)
int P_set_dim(struct Reg_dimens *dim, double pe, double pn, int *nsplx, int *nsply)
int P_Drop_Aux_Table(dbDriver *driver, char *tab_name)
int P_Create_Aux4_Table(dbDriver *driver, char *tab_name)
int P_set_regions(struct Cell_head *Elaboration, struct bound_box *General, struct bound_box *Overlap, struct Reg_dimens dim, int type)