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
dbValue * db_get_column_value(dbColumn *)
Returns column value for given column structure.
int db_create_table(dbDriver *, dbTable *)
Create table.
void Rast_put_d_row(int, const DCELL *)
Writes the next row for dcell file (DCELL version)
void db_set_column_sqltype(dbColumn *, int)
Define column sqltype for column.
2D/3D raster map header (used also for region)
#define Rast_is_d_null_value(dcellVal)
void db_init_string(dbString *)
Initialize dbString.
double west
Extent coordinates (west)
int db_fetch(dbCursor *, int, int *)
Fetch data from open cursor.
void P_zero_dim(struct Reg_dimens *dim)
int db_open_select_cursor(dbDriver *, dbString *, dbCursor *, int)
Open select cursor.
int Vect_copy_xyz_to_pnts(struct line_pnts *, const double *, const double *, const double *, int)
Copy points from array to line_pnts structure.
struct Point * P_Read_Vector_Region_Map(struct Map_info *Map, struct Cell_head *Elaboration, int *num_points, int dim_vect, int layer)
int db_get_value_int(dbValue *)
Get integer value.
int Segment_get(SEGMENT *, void *, off_t, off_t)
Get value from segment file.
#define G_incr_void_ptr(ptr, size)
void P_Aux_to_Vector(struct Map_info *Map, struct Map_info *Out, dbDriver *driver, char *tab_name)
#define GV_POINT
Feature types used in memory on run time (may change)
int db_set_column_name(dbColumn *, const char *)
Set column name.
double * x
Array of X coordinates.
int P_get_edge(int interpolator, struct Reg_dimens *dim, double pe, double pn)
Feature geometry info - coordinates.
int db_get_column_sqltype(dbColumn *)
Returns column sqltype for column.
int P_Create_Aux4_Table(dbDriver *driver, char *tab_name)
double north
Extent coordinates (north)
int db_append_string(dbString *, const char *)
Append string to dbString.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int db_set_table_description(dbTable *, const char *)
Set the description of the table.
size_t Rast_cell_size(RASTER_MAP_TYPE)
Returns size of a raster cell in bytes.
double south
Extent coordinates (south)
int db_execute_immediate(dbDriver *, dbString *)
Execute SQL statements.
int * cat
Array of categories.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
void P_Aux_to_Raster(double **matrix, int fd)
double P_estimate_splinestep(struct Map_info *Map, double *dens, double *dist)
int db_sqltype_to_Ctype(int)
Get C data type based on given SQL data type.
void db_zero_string(dbString *)
Zero string.
int P_Drop_Aux_Table(dbDriver *driver, char *tab_name)
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
int Vect_reset_cats(struct line_cats *)
Reset category structure to make sure cats structure is clean to be re-used.
int Vect_rewind(struct Map_info *)
Rewind vector map to cause reads to start at beginning.
int db_set_table_name(dbTable *, const char *)
Set the name of the table.
int P_Create_Aux2_Table(dbDriver *driver, char *tab_name)
dbTable * db_alloc_table(int)
Allocate a table with a specific number of columns.
#define DB_SQL_TYPE_DOUBLE_PRECISION
int P_set_dim(struct Reg_dimens *dim, double pe, double pn, int *nsplx, int *nsply)
void G_percent(long, long, int)
Print percent complete messages.
double * y
Array of Y coordinates.
void Rast_set_d_value(void *, DCELL, RASTER_MAP_TYPE)
Places a DCELL raster value.
int P_get_BandWidth(int interpolator, int nsplines)
int cols
Number of columns for 2D data.
int Vect_point_in_box(double, double, double, const struct bound_box *)
Tests if point is in 3D box.
double db_get_value_double(dbValue *)
Get double precision value.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
double Rast_col_to_easting(double, const struct Cell_head *)
Column to easting.
double ns_res
Resolution - north to south cell size for 2D data.
int Rast_window_rows(void)
Number of rows in active window.
void * Rast_allocate_buf(RASTER_MAP_TYPE)
Allocate memory for a raster map of given type.
int Rast_window_cols(void)
Number of columns in active window.
void G_warning(const char *,...) __attribute__((format(printf
dbColumn * db_get_table_column(dbTable *, int)
Returns column structure for given table and column number.
double P_Mean_Calc(struct Cell_head *Elaboration, struct Point *obs, int npoints)
double east
Extent coordinates (east)
double * z
Array of Z coordinates.
int P_set_regions(struct Cell_head *Elaboration, struct bound_box *General, struct bound_box *Overlap, struct Reg_dimens dim, int type)
dbTable * db_get_cursor_table(dbCursor *)
Get table allocated by cursor.
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
double ew_res
Resolution - east to west cell size for 2D data.
int Vect_read_next_line(const struct Map_info *, struct line_pnts *, struct line_cats *)
Read next vector feature.
int Vect_region_box(const struct Cell_head *, struct bound_box *)
Copy region window to bounding box.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int rows
Number of rows for 2D data.
void G_get_window(struct Cell_head *)
Get the current region.
int G_debug(int, const char *,...) __attribute__((format(printf
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
int Vect_cat_get(const struct line_cats *, int, int *)
Get first found category of given field.
struct Point * P_Read_Raster_Region_Map(SEGMENT *in_seg, struct Cell_head *Elaboration, struct Cell_head *Original, int *num_points, int dim_vect)
int Vect_cat_set(struct line_cats *, int, int)
Add new field/cat to category structure if doesn't exist yet.
double Rast_row_to_northing(double, const struct Cell_head *)
Row to northing.