GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
zones.c
Go to the documentation of this file.
1 #include <grass/config.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <math.h>
6 #include <grass/lidar.h>
7 
8 /*----------------------------------------------------------------------------------------*/
9 void P_zero_dim(struct Reg_dimens *dim)
10 {
11  dim->edge_h = 0.0;
12  dim->edge_v = 0.0;
13  dim->overlap = 0.0;
14  dim->sn_size = 0.0;
15  dim->ew_size = 0.0;
16  return;
17 }
18 
19 /*----------------------------------------------------------------------------------------*/
20 /*
21  --------------------------------------------
22  | Elaboration region |
23  | ------------------------------------ |
24  | | General region | |
25  | | ---------------------------- | |
26  | | | | | |
27  | | | | | |
28  | | | | | |
29  | | | Overlap region | | |
30  | | | | | |
31  | | | | | |
32  | | | | | |
33  | | ---------------------------- | |
34  | | | |
35  | ------------------------------------ |
36  | |
37  --------------------------------------------
38 
39  The terminology is misleading:
40  The Overlap region does NOT overlap with neighbouring segments,
41  but the Elaboration and General region do overlap
42 
43  Elaboration is used for interpolation
44  Interpolated points in Elaboration but outside General are discarded
45  Interpolated points in General but outside Overlap are weighed by
46  their distance to Overlap and summed up
47  Interpolated points in Overlap are taken as they are
48 
49  The buffer zones Elaboration - General and General - Overlap must be
50  large enough to avoid artifacts
51  */
52 
53 int
54 P_set_regions(struct Cell_head *Elaboration, struct bound_box * General,
55  struct bound_box * Overlap, struct Reg_dimens dim, int type)
56 {
57  /* Set the Elaboration, General, and Overlap region limits
58  * Returns 0 on success; -1 on failure*/
59  struct Cell_head orig;
60 
61  G_get_window(&orig);
62 
63  switch (type) {
64  case GENERAL_ROW: /* General case N-S direction */
65  Elaboration->north =
66  Elaboration->south + dim.overlap + (2 * dim.edge_h);
67  Elaboration->south = Elaboration->north - dim.sn_size;
68  General->N = Elaboration->north - dim.edge_h;
69  General->S = Elaboration->south + dim.edge_h;
70  Overlap->N = General->N - dim.overlap;
71  Overlap->S = General->S + dim.overlap;
72  return 0;
73 
74  case GENERAL_COLUMN: /* General case E-W direction */
75  Elaboration->west =
76  Elaboration->east - dim.overlap - (2 * dim.edge_v);
77  Elaboration->east = Elaboration->west + dim.ew_size;
78  General->W = Elaboration->west + dim.edge_v;
79  General->E = Elaboration->east - dim.edge_v;
80  Overlap->W = General->W + dim.overlap;
81  Overlap->E = General->E - dim.overlap;
82  return 0;
83 
84  case FIRST_ROW: /* Just started with first row */
85  Elaboration->north = orig.north + 2 * dim.edge_h;
86  Elaboration->south = Elaboration->north - dim.sn_size;
87  General->N = orig.north;
88  General->S = Elaboration->south + dim.edge_h;
89  Overlap->N = General->N;
90  Overlap->S = General->S + dim.overlap;
91  return 0;
92 
93  case LAST_ROW: /* Reached last row */
94  Elaboration->south = orig.south - 2 * dim.edge_h;
95  General->S = orig.south;
96  Overlap->S = General->S;
97  return 0;
98 
99  case FIRST_COLUMN: /* Just started with first column */
100  Elaboration->west = orig.west - 2 * dim.edge_v;
101  Elaboration->east = Elaboration->west + dim.ew_size;
102  General->W = orig.west;
103  General->E = Elaboration->east - dim.edge_v;
104  Overlap->W = General->W;
105  Overlap->E = General->E - dim.overlap;
106  return 0;
107 
108  case LAST_COLUMN: /* Reached last column */
109  Elaboration->east = orig.east + 2 * dim.edge_v;
110  General->E = orig.east;
111  Overlap->E = General->E;
112  return 0;
113  }
114 
115  return -1;
116 }
117 
118 /*----------------------------------------------------------------------------------------*/
119 int P_set_dim(struct Reg_dimens *dim, double pe, double pn, int *nsplx, int *nsply)
120 {
121  int total_splines, edge_splines, n_windows;
122  int lastsplines, lastsplines_min, lastsplines_max;
123  double E_extension, N_extension, edgeE, edgeN;
124  struct Cell_head orig;
125  int ret = 0;
126 
127  G_get_window(&orig);
128 
129  E_extension = orig.east - orig.west;
130  N_extension = orig.north - orig.south;
131  dim->ew_size = *nsplx * pe;
132  dim->sn_size = *nsply * pn;
133  edgeE = dim->ew_size - dim->overlap - 2 * dim->edge_v;
134  edgeN = dim->sn_size - dim->overlap - 2 * dim->edge_h;
135 
136  /* number of moving windows: E_extension / edgeE */
137  /* remaining steps: total steps - (floor(E_extension / edgeE) * E_extension) / passoE */
138  /* remaining steps must be larger than edge_v + overlap + half of overlap window */
139  total_splines = ceil(E_extension / pe);
140  edge_splines = edgeE / pe;
141  n_windows = E_extension / edgeE; /* without last one */
142  if (n_windows > 0) {
143  /* min size of the last overlap window = half of current overlap window */
144  /* max size of the last overlap window = elaboration - 3 * edge - overlap */
145  lastsplines_min = ceil((dim->ew_size / 2.0 - (dim->edge_v + dim->overlap)) / pe);
146  lastsplines_max = ceil((dim->ew_size - 3 * dim->edge_v - dim->overlap) / pe);
147  lastsplines = total_splines - edge_splines * n_windows;
148  while (lastsplines > lastsplines_max || lastsplines < lastsplines_min) {
149  *nsplx -= 1;
150  dim->ew_size = *nsplx * pe;
151  edgeE = dim->ew_size - dim->overlap - 2 * dim->edge_v;
152 
153  edge_splines = edgeE / pe;
154  n_windows = E_extension / edgeE; /* without last one */
155  lastsplines = total_splines - edge_splines * n_windows;
156  if (ret == 0)
157  ret = 1;
158  }
159  }
160 
161  total_splines = ceil(N_extension / pn);
162  edge_splines = edgeN / pn;
163  n_windows = N_extension / edgeN; /* without last one */
164  if (n_windows > 0) {
165  /* min size of the last overlap window = half of current overlap window */
166  /* max size of the last overlap window = elaboration - 3 * edge - overlap */
167  lastsplines_min = ceil((dim->sn_size / 2.0 - (dim->edge_h + dim->overlap)) / pn);
168  lastsplines_max = ceil((dim->sn_size - 3 * dim->edge_h - dim->overlap) / pn);
169  lastsplines = total_splines - edge_splines * n_windows;
170  while (lastsplines > lastsplines_max || lastsplines < lastsplines_min) {
171  *nsply -= 1;
172  dim->sn_size = *nsply * pn;
173  edgeN = dim->sn_size - dim->overlap - 2 * dim->edge_h;
174 
175  edge_splines = edgeN / pn;
176  n_windows = N_extension / edgeN; /* without last one */
177  lastsplines = total_splines - edge_splines * n_windows;
178  if (ret < 2)
179  ret += 2;
180  }
181  }
182 
183  return ret;
184 }
185 
186 /*----------------------------------------------------------------------------------------*/
187 int P_get_edge(int interpolator, struct Reg_dimens *dim, double pe, double pn)
188 {
189  /* Set the edge regions dimension
190  * Returns 1 on success of bilinear; 2 on success of bicubic, 0 on failure */
191  if (interpolator == P_BILINEAR) {
192  /* in case of edge artifacts, increase as multiples of 3 */
193  dim->edge_v = 9 * pe;
194  dim->edge_h = 9 * pn;
195  return 1;
196  }
197  else if (interpolator == P_BICUBIC) {
198  /* in case of edge artifacts, increase as multiples of 4 */
199  dim->edge_v = 12 * pe; /*3 */
200  dim->edge_h = 12 * pn;
201  return 2;
202  }
203  else
204  return 0; /* The interpolator is neither bilinear nor bicubic!! */
205 }
206 
207 /*----------------------------------------------------------------------------------------*/
208 int P_get_BandWidth(int interpolator, int nsplines)
209 {
210  /* Returns the interpolation matrixes BandWidth dimension */
211 
212  if (interpolator == P_BILINEAR) {
213  return (2 * nsplines + 1);
214  }
215  else {
216  return (4 * nsplines + 3);
217  }
218 }
219 
220 /*----------------------------------------------------------------------------------------*/
221 double
222 P_Mean_Calc(struct Cell_head *Elaboration, struct Point *obs, int npoints)
223 {
224  int i, mean_count = 0;
225  double mean = 0.0;
226  struct bound_box mean_box;
227 
228  Vect_region_box(Elaboration, &mean_box);
229  mean_box.W -= CONTOUR;
230  mean_box.E += CONTOUR;
231  mean_box.N += CONTOUR;
232  mean_box.S -= CONTOUR;
233 
234  for (i = 0; i < npoints; i++) { /* */
236  (obs[i].coordX, obs[i].coordY, obs[i].coordZ, &mean_box)) {
237  mean_count++;
238  mean += obs[i].coordZ;
239  }
240  }
241  if (mean_count == 0)
242  mean = .0;
243  else
244  mean /= (double)mean_count;
245 
246  return mean;
247 }
248 
249 double P_estimate_splinestep(struct Map_info *Map, double *dens, double *dist)
250 {
251  int type, npoints = 0;
252  double xmin = 0, xmax = 0, ymin = 0, ymax = 0;
253  double x, y, z;
254  struct line_pnts *points;
255  struct line_cats *categories;
256  struct bound_box region_box;
257  struct Cell_head orig;
258 
259  G_get_set_window(&orig);
260  Vect_region_box(&orig, &region_box);
261 
262  points = Vect_new_line_struct();
263  categories = Vect_new_cats_struct();
264 
265  Vect_rewind(Map);
266  while ((type = Vect_read_next_line(Map, points, categories)) > 0) {
267  if (!(type & GV_POINT))
268  continue;
269 
270  x = points->x[0];
271  y = points->y[0];
272  if (points->z != NULL)
273  z = points->z[0];
274  else
275  z = 0.0;
276 
277  /* only use points in current region */
278  if (Vect_point_in_box(x, y, z, &region_box)) {
279  npoints++;
280 
281  if (npoints > 1) {
282  if (xmin > x)
283  xmin = x;
284  else if (xmax < x)
285  xmax = x;
286  if (ymin > y)
287  ymin = y;
288  else if (ymax < y)
289  ymax = y;
290  }
291  else {
292  xmin = xmax = x;
293  ymin = ymax = y;
294  }
295  }
296  }
297  Vect_destroy_cats_struct(categories);
298  Vect_destroy_line_struct(points);
299 
300  if (npoints > 0) {
301  /* estimated average distance between points in map units */
302  *dist = sqrt(((xmax - xmin) * (ymax - ymin)) / npoints);
303  /* estimated point density as number of points per square map unit */
304  *dens = npoints / ((xmax - xmin) * (ymax - ymin));
305  return 0;
306  }
307  else {
308  return -1;
309  }
310 }
311 
313  struct Cell_head *Elaboration,
314  int *num_points, int dim_vect,
315  int layer)
316 {
317  int line_num, pippo, npoints, cat, type;
318  double x, y, z;
319  struct Point *obs;
320  struct line_pnts *points;
321  struct line_cats *categories;
322  struct bound_box elaboration_box;
323 
324  pippo = dim_vect;
325  obs = (struct Point *)G_calloc(pippo, sizeof(struct Point));
326 
327  points = Vect_new_line_struct();
328  categories = Vect_new_cats_struct();
329 
330  /* Reading points inside elaboration zone */
331  Vect_region_box(Elaboration, &elaboration_box);
332 
333  npoints = 0;
334  line_num = 0;
335 
336  Vect_rewind(Map);
337  while ((type = Vect_read_next_line(Map, points, categories)) > 0) {
338 
339  if (!(type & GV_POINT))
340  continue;
341 
342  line_num++;
343 
344  x = points->x[0];
345  y = points->y[0];
346  if (points->z != NULL)
347  z = points->z[0];
348  else
349  z = 0.0;
350 
351  /* Reading and storing points only if in elaboration_reg */
352  if (Vect_point_in_box(x, y, z, &elaboration_box)) {
353  npoints++;
354  if (npoints >= pippo) {
355  pippo += dim_vect;
356  obs =
357  (struct Point *)G_realloc((void *)obs,
358  (signed int)pippo *
359  sizeof(struct Point));
360  }
361 
362  /* Storing observation vector */
363  obs[npoints - 1].coordX = x;
364  obs[npoints - 1].coordY = y;
365  obs[npoints - 1].coordZ = z;
366  obs[npoints - 1].lineID = line_num; /* Storing also the line's number */
367 
368  Vect_cat_get(categories, layer, &cat);
369  obs[npoints - 1].cat = cat;
370  }
371  }
372  Vect_destroy_line_struct(points);
373  Vect_destroy_cats_struct(categories);
374 
375  *num_points = npoints;
376  return obs;
377 }
378 
380  struct Cell_head *Elaboration,
381  struct Cell_head *Original,
382  int *num_points, int dim_vect)
383 {
384  int col, row, startcol, endcol, startrow, endrow, nrows, ncols;
385  int pippo, npoints;
386  double x, y, z;
387  struct Point *obs;
388  struct bound_box elaboration_box;
389 
390  pippo = dim_vect;
391  obs = (struct Point *)G_calloc(pippo, sizeof(struct Point));
392 
393  /* Reading points inside elaboration zone */
394  Vect_region_box(Elaboration, &elaboration_box);
395 
396  npoints = 0;
397  nrows = Original->rows;
398  ncols = Original->cols;
399 
400  if (Original->north > Elaboration->north)
401  startrow = (Original->north - Elaboration->north) / Original->ns_res - 1;
402  else
403  startrow = 0;
404  if (Original->north > Elaboration->south) {
405  endrow = (Original->north - Elaboration->south) / Original->ns_res + 1;
406  if (endrow > nrows)
407  endrow = nrows;
408  }
409  else
410  endrow = nrows;
411  if (Elaboration->west > Original->west)
412  startcol = (Elaboration->west - Original->west) / Original->ew_res - 1;
413  else
414  startcol = 0;
415  if (Elaboration->east > Original->west) {
416  endcol = (Elaboration->east - Original->west) / Original->ew_res + 1;
417  if (endcol > ncols)
418  endcol = ncols;
419  }
420  else
421  endcol = ncols;
422 
423  for (row = startrow; row < endrow; row++) {
424  for (col = startcol; col < endcol; col++) {
425 
426  Segment_get(in_seg, &z, row, col);
427 
428  if (!Rast_is_d_null_value(&z)) {
429 
430  x = Rast_col_to_easting((double)(col) + 0.5, Original);
431  y = Rast_row_to_northing((double)(row) + 0.5, Original);
432 
433  if (Vect_point_in_box(x, y, 0, &elaboration_box)) {
434  npoints++;
435  if (npoints >= pippo) {
436  pippo += dim_vect;
437  obs =
438  (struct Point *)G_realloc((void *)obs,
439  (signed int)pippo *
440  sizeof(struct Point));
441  }
442 
443  /* Storing observation vector */
444  obs[npoints - 1].coordX = x;
445  obs[npoints - 1].coordY = y;
446  obs[npoints - 1].coordZ = z;
447  }
448  }
449  }
450  }
451 
452  *num_points = npoints;
453  return obs;
454 }
455 
456 /*------------------------------------------------------------------------------------------------*/
457 int P_Create_Aux2_Table(dbDriver * driver, char *tab_name)
458 {
459  dbTable *auxiliar_tab;
460  dbColumn *column;
461 
462  auxiliar_tab = db_alloc_table(2);
463  db_set_table_name(auxiliar_tab, tab_name);
464  db_set_table_description(auxiliar_tab,
465  "Intermediate interpolated values");
466 
467  column = db_get_table_column(auxiliar_tab, 0);
468  db_set_column_name(column, "ID");
470 
471  column = db_get_table_column(auxiliar_tab, 1);
472  db_set_column_name(column, "Interp");
474 
475  if (db_create_table(driver, auxiliar_tab) == DB_OK) {
476  G_debug(1, _("<%s> created in database."), tab_name);
477  return TRUE;
478  }
479  else
480  G_warning(_("<%s> has not been created in database."), tab_name);
481 
482  return FALSE;
483 }
484 
485 /*------------------------------------------------------------------------------------------------*/
486 int P_Create_Aux4_Table(dbDriver * driver, char *tab_name)
487 {
488  dbTable *auxiliar_tab;
489  dbColumn *column;
490 
491  auxiliar_tab = db_alloc_table(4);
492  db_set_table_name(auxiliar_tab, tab_name);
493  db_set_table_description(auxiliar_tab,
494  "Intermediate interpolated values");
495 
496  column = db_get_table_column(auxiliar_tab, 0);
497  db_set_column_name(column, "ID");
499 
500  column = db_get_table_column(auxiliar_tab, 1);
501  db_set_column_name(column, "Interp");
503 
504  column = db_get_table_column(auxiliar_tab, 2);
505  db_set_column_name(column, "X");
507 
508  column = db_get_table_column(auxiliar_tab, 3);
509  db_set_column_name(column, "Y");
511 
512  if (db_create_table(driver, auxiliar_tab) == DB_OK) {
513  G_debug(1, _("<%s> created in database."), tab_name);
514  return TRUE;
515  }
516  else
517  G_warning(_("<%s> has not been created in database."), tab_name);
518 
519  return FALSE;
520 }
521 
522 /*------------------------------------------------------------------------------------------------*/
523 int P_Drop_Aux_Table(dbDriver * driver, char *tab_name)
524 {
525  dbString drop;
526 
527  db_init_string(&drop);
528  db_append_string(&drop, "drop table ");
529  db_append_string(&drop, tab_name);
530  return db_execute_immediate(driver, &drop);
531 }
532 
533 /*---------------------------------------------------------------------------------------*/
534 void P_Aux_to_Raster(double **matrix, int fd)
535 {
536  int ncols, col, nrows, row;
537  void *ptr, *raster;
538 
539  nrows = Rast_window_rows();
540  ncols = Rast_window_cols();
541 
542  raster = Rast_allocate_buf(DCELL_TYPE);
543 
544  for (row = 0; row < nrows; row++) {
545  G_percent(row, nrows, 2);
546 
547  Rast_set_d_null_value(raster, ncols);
548 
549  for (col = 0, ptr = raster; col < ncols;
550  col++, ptr = G_incr_void_ptr(ptr, Rast_cell_size(DCELL_TYPE))) {
551  Rast_set_d_value(ptr, (DCELL) (matrix[row][col]), DCELL_TYPE);
552  }
553  Rast_put_d_row(fd, raster);
554  }
555  G_percent(row, nrows, 2);
556 }
557 
558 /*------------------------------------------------------------------------------------------------*/
559 void
560 P_Aux_to_Vector(struct Map_info *Map, struct Map_info *Out, dbDriver * driver,
561  char *tab_name)
562 {
563 
564  int more, line_num, type, count = 0;
565  double coordX, coordY, coordZ;
566 
567  struct line_pnts *point;
568  struct line_cats *cat;
569  dbTable *table;
570  dbColumn *column;
571  dbValue *value;
572  dbCursor cursor;
573  dbString sql;
574 
575  char buf[1024];
576 
577  point = Vect_new_line_struct();
578  cat = Vect_new_cats_struct();
579 
580  db_init_string(&sql);
581  db_zero_string(&sql);
582 
583  sprintf(buf, "select ID, X, Y, sum(Interp) from %s group by ID, X, Y",
584  tab_name);
585 
586  db_append_string(&sql, buf);
587  db_open_select_cursor(driver, &sql, &cursor, DB_SEQUENTIAL);
588 
589  while (db_fetch(&cursor, DB_NEXT, &more) == DB_OK && more) {
590  count++;
591  table = db_get_cursor_table(&cursor);
592 
593  column = db_get_table_column(table, 0);
595  if (type == DB_C_TYPE_INT)
596  value = db_get_column_value(column);
597  else
598  continue;
599  line_num = db_get_value_int(value);
600 
601  column = db_get_table_column(table, 1);
603  if (type == DB_C_TYPE_DOUBLE)
604  value = db_get_column_value(column);
605  else
606  continue;
607  coordZ = db_get_value_double(value);
608 
609  column = db_get_table_column(table, 2);
611  if (type == DB_C_TYPE_DOUBLE)
612  value = db_get_column_value(column);
613  else
614  continue;
615  coordX = db_get_value_double(value);
616 
617  column = db_get_table_column(table, 3);
619  if (type == DB_C_TYPE_DOUBLE)
620  value = db_get_column_value(column);
621  else
622  continue;
623  coordY = db_get_value_double(value);
624 
625  Vect_copy_xyz_to_pnts(point, &coordX, &coordY, &coordZ, 1);
626  Vect_reset_cats(cat);
627  Vect_cat_set(cat, 1, 1);
628  Vect_write_line(Out, GV_POINT, point, cat);
629  }
630  return;
631 }
632 
633 /*! DEFINITION OF THE SUBZONES
634 
635  5: inside Overlap region
636  all others: inside General region but outside Overlap region
637 
638  ---------------------------------
639  | | | | | | | |
640  ---------------------------------
641  | | | | | | | |
642  | | | | | | | |
643  | | | | | | | |
644  ---------------------------------
645  | | |4| 3 |3| | |
646  ---------------------------------
647  | | | | | | | |
648  | | |2| 5 |1| | |
649  | | | | | | | |
650  ---------------------------------
651  | | |2| 1 |1| | |
652  ---------------------------------
653  | | | | | | | |
654  | | | | | | | |
655  | | | | | | | |
656  ---------------------------------
657  | | | | | | | |
658  ---------------------------------
659  */
#define TRUE
Definition: gis.h:59
#define DB_SQL_TYPE_INTEGER
Definition: dbmi.h:83
Bounding box.
Definition: dig_structs.h:65
if(!(yy_init))
Definition: sqlp.yy.c:775
dbValue * db_get_column_value(dbColumn *)
Returns column value for given column structure.
int db_create_table(dbDriver *, dbTable *)
Create table.
Definition: c_create_tab.c:27
#define P_BILINEAR
Definition: lidar.h:63
void Rast_put_d_row(int, const DCELL *)
Writes the next row for dcell file (DCELL version)
int cat
Definition: lidar.h:83
double W
West.
Definition: dig_structs.h:82
double coordX
Definition: lidar.h:79
#define GENERAL_ROW
Definition: lidar.h:39
void db_set_column_sqltype(dbColumn *, int)
Define column sqltype for column.
2D/3D raster map header (used also for region)
Definition: gis.h:423
#define Rast_is_d_null_value(dcellVal)
Definition: defs/raster.h:414
void db_init_string(dbString *)
Initialize dbString.
Definition: string.c:25
double west
Extent coordinates (west)
Definition: gis.h:475
int db_fetch(dbCursor *, int, int *)
Fetch data from open cursor.
Definition: c_fetch.c:28
double DCELL
Definition: gis.h:614
void P_zero_dim(struct Reg_dimens *dim)
Definition: zones.c:9
int db_open_select_cursor(dbDriver *, dbString *, dbCursor *, int)
Open select cursor.
Definition: c_openselect.c:37
double coordY
Definition: lidar.h:80
int Vect_copy_xyz_to_pnts(struct line_pnts *, const double *, const double *, const double *, int)
Copy points from array to line_pnts structure.
Definition: line.c:99
#define FIRST_ROW
Definition: lidar.h:41
struct Point * P_Read_Vector_Region_Map(struct Map_info *Map, struct Cell_head *Elaboration, int *num_points, int dim_vect, int layer)
Definition: zones.c:312
int db_get_value_int(dbValue *)
Get integer value.
Definition: value.c:38
int count
int lineID
Definition: lidar.h:82
int Segment_get(SEGMENT *, void *, off_t, off_t)
Get value from segment file.
Definition: segment/get.c:39
#define DB_SQL_TYPE_REAL
Definition: dbmi.h:84
double E
East.
Definition: dig_structs.h:78
#define G_incr_void_ptr(ptr, size)
Definition: defs/gis.h:100
#define FIRST_COLUMN
Definition: lidar.h:43
void P_Aux_to_Vector(struct Map_info *Map, struct Map_info *Out, dbDriver *driver, char *tab_name)
Definition: zones.c:560
#define GENERAL_COLUMN
Definition: lidar.h:40
#define NULL
Definition: ccmath.h:32
#define x
double ew_size
Definition: lidar.h:74
#define GV_POINT
Feature types used in memory on run time (may change)
Definition: dig_defines.h:182
#define G_calloc(m, n)
Definition: defs/gis.h:113
Feature category info.
Definition: dig_structs.h:1702
double N
North.
Definition: dig_structs.h:70
int db_set_column_name(dbColumn *, const char *)
Set column name.
double * x
Array of X coordinates.
Definition: dig_structs.h:1680
int P_get_edge(int interpolator, struct Reg_dimens *dim, double pe, double pn)
Definition: zones.c:187
Feature geometry info - coordinates.
Definition: dig_structs.h:1675
int db_get_column_sqltype(dbColumn *)
Returns column sqltype for column.
#define DCELL_TYPE
Definition: raster.h:13
int P_Create_Aux4_Table(dbDriver *driver, char *tab_name)
Definition: zones.c:486
double north
Extent coordinates (north)
Definition: gis.h:469
int db_append_string(dbString *, const char *)
Append string to dbString.
Definition: string.c:205
#define FALSE
Definition: gis.h:63
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
Definition: line.c:45
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.
Definition: alloc_cell.c:39
double south
Extent coordinates (south)
Definition: gis.h:471
#define DB_NEXT
Definition: dbmi.h:114
int db_execute_immediate(dbDriver *, dbString *)
Execute SQL statements.
Definition: c_execute.c:27
#define CONTOUR
Definition: lidar.h:38
int * cat
Array of categories.
Definition: dig_structs.h:1711
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)
Definition: zones.c:534
double P_estimate_splinestep(struct Map_info *Map, double *dens, double *dist)
Definition: zones.c:249
int db_sqltype_to_Ctype(int)
Get C data type based on given SQL data type.
Definition: sqlCtype.c:24
void db_zero_string(dbString *)
Zero string.
Definition: string.c:79
int P_Drop_Aux_Table(dbDriver *driver, char *tab_name)
Definition: zones.c:523
double coordZ
Definition: lidar.h:81
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
double edge_h
Definition: lidar.h:70
double overlap
Definition: lidar.h:72
int Vect_reset_cats(struct line_cats *)
Reset category structure to make sure cats structure is clean to be re-used.
#define DB_C_TYPE_INT
Definition: dbmi.h:108
int Vect_rewind(struct Map_info *)
Rewind vector map to cause reads to start at beginning.
#define LAST_COLUMN
Definition: lidar.h:44
double sn_size
Definition: lidar.h:73
int db_set_table_name(dbTable *, const char *)
Set the name of the table.
int P_Create_Aux2_Table(dbDriver *driver, char *tab_name)
Definition: zones.c:457
dbTable * db_alloc_table(int)
Allocate a table with a specific number of columns.
#define DB_SQL_TYPE_DOUBLE_PRECISION
Definition: dbmi.h:85
int P_set_dim(struct Reg_dimens *dim, double pe, double pn, int *nsplx, int *nsply)
Definition: zones.c:119
void G_percent(long, long, int)
Print percent complete messages.
Definition: percent.c:62
Vector map info.
Definition: dig_structs.h:1259
double * y
Array of Y coordinates.
Definition: dig_structs.h:1684
double edge_v
Definition: lidar.h:71
void Rast_set_d_value(void *, DCELL, RASTER_MAP_TYPE)
Places a DCELL raster value.
int P_get_BandWidth(int interpolator, int nsplines)
Definition: zones.c:208
int cols
Number of columns for 2D data.
Definition: gis.h:442
int Vect_point_in_box(double, double, double, const struct bound_box *)
Tests if point is in 3D box.
Definition: driver.h:22
double db_get_value_double(dbValue *)
Get double precision value.
Definition: value.c:50
#define DB_SEQUENTIAL
Definition: dbmi.h:123
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.
Definition: gis.h:463
int Rast_window_rows(void)
Number of rows in active window.
Definition: raster/window.c:85
void * Rast_allocate_buf(RASTER_MAP_TYPE)
Allocate memory for a raster map of given type.
Definition: alloc_cell.c:55
#define DB_C_TYPE_DOUBLE
Definition: dbmi.h:109
int Rast_window_cols(void)
Number of columns in active window.
void G_warning(const char *,...) __attribute__((format(printf
double S
South.
Definition: dig_structs.h:74
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)
Definition: zones.c:222
double east
Extent coordinates (east)
Definition: gis.h:473
#define G_realloc(p, n)
Definition: defs/gis.h:114
double * z
Array of Z coordinates.
Definition: dig_structs.h:1688
#define _(str)
Definition: glocale.h:10
Definition: lidar.h:77
int P_set_regions(struct Cell_head *Elaboration, struct bound_box *General, struct bound_box *Overlap, struct Reg_dimens dim, int type)
Definition: zones.c:54
dbTable * db_get_cursor_table(dbCursor *)
Get table allocated by cursor.
Definition: cursor.c:67
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
#define LAST_ROW
Definition: lidar.h:42
double ew_res
Resolution - east to west cell size for 2D data.
Definition: gis.h:459
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.
Definition: line.c:77
int rows
Number of rows for 2D data.
Definition: gis.h:438
void G_get_window(struct Cell_head *)
Get the current region.
Definition: get_window.c:47
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.
Definition: null_val.c:155
int Vect_cat_get(const struct line_cats *, int, int *)
Get first found category of given field.
#define P_BICUBIC
Definition: lidar.h:64
struct Point * P_Read_Raster_Region_Map(SEGMENT *in_seg, struct Cell_head *Elaboration, struct Cell_head *Original, int *num_points, int dim_vect)
Definition: zones.c:379
#define DB_OK
Definition: dbmi.h:71
int Vect_cat_set(struct line_cats *, int, int)
Add new field/cat to category structure if doesn&#39;t exist yet.
double Rast_row_to_northing(double, const struct Cell_head *)
Row to northing.