grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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/*----------------------------------------------------------------------------------------*/
9void 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
53int
54P_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/*----------------------------------------------------------------------------------------*/
119int 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/*----------------------------------------------------------------------------------------*/
187int 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/*----------------------------------------------------------------------------------------*/
208int 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/*----------------------------------------------------------------------------------------*/
221double
222P_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
249double 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);
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 }
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/*------------------------------------------------------------------------------------------------*/
457int 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/*------------------------------------------------------------------------------------------------*/
486int 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/*------------------------------------------------------------------------------------------------*/
523int 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/*---------------------------------------------------------------------------------------*/
534void 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();
541
543
544 for (row = 0; row < nrows; row++) {
545 G_percent(row, nrows, 2);
546
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/*------------------------------------------------------------------------------------------------*/
559void
560P_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
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);
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);
627 Vect_cat_set(cat, 1, 1);
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 * Rast_allocate_buf(RASTER_MAP_TYPE data_type)
Allocate memory for a raster map of given type.
Definition: alloc_cell.c:55
size_t Rast_cell_size(RASTER_MAP_TYPE data_type)
Returns size of a raster cell in bytes.
Definition: alloc_cell.c:39
int db_create_table(dbDriver *driver, dbTable *table)
Create table.
Definition: c_create_tab.c:27
int db_execute_immediate(dbDriver *driver, dbString *SQLstatement)
Execute SQL statements.
Definition: c_execute.c:27
int db_fetch(dbCursor *cursor, int position, int *more)
Fetch data from open cursor.
Definition: c_fetch.c:28
int db_open_select_cursor(dbDriver *driver, dbString *select, dbCursor *cursor, int mode)
Open select cursor.
Definition: c_openselect.c:37
#define NULL
Definition: ccmath.h:32
dbTable * db_get_cursor_table(dbCursor *cursor)
Get table allocated by cursor.
Definition: cursor.c:67
if(!DBFLoadRecord(psDBF, hEntity)) return NULL
#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 *column)
Returns column value for given column structure.
Definition: column.c:27
int db_set_column_name(dbColumn *column, const char *name)
Set column name.
Definition: column.c:406
int db_get_column_sqltype(dbColumn *column)
Returns column sqltype for column.
Definition: column.c:142
void db_set_column_sqltype(dbColumn *column, int sqltype)
Define column sqltype for column.
Definition: column.c:71
dbTable * db_alloc_table(int ncols)
Allocate a table with a specific number of columns.
Definition: table.c:28
int db_set_table_name(dbTable *table, const char *name)
Set the name of the table.
Definition: table.c:89
int db_set_table_description(dbTable *table, const char *description)
Set the description of the table.
Definition: table.c:114
dbColumn * db_get_table_column(dbTable *table, int idx)
Returns column structure for given table and column number.
Definition: table.c:307
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
#define GV_POINT
Feature types used in memory on run time (may change)
Definition: dig_defines.h:182
static int type
Definition: fpxdr.c:101
void G_get_window(struct Cell_head *window)
Get the current region.
Definition: get_window.c:47
void * G_incr_void_ptr(const void *ptr, size_t size)
Advance void pointer.
Definition: alloc.c:186
static struct table table
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition: error.c:204
void G_get_set_window(struct Cell_head *window)
Get the current working window (region)
Definition: set_window.c:35
#define TRUE
Definition: gis.h:59
#define FALSE
Definition: gis.h:63
double DCELL
Definition: gis.h:604
#define _(str)
Definition: glocale.h:13
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
int count
#define GENERAL_ROW
Definition: lidar.h:39
#define P_BILINEAR
Definition: lidar.h:63
#define LAST_COLUMN
Definition: lidar.h:44
#define FIRST_ROW
Definition: lidar.h:41
#define FIRST_COLUMN
Definition: lidar.h:43
#define LAST_ROW
Definition: lidar.h:42
#define CONTOUR
Definition: lidar.h:38
#define GENERAL_COLUMN
Definition: lidar.h:40
#define P_BICUBIC
Definition: lidar.h:64
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
struct line_pnts * Vect_new_line_struct()
Creates and initializes a line_pnts structure.
Definition: line.c:45
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
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
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
void G_percent(long n, long d, int s)
Print percent complete messages.
Definition: percent.c:62
static int ncols
Definition: raster.c:29
void Rast_put_d_row(int fd, const DCELL *buf)
Writes the next row for dcell file (DCELL version)
Definition: put_row.c:110
void Rast_set_d_value(void *rast, DCELL dval, RASTER_MAP_TYPE data_type)
Places a DCELL raster value.
Definition: raster.c:163
double Rast_row_to_northing(double row, const struct Cell_head *window)
Row to northing.
Definition: window.c:244
double Rast_col_to_easting(double col, const struct Cell_head *window)
Column to easting.
Definition: window.c:264
int Rast_window_cols(void)
Number of columns in active window.
Definition: window.c:120
int Rast_window_rows(void)
Number of rows in active window.
Definition: window.c:85
#define DCELL_TYPE
Definition: raster.h:13
static int more(const char **)
Definition: scan.c:477
int Segment_get(SEGMENT *SEG, void *buf, off_t row, off_t col)
Get value from segment file.
Definition: get.c:39
int db_sqltype_to_Ctype(int sqltype)
Get C data type based on given SQL data type.
Definition: sqlCtype.c:24
void db_zero_string(dbString *x)
Zero string.
Definition: string.c:79
void db_init_string(dbString *x)
Initialize dbString.
Definition: string.c:25
int db_append_string(dbString *x, const char *s)
Append string to dbString.
Definition: string.c:205
2D/3D raster map header (used also for region)
Definition: gis.h:414
double ew_res
Resolution - east to west cell size for 2D data.
Definition: gis.h:449
double north
Extent coordinates (north)
Definition: gis.h:459
double east
Extent coordinates (east)
Definition: gis.h:463
double ns_res
Resolution - north to south cell size for 2D data.
Definition: gis.h:453
int rows
Number of rows for 2D data.
Definition: gis.h:428
int cols
Number of columns for 2D data.
Definition: gis.h:432
double south
Extent coordinates (south)
Definition: gis.h:461
double west
Extent coordinates (west)
Definition: gis.h:465
Vector map info.
Definition: dig_structs.h:1260
Definition: lidar.h:78
int cat
Definition: lidar.h:83
int lineID
Definition: lidar.h:82
double coordY
Definition: lidar.h:80
double coordX
Definition: lidar.h:79
double coordZ
Definition: lidar.h:81
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:66
double W
West.
Definition: dig_structs.h:82
double S
South.
Definition: dig_structs.h:74
double N
North.
Definition: dig_structs.h:70
double E
East.
Definition: dig_structs.h:78
Definition: node.c:30
Definition: driver.h:23
Feature category info.
Definition: dig_structs.h:1703
int * cat
Array of categories.
Definition: dig_structs.h:1711
Feature geometry info - coordinates.
Definition: dig_structs.h:1676
double * y
Array of Y coordinates.
Definition: dig_structs.h:1684
double * x
Array of X coordinates.
Definition: dig_structs.h:1680
double * z
Array of Z coordinates.
Definition: dig_structs.h:1688
Definition: plot.c:44
Definition: datum.c:28
int db_get_value_int(dbValue *value)
Get integer value.
Definition: value.c:38
double db_get_value_double(dbValue *value)
Get double precision value.
Definition: value.c:50
int Vect_region_box(const struct Cell_head *Window, struct bound_box *Box)
Copy region window to bounding box.
Definition: box.c:467
int Vect_point_in_box(double x, double y, double z, const struct bound_box *Box)
Tests if point is in 3D box.
Definition: box.c:48
void Vect_destroy_cats_struct(struct line_cats *p)
Frees all memory associated with line_cats structure, including the struct itself.
Definition: cats.c:80
int Vect_cat_get(const struct line_cats *Cats, int field, int *cat)
Get first found category of given field.
Definition: cats.c:156
int Vect_reset_cats(struct line_cats *Cats)
Reset category structure to make sure cats structure is clean to be re-used.
Definition: cats.c:294
struct line_cats * Vect_new_cats_struct()
Creates and initializes line_cats structure.
Definition: cats.c:40
int Vect_cat_set(struct line_cats *Cats, int field, int cat)
Add new field/cat to category structure if doesn't exist yet.
Definition: cats.c:104
int Vect_read_next_line(const struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next vector feature.
Definition: read.c:121
int Vect_rewind(struct Map_info *Map)
Rewind vector map to cause reads to start at beginning.
Definition: rewind.c:66
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.
Definition: write.c:178
#define x
void P_Aux_to_Vector(struct Map_info *Map, struct Map_info *Out, dbDriver *driver, char *tab_name)
Definition: zones.c:560
void P_Aux_to_Raster(double **matrix, int fd)
Definition: zones.c:534
double P_Mean_Calc(struct Cell_head *Elaboration, struct Point *obs, int npoints)
Definition: zones.c:222
double P_estimate_splinestep(struct Map_info *Map, double *dens, double *dist)
Definition: zones.c:249
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 P_get_edge(int interpolator, struct Reg_dimens *dim, double pe, double pn)
Definition: zones.c:187
void P_zero_dim(struct Reg_dimens *dim)
Definition: zones.c:9
int P_get_BandWidth(int interpolator, int nsplines)
Definition: zones.c:208
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
int P_Create_Aux2_Table(dbDriver *driver, char *tab_name)
Definition: zones.c:457
int P_set_dim(struct Reg_dimens *dim, double pe, double pn, int *nsplx, int *nsply)
Definition: zones.c:119
int P_Drop_Aux_Table(dbDriver *driver, char *tab_name)
Definition: zones.c:523
int P_Create_Aux4_Table(dbDriver *driver, char *tab_name)
Definition: zones.c:486
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