38 #include <grass/interpf.h> 57 double *xmin,
double *xmax,
58 double *ymin,
double *ymax,
59 double *zmin,
double *zmax,
65 double c1, c2, c3, c4;
71 double xprev, yprev, zprev, x1, y1, z1, d1, xt, yt, z, sm;
74 int times, j1, ltype, cat, zctype = 0, sctype = 0;
84 G_debug(2,
"IL_vector_input_data_2d(): field = %d, zcol = %s, scol = %s",
88 dmax2 = *dmax * *dmax;
96 if (field > 0 && zcol !=
NULL) {
102 G_debug(3,
" driver = %s database = %s table = %s", Fi->driver,
103 Fi->database, Fi->table);
110 Fi->database, Fi->driver);
113 G_debug(3,
" zcol C type = %d", zctype);
118 G_fatal_error(
_(
"Data type of column <%s> must be numeric"), zcol);
127 G_debug(3,
" scol C type = %d", sctype);
131 G_fatal_error(
_(
"Data type of column <%s> must be numeric"), scol);
142 G_message(
_(
"Reading features from vector map ..."));
174 G_warning(
_(
"Database record for cat %d not found"),
192 G_fatal_error(
_(
"Negative value of smoothing detected: sm must be >= 0"));
194 G_debug(5,
" z = %f sm = %f", z, sm);
199 for (i = 0; i < Points->n_points; i++) {
203 params->
zmult, xmin, xmax, ymin, ymax, zmin,
204 zmax, &npoint, &OUTRANGE, &k);
209 xprev = Points->x[0];
210 yprev = Points->y[0];
211 zprev = Points->z[0];
212 for (i = 1; i < Points->n_points; i++) {
220 d1 = (xt * xt + yt * yt);
221 if ((d1 > dmax2) && (dmax2 != 0.)) {
222 times = (int)(d1 / dmax2 + 0.5);
223 for (j1 = 0; j1 < times; j1++) {
224 xt = x1 - j1 * ((x1 - xprev) / times);
225 yt = y1 - j1 * ((y1 - yprev) / times);
227 z = z1 - j1 * ((z1 - zprev) / times);
230 xmin, xmax, ymin, ymax, zmin, zmax, &npoint,
240 if (field > 0 && zcol !=
NULL)
246 c1 = *xmin - data->
x_orig;
248 c3 = *ymin - data->
y_orig;
250 if ((c1 > 5 * ew_res) || (c2 > 5 * ew_res) || (c3 > 5 * ns_res) ||
256 G_warning(
_(
"Strip exists with insufficient data"));
270 G_warning(
_(
"There are points outside specified 2D/3D region - %d points ignored"),
274 npoint = k - npoint - OUTRANGE;
275 if (npoint < params->kmin) {
277 G_warning(
_(
"%d points given for interpolation (after thinning) is less than given NPMIN=%d"),
278 npoint, params->
kmin);
279 params->
kmin = npoint;
282 G_warning(
_(
"Zero points in the given region"));
286 if (npoint > params->
KMAX2 && params->
kmin <= params->
kmax) {
287 G_warning(
_(
"Segmentation parameters set to invalid values: npmin= %d, segmax= %d " 288 "for smooth connection of segments, npmin > segmax (see manual)"),
292 if (npoint < params->KMAX2 && params->
kmax != params->
KMAX2)
293 G_warning(
_(
"There are less than %d points for interpolation. No " 294 "segmentation is necessary, to run the program faster set " 295 "segmax=%d (see manual)"), params->
KMAX2, params->
KMAX2);
313 double *zmax,
int *npoint,
int *OUTRANGE,
int *total)
316 double c1, c2, c3, c4;
318 static int first_time = 1;
331 if (!((c1 >= 0) && (c2 >= 0) && (c3 >= 0) && (c4 >= 0))) {
333 G_warning(
_(
"Some points outside of region (ignored)"));
347 G_warning(
_(
"Unable to insert %f,%f,%f a = %d"), x, y, z, a);
360 *xmin =
amin1(*xmin, x);
361 *ymin =
amin1(*ymin, y);
362 *zmin =
amin1(*zmin, z);
363 *xmax =
amax1(*xmax, x);
364 *ymax =
amax1(*ymax, y);
365 *zmax =
amax1(*zmax, z);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void void void G_important_message(const char *,...) __attribute__((format(printf
void db_CatValArray_init(dbCatValArray *)
Initialize dbCatValArray.
int db_CatValArray_get_value_int(dbCatValArray *, int, int *)
Find value (integer) by key.
dbDriver * db_start_driver(const char *)
Initialize a new dbDriver for db transaction.
void db_init_string(dbString *)
Initialize dbString.
double amax1(double, double)
int db_set_handle(dbHandle *, const char *, const char *)
Set handle (database and schema name)
#define GV_POINT
Feature types used in memory on run time (may change)
struct triple * quad_point_new(double x, double y, double z, double sm)
int db_close_database_shutdown_driver(dbDriver *)
Close driver/database connection.
struct field_info * Vect_get_field(const struct Map_info *, int)
Get information about link to database (by layer number)
Layer (old: field) information.
void G_message(const char *,...) __attribute__((format(printf
Feature geometry info - coordinates.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int db_CatValArray_get_value_double(dbCatValArray *, int, double *)
Find value (double) by key.
void db_init_handle(dbHandle *)
Initialize handle (i.e database/schema)
double amin1(double, double)
int db_open_database(dbDriver *, dbHandle *)
Open database connection.
int Vect_is_3d(const struct Map_info *)
Check if vector map is 3D.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
double ns_res
Resolution - north to south cell size for 2D data.
void db_CatValArray_free(dbCatValArray *)
Free allocated dbCatValArray.
const char * Vect_get_full_name(const struct Map_info *)
Get fully qualified name of vector map.
void G_warning(const char *,...) __attribute__((format(printf
int db_column_Ctype(dbDriver *, const char *, const char *)
Get column ctype.
int MT_insert(struct triple *point, struct tree_info *info, struct multtree *tree, int n_leafs)
int db_select_CatValArray(dbDriver *, const char *, const char *, const char *, const char *, dbCatValArray *)
Select pairs key/value to array, values are sorted by key (must be integer)
int Vect_read_next_line(const struct Map_info *, struct line_pnts *, struct line_cats *)
Read next vector feature.
double ew_res
Resolution - east to west cell size for 2D data.
void void G_verbose_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int Vect_cat_get(const struct line_cats *, int, int *)
Get first found category of given field.