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