GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71817
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  */
void db_zero_string(dbString *x)
Zero string.
Definition: string.c:79
void db_set_column_sqltype(dbColumn *column, int sqltype)
Define column sqltype for column.
#define TRUE
Definition: gis.h:49
#define DB_SQL_TYPE_INTEGER
Definition: dbmi.h:83
Bounding box.
Definition: dig_structs.h:65
CELL cat
Definition: raster3d/cats.c:82
void G_get_window(struct Cell_head *window)
Get the current region.
Definition: get_window.c:47
#define P_BILINEAR
Definition: lidar.h:63
int cat
Definition: lidar.h:86
int P_Create_Aux4_Table(dbDriver *, char *)
Definition: zones.c:486
double W
West.
Definition: dig_structs.h:82
double coordX
Definition: lidar.h:82
#define GENERAL_ROW
Definition: lidar.h:39
int Segment_get(SEGMENT *SEG, void *buf, off_t row, off_t col)
Get value from segment file.
Definition: segment/get.c:39
dbTable * db_alloc_table(int ncols)
Allocate a table with a specific number of columns.
if(!YY_CURRENT_BUFFER)
Definition: sqlp.yy.c:803
int db_set_table_name(dbTable *table, const char *name)
Set the name of the table.
2D/3D raster map header (used also for region)
Definition: gis.h:390
void Rast_set_d_value(void *rast, DCELL dval, RASTER_MAP_TYPE data_type)
Places a DCELL raster value.
struct line_pnts * Vect_new_line_struct()
Creates and initializes a line_pnts structure.
Definition: line.c:45
off_t Vect_write_line(struct Map_info *Map, int type, const struct line_pnts *points, const struct line_cats *cats)
Writes a new feature.
double west
Extent coordinates (west)
Definition: gis.h:442
double DCELL
Definition: gis.h:581
double Rast_col_to_easting(double col, const struct Cell_head *window)
Column to easting.
double coordY
Definition: lidar.h:83
#define FIRST_ROW
Definition: lidar.h:41
int Vect_region_box(const struct Cell_head *Window, struct bound_box *Box)
Copy region window to bounding box.
int P_get_BandWidth(int, int)
Definition: zones.c:208
int count
int lineID
Definition: lidar.h:85
int Rast_window_rows(void)
Number of rows in active window.
Definition: raster/window.c:85
#define DB_SQL_TYPE_REAL
Definition: dbmi.h:84
void Vect_destroy_line_struct(struct line_pnts *p)
Frees all memory associated with a line_pnts structure, including the structure itself.
Definition: line.c:77
double E
East.
Definition: dig_structs.h:78
#define FIRST_COLUMN
Definition: lidar.h:43
void Vect_destroy_cats_struct(struct line_cats *p)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_copy_xyz_to_pnts(struct line_pnts *Points, const double *x, const double *y, const double *z, int n)
Copy points from array to line_pnts structure.
Definition: line.c:99
#define GENERAL_COLUMN
Definition: lidar.h:40
int Vect_reset_cats(struct line_cats *Cats)
Reset category structure to make sure cats structure is clean to be re-used.
struct Point * P_Read_Vector_Region_Map(struct Map_info *, struct Cell_head *, int *, int, int)
Definition: zones.c:312
#define NULL
Definition: ccmath.h:32
#define x
double ew_size
Definition: lidar.h:77
#define GV_POINT
Feature types used in memory on run time (may change)
Definition: dig_defines.h:182
int db_execute_immediate(dbDriver *driver, dbString *SQLstatement)
Execute SQL statements.
Definition: c_execute.c:27
fd
Definition: d/range.c:69
int db_set_column_name(dbColumn *column, const char *name)
Set column name.
struct Point * P_Read_Raster_Region_Map(SEGMENT *, struct Cell_head *, struct Cell_head *, int *, int)
Definition: zones.c:379
Feature category info.
Definition: dig_structs.h:1702
int db_append_string(dbString *x, const char *s)
Append string to dbString.
Definition: string.c:205
int db_sqltype_to_Ctype(int sqltype)
Get C data type based on given SQL data type.
Definition: sqlCtype.c:24
int Vect_cat_set(struct line_cats *Cats, int field, int cat)
Add new field/cat to category structure if doesn&#39;t exist yet.
double N
North.
Definition: dig_structs.h:70
int db_fetch(dbCursor *cursor, int position, int *more)
Fetch data from open cursor.
Definition: c_fetch.c:28
int P_Drop_Aux_Table(dbDriver *, char *)
Definition: zones.c:523
double * x
Array of X coordinates.
Definition: dig_structs.h:1680
Feature geometry info - coordinates.
Definition: dig_structs.h:1675
void P_zero_dim(struct Reg_dimens *)
Definition: zones.c:9
#define DCELL_TYPE
Definition: raster.h:13
size_t Rast_cell_size(RASTER_MAP_TYPE data_type)
Returns size of a raster cell in bytes.
Definition: alloc_cell.c:39
double north
Extent coordinates (north)
Definition: gis.h:436
double db_get_value_double(dbValue *value)
Get double precision value.
Definition: value.c:50
int db_get_column_sqltype(dbColumn *column)
Returns column sqltype for column.
dbTable * db_get_cursor_table(dbCursor *cursor)
Get table allocated by cursor.
Definition: cursor.c:67
int Vect_cat_get(const struct line_cats *Cats, int field, int *cat)
Get first found category of given field.
#define FALSE
Definition: gis.h:53
double south
Extent coordinates (south)
Definition: gis.h:438
#define DB_NEXT
Definition: dbmi.h:114
int P_get_edge(int, struct Reg_dimens *, double, double)
Definition: zones.c:187
#define CONTOUR
Definition: lidar.h:38
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
dbValue * db_get_column_value(dbColumn *column)
Returns column value for given column structure.
int Rast_window_cols(void)
Number of columns in active window.
double coordZ
Definition: lidar.h:84
double edge_h
Definition: lidar.h:73
double overlap
Definition: lidar.h:75
#define DB_C_TYPE_INT
Definition: dbmi.h:108
void G_percent(long n, long d, int s)
Print percent complete messages.
Definition: percent.c:62
#define LAST_COLUMN
Definition: lidar.h:44
double sn_size
Definition: lidar.h:76
void P_Aux_to_Vector(struct Map_info *, struct Map_info *, dbDriver *, char *)
Definition: zones.c:560
#define DB_SQL_TYPE_DOUBLE_PRECISION
Definition: dbmi.h:85
void Rast_set_d_null_value(DCELL *dcellVals, int numVals)
To set a number of DCELL raster values to NULL.
Definition: null_val.c:155
Vector map info.
Definition: dig_structs.h:1259
double Rast_row_to_northing(double row, const struct Cell_head *window)
Row to northing.
double * y
Array of Y coordinates.
Definition: dig_structs.h:1684
double edge_v
Definition: lidar.h:74
void Rast_put_d_row(int fd, const DCELL *buf)
Writes the next row for dcell file (DCELL version)
int db_create_table(dbDriver *driver, dbTable *table)
Create table.
Definition: c_create_tab.c:27
int cols
Number of columns for 2D data.
Definition: gis.h:409
struct line_cats * Vect_new_cats_struct()
Creates and initializes line_cats structure.
Definition: driver.h:22
#define DB_SEQUENTIAL
Definition: dbmi.h:123
double ns_res
Resolution - north to south cell size for 2D data.
Definition: gis.h:430
#define DB_C_TYPE_DOUBLE
Definition: dbmi.h:109
void G_get_set_window(struct Cell_head *window)
Get the current working window (region)
void * G_incr_void_ptr(const void *ptr, size_t size)
Advance void pointer.
Definition: gis/alloc.c:186
int Vect_read_next_line(const struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next vector feature.
double S
South.
Definition: dig_structs.h:74
int P_Create_Aux2_Table(dbDriver *, char *)
Definition: zones.c:457
double P_estimate_splinestep(struct Map_info *, double *, double *)
Definition: zones.c:249
double east
Extent coordinates (east)
Definition: gis.h:440
void P_Aux_to_Raster(double **, int)
Definition: zones.c:534
double * z
Array of Z coordinates.
Definition: dig_structs.h:1688
int P_set_dim(struct Reg_dimens *, double, double, int *, int *)
Definition: zones.c:119
#define _(str)
Definition: glocale.h:13
Definition: lidar.h:80
int db_set_table_description(dbTable *table, const char *description)
Set the description of the table.
int db_get_value_int(dbValue *value)
Get integer value.
Definition: value.c:38
void * Rast_allocate_buf(RASTER_MAP_TYPE data_type)
Allocate memory for a raster map of given type.
Definition: alloc_cell.c:55
int
Reads the categories file for map name in mapset and stores the categories in the pcats structure...
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:426
dbColumn * db_get_table_column(dbTable *table, int idx)
Returns column structure for given table and column number.
int rows
Number of rows for 2D data.
Definition: gis.h:405
double P_Mean_Calc(struct Cell_head *, struct Point *, int)
Definition: zones.c:222
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition: gis/error.c:203
int Vect_point_in_box(double x, double y, double z, const struct bound_box *Box)
Tests if point is in 3D box.
int P_set_regions(struct Cell_head *, struct bound_box *, struct bound_box *, struct Reg_dimens, int)
Definition: zones.c:54
int db_open_select_cursor(dbDriver *driver, dbString *select, dbCursor *cursor, int mode)
Open select cursor.
Definition: c_openselect.c:37
void db_init_string(dbString *x)
Initialize dbString.
Definition: string.c:25
#define P_BICUBIC
Definition: lidar.h:64
int Rast_is_d_null_value(const DCELL *dcellVal)
To check if a DCELL raster value is set to NULL.
Definition: null_val.c:261
#define DB_OK
Definition: dbmi.h:71
int Vect_rewind(struct Map_info *Map)
Rewind vector map to cause reads to start at beginning.