82static int compare_xpnts(
const void *
Xpnta,
const void *
Xpntb)
102 G_warning(
_(
"Break polygons: Bug in binary tree!"));
117 double dx, dy, a1 = 0, a2 = 0;
130 G_debug(1,
"File-based version of Vect_break_polygons()");
156 G_debug(3,
"nlines = %d", nlines);
164 G_message(
_(
"Breaking polygons (pass 1: select break points)..."));
166 for (i = 1; i <= nlines; i++) {
208 G_debug(3,
"fpoint = %d", fpoint);
220 dx = Points->
x[1] - Points->
x[0];
221 dy = Points->
y[1] - Points->
y[0];
225 dx = Points->
x[
j - 1] - Points->
x[
j];
226 dy = Points->
y[
j - 1] - Points->
y[
j];
228 dx = Points->
x[
j + 1] - Points->
x[
j];
229 dy = Points->
y[
j + 1] - Points->
y[
j];
240 _(
"File read/write operation failed: %s (%d)"),
257 _(
"File read/write operation failed: %s (%d)"),
265 G_debug(3,
"a1 = %f xa1 = %f a2 = %f xa2 = %f", a1,
XPnt.a1,
267 if ((a1 ==
XPnt.a1 && a2 ==
XPnt.a2) ||
277 _(
"File read/write operation failed: %s (%d)"),
305 _(
"File read/write operation failed: %s (%d)"),
322 G_message(
_(
"Breaking polygons (pass 2: break at selected points)..."));
324 for (i = 1; i <= nlines; i++) {
363 G_debug(3,
"fpoint = %d", fpoint);
379 for (k = last; k <=
j; k++) {
389 "Line %d written j = %d n_points(orig,pruned) = %d "
390 "n_points(new) = %d",
412 _(
"File read/write operation failed: %s (%d)"),
435 G_debug(3,
"Line %d was deleted", i);
439 G_debug(3,
"Line %d was not changed", i);
463 double dx, dy, a1 = 0, a2 = 0;
466 G_debug(1,
"Memory-based version of Vect_break_polygons()");
477 G_debug(3,
"nlines = %d", nlines);
484 G_message(
_(
"Breaking polygons (pass 1: select break points)..."));
486 for (i = 1; i <= nlines; i++) {
533 dx = Points->
x[1] - Points->
x[0];
534 dy = Points->
y[1] - Points->
y[0];
538 dx = Points->
x[
j - 1] - Points->
x[
j];
539 dy = Points->
y[
j - 1] - Points->
y[
j];
541 dx = Points->
x[
j + 1] - Points->
x[
j];
542 dy = Points->
y[
j + 1] - Points->
y[
j];
556 G_debug(3,
"a1 = %f xa1 = %f a2 = %f xa2 = %f", a1,
587 G_debug(2,
"Break polygons: unique vertices: %ld", (
long int)
RBTree->count);
596 G_message(
_(
"Breaking polygons (pass 2: break at selected points)..."));
598 for (i = 1; i <= nlines; i++) {
640 for (k = last; k <=
j; k++) {
650 "Line %d written j = %d n_points(orig,pruned) = %d "
651 "n_points(new) = %d",
683 G_debug(3,
"Line %d was deleted", i);
687 G_debug(3,
"Line %d was not changed", i);
719 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 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.