81static int compare_xpnts(
const void *
Xpnta,
const void *
Xpntb)
101 G_warning(
_(
"Break polygons: Bug in binary tree!"));
116 double dx, dy, a1 = 0, a2 = 0;
129 G_debug(1,
"File-based version of Vect_break_polygons()");
155 G_debug(3,
"nlines = %d", nlines);
163 G_message(
_(
"Breaking polygons (pass 1: select break points)..."));
165 for (i = 1; i <= nlines; i++) {
207 G_debug(3,
"fpoint = %d", fpoint);
219 dx = Points->
x[1] - Points->
x[0];
220 dy = Points->
y[1] - Points->
y[0];
224 dx = Points->
x[
j - 1] - Points->
x[
j];
225 dy = Points->
y[
j - 1] - Points->
y[
j];
227 dx = Points->
x[
j + 1] - Points->
x[
j];
228 dy = Points->
y[
j + 1] - Points->
y[
j];
239 _(
"File read/write operation failed: %s (%d)"),
256 _(
"File read/write operation failed: %s (%d)"),
264 G_debug(3,
"a1 = %f xa1 = %f a2 = %f xa2 = %f", a1,
XPnt.a1,
266 if ((a1 ==
XPnt.a1 && a2 ==
XPnt.a2) ||
276 _(
"File read/write operation failed: %s (%d)"),
304 _(
"File read/write operation failed: %s (%d)"),
321 G_message(
_(
"Breaking polygons (pass 2: break at selected points)..."));
323 for (i = 1; i <= nlines; i++) {
362 G_debug(3,
"fpoint = %d", fpoint);
378 for (k = last; k <=
j; k++) {
388 "Line %d written j = %d n_points(orig,pruned) = %d "
389 "n_points(new) = %d",
411 _(
"File read/write operation failed: %s (%d)"),
434 G_debug(3,
"Line %d was deleted", i);
438 G_debug(3,
"Line %d was not changed", i);
462 double dx, dy, a1 = 0, a2 = 0;
465 G_debug(1,
"Memory-based version of Vect_break_polygons()");
476 G_debug(3,
"nlines = %d", nlines);
483 G_message(
_(
"Breaking polygons (pass 1: select break points)..."));
485 for (i = 1; i <= nlines; i++) {
532 dx = Points->
x[1] - Points->
x[0];
533 dy = Points->
y[1] - Points->
y[0];
537 dx = Points->
x[
j - 1] - Points->
x[
j];
538 dy = Points->
y[
j - 1] - Points->
y[
j];
540 dx = Points->
x[
j + 1] - Points->
x[
j];
541 dy = Points->
y[
j + 1] - Points->
y[
j];
555 G_debug(3,
"a1 = %f xa1 = %f a2 = %f xa2 = %f", a1,
586 G_debug(2,
"Break polygons: unique vertices: %ld", (
long int)
RBTree->count);
595 G_message(
_(
"Breaking polygons (pass 2: break at selected points)..."));
597 for (i = 1; i <= nlines; i++) {
639 for (k = last; k <=
j; k++) {
649 "Line %d written j = %d n_points(orig,pruned) = %d "
650 "n_points(new) = %d",
682 G_debug(3,
"Line %d was deleted", i);
686 G_debug(3,
"Line %d was not changed", i);
718 if (
getenv(
"GRASS_VECTOR_LOWMEM"))
void Vect_break_polygons_mem(struct Map_info *Map, int type, struct Map_info *Err)
void Vect_break_polygons_file(struct Map_info *Map, int type, struct Map_info *Err)
void Vect_break_polygons(struct Map_info *Map, int type, struct Map_info *Err)
Break polygons in vector map.
void G_percent(long, long, int)
Print percent complete messages.
void G_free(void *)
Free allocated memory.
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
char * G_tempfile(void)
Returns a temporary file name.
void G_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int rbtree_insert(struct RB_TREE *, void *)
struct RB_TREE * rbtree_create(rb_compare_fn *, size_t)
void * rbtree_find(struct RB_TREE *, const void *)
void rbtree_destroy(struct RB_TREE *)
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
off_t Vect_rewrite_line(struct Map_info *, off_t, int, const struct line_pnts *, const struct line_cats *)
Rewrites existing feature (topological level required)
plus_t Vect_get_num_lines(struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
void Vect_reset_line(struct line_pnts *)
Reset line.
int Vect_line_prune(struct line_pnts *)
Remove duplicate points, i.e. zero length segments.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
#define GV_POINT
Feature types used in memory on run time (may change)
Header file for msvc/fcntl.c.
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z coordinates.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
struct RTree * RTreeCreateTree(int fd, off_t rootpos, int ndims)
Create new empty R*-Tree.
int RTreeInsertRect(struct RTree_Rect *r, int tid, struct RTree *t)
Insert an item into a R*-Tree.
void RTreeDestroyTree(struct RTree *t)
Destroy an R*-Tree.
int RTreeSearch(struct RTree *t, struct RTree_Rect *r, SearchHitCallback *shcb, void *cbarg)
Search an R*-Tree.