37 #include <grass/interpf.h>
57 double *xmin,
double *xmax,
double *ymin,
double *ymax,
double *zmin,
58 double *zmax,
int *n_points,
63 double c1, c2, c3, c4;
65 double ns_res, ew_res;
69 double xprev, yprev, zprev, x1, y1, z1, d1, xt, yt, z, sm;
72 int times, j1, ltype, cat, zctype = 0, sctype = 0;
82 G_debug(2,
"IL_vector_input_data_2d(): field = %d, zcol = %s, scol = %s",
86 dmax2 = *dmax * *dmax;
94 if (field > 0 && zcol !=
NULL) {
100 G_debug(3,
" driver = %s database = %s table = %s", Fi->driver,
101 Fi->database, Fi->table);
108 Fi->database, Fi->driver);
111 G_debug(3,
" zcol C type = %d", zctype);
115 G_fatal_error(
_(
"Data type of column <%s> must be numeric"), zcol);
124 G_debug(3,
" scol C type = %d", sctype);
140 G_message(
_(
"Reading features from vector map ..."));
172 G_warning(
_(
"Database record for cat %d not found"),
191 G_debug(5,
" z = %f sm = %f", z, sm);
196 for (i = 0; i < Points->n_points; i++) {
201 &npoint, &OUTRANGE, &k);
205 xprev = Points->x[0];
206 yprev = Points->y[0];
207 zprev = Points->z[0];
208 for (i = 1; i < Points->n_points; i++) {
216 d1 = (xt * xt + yt * yt);
217 if ((d1 > dmax2) && (dmax2 != 0.)) {
218 times = (int)(d1 / dmax2 + 0.5);
219 for (j1 = 0; j1 < times; j1++) {
220 xt = x1 - j1 * ((x1 - xprev) / times);
221 yt = y1 - j1 * ((y1 - yprev) / times);
223 z = z1 - j1 * ((z1 - zprev) / times);
226 xmax, ymin,
ymax, zmin, zmax, &npoint,
236 if (field > 0 && zcol !=
NULL)
242 c1 = *xmin - data->
x_orig;
244 c3 = *ymin - data->
y_orig;
246 if ((c1 > 5 * ew_res) || (c2 > 5 * ew_res) || (c3 > 5 * ns_res) ||
252 G_warning(
_(
"Strip exists with insufficient data"));
265 G_warning(
_(
"There are points outside specified 2D/3D region - %d "
270 npoint = k - npoint - OUTRANGE;
271 if (npoint < params->kmin) {
273 G_warning(
_(
"%d points given for interpolation (after thinning) is "
274 "less than given NPMIN=%d"),
275 npoint, params->
kmin);
276 params->
kmin = npoint;
279 G_warning(
_(
"Zero points in the given region"));
283 if (npoint > params->
KMAX2 && params->
kmin <= params->
kmax) {
285 _(
"Segmentation parameters set to invalid values: npmin= %d, "
287 "for smooth connection of segments, npmin > segmax (see manual)"),
291 if (npoint < params->KMAX2 && params->
kmax != params->
KMAX2)
292 G_warning(
_(
"There are less than %d points for interpolation. No "
293 "segmentation is necessary, to run the program faster set "
294 "segmax=%d (see manual)"),
309 double *xmin,
double *
xmax,
double *ymin,
double *
ymax,
310 double *zmin,
double *zmax,
int *npoint,
int *OUTRANGE,
314 double c1, c2, c3, c4;
316 static int first_time = 1;
327 if (!((c1 >= 0) && (c2 >= 0) && (c3 >= 0) && (c4 >= 0))) {
329 G_warning(
_(
"Some points outside of region (ignored)"));
343 G_warning(
_(
"Unable to insert %f,%f,%f a = %d"),
x, y, z, a);
357 *ymin =
amin1(*ymin, y);
358 *zmin =
amin1(*zmin, z);
361 *zmax =
amax1(*zmax, z);
struct triple * quad_point_new(double x, double y, double z, double sm)
void db_CatValArray_free(dbCatValArray *)
Free allocated dbCatValArray.
int db_CatValArray_get_value_int(dbCatValArray *, int, int *)
Find value (integer) by key.
void db_CatValArray_init(dbCatValArray *)
Initialize dbCatValArray.
int db_column_Ctype(dbDriver *, const char *, const char *)
Get column ctype.
dbDriver * db_start_driver(const char *)
Initialize a new dbDriver for db transaction.
int db_open_database(dbDriver *, dbHandle *)
Open database connection.
int db_close_database_shutdown_driver(dbDriver *)
Close driver/database connection.
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 db_set_handle(dbHandle *, const char *, const char *)
Set handle (database and schema name)
void db_init_handle(dbHandle *)
Initialize handle (i.e database/schema)
void db_init_string(dbString *)
Initialize dbString.
int db_CatValArray_get_value_double(dbCatValArray *, int, double *)
Find value (double) by key.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
void void G_verbose_message(const char *,...) __attribute__((format(printf
void void void G_important_message(const char *,...) __attribute__((format(printf
void G_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
const char * Vect_get_full_name(struct Map_info *)
Get fully qualified name of vector map.
int Vect_cat_get(const struct line_cats *, int, int *)
Get first found category of given field.
struct field_info * Vect_get_field(struct Map_info *, int)
Get information about link to database (by layer number)
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_read_next_line(struct Map_info *, struct line_pnts *, struct line_cats *)
Read next vector feature.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_is_3d(struct Map_info *)
Check if vector map is 3D.
#define GV_POINT
Feature types used in memory on run time (may change)
double amin1(double, double)
double amax1(double, double)
int MT_insert(struct triple *point, struct tree_info *info, struct multtree *tree, int n_leafs)
Layer (old: field) information.
Feature geometry info - coordinates.